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