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