프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / MarkupToPDF / Controls / Polygon / CloudControl.cs @ f633b10b

이력 | 보기 | 이력해설 | 다운로드 (29.2 KB)

1
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
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
60
                "PathData", typeof(Geometry), typeof(CloudControl), null);
61

    
62
        public static readonly DependencyProperty PathSubDataProperty = DependencyProperty.Register(
63
                "PathSubData", typeof(Geometry), typeof(CloudControl), null);
64

    
65
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
66
                "EndPoint", typeof(Point), typeof(CloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
67

    
68
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
69
                "StartPoint", typeof(Point), typeof(CloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
70

    
71
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
72
                "PointSet", typeof(List<Point>), typeof(CloudControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
73
        public static readonly DependencyProperty isTransOnProperty = DependencyProperty.Register(
74
                "isTransOn", typeof(bool), typeof(CloudControl), new PropertyMetadata(false));
75
        public static readonly DependencyProperty isChainProperty = DependencyProperty.Register(
76
                "isChain", typeof(bool), typeof(CloudControl), new PropertyMetadata(false));
77
       
78
        /// <summary>
79
        /// StylusPointSet을 List<Point>로 대체하면 PointValueChanged가 작동안한다.
80
        /// </summary>
81
        public static readonly DependencyProperty StylusPointSetProperty = DependencyProperty.Register(
82
               "PointC", typeof(StylusPointSet), typeof(CloudControl), new PropertyMetadata(new StylusPointSet(), PointValueChanged));
83

    
84
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("AngleValue", typeof(double), typeof(CloudControl),
85
            new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged)));
86

    
87
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(CloudControl),
88
            new PropertyMetadata((double)0, OnCenterXYChanged));
89

    
90
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(CloudControl),
91
            new PropertyMetadata((double)0, OnCenterXYChanged));
92

    
93
        public static readonly DependencyProperty IsSelectedProperty =
94
    DependencyProperty.Register("IsSelected", typeof(bool), typeof(CloudControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
95

    
96
        public static readonly DependencyProperty ControlTypeProperty =
97
            DependencyProperty.Register("ControlType", typeof(ControlType), typeof(CloudControl), new FrameworkPropertyMetadata(ControlType.PolygonCloud));
98

    
99
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
100
        "OverViewPathData", typeof(Geometry), typeof(ControlType), null);
101

    
102

    
103
        public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
104
                "CanvasX", typeof(double), typeof(CloudControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
105

    
106
        public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
107
                "CanvasY", typeof(double), typeof(CloudControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
108

    
109

    
110
        #endregion
111
        #region PropertyChanged Method
112

    
113
        public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
114
        {
115
            var instance = (CloudControl)sender;
116

    
117
            if (e.OldValue != e.NewValue && instance != null)
118
            {
119
                instance.SetValue(e.Property, e.NewValue);
120
            }
121
        }
122

    
123
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
124
        {
125
            var instance = (CloudControl)sender;
126
            if (e.OldValue != e.NewValue && instance.Base_CloudPath != null)
127
            {
128
                instance.SetValue(e.Property, e.NewValue);
129
                //강인구 추가
130
                instance.SetCloud();
131
                //주석처리
132
            }
133
        }
134
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
135
        {
136
            //var instance = (CloudControl)sender;
137

    
138
            //if (e.OldValue != e.NewValue && instance.Base_CloudPath != null)
139
            //{
140

    
141
            //    instance.SetValue(e.Property, e.NewValue);
142

    
143
            //    if (instance.IsSelected)
144
            //    {
145
            //        instance.Base_CloudPath.Stroke = new SolidColorBrush(Colors.Blue);
146
            //    }
147
            //    else
148
            //    {
149
            //        instance.Base_CloudPath.Stroke = new SolidColorBrush(Colors.Red);
150
            //    }
151
            //}
152
        }
153

    
154
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
155
        {
156
            var instance = (CloudControl)sender;
157
            if (e.OldValue != e.NewValue && instance.Base_CloudPath != null)
158
            {
159
                instance.SetValue(e.Property, e.NewValue);
160
                instance.DrawingCloud();
161
            }
162
        }
163
        public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
164
        {
165
            var instance = (CloudControl)sender;
166
            if (e.OldValue != e.NewValue && instance.Base_CloudPath != null)
167
            {
168
                instance.SetValue(e.Property, e.NewValue);
169
                instance.DrawingCloud();
170
            }
171
        }
172
        #endregion
173
        #region Properties
174

    
175

    
176
        public bool IsCompleted
177
        {
178
            get { return (bool)GetValue(IsCompletedProperty); }
179
            set
180
            {
181
                SetValue(IsCompletedProperty, value);
182
            }
183
        }
184

    
185
        public Geometry OverViewPathData
186
        {
187
            get { return (Geometry)GetValue(OverViewPathDataProperty); }
188
            set
189
            {
190
                SetValue(OverViewPathDataProperty, value);
191
                OnPropertyChanged("OverViewPathData");
192
            }
193
        }
194

    
195
        public double CanvasX
196
        {
197
            get { return (double)GetValue(CanvasXProperty); }
198
            set
199
            {
200
                if (this.CanvasX != value)
201
                {
202
                    SetValue(CanvasXProperty, value);
203
                }
204
            }
205
        }
206

    
207
        public double CanvasY
208
        {
209
            get { return (double)GetValue(CanvasYProperty); }
210
            set
211
            {
212
                if (this.CanvasY != value)
213
                {
214
                    SetValue(CanvasYProperty, value);
215
                }
216
            }
217
        }
218

    
219
        public bool IsSelected
220
        {
221
            get
222
            {
223
                return (bool)GetValue(IsSelectedProperty);
224
            }
225
            set
226
            {
227
                SetValue(IsSelectedProperty, value);
228
            }
229
        }
230

    
231
        public ControlType ControlType
232
        {
233
            set
234
            {
235
                SetValue(ControlTypeProperty, value);
236
            }
237
            get
238
            {
239
                return (ControlType)GetValue(ControlTypeProperty);
240
            }
241
        }
242

    
243
        public Double LineSize
244
        {
245
            get { return (Double)GetValue(LineSizeProperty); }
246
            set
247
            {
248
                if (this.LineSize != value)
249
                {
250
                    SetValue(LineSizeProperty, value);
251
                }
252
            }
253
        }
254
        public bool isChain
255
        {
256
            get { return (bool)GetValue(isChainProperty); }
257
            set
258
            {
259
                SetValue(isChainProperty, value);
260
                OnPropertyChanged("isChain");
261
            }
262
        }
263
        public bool isTransOn
264
        {
265
            get { return (bool)GetValue(isTransOnProperty); }
266
            set
267
            {
268
                SetValue(isTransOnProperty, value);
269
                OnPropertyChanged("isTransOn");
270
            }
271
        }
272
        public DoubleCollection DashSize
273
        {
274
            get { return (DoubleCollection)GetValue(DashSizeProperty); }
275
            set
276
            {
277
                if (this.DashSize != value)
278
                {
279
                    SetValue(DashSizeProperty, value);
280
                    OnPropertyChanged("DashSize");
281
                }
282
            }
283
        }
284
        public string UserID
285
        {
286
            get { return (string)GetValue(UserIDProperty); }
287
            set
288
            {
289
                if (this.UserID != value)
290
                {
291
                    SetValue(UserIDProperty, value);
292
                    OnPropertyChanged("UserID");
293
                }
294
            }
295
        }
296
        public PaintSet Paint
297
        {
298
            get { return (PaintSet)GetValue(PaintProperty); }
299
            set
300
            {
301
                if (this.Paint != value)
302
                {
303
                    SetValue(PaintProperty, value);
304
                    OnPropertyChanged("Paint");
305
                }
306
            }
307
        }
308

    
309
        public SolidColorBrush FillColor
310
        {
311
            get { return (SolidColorBrush)GetValue(FillColorProperty); }
312
            set
313
            {
314
                if (this.FillColor != value)
315
                {
316
                    SetValue(FillColorProperty, value);
317
                    OnPropertyChanged("FillColor");
318
                }
319
            }
320
        }
321
        public SolidColorBrush StrokeColor
322
        {
323
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
324
            set
325
            {
326
                if (this.StrokeColor != value)
327
                {
328
                    SetValue(StrokeColorProperty, value);
329
                    OnPropertyChanged("StrokeColor");
330
                }
331
            }
332
        }
333
        public Geometry PathData
334
        {
335
            get 
336
            {
337
                return (Geometry)GetValue(PathDataProperty); 
338
            }
339
            set 
340
            {
341
                SetValue(PathDataProperty, value);
342
                OnPropertyChanged("PathData");
343
            }
344
        }
345
        public Geometry PathSubData
346
        {
347
            get 
348
            {
349
                return (Geometry)GetValue(PathSubDataProperty); 
350
            }
351
            set
352
            {
353
                SetValue(PathSubDataProperty, value);
354
                OnPropertyChanged("PathSubData");
355
            }
356
        }
357
        public Point EndPoint
358
        {
359
            get 
360
            {
361
                return (Point)GetValue(EndPointProperty); 
362
            }
363
            set
364
            {
365
                SetValue(EndPointProperty, value);
366
                OnPropertyChanged("EndPoint");
367
            }
368
        }
369
        public Point StartPoint
370
        {
371
            get 
372
            {
373
                return (Point)GetValue(StartPointProperty); 
374
            }
375
            set
376
            {
377
                SetValue(StartPointProperty, value);
378
                OnPropertyChanged("StartPoint");
379
            }
380
        }
381
        public List<Point> _pointSet;
382

    
383
        public List<Point> PointSet
384
        {
385
            get 
386
            {
387
                return (List<Point>)GetValue(PointSetProperty);
388
            }
389
            set 
390
            {
391
                SetValue(PointSetProperty, value);
392
                OnPropertyChanged("PointSet");
393
            }
394
        }
395

    
396
        public List<Point> pointSet
397
        {
398
            get
399
            {
400
                return _pointSet;
401
            }
402
            set
403
            {
404
                _pointSet = value;
405
                OnPropertyChanged("pointSet");
406
            }
407
        }
408

    
409
        private double _toler = 1;
410
        public double Toler
411
        {
412
            get { return _toler; }
413
            set { _toler = value; }
414
        }
415
        //강인구 수정 클라우드 사이즈
416
        private double _arcLength;
417
        //private double _arcLength = 30;
418
        public double ArcLength
419
        {
420
            get { return _arcLength; }
421
            set { _arcLength = value; }
422
        }
423
        private bool _fill = false;
424
        public bool Fill
425
        {
426
            get { return _fill; }
427
            set { _fill = value; }
428
        }
429
        public double Angle
430
        {
431
            get { return (double)GetValue(AngleProperty); }
432
            set
433
            {
434
                if (this.Angle != value)
435
                {
436
                    SetValue(AngleProperty, value);
437
                    OnPropertyChanged("Angle");
438
                }
439
            }
440
        }
441
        public StylusPointSet PointC
442
        {
443
            get { return (StylusPointSet)GetValue(StylusPointSetProperty); }
444
            set
445
            {
446
                SetValue(StylusPointSetProperty, value);
447
                OnPropertyChanged("PointC");
448
            }
449
        }
450
        public double CenterX
451
        {
452
            get
453
            {
454
                return (double)GetValue(CenterXProperty); 
455
            }
456
            set
457
            {
458
                SetValue(CenterXProperty, value);
459
                OnPropertyChanged("CenterX");
460
            }
461
        }
462
        public double CenterY
463
        {
464
            get
465
            { 
466
                return (double)GetValue(CenterYProperty); 
467
            }
468
            set
469
            {
470
                SetValue(CenterYProperty, value);
471
                OnPropertyChanged("CenterY");
472
            }
473
        }
474
        public double AngleValue
475
        {
476
            get 
477
            {
478
                return (double)GetValue(AngleProperty); 
479
            }
480
            set
481
            {
482
                SetValue(AngleProperty, value);
483
                OnPropertyChanged("AngleValue");
484
            }
485
        }
486
        #endregion
487
        #region Data
488
        private PathGeometry _pathGeometry = new PathGeometry();
489
        private PathGeometry _pathSubGeometry = new PathGeometry();
490
        #endregion
491

    
492
        public override void OnApplyTemplate()
493
        {
494
            base.OnApplyTemplate();
495
            Base_CloudPath = GetTemplateChild(PART_CloudPath) as Path;
496
            Base_CloudSubPath = GetTemplateChild(PART_CloudSubPath) as Path;
497
            SetCloud();
498
        }
499
        public void SetCloud()
500
        {
501
            //this.Width = this.Base_CloudPath.Width;
502
            //this.Height = this.Base_CloudPath.Height;
503

    
504
            this.ApplyTemplate();
505

    
506
            Generate();
507

    
508
            if (!isChain)
509
            {
510
                //ClosePath();
511
            }
512
        }
513
        public int Generate()
514
        {
515
            this._pathGeometry = null;
516
            this._pathSubGeometry = null;
517
            switch (this.Paint)
518
            {
519
                case PaintSet.None:
520
                    this.FillColor = null;
521
                    if (Base_CloudSubPath != null)
522
                    {
523
                        Base_CloudPath.Fill = null;
524
                        Base_CloudSubPath.Fill = null;
525
                        Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent);
526
                        //Base_CloudSubPath.StrokeThickness = 3;
527
                    }                    
528
                    break;
529
                case PaintSet.Fill:
530
                    this.FillColor = this.StrokeColor;
531
                    if (Base_CloudSubPath != null)
532
                    {
533
                        if (isChain)
534
                        {
535
                            Base_CloudPath.Fill = null;
536
                            Base_CloudSubPath.Fill = null;
537
                            Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent);
538
                            //Base_CloudSubPath.StrokeThickness = 3;
539
                        }
540
                        else
541
                        {
542
                            Base_CloudSubPath.Stroke = this.StrokeColor;
543
                            //Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent);
544
                            Base_CloudSubPath.StrokeThickness = 0.5;
545
                            Base_CloudPath.Stroke = this.StrokeColor;
546
                            //Base_CloudPath.StrokeThickness = 3;
547
                            Base_CloudPath.Fill = this.FillColor;
548
                            Base_CloudSubPath.Fill = this.FillColor;
549
                        }
550
                    }                   
551
                    break;
552
                case PaintSet.Hatch:
553
                    if (Base_CloudSubPath != null && !isChain)
554
                    {
555
                        if (isChain)
556
                        {
557
                            Base_CloudPath.Fill = null;
558
                            Base_CloudSubPath.Fill = null;
559
                            Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent);
560
                            //Base_CloudSubPath.StrokeThickness = 3;
561
                        }
562
                        else
563
                        {
564
                            Base_CloudPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor, this.LineSize * 0.1);
565
                            Base_CloudSubPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor, this.LineSize * 0.1);
566
                            Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent);
567
                        }
568
                    }
569
                    break;
570
                default:
571
                    break;
572
            }
573

    
574
            //강인구 추가
575
            if (Base_CloudPath != null)
576
            {
577
                Base_CloudPath.StrokeDashArray.Clear();
578
                Base_CloudSubPath.StrokeDashArray.Clear();
579
                foreach (var item in this.DashSize)
580
                {
581
                    Base_CloudPath.StrokeDashArray.Add(item);
582
                    Base_CloudSubPath.StrokeDashArray.Add(item);
583
                }
584
            }
585

    
586

    
587
            /// set reverse if area is greater 0 - 2012.07.04 added by humkyung
588
            double area = MathSet.AreaOf(this.PointSet);
589
            bool reverse = (area > 0);
590
            /// up to here
591

    
592
            this._pathGeometry = new PathGeometry();
593
            this._pathSubGeometry = new PathGeometry();
594
            int count = this.PointSet.Count;
595

    
596

    
597
            //인구 수정 클라우드 크기 설정(2018.04.19)
598
            double size = 0;
599
            double tmp = 0;
600

    
601
            for (int i = 0; i < count - 1; i++)
602
            {
603
                tmp = size;
604
                size = Math.Max(MathSet.DistanceTo(this.PointSet[i], this.PointSet[i + 1]), tmp);
605
            }
606
            ArcLength = (size * 0.05);
607

    
608
            if (ArcLength <= 3)
609
            {
610
                ArcLength = 10;
611
            }
612
            else if (ArcLength <= 10)
613
            {
614
                ArcLength = 20;
615
            }
616
            else if (ArcLength <= 30)
617
            {
618
                ArcLength = 30;
619
            }
620
            /////////////////////////////////////////
621

    
622
            if (isTransOn) // true라면 클라우드 컨트롤
623
            {
624
                for (int i = 0; i < (count - 1); i++)
625
                {
626
                    PathFigure pathFigure = CloudControl.GenerateLineWithCloud(this.PointSet[i], this.PointSet[i + 1], this.ArcLength, reverse);
627
                    _pathGeometry.Figures.Add(pathFigure);
628
                }
629
            }
630
            else
631
            {
632
                PathFigure fm = new PathFigure();
633
                fm.StartPoint = this.PointSet[0];
634
                for (int i = 0; i < (count - 1); i++)
635
                {
636
                    fm.Segments.Add(new LineSegment { Point = this.PointSet[i] });
637
                }
638
                _pathGeometry.Figures.Add(fm);
639
            }
640

    
641
            if (this.Paint == PaintSet.Fill || this.Paint == PaintSet.Hatch)
642
            {
643
                PointCollection pd = new PointCollection();
644
                foreach (var item in this.PointSet)
645
                {
646
                    pd.Add(item);
647
                }
648
                _pathSubGeometry.Figures.Add(new PathFigure()
649
                {
650
                    Segments = new PathSegmentCollection()
651
                    {
652
                        new PolyLineSegment()
653
                        {
654
                              Points = pd
655
                        },
656
                    },
657
                    StartPoint = this.PointSet[0]
658
                });
659

    
660
                this.PathSubData = _pathSubGeometry;
661
            }
662
            StartPoint = PointSet[0];
663
            this.PathData = this._pathGeometry;
664
            this.OverViewPathData = PathData;
665
            this.StrokeColor = StrokeColor;
666
            this.LineSize = LineSize;
667
            EndPoint = PointSet[PointSet.Count - 1];
668

    
669
            return 0;
670
        }
671

    
672
        /// <summary>
673
        /// draw arcs between p1 and p2
674
        /// </summary>
675
        /// <author>humkyung</author>
676
        /// <param name="p1"></param>
677
        /// <param name="p2"></param>
678
        /// <param name="reverse"></param>
679
        /// <returns></returns>
680
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
681
        {
682
            PathFigure pathFigure = new PathFigure();
683
            pathFigure.StartPoint = p1;
684

    
685
            double arcLength = arcLength_;
686
            /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung 
687
            double dx = p2.X - p1.X;
688
            double dy = p2.Y - p1.Y;
689
            double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2
690
            double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
691
            Point lastPt = new Point(p1.X, p1.Y);
692
            double count = l / arcLength;
693
            /// normalize
694
            dx /= l;
695
            dy /= l;
696
            Double j = 1;
697
            for (j = 1; j < (count - 1); j++)
698
            {
699
                ArcSegment arcSeg = new ArcSegment();
700
                arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8);						/// x size and y size of arc
701
                arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);	/// end point of arc
702
                lastPt = arcSeg.Point;  /// save last point
703
                arcSeg.RotationAngle = theta + 90;
704
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
705
                pathFigure.Segments.Add(arcSeg);
706
            }
707

    
708
            /// draw arc between last point and end point
709
            if ((count > j) || (count > 0))
710
            {
711
                arcLength = MathSet.DistanceTo(lastPt, p2);
712
                ArcSegment arcSeg = new ArcSegment();
713
                arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8);	/// x size and y size of arc
714
                arcSeg.Point = new Point(p2.X, p2.Y);						/// end point of arc
715
                arcSeg.RotationAngle = theta;
716
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
717
                pathFigure.Segments.Add(arcSeg);
718

    
719
            }
720

    
721
            pathFigure.IsFilled = true;    
722
            return pathFigure;
723
        }
724

    
725
        /// <summary>
726
        /// close path if it's open
727
        /// </summary>
728
        /// <author>humkyung</author>
729
        /// <returns></returns>
730
        public int ClosePath()
731
        {
732
            if (this.PointSet.Count > 1)
733
            {
734
                double d = MathSet.DistanceTo(this.PointSet[0], this.PointSet[this.PointSet.Count - 1]);
735
                if (d > _toler)
736
                {
737
                    /// set reverse if area is greater 0 - 2012.07.04 added by humkyung
738
                    double area = MathSet.AreaOf(this.PointSet);
739
                    bool reverse = (area > 0);
740
                    /// up to here
741

    
742
                    int count = this.PointSet.Count;
743

    
744
                    if (isTransOn) // true라면 클라우드 컨트롤
745
                    {
746
                        PathFigure pathFigure = CloudControl.GenerateLineWithCloud(this.PointSet[count - 1], this.PointSet[0], this.ArcLength - 5, reverse);
747
                        
748
                        if (this.Paint == PaintSet.Fill)
749
                        {
750
                            pathFigure.IsClosed = true;
751
                        }
752

    
753
                        _pathGeometry.Figures.Add(pathFigure);                        
754
                    }
755
                    else
756
                    {
757

    
758
                        PathFigure fm = new PathFigure();
759
                        fm.StartPoint = this.PointSet[count - 1];
760
                        
761
                        //for (int i = 0; i < (count - 1); i++)
762
                        //{
763
                            _pathGeometry.Figures[_pathGeometry.Figures.Count - 1].Segments.Add(new LineSegment { Point = this.PointSet[0] });
764
                            _pathGeometry.Figures[_pathGeometry.Figures.Count - 1].Segments.Add(new LineSegment { Point = this.PointSet[1] });
765
                            //fm.Segments.Add(new LineSegment { Point = this.PointSet[0] });
766
                        //}
767
                    }                 
768
                }
769
            }
770

    
771
            return 0;
772
        }
773
        public void DrawingCloud()
774
        {
775
            AnotherSetCloud();
776
            if (!isChain)
777
            {
778
                //ClosePath();
779
            }
780
        }
781
        public void AnotherSetCloud()
782
        {
783
            this.StrokeColor = StrokeColor;
784
            this.LineSize = LineSize;
785
            this.SetCloud();
786
            //Generate();
787
            this.Width = this.Base_CloudPath.Width;
788
            this.Height = this.Base_CloudPath.Height;
789
        }
790
        public void Dispose()
791
        {
792
            GC.Collect();
793
            GC.SuppressFinalize(this);
794
        }
795
        public event PropertyChangedEventHandler PropertyChanged;
796
        protected void OnPropertyChanged(string propName)
797
        {
798
            if (PropertyChanged != null)
799
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
800
        }
801
        public void updateControl()
802
        {
803

    
804
            var lastIndex = this.PointSet.Count - 1;
805
            //this.StartPoint = this.PointSet[0];
806
            //this.EndPoint = this.PointSet[lastIndex];
807
            CenterX = MathSet.getMiddlePoint(this.PointSet[0], this.PointSet[lastIndex]).X;
808
            CenterY = MathSet.getMiddlePoint(this.PointSet[0], this.PointSet[lastIndex]).Y;
809
        }
810
        public void ChangePaint(PaintSet state)
811
        {
812
            this.Paint = state;
813
            this.SetCloud();
814
            
815
        }
816
        #region Method
817
        public void ApplyOverViewData()
818
        {
819
            this.OverViewPathData = this.PathData;
820
        }
821
        #endregion
822
    }
823

    
824
}
클립보드 이미지 추가 (최대 크기: 500 MB)