markus / MarkupToPDF / Controls / Polygon / CloudControl.cs @ fa48eb85
이력 | 보기 | 이력해설 | 다운로드 (34.7 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 | 036650a0 | humkyung | using MarkupToPDF.Serialize.Core; |
16 | using MarkupToPDF.Serialize.S_Control; |
||
17 | 661b7416 | humkyung | using System.Linq; |
18 | 787a4489 | KangIngu | |
19 | namespace MarkupToPDF.Controls.Polygon |
||
20 | { |
||
21 | public class CloudControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IPath, IShapeControl, ICloudControl, IDashControl |
||
22 | { |
||
23 | private const string PART_CloudPath = "PART_CloudPath"; |
||
24 | private const string PART_CloudSubPath = "PART_CloudSubPath"; |
||
25 | |||
26 | public Path Base_CloudPath = null; |
||
27 | public Path Base_CloudSubPath = null; |
||
28 | |||
29 | 53393bae | KangIngu | private const double _CloudArcDepth = 0.8; /// 2018.05.14 added by humkyung |
30 | 5a9353a9 | humkyung | |
31 | 787a4489 | KangIngu | static CloudControl() |
32 | { |
||
33 | DefaultStyleKeyProperty.OverrideMetadata(typeof(CloudControl), new FrameworkPropertyMetadata(typeof(CloudControl))); |
||
34 | //Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
||
35 | a6f7f9b6 | djkim | //ResourceDictionary dictionary = new ResourceDictionary(); |
36 | //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
||
37 | //Application.Current.Resources.MergedDictionaries.Add(dictionary); |
||
38 | 787a4489 | KangIngu | } |
39 | public CloudControl() |
||
40 | { |
||
41 | a6f7f9b6 | djkim | //this.DefaultStyleKey = typeof(CloudControl); |
42 | 787a4489 | KangIngu | } |
43 | |||
44 | #region Dependency Properties |
||
45 | public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
||
46 | "UserID", typeof(string), typeof(CloudControl), new PropertyMetadata(null)); |
||
47 | public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
||
48 | "LineSize", typeof(double), typeof(CloudControl), new PropertyMetadata((Double)3)); |
||
49 | //강인구 추가 |
||
50 | public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
||
51 | "DashSize", typeof(DoubleCollection), typeof(CloudControl), new PropertyMetadata(new DoubleCollection { 99999999 }, PointValueChanged)); |
||
52 | public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register( |
||
53 | "FillColor", typeof(SolidColorBrush), typeof(CloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
||
54 | |||
55 | public static readonly DependencyProperty IsCompletedProperty = DependencyProperty.Register( |
||
56 | "IsCompleted", typeof(bool), typeof(CloudControl), null); |
||
57 | //강인구 |
||
58 | public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
||
59 | "Paint", typeof(PaintSet), typeof(CloudControl), new PropertyMetadata(PaintSet.None, PointValueChanged)); |
||
60 | |||
61 | public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
||
62 | "StrokeColor", typeof(SolidColorBrush), typeof(CloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
||
63 | |||
64 | 9f473fb7 | KangIngu | public static readonly DependencyProperty ArcLengthProperty = DependencyProperty.Register( |
65 | "ArcLength", typeof(double), typeof(CloudControl), new PropertyMetadata((Double)10, PointValueChanged)); |
||
66 | |||
67 | 787a4489 | KangIngu | public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
68 | "PathData", typeof(Geometry), typeof(CloudControl), null); |
||
69 | |||
70 | public static readonly DependencyProperty PathSubDataProperty = DependencyProperty.Register( |
||
71 | "PathSubData", typeof(Geometry), typeof(CloudControl), null); |
||
72 | |||
73 | public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
||
74 | "EndPoint", typeof(Point), typeof(CloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
75 | |||
76 | public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
||
77 | "StartPoint", typeof(Point), typeof(CloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
78 | |||
79 | public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
||
80 | "PointSet", typeof(List<Point>), typeof(CloudControl), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
||
81 | public static readonly DependencyProperty isTransOnProperty = DependencyProperty.Register( |
||
82 | "isTransOn", typeof(bool), typeof(CloudControl), new PropertyMetadata(false)); |
||
83 | public static readonly DependencyProperty isChainProperty = DependencyProperty.Register( |
||
84 | "isChain", typeof(bool), typeof(CloudControl), new PropertyMetadata(false)); |
||
85 | |||
86 | /// <summary> |
||
87 | /// StylusPointSet을 List<Point>로 대체하면 PointValueChanged가 작동안한다. |
||
88 | /// </summary> |
||
89 | public static readonly DependencyProperty StylusPointSetProperty = DependencyProperty.Register( |
||
90 | "PointC", typeof(StylusPointSet), typeof(CloudControl), new PropertyMetadata(new StylusPointSet(), PointValueChanged)); |
||
91 | |||
92 | public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("AngleValue", typeof(double), typeof(CloudControl), |
||
93 | new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
||
94 | |||
95 | public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(CloudControl), |
||
96 | new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
97 | |||
98 | public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(CloudControl), |
||
99 | new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
100 | |||
101 | public static readonly DependencyProperty IsSelectedProperty = |
||
102 | DependencyProperty.Register("IsSelected", typeof(bool), typeof(CloudControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
||
103 | |||
104 | public static readonly DependencyProperty ControlTypeProperty = |
||
105 | DependencyProperty.Register("ControlType", typeof(ControlType), typeof(CloudControl), new FrameworkPropertyMetadata(ControlType.PolygonCloud)); |
||
106 | |||
107 | public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
||
108 | "OverViewPathData", typeof(Geometry), typeof(ControlType), null); |
||
109 | |||
110 | |||
111 | public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register( |
||
112 | "CanvasX", typeof(double), typeof(CloudControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
||
113 | |||
114 | public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register( |
||
115 | "CanvasY", typeof(double), typeof(CloudControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
||
116 | |||
117 | |||
118 | #endregion |
||
119 | #region PropertyChanged Method |
||
120 | |||
121 | public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
122 | { |
||
123 | var instance = (CloudControl)sender; |
||
124 | |||
125 | if (e.OldValue != e.NewValue && instance != null) |
||
126 | { |
||
127 | instance.SetValue(e.Property, e.NewValue); |
||
128 | } |
||
129 | } |
||
130 | |||
131 | public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
132 | { |
||
133 | var instance = (CloudControl)sender; |
||
134 | if (e.OldValue != e.NewValue && instance.Base_CloudPath != null) |
||
135 | { |
||
136 | instance.SetValue(e.Property, e.NewValue); |
||
137 | //강인구 추가 |
||
138 | instance.SetCloud(); |
||
139 | //주석처리 |
||
140 | } |
||
141 | } |
||
142 | public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
143 | { |
||
144 | //var instance = (CloudControl)sender; |
||
145 | |||
146 | //if (e.OldValue != e.NewValue && instance.Base_CloudPath != null) |
||
147 | //{ |
||
148 | |||
149 | // instance.SetValue(e.Property, e.NewValue); |
||
150 | |||
151 | // if (instance.IsSelected) |
||
152 | // { |
||
153 | // instance.Base_CloudPath.Stroke = new SolidColorBrush(Colors.Blue); |
||
154 | // } |
||
155 | // else |
||
156 | // { |
||
157 | // instance.Base_CloudPath.Stroke = new SolidColorBrush(Colors.Red); |
||
158 | // } |
||
159 | //} |
||
160 | } |
||
161 | |||
162 | public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
163 | { |
||
164 | var instance = (CloudControl)sender; |
||
165 | if (e.OldValue != e.NewValue && instance.Base_CloudPath != null) |
||
166 | { |
||
167 | instance.SetValue(e.Property, e.NewValue); |
||
168 | instance.DrawingCloud(); |
||
169 | } |
||
170 | } |
||
171 | public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
172 | { |
||
173 | var instance = (CloudControl)sender; |
||
174 | if (e.OldValue != e.NewValue && instance.Base_CloudPath != null) |
||
175 | { |
||
176 | instance.SetValue(e.Property, e.NewValue); |
||
177 | instance.DrawingCloud(); |
||
178 | } |
||
179 | } |
||
180 | #endregion |
||
181 | #region Properties |
||
182 | |||
183 | |||
184 | public bool IsCompleted |
||
185 | { |
||
186 | get { return (bool)GetValue(IsCompletedProperty); } |
||
187 | set |
||
188 | { |
||
189 | SetValue(IsCompletedProperty, value); |
||
190 | } |
||
191 | } |
||
192 | |||
193 | public Geometry OverViewPathData |
||
194 | { |
||
195 | get { return (Geometry)GetValue(OverViewPathDataProperty); } |
||
196 | set |
||
197 | { |
||
198 | SetValue(OverViewPathDataProperty, value); |
||
199 | OnPropertyChanged("OverViewPathData"); |
||
200 | } |
||
201 | } |
||
202 | |||
203 | public double CanvasX |
||
204 | { |
||
205 | get { return (double)GetValue(CanvasXProperty); } |
||
206 | set |
||
207 | { |
||
208 | if (this.CanvasX != value) |
||
209 | { |
||
210 | SetValue(CanvasXProperty, value); |
||
211 | } |
||
212 | } |
||
213 | } |
||
214 | |||
215 | public double CanvasY |
||
216 | { |
||
217 | get { return (double)GetValue(CanvasYProperty); } |
||
218 | set |
||
219 | { |
||
220 | if (this.CanvasY != value) |
||
221 | { |
||
222 | SetValue(CanvasYProperty, value); |
||
223 | } |
||
224 | } |
||
225 | } |
||
226 | |||
227 | 959b3ef2 | humkyung | public override bool IsSelected |
228 | 787a4489 | KangIngu | { |
229 | get |
||
230 | { |
||
231 | return (bool)GetValue(IsSelectedProperty); |
||
232 | } |
||
233 | set |
||
234 | { |
||
235 | SetValue(IsSelectedProperty, value); |
||
236 | } |
||
237 | } |
||
238 | |||
239 | 5529d2a2 | humkyung | public override ControlType ControlType |
240 | 787a4489 | KangIngu | { |
241 | set |
||
242 | { |
||
243 | SetValue(ControlTypeProperty, value); |
||
244 | } |
||
245 | get |
||
246 | { |
||
247 | return (ControlType)GetValue(ControlTypeProperty); |
||
248 | } |
||
249 | } |
||
250 | |||
251 | public Double LineSize |
||
252 | { |
||
253 | get { return (Double)GetValue(LineSizeProperty); } |
||
254 | set |
||
255 | { |
||
256 | if (this.LineSize != value) |
||
257 | { |
||
258 | SetValue(LineSizeProperty, value); |
||
259 | } |
||
260 | } |
||
261 | } |
||
262 | public bool isChain |
||
263 | { |
||
264 | get { return (bool)GetValue(isChainProperty); } |
||
265 | set |
||
266 | { |
||
267 | SetValue(isChainProperty, value); |
||
268 | OnPropertyChanged("isChain"); |
||
269 | } |
||
270 | } |
||
271 | public bool isTransOn |
||
272 | { |
||
273 | get { return (bool)GetValue(isTransOnProperty); } |
||
274 | set |
||
275 | { |
||
276 | SetValue(isTransOnProperty, value); |
||
277 | OnPropertyChanged("isTransOn"); |
||
278 | } |
||
279 | } |
||
280 | public DoubleCollection DashSize |
||
281 | { |
||
282 | get { return (DoubleCollection)GetValue(DashSizeProperty); } |
||
283 | set |
||
284 | { |
||
285 | if (this.DashSize != value) |
||
286 | { |
||
287 | SetValue(DashSizeProperty, value); |
||
288 | OnPropertyChanged("DashSize"); |
||
289 | } |
||
290 | } |
||
291 | } |
||
292 | public string UserID |
||
293 | { |
||
294 | get { return (string)GetValue(UserIDProperty); } |
||
295 | set |
||
296 | { |
||
297 | if (this.UserID != value) |
||
298 | { |
||
299 | SetValue(UserIDProperty, value); |
||
300 | OnPropertyChanged("UserID"); |
||
301 | } |
||
302 | } |
||
303 | } |
||
304 | public PaintSet Paint |
||
305 | { |
||
306 | get { return (PaintSet)GetValue(PaintProperty); } |
||
307 | set |
||
308 | { |
||
309 | if (this.Paint != value) |
||
310 | { |
||
311 | SetValue(PaintProperty, value); |
||
312 | OnPropertyChanged("Paint"); |
||
313 | } |
||
314 | } |
||
315 | } |
||
316 | |||
317 | public SolidColorBrush FillColor |
||
318 | { |
||
319 | get { return (SolidColorBrush)GetValue(FillColorProperty); } |
||
320 | set |
||
321 | { |
||
322 | if (this.FillColor != value) |
||
323 | { |
||
324 | SetValue(FillColorProperty, value); |
||
325 | OnPropertyChanged("FillColor"); |
||
326 | } |
||
327 | } |
||
328 | } |
||
329 | 4913851c | humkyung | public override SolidColorBrush StrokeColor |
330 | 787a4489 | KangIngu | { |
331 | get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
||
332 | set |
||
333 | { |
||
334 | if (this.StrokeColor != value) |
||
335 | { |
||
336 | SetValue(StrokeColorProperty, value); |
||
337 | OnPropertyChanged("StrokeColor"); |
||
338 | } |
||
339 | } |
||
340 | } |
||
341 | public Geometry PathData |
||
342 | { |
||
343 | get |
||
344 | { |
||
345 | return (Geometry)GetValue(PathDataProperty); |
||
346 | } |
||
347 | set |
||
348 | { |
||
349 | SetValue(PathDataProperty, value); |
||
350 | OnPropertyChanged("PathData"); |
||
351 | } |
||
352 | } |
||
353 | public Geometry PathSubData |
||
354 | { |
||
355 | get |
||
356 | { |
||
357 | return (Geometry)GetValue(PathSubDataProperty); |
||
358 | } |
||
359 | set |
||
360 | { |
||
361 | SetValue(PathSubDataProperty, value); |
||
362 | OnPropertyChanged("PathSubData"); |
||
363 | } |
||
364 | } |
||
365 | public Point EndPoint |
||
366 | { |
||
367 | get |
||
368 | { |
||
369 | return (Point)GetValue(EndPointProperty); |
||
370 | } |
||
371 | set |
||
372 | { |
||
373 | SetValue(EndPointProperty, value); |
||
374 | OnPropertyChanged("EndPoint"); |
||
375 | } |
||
376 | } |
||
377 | public Point StartPoint |
||
378 | { |
||
379 | get |
||
380 | { |
||
381 | return (Point)GetValue(StartPointProperty); |
||
382 | } |
||
383 | set |
||
384 | { |
||
385 | SetValue(StartPointProperty, value); |
||
386 | OnPropertyChanged("StartPoint"); |
||
387 | } |
||
388 | } |
||
389 | public List<Point> _pointSet; |
||
390 | |||
391 | public List<Point> PointSet |
||
392 | { |
||
393 | get |
||
394 | { |
||
395 | return (List<Point>)GetValue(PointSetProperty); |
||
396 | } |
||
397 | set |
||
398 | { |
||
399 | SetValue(PointSetProperty, value); |
||
400 | OnPropertyChanged("PointSet"); |
||
401 | } |
||
402 | } |
||
403 | |||
404 | public List<Point> pointSet |
||
405 | { |
||
406 | get |
||
407 | { |
||
408 | return _pointSet; |
||
409 | } |
||
410 | set |
||
411 | { |
||
412 | _pointSet = value; |
||
413 | OnPropertyChanged("pointSet"); |
||
414 | } |
||
415 | } |
||
416 | |||
417 | 9f473fb7 | KangIngu | public Double ArcLength |
418 | { |
||
419 | get { return (Double)GetValue(ArcLengthProperty); } |
||
420 | set |
||
421 | { |
||
422 | if (this.ArcLength != value) |
||
423 | { |
||
424 | SetValue(ArcLengthProperty, value); |
||
425 | OnPropertyChanged("ArcLength"); |
||
426 | } |
||
427 | } |
||
428 | } |
||
429 | |||
430 | 787a4489 | KangIngu | private double _toler = 1; |
431 | public double Toler |
||
432 | { |
||
433 | get { return _toler; } |
||
434 | set { _toler = value; } |
||
435 | } |
||
436 | 5ce56a3a | KangIngu | //강인구 수정 클라우드 사이즈 |
437 | 9f473fb7 | KangIngu | //private double _arcLength; |
438 | ////private double _arcLength = 30; |
||
439 | //public double ArcLength |
||
440 | //{ |
||
441 | // get { return _arcLength; } |
||
442 | // set { _arcLength = value; } |
||
443 | //} |
||
444 | 787a4489 | KangIngu | private bool _fill = false; |
445 | public bool Fill |
||
446 | { |
||
447 | get { return _fill; } |
||
448 | set { _fill = value; } |
||
449 | } |
||
450 | 168f8027 | taeseongkim | //public double Angle |
451 | //{ |
||
452 | // get { return (double)GetValue(AngleProperty); } |
||
453 | // set |
||
454 | // { |
||
455 | // if (this.Angle != value) |
||
456 | // { |
||
457 | // SetValue(AngleProperty, value); |
||
458 | // OnPropertyChanged("Angle"); |
||
459 | // } |
||
460 | // } |
||
461 | //} |
||
462 | 787a4489 | KangIngu | public StylusPointSet PointC |
463 | { |
||
464 | get { return (StylusPointSet)GetValue(StylusPointSetProperty); } |
||
465 | set |
||
466 | { |
||
467 | SetValue(StylusPointSetProperty, value); |
||
468 | OnPropertyChanged("PointC"); |
||
469 | } |
||
470 | } |
||
471 | public double CenterX |
||
472 | { |
||
473 | get |
||
474 | { |
||
475 | return (double)GetValue(CenterXProperty); |
||
476 | } |
||
477 | set |
||
478 | { |
||
479 | SetValue(CenterXProperty, value); |
||
480 | OnPropertyChanged("CenterX"); |
||
481 | } |
||
482 | } |
||
483 | public double CenterY |
||
484 | { |
||
485 | get |
||
486 | { |
||
487 | return (double)GetValue(CenterYProperty); |
||
488 | } |
||
489 | set |
||
490 | { |
||
491 | SetValue(CenterYProperty, value); |
||
492 | OnPropertyChanged("CenterY"); |
||
493 | } |
||
494 | } |
||
495 | public double AngleValue |
||
496 | { |
||
497 | get |
||
498 | { |
||
499 | return (double)GetValue(AngleProperty); |
||
500 | } |
||
501 | set |
||
502 | { |
||
503 | SetValue(AngleProperty, value); |
||
504 | OnPropertyChanged("AngleValue"); |
||
505 | } |
||
506 | } |
||
507 | #endregion |
||
508 | #region Data |
||
509 | private PathGeometry _pathGeometry = new PathGeometry(); |
||
510 | private PathGeometry _pathSubGeometry = new PathGeometry(); |
||
511 | #endregion |
||
512 | |||
513 | public override void OnApplyTemplate() |
||
514 | { |
||
515 | base.OnApplyTemplate(); |
||
516 | Base_CloudPath = GetTemplateChild(PART_CloudPath) as Path; |
||
517 | Base_CloudSubPath = GetTemplateChild(PART_CloudSubPath) as Path; |
||
518 | SetCloud(); |
||
519 | } |
||
520 | public void SetCloud() |
||
521 | { |
||
522 | //this.Width = this.Base_CloudPath.Width; |
||
523 | //this.Height = this.Base_CloudPath.Height; |
||
524 | |||
525 | this.ApplyTemplate(); |
||
526 | |||
527 | Generate(); |
||
528 | |||
529 | if (!isChain) |
||
530 | { |
||
531 | //ClosePath(); |
||
532 | } |
||
533 | } |
||
534 | public int Generate() |
||
535 | { |
||
536 | this._pathGeometry = null; |
||
537 | this._pathSubGeometry = null; |
||
538 | switch (this.Paint) |
||
539 | { |
||
540 | case PaintSet.None: |
||
541 | this.FillColor = null; |
||
542 | if (Base_CloudSubPath != null) |
||
543 | { |
||
544 | Base_CloudPath.Fill = null; |
||
545 | Base_CloudSubPath.Fill = null; |
||
546 | Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
547 | //Base_CloudSubPath.StrokeThickness = 3; |
||
548 | } |
||
549 | break; |
||
550 | case PaintSet.Fill: |
||
551 | this.FillColor = this.StrokeColor; |
||
552 | if (Base_CloudSubPath != null) |
||
553 | { |
||
554 | if (isChain) |
||
555 | { |
||
556 | Base_CloudPath.Fill = null; |
||
557 | Base_CloudSubPath.Fill = null; |
||
558 | Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
559 | //Base_CloudSubPath.StrokeThickness = 3; |
||
560 | } |
||
561 | else |
||
562 | { |
||
563 | Base_CloudSubPath.Stroke = this.StrokeColor; |
||
564 | //Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
565 | Base_CloudSubPath.StrokeThickness = 0.5; |
||
566 | Base_CloudPath.Stroke = this.StrokeColor; |
||
567 | //Base_CloudPath.StrokeThickness = 3; |
||
568 | Base_CloudPath.Fill = this.FillColor; |
||
569 | Base_CloudSubPath.Fill = this.FillColor; |
||
570 | } |
||
571 | } |
||
572 | break; |
||
573 | case PaintSet.Hatch: |
||
574 | if (Base_CloudSubPath != null && !isChain) |
||
575 | { |
||
576 | if (isChain) |
||
577 | { |
||
578 | Base_CloudPath.Fill = null; |
||
579 | Base_CloudSubPath.Fill = null; |
||
580 | Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
581 | //Base_CloudSubPath.StrokeThickness = 3; |
||
582 | } |
||
583 | else |
||
584 | { |
||
585 | Base_CloudPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor, this.LineSize * 0.1); |
||
586 | Base_CloudSubPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor, this.LineSize * 0.1); |
||
587 | Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
588 | } |
||
589 | } |
||
590 | break; |
||
591 | default: |
||
592 | break; |
||
593 | } |
||
594 | |||
595 | //강인구 추가 |
||
596 | if (Base_CloudPath != null) |
||
597 | { |
||
598 | Base_CloudPath.StrokeDashArray.Clear(); |
||
599 | Base_CloudSubPath.StrokeDashArray.Clear(); |
||
600 | foreach (var item in this.DashSize) |
||
601 | { |
||
602 | Base_CloudPath.StrokeDashArray.Add(item); |
||
603 | Base_CloudSubPath.StrokeDashArray.Add(item); |
||
604 | } |
||
605 | } |
||
606 | |||
607 | |||
608 | /// set reverse if area is greater 0 - 2012.07.04 added by humkyung |
||
609 | double area = MathSet.AreaOf(this.PointSet); |
||
610 | bool reverse = (area > 0); |
||
611 | /// up to here |
||
612 | |||
613 | this._pathGeometry = new PathGeometry(); |
||
614 | this._pathSubGeometry = new PathGeometry(); |
||
615 | int count = this.PointSet.Count; |
||
616 | |||
617 | if (isTransOn) // true라면 클라우드 컨트롤 |
||
618 | { |
||
619 | for (int i = 0; i < (count - 1); i++) |
||
620 | { |
||
621 | PathFigure pathFigure = CloudControl.GenerateLineWithCloud(this.PointSet[i], this.PointSet[i + 1], this.ArcLength, reverse); |
||
622 | _pathGeometry.Figures.Add(pathFigure); |
||
623 | } |
||
624 | } |
||
625 | else |
||
626 | { |
||
627 | PathFigure fm = new PathFigure(); |
||
628 | fm.StartPoint = this.PointSet[0]; |
||
629 | for (int i = 0; i < (count - 1); i++) |
||
630 | { |
||
631 | fm.Segments.Add(new LineSegment { Point = this.PointSet[i] }); |
||
632 | } |
||
633 | _pathGeometry.Figures.Add(fm); |
||
634 | } |
||
635 | |||
636 | if (this.Paint == PaintSet.Fill || this.Paint == PaintSet.Hatch) |
||
637 | { |
||
638 | PointCollection pd = new PointCollection(); |
||
639 | foreach (var item in this.PointSet) |
||
640 | { |
||
641 | pd.Add(item); |
||
642 | } |
||
643 | _pathSubGeometry.Figures.Add(new PathFigure() |
||
644 | { |
||
645 | Segments = new PathSegmentCollection() |
||
646 | { |
||
647 | new PolyLineSegment() |
||
648 | { |
||
649 | Points = pd |
||
650 | }, |
||
651 | }, |
||
652 | StartPoint = this.PointSet[0] |
||
653 | }); |
||
654 | |||
655 | this.PathSubData = _pathSubGeometry; |
||
656 | } |
||
657 | StartPoint = PointSet[0]; |
||
658 | this.PathData = this._pathGeometry; |
||
659 | this.OverViewPathData = PathData; |
||
660 | this.StrokeColor = StrokeColor; |
||
661 | this.LineSize = LineSize; |
||
662 | EndPoint = PointSet[PointSet.Count - 1]; |
||
663 | |||
664 | return 0; |
||
665 | } |
||
666 | |||
667 | /// <summary> |
||
668 | /// draw arcs between p1 and p2 |
||
669 | /// </summary> |
||
670 | /// <author>humkyung</author> |
||
671 | /// <param name="p1"></param> |
||
672 | /// <param name="p2"></param> |
||
673 | /// <param name="reverse"></param> |
||
674 | /// <returns></returns> |
||
675 | public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse) |
||
676 | { |
||
677 | PathFigure pathFigure = new PathFigure(); |
||
678 | pathFigure.StartPoint = p1; |
||
679 | |||
680 | double arcLength = arcLength_; |
||
681 | /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung |
||
682 | double dx = p2.X - p1.X; |
||
683 | double dy = p2.Y - p1.Y; |
||
684 | double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2 |
||
685 | double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI; |
||
686 | Point lastPt = new Point(p1.X, p1.Y); |
||
687 | double count = l / arcLength; |
||
688 | /// normalize |
||
689 | dx /= l; |
||
690 | dy /= l; |
||
691 | Double j = 1; |
||
692 | for (j = 1; j < (count - 1); j++) |
||
693 | { |
||
694 | ArcSegment arcSeg = new ArcSegment(); |
||
695 | 5a9353a9 | humkyung | arcSeg.Size = new Size(arcLength * CloudControl._CloudArcDepth, arcLength * CloudControl._CloudArcDepth); /// x size and y size of arc |
696 | 787a4489 | KangIngu | arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength); /// end point of arc |
697 | lastPt = arcSeg.Point; /// save last point |
||
698 | arcSeg.RotationAngle = theta + 90; |
||
699 | if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
||
700 | pathFigure.Segments.Add(arcSeg); |
||
701 | } |
||
702 | |||
703 | /// draw arc between last point and end point |
||
704 | if ((count > j) || (count > 0)) |
||
705 | { |
||
706 | arcLength = MathSet.DistanceTo(lastPt, p2); |
||
707 | ArcSegment arcSeg = new ArcSegment(); |
||
708 | 5a9353a9 | humkyung | arcSeg.Size = new Size(arcLength * CloudControl._CloudArcDepth, arcLength * CloudControl._CloudArcDepth); /// x size and y size of arc |
709 | 787a4489 | KangIngu | arcSeg.Point = new Point(p2.X, p2.Y); /// end point of arc |
710 | arcSeg.RotationAngle = theta; |
||
711 | if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
||
712 | pathFigure.Segments.Add(arcSeg); |
||
713 | |||
714 | } |
||
715 | |||
716 | pathFigure.IsFilled = true; |
||
717 | return pathFigure; |
||
718 | } |
||
719 | |||
720 | /// <summary> |
||
721 | /// close path if it's open |
||
722 | /// </summary> |
||
723 | /// <author>humkyung</author> |
||
724 | /// <returns></returns> |
||
725 | public int ClosePath() |
||
726 | { |
||
727 | if (this.PointSet.Count > 1) |
||
728 | { |
||
729 | double d = MathSet.DistanceTo(this.PointSet[0], this.PointSet[this.PointSet.Count - 1]); |
||
730 | if (d > _toler) |
||
731 | { |
||
732 | /// set reverse if area is greater 0 - 2012.07.04 added by humkyung |
||
733 | double area = MathSet.AreaOf(this.PointSet); |
||
734 | bool reverse = (area > 0); |
||
735 | /// up to here |
||
736 | |||
737 | int count = this.PointSet.Count; |
||
738 | |||
739 | if (isTransOn) // true라면 클라우드 컨트롤 |
||
740 | { |
||
741 | 53393bae | KangIngu | ArcLength = ArcLength == 0 ? 10 : ArcLength; |
742 | |||
743 | 787a4489 | KangIngu | PathFigure pathFigure = CloudControl.GenerateLineWithCloud(this.PointSet[count - 1], this.PointSet[0], this.ArcLength - 5, reverse); |
744 | |||
745 | if (this.Paint == PaintSet.Fill) |
||
746 | { |
||
747 | pathFigure.IsClosed = true; |
||
748 | } |
||
749 | |||
750 | _pathGeometry.Figures.Add(pathFigure); |
||
751 | } |
||
752 | else |
||
753 | { |
||
754 | |||
755 | PathFigure fm = new PathFigure(); |
||
756 | fm.StartPoint = this.PointSet[count - 1]; |
||
757 | |||
758 | //for (int i = 0; i < (count - 1); i++) |
||
759 | //{ |
||
760 | _pathGeometry.Figures[_pathGeometry.Figures.Count - 1].Segments.Add(new LineSegment { Point = this.PointSet[0] }); |
||
761 | _pathGeometry.Figures[_pathGeometry.Figures.Count - 1].Segments.Add(new LineSegment { Point = this.PointSet[1] }); |
||
762 | //fm.Segments.Add(new LineSegment { Point = this.PointSet[0] }); |
||
763 | //} |
||
764 | } |
||
765 | } |
||
766 | } |
||
767 | |||
768 | return 0; |
||
769 | } |
||
770 | public void DrawingCloud() |
||
771 | { |
||
772 | AnotherSetCloud(); |
||
773 | if (!isChain) |
||
774 | { |
||
775 | //ClosePath(); |
||
776 | } |
||
777 | } |
||
778 | public void AnotherSetCloud() |
||
779 | { |
||
780 | this.StrokeColor = StrokeColor; |
||
781 | this.LineSize = LineSize; |
||
782 | this.SetCloud(); |
||
783 | //Generate(); |
||
784 | this.Width = this.Base_CloudPath.Width; |
||
785 | this.Height = this.Base_CloudPath.Height; |
||
786 | } |
||
787 | public void Dispose() |
||
788 | { |
||
789 | a6f7f9b6 | djkim | //GC.Collect(); |
790 | //GC.SuppressFinalize(this); |
||
791 | this.Base_CloudPath = null; |
||
792 | this.Base_CloudSubPath = null; |
||
793 | 787a4489 | KangIngu | } |
794 | public event PropertyChangedEventHandler PropertyChanged; |
||
795 | protected void OnPropertyChanged(string propName) |
||
796 | { |
||
797 | if (PropertyChanged != null) |
||
798 | PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
||
799 | } |
||
800 | 0d00f9c8 | humkyung | |
801 | public override void UpdateControl() |
||
802 | 787a4489 | KangIngu | { |
803 | var lastIndex = this.PointSet.Count - 1; |
||
804 | //this.StartPoint = this.PointSet[0]; |
||
805 | //this.EndPoint = this.PointSet[lastIndex]; |
||
806 | CenterX = MathSet.getMiddlePoint(this.PointSet[0], this.PointSet[lastIndex]).X; |
||
807 | CenterY = MathSet.getMiddlePoint(this.PointSet[0], this.PointSet[lastIndex]).Y; |
||
808 | } |
||
809 | public void ChangePaint(PaintSet state) |
||
810 | { |
||
811 | this.Paint = state; |
||
812 | this.SetCloud(); |
||
813 | |||
814 | } |
||
815 | 036650a0 | humkyung | |
816 | /// <summary> |
||
817 | a6272c57 | humkyung | /// call when mouse is moving while drawing control |
818 | /// </summary> |
||
819 | /// <param name="pt"></param> |
||
820 | /// <param name="bAxisLocked"></param> |
||
821 | public override void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed) |
||
822 | { |
||
823 | this.isTransOn = true; |
||
824 | this.PointSet.RemoveAt(this.PointSet.Count - 1); |
||
825 | |||
826 | Point tmp = pt; |
||
827 | 168f8027 | taeseongkim | |
828 | a6272c57 | humkyung | if (bAxisLocked || bShiftKeyPressed) |
829 | { |
||
830 | fa48eb85 | taeseongkim | CommentAngle = MathSet.returnAngle(this.StartPoint, ref tmp, bShiftKeyPressed); |
831 | a6272c57 | humkyung | } |
832 | 168f8027 | taeseongkim | |
833 | a6272c57 | humkyung | this.PointSet.Add(tmp); |
834 | |||
835 | this.SetCloud(); |
||
836 | } |
||
837 | |||
838 | /// <summary> |
||
839 | d2114d3b | humkyung | /// move control point has same location of given pt along given delta |
840 | /// </summary> |
||
841 | /// <author>humkyung</author> |
||
842 | /// <date>2019.06.20</date> |
||
843 | /// <param name="pt"></param> |
||
844 | /// <param name="dx"></param> |
||
845 | /// <param name="dy"></param> |
||
846 | public override void OnMoveCtrlPoint(Point pt, double dx, double dy) |
||
847 | { |
||
848 | Point selected = MathSet.getNearPoint((this as IPath).PointSet, pt); |
||
849 | selected.X += dx; |
||
850 | selected.Y += dy; |
||
851 | for (int i = 0; i < (this as IPath).PointSet.Count; i++) |
||
852 | { |
||
853 | if (pt.Equals((this as IPath).PointSet[i])) |
||
854 | { |
||
855 | (this as IPath).PointSet[i] = selected; |
||
856 | break; |
||
857 | } |
||
858 | } |
||
859 | 0d00f9c8 | humkyung | this.UpdateControl(); |
860 | d2114d3b | humkyung | this.DrawingCloud(); |
861 | } |
||
862 | |||
863 | /// <summary> |
||
864 | 91efe37a | humkyung | /// return Cloud's area |
865 | /// </summary> |
||
866 | /// <author>humkyung</author> |
||
867 | /// <date>2019.06.13</date> |
||
868 | public override Rect ItemRect |
||
869 | { |
||
870 | get |
||
871 | { |
||
872 | double dMinX = double.MaxValue; |
||
873 | double dMinY = double.MaxValue; |
||
874 | double dMaxX = double.MinValue; |
||
875 | double dMaxY = double.MinValue; |
||
876 | foreach (Point pt in this.PointSet) |
||
877 | { |
||
878 | dMinX = Math.Min(dMinX, pt.X); |
||
879 | dMinY = Math.Min(dMinY, pt.Y); |
||
880 | dMaxX = Math.Max(dMaxX, pt.X); |
||
881 | dMaxY = Math.Max(dMaxY, pt.Y); |
||
882 | } |
||
883 | |||
884 | return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY)); |
||
885 | } |
||
886 | } |
||
887 | |||
888 | /// <summary> |
||
889 | 036650a0 | humkyung | /// Serialize this |
890 | /// </summary> |
||
891 | /// <param name="sUserId"></param> |
||
892 | /// <returns></returns> |
||
893 | public override string Serialize() |
||
894 | { |
||
895 | using (S_CloudControl STemp = new S_CloudControl()) |
||
896 | { |
||
897 | STemp.TransformPoint = "0|0"; |
||
898 | STemp.SizeSet = String.Format("{0}", this.LineSize); |
||
899 | //STemp.StrokeColor = "#FF000FFF"; |
||
900 | STemp.StrokeColor = this.StrokeColor.Color.ToString(); |
||
901 | STemp.Name = this.GetType().Name.ToString(); |
||
902 | STemp.Toler = this.Toler; |
||
903 | STemp.PaintState = this.Paint; |
||
904 | STemp.Opac = this.Opacity; |
||
905 | STemp.UserID = this.UserID; |
||
906 | STemp.IsTrans = this.isTransOn; |
||
907 | STemp.IsChain = this.isChain; |
||
908 | STemp.PointSet = new List<Point>(); |
||
909 | STemp.DashSize = this.DashSize; |
||
910 | STemp.StartPoint = this.StartPoint; |
||
911 | STemp.EndPoint = this.EndPoint; |
||
912 | STemp.ArcLength = this.ArcLength; |
||
913 | foreach (var point in this.PointSet) |
||
914 | { |
||
915 | STemp.PointSet.Add(point); |
||
916 | } |
||
917 | |||
918 | //STemp.CloudFill = this.Fill; |
||
919 | STemp.ArcLength = this.ArcLength; |
||
920 | ///강인구 추가(2017.11.02) |
||
921 | ///Memo 추가 |
||
922 | STemp.Memo = this.Memo; |
||
923 | |||
924 | return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize())); |
||
925 | } |
||
926 | } |
||
927 | |||
928 | 661b7416 | humkyung | /// <summary> |
929 | /// create a cloudcontrol from given string |
||
930 | /// </summary> |
||
931 | /// <param name="str"></param> |
||
932 | /// <returns></returns> |
||
933 | public static CloudControl FromString(string str, SolidColorBrush brush, string sProjectNo) |
||
934 | { |
||
935 | CloudControl instance = null; |
||
936 | using (S_CloudControl s = JsonSerializerHelper.JsonDeserialize<S_CloudControl>(str)) |
||
937 | { |
||
938 | string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
939 | instance = new CloudControl |
||
940 | { |
||
941 | LineSize = Convert.ToDouble(data2.First()), |
||
942 | Toler = s.Toler, |
||
943 | PointSet = s.PointSet, |
||
944 | ArcLength = s.ArcLength, |
||
945 | Paint = s.PaintState, |
||
946 | Opacity = s.Opac, |
||
947 | StrokeColor = brush, |
||
948 | isTransOn = s.IsTrans, |
||
949 | isChain = s.IsChain, |
||
950 | DashSize = s.DashSize, |
||
951 | UserID = s.UserID, |
||
952 | |||
953 | StartPoint = s.StartPoint, |
||
954 | EndPoint = s.EndPoint, |
||
955 | Memo = s.Memo |
||
956 | |||
957 | //Fill = s.CloudFill, |
||
958 | }; |
||
959 | } |
||
960 | |||
961 | return instance; |
||
962 | } |
||
963 | |||
964 | 787a4489 | KangIngu | #region Method |
965 | f513c215 | humkyung | public override void ApplyOverViewData() |
966 | 787a4489 | KangIngu | { |
967 | this.OverViewPathData = this.PathData; |
||
968 | } |
||
969 | #endregion |
||
970 | } |
||
971 | |||
972 | 5529d2a2 | humkyung | } |