markus / MarkupToPDF / Controls / Polygon / CloudControl.cs.bak @ 6e5f7eaf
이력 | 보기 | 이력해설 | 다운로드 (28.2 KB)
1 | 787a4489 | KangIngu | using System; |
---|---|---|---|
2 | using System.Net; |
||
3 | using System.Windows; |
||
4 | using System.Windows.Controls; |
||
5 | using System.Windows.Documents; |
||
6 | using System.Windows.Ink; |
||
7 | using System.Windows.Input; |
||
8 | using System.Windows.Media; |
||
9 | using System.Windows.Media.Animation; |
||
10 | using System.Windows.Shapes; |
||
11 | using System.Collections.Generic; |
||
12 | using System.ComponentModel; |
||
13 | using MarkupToPDF.Controls.Common; |
||
14 | using MarkupToPDF.Common; |
||
15 | |||
16 | namespace MarkupToPDF.Controls.Polygon |
||
17 | { |
||
18 | public class CloudControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IPath, IShapeControl, ICloudControl, IDashControl |
||
19 | { |
||
20 | private const string PART_CloudPath = "PART_CloudPath"; |
||
21 | private const string PART_CloudSubPath = "PART_CloudSubPath"; |
||
22 | |||
23 | public Path Base_CloudPath = null; |
||
24 | public Path Base_CloudSubPath = null; |
||
25 | |||
26 | static CloudControl() |
||
27 | { |
||
28 | DefaultStyleKeyProperty.OverrideMetadata(typeof(CloudControl), new FrameworkPropertyMetadata(typeof(CloudControl))); |
||
29 | //Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
||
30 | ResourceDictionary dictionary = new ResourceDictionary(); |
||
31 | dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
||
32 | Application.Current.Resources.MergedDictionaries.Add(dictionary); |
||
33 | } |
||
34 | public CloudControl() |
||
35 | { |
||
36 | this.DefaultStyleKey = typeof(CloudControl); |
||
37 | } |
||
38 | |||
39 | #region Dependency Properties |
||
40 | public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
||
41 | "UserID", typeof(string), typeof(CloudControl), new PropertyMetadata(null)); |
||
42 | public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
||
43 | "LineSize", typeof(double), typeof(CloudControl), new PropertyMetadata((Double)3)); |
||
44 | public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
||
45 | "DashSize", typeof(DoubleCollection), typeof(CloudControl), new PropertyMetadata(new DoubleCollection {7,7,1,7 })); |
||
46 | public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register( |
||
47 | "FillColor", typeof(SolidColorBrush), typeof(CloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
||
48 | |||
49 | public static readonly DependencyProperty IsCompletedProperty = DependencyProperty.Register( |
||
50 | "IsCompleted", typeof(bool), typeof(CloudControl), null); |
||
51 | |||
52 | public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
||
53 | "Paint", typeof(PaintSet), typeof(CloudControl), new PropertyMetadata(PaintSet.None)); |
||
54 | |||
55 | public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
||
56 | "StrokeColor", typeof(SolidColorBrush), typeof(CloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
||
57 | |||
58 | public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
||
59 | "PathData", typeof(Geometry), typeof(CloudControl), null); |
||
60 | |||
61 | public static readonly DependencyProperty PathSubDataProperty = DependencyProperty.Register( |
||
62 | "PathSubData", typeof(Geometry), typeof(CloudControl), null); |
||
63 | |||
64 | public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
||
65 | "EndPoint", typeof(Point), typeof(CloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
66 | |||
67 | public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
||
68 | "StartPoint", typeof(Point), typeof(CloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
69 | |||
70 | public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
||
71 | "PointSet", typeof(List<Point>), typeof(CloudControl), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
||
72 | public static readonly DependencyProperty isTransOnProperty = DependencyProperty.Register( |
||
73 | "isTransOn", typeof(bool), typeof(CloudControl), new PropertyMetadata(false)); |
||
74 | public static readonly DependencyProperty isChainProperty = DependencyProperty.Register( |
||
75 | "isChain", typeof(bool), typeof(CloudControl), new PropertyMetadata(false)); |
||
76 | |||
77 | /// <summary> |
||
78 | /// StylusPointSet을 List<Point>로 대체하면 PointValueChanged가 작동안한다. |
||
79 | /// </summary> |
||
80 | public static readonly DependencyProperty StylusPointSetProperty = DependencyProperty.Register( |
||
81 | "PointC", typeof(StylusPointSet), typeof(CloudControl), new PropertyMetadata(new StylusPointSet(), PointValueChanged)); |
||
82 | |||
83 | public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("AngleValue", typeof(double), typeof(CloudControl), |
||
84 | new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
||
85 | |||
86 | public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(CloudControl), |
||
87 | new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
88 | |||
89 | public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(CloudControl), |
||
90 | new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
91 | |||
92 | public static readonly DependencyProperty IsSelectedProperty = |
||
93 | DependencyProperty.Register("IsSelected", typeof(bool), typeof(CloudControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
||
94 | |||
95 | public static readonly DependencyProperty ControlTypeProperty = |
||
96 | DependencyProperty.Register("ControlType", typeof(ControlType), typeof(CloudControl), new FrameworkPropertyMetadata(ControlType.PolygonCloud)); |
||
97 | |||
98 | public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
||
99 | "OverViewPathData", typeof(Geometry), typeof(ControlType), null); |
||
100 | |||
101 | |||
102 | public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register( |
||
103 | "CanvasX", typeof(double), typeof(CloudControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
||
104 | |||
105 | public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register( |
||
106 | "CanvasY", typeof(double), typeof(CloudControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
||
107 | |||
108 | |||
109 | #endregion |
||
110 | #region PropertyChanged Method |
||
111 | |||
112 | public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
113 | { |
||
114 | var instance = (CloudControl)sender; |
||
115 | |||
116 | if (e.OldValue != e.NewValue && instance != null) |
||
117 | { |
||
118 | instance.SetValue(e.Property, e.NewValue); |
||
119 | } |
||
120 | } |
||
121 | |||
122 | public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
123 | { |
||
124 | var instance = (CloudControl)sender; |
||
125 | if (e.OldValue != e.NewValue && instance.Base_CloudPath != null) |
||
126 | { |
||
127 | instance.SetValue(e.Property, e.NewValue); |
||
128 | //instance.SetCloud(); 주석처리 |
||
129 | } |
||
130 | } |
||
131 | public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
132 | { |
||
133 | //var instance = (CloudControl)sender; |
||
134 | |||
135 | //if (e.OldValue != e.NewValue && instance.Base_CloudPath != null) |
||
136 | //{ |
||
137 | |||
138 | // instance.SetValue(e.Property, e.NewValue); |
||
139 | |||
140 | // if (instance.IsSelected) |
||
141 | // { |
||
142 | // instance.Base_CloudPath.Stroke = new SolidColorBrush(Colors.Blue); |
||
143 | // } |
||
144 | // else |
||
145 | // { |
||
146 | // instance.Base_CloudPath.Stroke = new SolidColorBrush(Colors.Red); |
||
147 | // } |
||
148 | //} |
||
149 | } |
||
150 | |||
151 | public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
152 | { |
||
153 | var instance = (CloudControl)sender; |
||
154 | if (e.OldValue != e.NewValue && instance.Base_CloudPath != null) |
||
155 | { |
||
156 | instance.SetValue(e.Property, e.NewValue); |
||
157 | instance.DrawingCloud(); |
||
158 | } |
||
159 | } |
||
160 | public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
161 | { |
||
162 | var instance = (CloudControl)sender; |
||
163 | if (e.OldValue != e.NewValue && instance.Base_CloudPath != null) |
||
164 | { |
||
165 | instance.SetValue(e.Property, e.NewValue); |
||
166 | instance.DrawingCloud(); |
||
167 | } |
||
168 | } |
||
169 | #endregion |
||
170 | #region Properties |
||
171 | |||
172 | |||
173 | public bool IsCompleted |
||
174 | { |
||
175 | get { return (bool)GetValue(IsCompletedProperty); } |
||
176 | set |
||
177 | { |
||
178 | SetValue(IsCompletedProperty, value); |
||
179 | } |
||
180 | } |
||
181 | |||
182 | public Geometry OverViewPathData |
||
183 | { |
||
184 | get { return (Geometry)GetValue(OverViewPathDataProperty); } |
||
185 | set |
||
186 | { |
||
187 | SetValue(OverViewPathDataProperty, value); |
||
188 | OnPropertyChanged("OverViewPathData"); |
||
189 | } |
||
190 | } |
||
191 | |||
192 | public double CanvasX |
||
193 | { |
||
194 | get { return (double)GetValue(CanvasXProperty); } |
||
195 | set |
||
196 | { |
||
197 | if (this.CanvasX != value) |
||
198 | { |
||
199 | SetValue(CanvasXProperty, value); |
||
200 | } |
||
201 | } |
||
202 | } |
||
203 | |||
204 | public double CanvasY |
||
205 | { |
||
206 | get { return (double)GetValue(CanvasYProperty); } |
||
207 | set |
||
208 | { |
||
209 | if (this.CanvasY != value) |
||
210 | { |
||
211 | SetValue(CanvasYProperty, value); |
||
212 | } |
||
213 | } |
||
214 | } |
||
215 | |||
216 | public bool IsSelected |
||
217 | { |
||
218 | get |
||
219 | { |
||
220 | return (bool)GetValue(IsSelectedProperty); |
||
221 | } |
||
222 | set |
||
223 | { |
||
224 | SetValue(IsSelectedProperty, value); |
||
225 | } |
||
226 | } |
||
227 | |||
228 | public ControlType ControlType |
||
229 | { |
||
230 | set |
||
231 | { |
||
232 | SetValue(ControlTypeProperty, value); |
||
233 | } |
||
234 | get |
||
235 | { |
||
236 | return (ControlType)GetValue(ControlTypeProperty); |
||
237 | } |
||
238 | } |
||
239 | |||
240 | public Double LineSize |
||
241 | { |
||
242 | get { return (Double)GetValue(LineSizeProperty); } |
||
243 | set |
||
244 | { |
||
245 | if (this.LineSize != value) |
||
246 | { |
||
247 | SetValue(LineSizeProperty, value); |
||
248 | } |
||
249 | } |
||
250 | } |
||
251 | public bool isChain |
||
252 | { |
||
253 | get { return (bool)GetValue(isChainProperty); } |
||
254 | set |
||
255 | { |
||
256 | SetValue(isChainProperty, value); |
||
257 | OnPropertyChanged("isChain"); |
||
258 | } |
||
259 | } |
||
260 | public bool isTransOn |
||
261 | { |
||
262 | get { return (bool)GetValue(isTransOnProperty); } |
||
263 | set |
||
264 | { |
||
265 | SetValue(isTransOnProperty, value); |
||
266 | OnPropertyChanged("isTransOn"); |
||
267 | } |
||
268 | } |
||
269 | public DoubleCollection DashSize |
||
270 | { |
||
271 | get { return (DoubleCollection)GetValue(DashSizeProperty); } |
||
272 | set |
||
273 | { |
||
274 | if (this.DashSize != value) |
||
275 | { |
||
276 | SetValue(DashSizeProperty, value); |
||
277 | OnPropertyChanged("DashSize"); |
||
278 | } |
||
279 | } |
||
280 | } |
||
281 | public string UserID |
||
282 | { |
||
283 | get { return (string)GetValue(UserIDProperty); } |
||
284 | set |
||
285 | { |
||
286 | if (this.UserID != value) |
||
287 | { |
||
288 | SetValue(UserIDProperty, value); |
||
289 | OnPropertyChanged("UserID"); |
||
290 | } |
||
291 | } |
||
292 | } |
||
293 | public PaintSet Paint |
||
294 | { |
||
295 | get { return (PaintSet)GetValue(PaintProperty); } |
||
296 | set |
||
297 | { |
||
298 | if (this.Paint != value) |
||
299 | { |
||
300 | SetValue(PaintProperty, value); |
||
301 | OnPropertyChanged("Paint"); |
||
302 | } |
||
303 | } |
||
304 | } |
||
305 | |||
306 | public SolidColorBrush FillColor |
||
307 | { |
||
308 | get { return (SolidColorBrush)GetValue(FillColorProperty); } |
||
309 | set |
||
310 | { |
||
311 | if (this.FillColor != value) |
||
312 | { |
||
313 | SetValue(FillColorProperty, value); |
||
314 | OnPropertyChanged("FillColor"); |
||
315 | } |
||
316 | } |
||
317 | } |
||
318 | public SolidColorBrush StrokeColor |
||
319 | { |
||
320 | get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
||
321 | set |
||
322 | { |
||
323 | if (this.StrokeColor != value) |
||
324 | { |
||
325 | SetValue(StrokeColorProperty, value); |
||
326 | OnPropertyChanged("StrokeColor"); |
||
327 | } |
||
328 | } |
||
329 | } |
||
330 | public Geometry PathData |
||
331 | { |
||
332 | get |
||
333 | { |
||
334 | return (Geometry)GetValue(PathDataProperty); |
||
335 | } |
||
336 | set |
||
337 | { |
||
338 | SetValue(PathDataProperty, value); |
||
339 | OnPropertyChanged("PathData"); |
||
340 | } |
||
341 | } |
||
342 | public Geometry PathSubData |
||
343 | { |
||
344 | get |
||
345 | { |
||
346 | return (Geometry)GetValue(PathSubDataProperty); |
||
347 | } |
||
348 | set |
||
349 | { |
||
350 | SetValue(PathSubDataProperty, value); |
||
351 | OnPropertyChanged("PathSubData"); |
||
352 | } |
||
353 | } |
||
354 | public Point EndPoint |
||
355 | { |
||
356 | get |
||
357 | { |
||
358 | return (Point)GetValue(EndPointProperty); |
||
359 | } |
||
360 | set |
||
361 | { |
||
362 | SetValue(EndPointProperty, value); |
||
363 | OnPropertyChanged("EndPoint"); |
||
364 | } |
||
365 | } |
||
366 | public Point StartPoint |
||
367 | { |
||
368 | get |
||
369 | { |
||
370 | return (Point)GetValue(StartPointProperty); |
||
371 | } |
||
372 | set |
||
373 | { |
||
374 | SetValue(StartPointProperty, value); |
||
375 | OnPropertyChanged("StartPoint"); |
||
376 | } |
||
377 | } |
||
378 | public List<Point> _pointSet; |
||
379 | |||
380 | public List<Point> PointSet |
||
381 | { |
||
382 | get |
||
383 | { |
||
384 | return (List<Point>)GetValue(PointSetProperty); |
||
385 | } |
||
386 | set |
||
387 | { |
||
388 | SetValue(PointSetProperty, value); |
||
389 | OnPropertyChanged("PointSet"); |
||
390 | } |
||
391 | } |
||
392 | |||
393 | public List<Point> pointSet |
||
394 | { |
||
395 | get |
||
396 | { |
||
397 | return _pointSet; |
||
398 | } |
||
399 | set |
||
400 | { |
||
401 | _pointSet = value; |
||
402 | OnPropertyChanged("pointSet"); |
||
403 | } |
||
404 | } |
||
405 | |||
406 | private double _toler = 1; |
||
407 | public double Toler |
||
408 | { |
||
409 | get { return _toler; } |
||
410 | set { _toler = value; } |
||
411 | } |
||
412 | private double _arcLength = 10; |
||
413 | public double ArcLength |
||
414 | { |
||
415 | get { return _arcLength; } |
||
416 | set { _arcLength = value; } |
||
417 | } |
||
418 | private bool _fill = false; |
||
419 | public bool Fill |
||
420 | { |
||
421 | get { return _fill; } |
||
422 | set { _fill = value; } |
||
423 | } |
||
424 | public double Angle |
||
425 | { |
||
426 | get { return (double)GetValue(AngleProperty); } |
||
427 | set |
||
428 | { |
||
429 | if (this.Angle != value) |
||
430 | { |
||
431 | SetValue(AngleProperty, value); |
||
432 | OnPropertyChanged("Angle"); |
||
433 | } |
||
434 | } |
||
435 | } |
||
436 | public StylusPointSet PointC |
||
437 | { |
||
438 | get { return (StylusPointSet)GetValue(StylusPointSetProperty); } |
||
439 | set |
||
440 | { |
||
441 | SetValue(StylusPointSetProperty, value); |
||
442 | OnPropertyChanged("PointC"); |
||
443 | } |
||
444 | } |
||
445 | public double CenterX |
||
446 | { |
||
447 | get |
||
448 | { |
||
449 | return (double)GetValue(CenterXProperty); |
||
450 | } |
||
451 | set |
||
452 | { |
||
453 | SetValue(CenterXProperty, value); |
||
454 | OnPropertyChanged("CenterX"); |
||
455 | } |
||
456 | } |
||
457 | public double CenterY |
||
458 | { |
||
459 | get |
||
460 | { |
||
461 | return (double)GetValue(CenterYProperty); |
||
462 | } |
||
463 | set |
||
464 | { |
||
465 | SetValue(CenterYProperty, value); |
||
466 | OnPropertyChanged("CenterY"); |
||
467 | } |
||
468 | } |
||
469 | public double AngleValue |
||
470 | { |
||
471 | get |
||
472 | { |
||
473 | return (double)GetValue(AngleProperty); |
||
474 | } |
||
475 | set |
||
476 | { |
||
477 | SetValue(AngleProperty, value); |
||
478 | OnPropertyChanged("AngleValue"); |
||
479 | } |
||
480 | } |
||
481 | #endregion |
||
482 | #region Data |
||
483 | private PathGeometry _pathGeometry = new PathGeometry(); |
||
484 | private PathGeometry _pathSubGeometry = new PathGeometry(); |
||
485 | #endregion |
||
486 | |||
487 | public override void OnApplyTemplate() |
||
488 | { |
||
489 | base.OnApplyTemplate(); |
||
490 | Base_CloudPath = GetTemplateChild(PART_CloudPath) as Path; |
||
491 | Base_CloudSubPath = GetTemplateChild(PART_CloudSubPath) as Path; |
||
492 | } |
||
493 | public void SetCloud() |
||
494 | { |
||
495 | //this.Width = this.Base_CloudPath.Width; |
||
496 | //this.Height = this.Base_CloudPath.Height; |
||
497 | |||
498 | this.ApplyTemplate(); |
||
499 | |||
500 | Generate(); |
||
501 | |||
502 | if (!isChain) |
||
503 | { |
||
504 | //ClosePath(); |
||
505 | } |
||
506 | } |
||
507 | public int Generate() |
||
508 | { |
||
509 | this._pathGeometry = null; |
||
510 | this._pathSubGeometry = null; |
||
511 | switch (this.Paint) |
||
512 | { |
||
513 | case PaintSet.None: |
||
514 | this.FillColor = null; |
||
515 | if (Base_CloudSubPath != null) |
||
516 | { |
||
517 | Base_CloudPath.Fill = null; |
||
518 | Base_CloudSubPath.Fill = null; |
||
519 | Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
520 | //Base_CloudSubPath.StrokeThickness = 3; |
||
521 | } |
||
522 | break; |
||
523 | case PaintSet.Fill: |
||
524 | this.FillColor = this.StrokeColor; |
||
525 | if (Base_CloudSubPath != null) |
||
526 | { |
||
527 | if (isChain) |
||
528 | { |
||
529 | Base_CloudPath.Fill = null; |
||
530 | Base_CloudSubPath.Fill = null; |
||
531 | Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
532 | //Base_CloudSubPath.StrokeThickness = 3; |
||
533 | } |
||
534 | else |
||
535 | { |
||
536 | Base_CloudSubPath.Stroke = this.StrokeColor; |
||
537 | //Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
538 | Base_CloudSubPath.StrokeThickness = 0.5; |
||
539 | Base_CloudPath.Stroke = this.StrokeColor; |
||
540 | //Base_CloudPath.StrokeThickness = 3; |
||
541 | Base_CloudPath.Fill = this.FillColor; |
||
542 | Base_CloudSubPath.Fill = this.FillColor; |
||
543 | } |
||
544 | } |
||
545 | break; |
||
546 | case PaintSet.Hatch: |
||
547 | if (Base_CloudSubPath != null && !isChain) |
||
548 | { |
||
549 | if (isChain) |
||
550 | { |
||
551 | Base_CloudPath.Fill = null; |
||
552 | Base_CloudSubPath.Fill = null; |
||
553 | Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
554 | //Base_CloudSubPath.StrokeThickness = 3; |
||
555 | } |
||
556 | else |
||
557 | { |
||
558 | Base_CloudPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor, this.LineSize * 0.1); |
||
559 | Base_CloudSubPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor, this.LineSize * 0.1); |
||
560 | Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
561 | } |
||
562 | } |
||
563 | break; |
||
564 | default: |
||
565 | break; |
||
566 | } |
||
567 | |||
568 | //if (Base_CloudPath != null) |
||
569 | //{ |
||
570 | // Base_CloudPath.StrokeDashArray.Clear(); |
||
571 | // Base_CloudSubPath.StrokeDashArray.Clear(); |
||
572 | // foreach (var item in this.DashSize) |
||
573 | // { |
||
574 | // Base_CloudPath.StrokeDashArray.Add(item); |
||
575 | // Base_CloudSubPath.StrokeDashArray.Add(item); |
||
576 | // } |
||
577 | //} |
||
578 | |||
579 | |||
580 | /// set reverse if area is greater 0 - 2012.07.04 added by humkyung |
||
581 | double area = MathSet.AreaOf(this.PointSet); |
||
582 | bool reverse = (area > 0); |
||
583 | /// up to here |
||
584 | |||
585 | this._pathGeometry = new PathGeometry(); |
||
586 | this._pathSubGeometry = new PathGeometry(); |
||
587 | int count = this.PointSet.Count; |
||
588 | |||
589 | if (isTransOn) // true라면 클라우드 컨트롤 |
||
590 | { |
||
591 | for (int i = 0; i < (count - 1); i++) |
||
592 | { |
||
593 | PathFigure pathFigure = CloudControl.GenerateLineWithCloud(this.PointSet[i], this.PointSet[i + 1], this.ArcLength, reverse); |
||
594 | _pathGeometry.Figures.Add(pathFigure); |
||
595 | } |
||
596 | } |
||
597 | else |
||
598 | { |
||
599 | PathFigure fm = new PathFigure(); |
||
600 | fm.StartPoint = this.PointSet[0]; |
||
601 | for (int i = 0; i < (count - 1); i++) |
||
602 | { |
||
603 | fm.Segments.Add(new LineSegment { Point = this.PointSet[i] }); |
||
604 | } |
||
605 | _pathGeometry.Figures.Add(fm); |
||
606 | } |
||
607 | |||
608 | if (this.Paint == PaintSet.Fill || this.Paint == PaintSet.Hatch) |
||
609 | { |
||
610 | PointCollection pd = new PointCollection(); |
||
611 | foreach (var item in this.PointSet) |
||
612 | { |
||
613 | pd.Add(item); |
||
614 | } |
||
615 | _pathSubGeometry.Figures.Add(new PathFigure() |
||
616 | { |
||
617 | Segments = new PathSegmentCollection() |
||
618 | { |
||
619 | new PolyLineSegment() |
||
620 | { |
||
621 | Points = pd |
||
622 | }, |
||
623 | }, |
||
624 | StartPoint = this.PointSet[0] |
||
625 | }); |
||
626 | |||
627 | this.PathSubData = _pathSubGeometry; |
||
628 | } |
||
629 | |||
630 | |||
631 | StartPoint = PointSet[0]; |
||
632 | this.PathData = this._pathGeometry; |
||
633 | this.OverViewPathData = PathData; |
||
634 | this.StrokeColor = StrokeColor; |
||
635 | this.LineSize = LineSize; |
||
636 | |||
637 | return 0; |
||
638 | } |
||
639 | |||
640 | /// <summary> |
||
641 | /// draw arcs between p1 and p2 |
||
642 | /// </summary> |
||
643 | /// <author>humkyung</author> |
||
644 | /// <param name="p1"></param> |
||
645 | /// <param name="p2"></param> |
||
646 | /// <param name="reverse"></param> |
||
647 | /// <returns></returns> |
||
648 | public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse) |
||
649 | { |
||
650 | PathFigure pathFigure = new PathFigure(); |
||
651 | pathFigure.StartPoint = p1; |
||
652 | |||
653 | double arcLength = arcLength_; |
||
654 | /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung |
||
655 | double dx = p2.X - p1.X; |
||
656 | double dy = p2.Y - p1.Y; |
||
657 | double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2 |
||
658 | double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI; |
||
659 | Point lastPt = new Point(p1.X, p1.Y); |
||
660 | double count = l / arcLength; |
||
661 | /// normalize |
||
662 | dx /= l; |
||
663 | dy /= l; |
||
664 | Double j = 1; |
||
665 | for (j = 1; j < (count - 1); j++) |
||
666 | { |
||
667 | ArcSegment arcSeg = new ArcSegment(); |
||
668 | arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8); /// x size and y size of arc |
||
669 | arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength); /// end point of arc |
||
670 | lastPt = arcSeg.Point; /// save last point |
||
671 | arcSeg.RotationAngle = theta + 90; |
||
672 | if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
||
673 | pathFigure.Segments.Add(arcSeg); |
||
674 | } |
||
675 | |||
676 | /// draw arc between last point and end point |
||
677 | if ((count > j) || (count > 0)) |
||
678 | { |
||
679 | arcLength = MathSet.DistanceTo(lastPt, p2); |
||
680 | ArcSegment arcSeg = new ArcSegment(); |
||
681 | arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8); /// x size and y size of arc |
||
682 | arcSeg.Point = new Point(p2.X, p2.Y); /// end point of arc |
||
683 | arcSeg.RotationAngle = theta; |
||
684 | if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
||
685 | pathFigure.Segments.Add(arcSeg); |
||
686 | |||
687 | } |
||
688 | |||
689 | pathFigure.IsFilled = true; |
||
690 | return pathFigure; |
||
691 | } |
||
692 | |||
693 | /// <summary> |
||
694 | /// close path if it's open |
||
695 | /// </summary> |
||
696 | /// <author>humkyung</author> |
||
697 | /// <returns></returns> |
||
698 | public int ClosePath() |
||
699 | { |
||
700 | if (this.PointSet.Count > 1) |
||
701 | { |
||
702 | double d = MathSet.DistanceTo(this.PointSet[0], this.PointSet[this.PointSet.Count - 1]); |
||
703 | if (d > _toler) |
||
704 | { |
||
705 | /// set reverse if area is greater 0 - 2012.07.04 added by humkyung |
||
706 | double area = MathSet.AreaOf(this.PointSet); |
||
707 | bool reverse = (area > 0); |
||
708 | /// up to here |
||
709 | |||
710 | int count = this.PointSet.Count; |
||
711 | |||
712 | |||
713 | |||
714 | if (isTransOn) // true라면 클라우드 컨트롤 |
||
715 | { |
||
716 | PathFigure pathFigure = CloudControl.GenerateLineWithCloud(this.PointSet[count - 1], this.PointSet[0], this.ArcLength - 5, reverse); |
||
717 | |||
718 | if (this.Paint == PaintSet.Fill) |
||
719 | { |
||
720 | pathFigure.IsClosed = true; |
||
721 | } |
||
722 | |||
723 | _pathGeometry.Figures.Add(pathFigure); |
||
724 | |||
725 | } |
||
726 | else |
||
727 | { |
||
728 | |||
729 | PathFigure fm = new PathFigure(); |
||
730 | fm.StartPoint = this.PointSet[count - 1]; |
||
731 | |||
732 | //for (int i = 0; i < (count - 1); i++) |
||
733 | //{ |
||
734 | _pathGeometry.Figures[_pathGeometry.Figures.Count - 1].Segments.Add(new LineSegment { Point = this.PointSet[0] }); |
||
735 | _pathGeometry.Figures[_pathGeometry.Figures.Count - 1].Segments.Add(new LineSegment { Point = this.PointSet[1] }); |
||
736 | //fm.Segments.Add(new LineSegment { Point = this.PointSet[0] }); |
||
737 | //} |
||
738 | } |
||
739 | } |
||
740 | } |
||
741 | |||
742 | return 0; |
||
743 | } |
||
744 | public void DrawingCloud() |
||
745 | { |
||
746 | AnotherSetCloud(); |
||
747 | if (!isChain) |
||
748 | { |
||
749 | //ClosePath(); |
||
750 | } |
||
751 | } |
||
752 | public void AnotherSetCloud() |
||
753 | { |
||
754 | this.StrokeColor = StrokeColor; |
||
755 | this.LineSize = LineSize; |
||
756 | this.SetCloud(); |
||
757 | //Generate(); |
||
758 | this.Width = this.Base_CloudPath.Width; |
||
759 | this.Height = this.Base_CloudPath.Height; |
||
760 | } |
||
761 | public void Dispose() |
||
762 | { |
||
763 | GC.Collect(); |
||
764 | GC.SuppressFinalize(this); |
||
765 | } |
||
766 | public event PropertyChangedEventHandler PropertyChanged; |
||
767 | protected void OnPropertyChanged(string propName) |
||
768 | { |
||
769 | if (PropertyChanged != null) |
||
770 | PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
||
771 | } |
||
772 | public void updateControl() |
||
773 | { |
||
774 | |||
775 | var lastIndex = this.PointSet.Count - 1; |
||
776 | //this.StartPoint = this.PointSet[0]; |
||
777 | //this.EndPoint = this.PointSet[lastIndex]; |
||
778 | CenterX = MathSet.getMiddlePoint(this.PointSet[0], this.PointSet[lastIndex]).X; |
||
779 | CenterY = MathSet.getMiddlePoint(this.PointSet[0], this.PointSet[lastIndex]).Y; |
||
780 | } |
||
781 | public void ChangePaint(PaintSet state) |
||
782 | { |
||
783 | this.Paint = state; |
||
784 | this.SetCloud(); |
||
785 | |||
786 | } |
||
787 | #region Method |
||
788 | public void ApplyOverViewData() |
||
789 | { |
||
790 | this.OverViewPathData = this.PathData; |
||
791 | } |
||
792 | #endregion |
||
793 | } |
||
794 | |||
795 | } |