프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Shape / RectCloudControl.cs @ 43e1d368

이력 | 보기 | 이력해설 | 다운로드 (27.6 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.ComponentModel;
12
using System.Collections.Generic;
13
using MarkupToPDF.Controls.Common;
14
using MarkupToPDF.Common;
15
using MarkupToPDF.Serialize.Core;
16
using MarkupToPDF.Serialize.S_Control;
17
using System.Linq;
18

    
19
namespace MarkupToPDF.Controls.Shape
20
{
21
    public class RectCloudControl : CommentUserInfo, IDisposable, IPath, INotifyPropertyChanged,  IMarkupCommonData, IShapeControl, IDashControl
22
    {
23
        #region 초기 선언
24
        private const string PART_ArcPath = "PART_ArcPath";
25
        private const string PART_BodyPath = "PART_BodyPath";
26
        public event PropertyChangedEventHandler PropertyChanged;
27

    
28
        public Path Base_ArcPath = null;
29
        public Path Base_BodyPath = null;
30

    
31
        private const double _CloudArcDepth = 0.8;  /// 2018.05.14 added by humkyung
32

    
33
        #endregion
34

    
35
        static RectCloudControl()
36
        {
37
            DefaultStyleKeyProperty.OverrideMetadata(typeof(RectCloudControl), new FrameworkPropertyMetadata(typeof(RectCloudControl)));
38
            //Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary);
39
            //ResourceDictionary dictionary = new ResourceDictionary();
40
            //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
41
            //Application.Current.Resources.MergedDictionaries.Add(dictionary);
42
        }
43

    
44
        #region Dependency Properties
45

    
46
        public static readonly DependencyProperty mousemodeProperty =
47
                DependencyProperty.Register("mousemode", typeof(MouseMode), typeof(RectangleControl), new PropertyMetadata(MouseMode.None, PointValueChanged));
48
        public static readonly DependencyProperty IsSelectedProperty =
49
     DependencyProperty.Register("IsSelected", typeof(bool), typeof(RectCloudControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
50

    
51
        public static readonly DependencyProperty ControlTypeProperty =
52
    DependencyProperty.Register("ControlType", typeof(ControlType), typeof(RectCloudControl), new FrameworkPropertyMetadata(ControlType.RectCloud));
53

    
54
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
55
                "OverViewPathData", typeof(Geometry), typeof(RectCloudControl), new PropertyMetadata(null));
56

    
57
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
58
                "LineSize", typeof(double), typeof(RectCloudControl), new PropertyMetadata((Double)3));
59

    
60
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
61
                "UserID", typeof(string), typeof(RectCloudControl), new PropertyMetadata(null));
62

    
63
        //강인구 추가
64
        public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register(
65
                 "DashSize", typeof(DoubleCollection), typeof(RectCloudControl), new PropertyMetadata(new DoubleCollection { 99999999 }, PointValueChanged));
66

    
67
        public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register(
68
                "FillColor", typeof(SolidColorBrush), typeof(RectCloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
69
        //강인구 추가
70
        public static readonly DependencyProperty PaintProperty = DependencyProperty.Register(
71
                "Paint", typeof(PaintSet), typeof(RectCloudControl), new PropertyMetadata(PaintSet.None, PointValueChanged));
72

    
73
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
74
                "StrokeColor", typeof(SolidColorBrush), typeof(RectCloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
75

    
76
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
77
                "PathData", typeof(Geometry), typeof(RectCloudControl), null);
78

    
79
        public static readonly DependencyProperty PathSubDataProperty = DependencyProperty.Register(
80
                "PathSubData", typeof(Geometry), typeof(RectCloudControl), null);
81

    
82
        public static readonly DependencyProperty ArcLengthProperty = DependencyProperty.Register(
83
        "ArcLength", typeof(double), typeof(RectCloudControl), new PropertyMetadata((Double)10, PointValueChanged));
84

    
85
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
86
                "EndPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
87

    
88
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
89
                "StartPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
90

    
91
        public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register(
92
              "TopRightPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
93

    
94
        public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register(
95
                "LeftBottomPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
96

    
97
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
98
                "PointSet", typeof(List<Point>), typeof(RectCloudControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
99

    
100
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("AngleValue", typeof(double), typeof(RectCloudControl),
101
            new PropertyMetadata((double)0.0, new PropertyChangedCallback(PointValueChanged)));
102

    
103
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(RectCloudControl),
104
            new PropertyMetadata((double)0, PointValueChanged));
105

    
106
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(RectCloudControl),
107
            new PropertyMetadata((double)0, PointValueChanged));
108

    
109
        #endregion
110

    
111
        #region PropertyChanged Method
112
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
113
        {
114
            var instance = (RectCloudControl)sender;
115
            if (e.OldValue != e.NewValue && instance.Base_ArcPath != null)
116
            {
117
                instance.SetValue(e.Property, e.NewValue);
118
                instance.SetRectCloud();
119
            }
120
        }
121
        #endregion
122

    
123
        #region Properties
124

    
125
        public MouseMode mousemode
126
        {
127
            get
128
            {
129
                return (MouseMode)GetValue(mousemodeProperty);
130
            }
131
            set
132
            {
133
                SetValue(mousemodeProperty, value);
134
                OnPropertyChanged("mousemode");
135
            }
136
        }
137
        public Double LineSize
138
        {
139
            get { return (Double)GetValue(LineSizeProperty); }
140
            set
141
            {
142
                if (this.LineSize != value)
143
                {
144
                    SetValue(LineSizeProperty, value);
145
                }
146
            }
147
        }
148
        public DoubleCollection DashSize
149
        {
150
            get { return (DoubleCollection)GetValue(DashSizeProperty); }
151
            set
152
            {
153
                if (this.DashSize != value)
154
                {
155
                    SetValue(DashSizeProperty, value);
156
                }
157
            }
158
        }
159
        public string UserID
160
        {
161
            get { return (string)GetValue(UserIDProperty); }
162
            set
163
            {
164
                if (this.UserID != value)
165
                {
166
                    SetValue(UserIDProperty, value);
167
                    OnPropertyChanged("UserID");
168
                }
169
            }
170
        }
171
        public PaintSet Paint
172
        {
173
            get { return (PaintSet)GetValue(PaintProperty); }
174
            set
175
            {
176
                if (this.Paint != value)
177
                {
178
                    SetValue(PaintProperty, value);
179
                }
180
            }
181
        }
182
        public SolidColorBrush FillColor
183
        {
184
            get { return (SolidColorBrush)GetValue(FillColorProperty); }
185
            set
186
            {
187
                if (this.FillColor != value)
188
                {
189
                    SetValue(FillColorProperty, value);
190
                }
191
            }
192
        }
193
        public override SolidColorBrush StrokeColor
194
        {
195
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
196
            set
197
            {
198
                if (this.StrokeColor != value)
199
                {
200
                    SetValue(StrokeColorProperty, value);
201
                }
202
            }
203
        }
204

    
205
        public Geometry OverViewPathData
206
        {
207
            get
208
            {
209
                return (Geometry)GetValue(OverViewPathDataProperty);
210
            }
211
            set
212
            {
213
                SetValue(OverViewPathDataProperty, value);
214
                OnPropertyChanged("OverViewPathData");
215
            }
216
        }
217

    
218
        public Geometry PathData
219
        {
220
            get { return (Geometry)GetValue(PathDataProperty); }
221
            set { SetValue(PathDataProperty, value); }
222
        }
223
        public Geometry PathSubData
224
        {
225
            get { return (Geometry)GetValue(PathSubDataProperty); }
226
            set { SetValue(PathSubDataProperty, value); }
227
        }
228
        public Point EndPoint
229
        {
230
            get { return (Point)GetValue(EndPointProperty); }
231
            set { SetValue(EndPointProperty, value); }
232
        }
233
        public Point StartPoint
234
        {
235
            get { return (Point)GetValue(StartPointProperty); }
236
            set { SetValue(StartPointProperty, value); }
237
        }
238
        public List<Point> PointSet
239
        {
240
            get { return (List<Point>)GetValue(PointSetProperty); }
241
            set { SetValue(PointSetProperty, value); }
242
        }
243
        public override bool IsSelected
244
        {
245
            get
246
            {
247
                return (bool)GetValue(IsSelectedProperty);
248
            }
249
            set
250
            {
251
                SetValue(IsSelectedProperty, value);
252
            }
253
        }
254

    
255
        public override ControlType ControlType
256
        {
257
            get
258
            {
259
                return (ControlType)GetValue(ControlTypeProperty);
260
            }
261
            set
262
            {
263
                SetValue(ControlTypeProperty, value);
264
            }
265
        }
266

    
267
        public Double ArcLength
268
        {
269
            get { return (Double)GetValue(ArcLengthProperty); }
270
            set
271
            {
272
                if (this.ArcLength != value)
273
                {
274
                    SetValue(ArcLengthProperty, value);
275
                    OnPropertyChanged("ArcLength");
276
                }
277
            }
278
        }
279

    
280

    
281
        private double _toler = 1;
282
        public double Toler
283
        {
284
            get { return _toler; }
285
            set { _toler = value; }
286
        }
287
        //private double _arcLength = 30;
288
        //public double ArcLength
289
        //{
290
        //    get { return _arcLength; }
291
        //    set { _arcLength = value; }
292
        //}
293

    
294
        private bool _fill = false;
295
        public bool Fill
296
        {
297
            get { return _fill; }
298
            set { _fill = value; }
299
        }
300
        public double CommentAngle
301
        {
302
            get { return (double)GetValue(AngleProperty); }
303
            set
304
            {
305
                if (this.CommentAngle != value)
306
                {
307
                    SetValue(AngleProperty, value);
308
                }
309
            }
310
        }
311
        public double CenterX
312
        {
313
            get { return (double)GetValue(CenterXProperty); }
314
            set { SetValue(CenterXProperty, value); }
315
        }
316
        public double CenterY
317
        {
318
            get { return (double)GetValue(CenterYProperty); }
319
            set { SetValue(CenterYProperty, value); }
320
        }
321
        public Point LeftBottomPoint
322
        {
323
            get { return (Point)GetValue(LeftBottomPointProperty); }
324
            set
325
            {
326
                SetValue(LeftBottomPointProperty, value);
327
                OnPropertyChanged("LeftBottomPoint");
328
            }
329
        }
330
        public Point TopRightPoint
331
        {
332
            get { return (Point)GetValue(TopRightPointProperty); }
333
            set
334
            {
335
                SetValue(TopRightPointProperty, value);
336
                OnPropertyChanged("TopRightPoint");
337
            }
338
        }
339
        #endregion
340

    
341
        #region Data
342
        private PathGeometry _pathGeometry = new PathGeometry();
343
        #endregion
344

    
345
        public override void OnApplyTemplate()
346
        {
347
            base.OnApplyTemplate();
348
            Base_ArcPath = GetTemplateChild(PART_ArcPath) as Path;
349
            Base_BodyPath = GetTemplateChild(PART_BodyPath) as Path;
350

    
351
            this.SetRectCloud();
352

    
353
        }
354
        protected void OnPropertyChanged(string propName)
355
        {
356
            if (PropertyChanged != null)
357
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
358
        }
359
        public void Dispose()
360
        {
361
            //GC.Collect();
362
            ////GC.SuppressFinalize(this);
363
            this.Base_ArcPath = null;
364
            this.Base_BodyPath = null;
365
        }
366

    
367
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
368
        {
369
            //var instance = (RectCloudControl)sender;
370

    
371
            //if (e.OldValue != e.NewValue && instance.Base_BodyPath != null)
372
            //{
373

    
374
            //    instance.SetValue(e.Property, e.NewValue);
375

    
376
            //    if (instance.IsSelected)
377
            //    {
378
            //        instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Blue);
379
            //    }
380
            //    else
381
            //    {
382
            //        instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Red);
383
            //    }
384
            //}
385
        }
386

    
387
        private void SetRectCloud()
388
        {
389
            this.ApplyTemplate();
390
            PathFigure pathFigure = new PathFigure();
391

    
392
            Base_ArcPath.StrokeDashArray.Clear();
393
            Base_BodyPath.StrokeDashArray.Clear();
394

    
395
            foreach (var item in this.DashSize)
396
            {
397
                Base_ArcPath.StrokeDashArray.Add(item);
398
                Base_BodyPath.StrokeDashArray.Add(item);
399
            }
400

    
401
            switch (this.Paint)
402
            {
403
                case PaintSet.None:
404
                    //강인구 추가
405
                    pathFigure.IsFilled = false;
406
                    Base_BodyPath.Fill = null;
407
                    Base_BodyPath.Stroke = null;
408
                    break;
409
                case PaintSet.Fill:
410
                    {
411
                        Base_BodyPath.Stroke = this.StrokeColor;
412
                        Base_BodyPath.StrokeThickness = 0.5;
413
                        Base_ArcPath.Stroke = this.StrokeColor;
414

    
415
                        Base_ArcPath.Fill = this.FillColor;
416
                        Base_BodyPath.Fill = this.FillColor;
417
                    }
418
                    //this.FillColor = this.StrokeColor;
419
                    //Base_BodyPath.Fill = this.FillColor;
420
                    //Base_ArcPath.Fill = this.FillColor;
421
                    //Base_BodyPath.Stroke = this.StrokeColor;
422
                    //Base_BodyPath.StrokeThickness = 2;
423
                    //Base_ArcPath.Stroke = this.StrokeColor;
424
                    //Base_ArcPath.StrokeThickness = 2;
425
                    //pathFigure.IsFilled = true;
426
                    break;
427
                case PaintSet.Hatch:
428
                    Base_BodyPath.Stroke = new SolidColorBrush(Colors.Transparent);
429
                    Base_BodyPath.StrokeThickness = 2;
430
                    Base_BodyPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor);
431
                    Base_ArcPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor);
432
                    pathFigure.IsFilled = true;
433
                    break;
434
                default:
435
                    break;
436
            }
437

    
438
            #region 사각형 만들기
439
            if (this.Paint != PaintSet.None)
440
            {
441
                pathFigure.StartPoint = this.StartPoint;
442

    
443
                List<Point> points = new List<Point>() { this.StartPoint, this.LeftBottomPoint, this.EndPoint, this.TopRightPoint };
444
                PolyLineSegment polyline = new PolyLineSegment(points, true);
445
                pathFigure.Segments.Add(polyline);
446
                
447
                PathGeometry pathGeometry = new PathGeometry();
448
                pathGeometry.Figures = new PathFigureCollection();
449
                pathFigure.IsClosed = true;
450
                pathGeometry.Figures.Add(pathFigure);
451
                //this.FillColor = new SolidColorBrush(Colors.Red);
452
                this.PathSubData = pathGeometry;
453
            }
454
            ArcLength = ArcLength == 0 ? 10 : ArcLength;
455

    
456
            #endregion
457
            #region Cloud 만들기
458
            /// set reverse if area is greater 0 - 2012.07.04 added by humkyung
459
            /// 
460

    
461
            System.Diagnostics.Debug.WriteLine(ArcLength);
462
            double area = MathSet.AreaOf(new List<Point>() { this.StartPoint, this.LeftBottomPoint, this.EndPoint, this.TopRightPoint });
463
            bool reverse = (area > 0);
464
            /// up to here
465
            this._pathGeometry = new PathGeometry();
466
            int count = this.PointSet.Count;
467
            PathFigure pathSubFigure = Polygon.CloudControl.GenerateLineWithCloud(this.StartPoint, this.LeftBottomPoint, this.ArcLength, reverse);
468
            _pathGeometry.Figures.Add(pathSubFigure);
469

    
470
            pathSubFigure = Polygon.CloudControl.GenerateLineWithCloud(this.LeftBottomPoint, this.EndPoint, this.ArcLength, reverse);
471
            _pathGeometry.Figures.Add(pathSubFigure);
472

    
473
            pathSubFigure = Polygon.CloudControl.GenerateLineWithCloud(this.EndPoint, this.TopRightPoint, this.ArcLength, reverse);
474
            _pathGeometry.Figures.Add(pathSubFigure);
475

    
476
            pathSubFigure = Polygon.CloudControl.GenerateLineWithCloud(this.TopRightPoint, this.StartPoint, this.ArcLength, reverse);
477
            _pathGeometry.Figures.Add(pathSubFigure);
478

    
479
            if (this.Paint != PaintSet.None)
480
            {
481
                foreach (var item in _pathGeometry.Figures)
482
                {
483
                    item.IsFilled = true;
484
                }
485
            }
486

    
487
            this.PathData = _pathGeometry;
488
            ApplyOverViewData();
489
            #endregion
490
        }
491

    
492
        public void ChangePaint(PaintSet state)
493
        {
494
            this.Paint = state;
495
            this.SetRectCloud();
496
        }
497

    
498
        public void CloseSettingPoint()
499
        {
500
            this.PointSet[0] = this.StartPoint;
501
            this.PointSet[1] = this.LeftBottomPoint;
502
            this.PointSet[2] = this.EndPoint;
503
            this.PointSet[3] = this.TopRightPoint;
504
        }
505

    
506
        public override void ApplyOverViewData()
507
        {
508
            this.OverViewPathData = this.PathData;
509
        }
510

    
511
        public override void UpdateControl()
512
        {
513
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
514
            this.LeftBottomPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
515
            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
516
            this.TopRightPoint = new Point(this.PointSet[3].X, this.PointSet[3].Y);
517
        }
518

    
519
        //public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
520
        //{
521
        //    PathFigure pathFigure = new PathFigure();
522
        //    pathFigure.StartPoint = p1;
523

    
524
        //    double arcLength = arcLength_;
525
        //    /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung 
526
        //    double dx = p2.X - p1.X;
527
        //    double dy = p2.Y - p1.Y;
528
        //    double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2
529
        //    double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
530
        //    Point lastPt = new Point(p1.X, p1.Y);
531
        //    double count = l / arcLength;
532
        //    /// normalize
533
        //    dx /= l;
534
        //    dy /= l;
535
        //    Double j = 1;
536
        //    for (j = 1; j < (count - 1); j++)
537
        //    {
538
        //        ArcSegment arcSeg = new ArcSegment();
539
        //        arcSeg.Size = new Size(arcLength * RectCloudControl._CloudArcDepth, arcLength * RectCloudControl._CloudArcDepth);						/// x size and y size of arc
540
        //        arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);	/// end point of arc
541
        //        lastPt = arcSeg.Point;  /// save last point
542
        //        arcSeg.RotationAngle = theta + 90;
543
        //        if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
544
        //        pathFigure.Segments.Add(arcSeg);
545
        //    }
546

    
547
        //    /// draw arc between last point and end point
548
        //    if ((count > j) || (count > 0))
549
        //    {
550
        //        arcLength = MathSet.DistanceTo(lastPt, p2);
551
        //        ArcSegment arcSeg = new ArcSegment();
552
        //        arcSeg.Size = new Size(arcLength * RectCloudControl._CloudArcDepth, arcLength * RectCloudControl._CloudArcDepth);	/// x size and y size of arc
553
        //        arcSeg.Point = new Point(p2.X, p2.Y);						/// end point of arc
554
        //        arcSeg.RotationAngle = theta;
555
        //        if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
556
        //        pathFigure.Segments.Add(arcSeg);
557
        //    }
558
        //    pathFigure.IsClosed = false;
559
        //    pathFigure.IsFilled = false;
560
        //    /// up to here
561
        //    //pathFigure.IsFilled = true;
562
        //    return pathFigure;
563
        //}
564

    
565
        /// <summary>
566
        /// call when mouse is moving while drawing control
567
        /// </summary>
568
        /// <author>humkyung</author>
569
        /// <param name="pt"></param>
570
        /// <param name="bAxisLocked"></param>
571
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
572
        {
573
            this.EndPoint = bAxisLocked ? this.GetSquareEndPoint(this.StartPoint, pt) : pt;
574
            this.LeftBottomPoint = new Point(this.StartPoint.X, this.EndPoint.Y);
575
            this.TopRightPoint = new Point(this.EndPoint.X, this.StartPoint.Y);
576
            
577
            this.PointSet = new List<Point>
578
            {
579
                this.StartPoint,
580
                this.LeftBottomPoint,
581
                this.EndPoint,
582
                this.TopRightPoint,
583
            };
584
        }
585

    
586
        /// <summary>
587
        /// move control point has same location of given pt along given delta
588
        /// </summary>
589
        /// <author>humkyung</author>
590
        /// <date>2019.06.20</date>
591
        /// <param name="pt"></param>
592
        /// <param name="dx"></param>
593
        /// <param name="dy"></param>
594
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
595
        {
596
            IPath path = (this as IPath);
597

    
598
            Point selected = MathSet.getNearPoint(path.PointSet, pt);
599
            selected.X += dx;
600
            selected.Y += dy;
601
            int i = 0;
602
            for (i = 0; i < (this as IPath).PointSet.Count; i++)
603
            {
604
                if (pt.Equals((this as IPath).PointSet[i]))
605
                {
606
                    (this as IPath).PointSet[i] = selected;
607
                    break;
608
                }
609
            }
610

    
611
            var ReverseP = (i + path.PointSet.Count() / 2) % path.PointSet.Count();
612
            var PreviousP = (i + (path.PointSet.Count() - 1)) % path.PointSet.Count();
613
            var NextP = (i + 1) % path.PointSet.Count();
614

    
615
            var distance = MathSet.DistanceTo(path.PointSet[ReverseP], path.PointSet[i]);
616

    
617
            var PreviousV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[PreviousP]);
618
            var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X,
619
                path.PointSet[i].Y - path.PointSet[ReverseP].Y);
620
            path.PointSet[PreviousP] = new Point(path.PointSet[ReverseP].X + PreviousV.X * l, path.PointSet
621
                [ReverseP].Y + PreviousV.Y * l);
622

    
623
            var NextV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[NextP]);
624
            l = MathSet.DotProduct(NextV.X, NextV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, path.PointSet
625
                [i].Y - path.PointSet[ReverseP].Y);
626
            path.PointSet[NextP] = new Point(path.PointSet[ReverseP].X + NextV.X * l, path.PointSet[ReverseP].Y + NextV.Y * l);
627

    
628
            this.UpdateControl();
629
        }
630

    
631
        /// <summary>
632
        /// return rectcloudcontrols' area
633
        /// </summary>
634
        /// <author>humkyung</author>
635
        /// <date>2019.06.13</date>
636
        public override Rect ItemRect
637
        {
638
            get
639
            {
640
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
641
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
642
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
643
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
644

    
645
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
646
            }
647
        }
648

    
649
        /// <summary>
650
        /// Serialize this
651
        /// </summary>
652
        /// <param name="sUserId"></param>
653
        /// <returns></returns>
654
        public override string Serialize()
655
        {
656
            using (S_RectCloudControl STemp = new S_RectCloudControl())
657
            {
658
                STemp.TransformPoint = "0|0";
659
                STemp.PointSet = this.PointSet;
660
                STemp.SizeSet = String.Format("{0}", this.LineSize);
661
                //STemp.StrokeColor = "#FF00FF00";
662
                STemp.StrokeColor = this.StrokeColor.Color.ToString();
663
                STemp.StartPoint = this.StartPoint;
664
                STemp.UserID = this.UserID;
665
                STemp.Opac = this.Opacity;
666
                STemp.TR = this.TopRightPoint;
667
                STemp.LB = this.LeftBottomPoint;
668
                STemp.EndPoint = this.EndPoint;
669
                STemp.PaintState = this.Paint;
670
                STemp.DashSize = this.DashSize;
671
                STemp.ArcLength = this.ArcLength;
672
                STemp.Name = this.GetType().Name.ToString();
673
                ///강인구 추가(2017.11.02)
674
                ///Memo 추가
675
                STemp.Memo = this.Memo;
676

    
677
                return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize()));
678
            }
679
        }
680

    
681
        /// <summary>
682
        /// create a rectcloudcontrol from given string
683
        /// </summary>
684
        /// <param name="str"></param>
685
        /// <returns></returns>
686
        public static RectCloudControl FromString(string str, SolidColorBrush brush, string sProjectNo)
687
        {
688
            using (S_RectCloudControl s = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(str))
689
            {
690
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
691
                return new RectCloudControl()
692
                {
693
                    StartPoint = s.StartPoint,
694
                    EndPoint = s.EndPoint,
695
                    LeftBottomPoint = s.LB,
696
                    Paint = s.PaintState,
697
                    Opacity = s.Opac,
698
                    DashSize = s.DashSize,
699
                    TopRightPoint = s.TR,
700
                    PointSet = s.PointSet,
701
                    StrokeColor = brush,
702
                    ArcLength = s.ArcLength,
703
                    LineSize = Convert.ToDouble(data2.First()),
704
                    UserID = s.UserID,
705
                    Memo = s.Memo
706
                };
707
            }
708
        }
709
    }
710
}
클립보드 이미지 추가 (최대 크기: 500 MB)