프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Polygon / PolygonControl.cs @ master

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

1 3f1068a7 humkyung
using iTextSharp.text;
2
using MarkupToPDF.Common;
3 787a4489 KangIngu
using MarkupToPDF.Controls.Common;
4 036650a0 humkyung
using MarkupToPDF.Serialize.Core;
5
using MarkupToPDF.Serialize.S_Control;
6 787a4489 KangIngu
using System;
7
using System.Collections.Generic;
8
using System.ComponentModel;
9
using System.Linq;
10
using System.Text;
11
using System.Threading.Tasks;
12
using System.Windows;
13
using System.Windows.Controls;
14 7a3b7ef3 swate0609
using System.Windows.Forms;
15
using System.Windows.Input;
16 787a4489 KangIngu
using System.Windows.Media;
17
using System.Windows.Shapes;
18
19
namespace MarkupToPDF.Controls.Polygon
20
{
21 86143026 humkyung
     public class PolygonControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IShapeControl, IMarkupControlData
22 787a4489 KangIngu
    {
23
        #region Constructure
24
25
        static PolygonControl()
26
        {
27
            DefaultStyleKeyProperty.OverrideMetadata(typeof(PolygonControl), new FrameworkPropertyMetadata(typeof(PolygonControl)));
28 a6f7f9b6 djkim
            //ResourceDictionary dictionary = new ResourceDictionary();
29
            //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
30
            //Application.Current.Resources.MergedDictionaries.Add(dictionary);
31 787a4489 KangIngu
        }
32
33
        public PolygonControl()
34
        {
35 a6f7f9b6 djkim
            //this.DefaultStyleKey = typeof(PolygonControl);
36 787a4489 KangIngu
        }
37 3f1068a7 humkyung
38
        public override void Copy(CommentUserInfo lhs)
39
        {
40
            if(lhs is PolygonControl item)
41
            {
42
                this.LineSize = item.LineSize;
43
                this.IsCompleted = item.IsCompleted;
44
                this.Opacity = item.Opacity;
45
                this.StrokeColor = item.StrokeColor;
46
                this.ControlType = item.ControlType;
47
                this.DashSize = item.DashSize;
48
                this.StartPoint = new Point(item.StartPoint.X, item.StartPoint.Y);
49
                this.EndPoint = new Point(item.EndPoint.X, item.EndPoint.Y);
50
                this.PointSet = item.PointSet.ConvertAll(x => new Point(x.X, x.Y));
51
                this.UserID = item.UserID;
52
                this.Paint = item.Paint;
53
                this.Memo = item.Memo;
54 b2d0f316 humkyung
                this.ZIndex = item.ZIndex;
55 e1b36bc0 humkyung
                this.GroupID = item.GroupID;
56 3f1068a7 humkyung
            }
57
        }
58
59
        public override CommentUserInfo Clone()
60
        {
61
            var clone = new PolygonControl();
62
            clone.Copy(this);
63
            return clone; 
64
        }
65
66 787a4489 KangIngu
        #endregion
67
68
        #region Variable
69
        private const string PART_PolyPath = "PART_PolyPath";
70
71
        public Path Base_PolyPath = null;
72
73
        #endregion
74
75
        #region Internal Method
76
        public override void OnApplyTemplate()
77
        {   
78
            base.OnApplyTemplate();
79
80
            Base_PolyPath = GetTemplateChild(PART_PolyPath) as Path;
81
82
            if (Base_PolyPath == null)
83
                return;
84
85
            this.SetPolyPath();
86
        }
87
88
89
        #endregion
90
91
        #region Method
92
93 f513c215 humkyung
        public override void ApplyOverViewData()
94 787a4489 KangIngu
        {
95
            this.OverViewPathData = this.PathData;
96
        }
97
98
        #endregion
99
100
        #region Dependency Properties
101
102
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
103
                "UserID", typeof(string), typeof(PolygonControl), new PropertyMetadata(null));
104
105
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
106
              "LineSize", typeof(double), typeof(PolygonControl), new PropertyMetadata((Double)3));
107
108
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
109
               "StrokeColor", typeof(SolidColorBrush), typeof(PolygonControl), 
110
               new PropertyMetadata(new SolidColorBrush(Colors.Red)));
111
112
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
113
                "PathData", typeof(Geometry), typeof(PolygonControl), null);
114
115
        //강인구 추가
116
        public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register(
117
                "DashSize", typeof(DoubleCollection), typeof(PolygonControl), new PropertyMetadata(new DoubleCollection { 99999999  }, PointValueChanged));
118
119
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
120
                "OverViewPathData", typeof(Geometry), typeof(PolygonControl), null);
121
        //강인구 추가
122
        public static readonly DependencyProperty PaintProperty = DependencyProperty.Register(
123
        "Paint", typeof(PaintSet), typeof(PolygonControl), new PropertyMetadata(PaintSet.None, PointValueChanged));
124
125
        public static readonly DependencyProperty IsCompletedProperty = DependencyProperty.Register(
126
               "IsCompleted", typeof(bool), typeof(PolygonControl), null);
127
128
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
129
               "StartPoint", typeof(Point), typeof(PolygonControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
130
131
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
132
               "EndPoint", typeof(Point), typeof(PolygonControl), new PropertyMetadata(new Point(100, 100), PointValueChanged));
133
134
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
135
                "PointSet", typeof(List<Point>), typeof(PolygonControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
136
137
        /// <summary>
138
        /// StylusPointSet을 List<Point>로 대체하면 PointValueChanged가 작동안한다.
139
        /// </summary>
140
        //public static readonly DependencyProperty StylusPointSetProperty = DependencyProperty.Register(
141
        //        "PointC", typeof(StylusPointSet), typeof(PolygonControl), new PropertyMetadata(new StylusPointSet(), PointValueChanged));
142
143
        public static readonly DependencyProperty AngleProperty =
144
            DependencyProperty.Register("Angle", typeof(double), typeof(PolygonControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback
145
                (AngleValueChanged)));
146
147
        public static readonly DependencyProperty CenterXProperty =
148
            DependencyProperty.Register("CenterX", typeof(double), typeof(PolygonControl), new PropertyMetadata((double)0, OnCenterXYChanged));
149
150
        public static readonly DependencyProperty CenterYProperty =
151
            DependencyProperty.Register("CenterY", typeof(double), typeof(PolygonControl), new PropertyMetadata((double)0, OnCenterXYChanged));
152
153
        public static readonly DependencyProperty IsSelectedProperty =
154
            DependencyProperty.Register("IsSelected", typeof(bool), typeof(PolygonControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
155
156
        public static readonly DependencyProperty ControlTypeProperty =
157
            DependencyProperty.Register("ControlType", typeof(ControlType), typeof(PolygonControl), new FrameworkPropertyMetadata(ControlType.PolygonControl));
158
159
        public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
160
                "CanvasX", typeof(double), typeof(PolygonControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
161
162
        public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
163
                "CanvasY", typeof(double), typeof(PolygonControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
164
165
        #endregion
166
167
        #region PropertyChanged Method
168
        public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
169
        {
170
            var instance = (PolygonControl)sender;
171
172
            if (e.OldValue != e.NewValue && instance != null)
173
            {
174
                instance.SetValue(e.Property, e.NewValue);
175
                //Canvas.SetLeft(instance, instance.CanvasX);
176
                //Canvas.SetTop(instance, instance.CanvasY);
177
            }
178
        }
179
180
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
181
        {
182
            var instance = (PolygonControl)sender;
183
184
            if (e.OldValue != e.NewValue && instance != null)
185
            {
186
                instance.SetValue(e.Property, e.NewValue);
187
                //강인구 추가
188
                instance.SetPolyPath();
189
                //instance.SetPolyPath(); 주석처리
190
191
            }
192
        }
193
        public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
194
        {
195
            var instance = (PolygonControl)sender;
196
197
            if (e.OldValue != e.NewValue && instance != null)
198
            {
199
                instance.SetValue(e.Property, e.NewValue);
200
                instance.SetPolyPath();
201
            }
202
        }
203
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
204
        {
205
            var instance = (PolygonControl)sender;
206
            if (e.OldValue != e.NewValue && instance != null)
207
            {
208
                instance.SetValue(e.Property, e.NewValue);
209
                instance.SetPolyPath();
210
            }
211
        }
212
213
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
214
        {
215
            //var instance = (PolygonControl)sender;
216
217
            //if (e.OldValue != e.NewValue && instance.Base_PolyPath != null)
218
            //{
219
            //    instance.SetValue(e.Property, e.NewValue);
220
221
            //    if (instance.IsSelected)
222
            //    {
223
            //        instance.Base_PolyPath.Stroke = new SolidColorBrush(Colors.Blue);
224
            //    }
225
            //    else
226
            //    {
227
            //        instance.Base_PolyPath.Stroke = new SolidColorBrush(Colors.Transparent);
228
            //    }
229
            //}
230
        }
231
232
        #endregion
233
234
        #region Properties
235
236
237
        public bool IsCompleted
238
        {
239
            get { return (bool)GetValue(IsCompletedProperty); }
240
            set
241
            {
242
                SetValue(IsCompletedProperty, value);
243
                OnPropertyChanged("IsCompleted");
244
            }
245
        }
246
247
248
        public Geometry OverViewPathData
249
        {
250
            get { return (Geometry)GetValue(OverViewPathDataProperty); }
251
            set
252
            {
253
                SetValue(OverViewPathDataProperty, value);
254
                OnPropertyChanged("OverViewPathData");
255
            }
256
        }
257
258
        public double CanvasX
259
        {
260
            get { return (double)GetValue(CanvasXProperty); }
261
            set
262
            {
263
                if (this.CanvasX != value)
264
                {
265
                    SetValue(CanvasXProperty, value);
266
                    OnPropertyChanged("CanvasX");
267
                }
268
            }
269
        }
270
271
        public double CanvasY
272
        {
273
            get { return (double)GetValue(CanvasYProperty); }
274
            set
275
            {
276
                if (this.CanvasY != value)
277
                {
278
                    SetValue(CanvasYProperty, value);
279
                    OnPropertyChanged("CanvasY");
280
                }
281
            }
282
        } 
283
284 959b3ef2 humkyung
        public override bool IsSelected
285 787a4489 KangIngu
        {
286
            get
287
            {
288
                return (bool)GetValue(IsSelectedProperty);
289
            }
290
            set
291
            {
292
                SetValue(IsSelectedProperty, value);
293
                OnPropertyChanged("IsSelected");
294
            }
295
        }
296
297
        public PaintSet Paint
298
        {
299
            get { return (PaintSet)GetValue(PaintProperty); }
300
            set
301
            {
302
                if (this.Paint != value)
303
                {
304
                    SetValue(PaintProperty, value);
305
                    OnPropertyChanged("Paint");
306
                }
307
            }
308
        }
309
310 5529d2a2 humkyung
        public override ControlType ControlType
311 787a4489 KangIngu
        {
312
            set
313
            {
314
                SetValue(ControlTypeProperty, value);
315
                OnPropertyChanged("ControlType");
316
            }
317
            get
318
            {
319
                return (ControlType)GetValue(ControlTypeProperty);
320
            }
321
        }
322
323
        public Double LineSize
324
        {
325
            get { return (Double)GetValue(LineSizeProperty); }
326
            set
327
            {
328
                if (this.LineSize != value)
329
                {
330
                    SetValue(LineSizeProperty, value);
331
                    OnPropertyChanged("LineSize");
332
                }
333
            }
334
        }
335
336
        public DoubleCollection DashSize
337
        {
338
            get { return (DoubleCollection)GetValue(DashSizeProperty); }
339
            set
340
            {
341
                if (this.DashSize != value)
342
                {
343
                    SetValue(DashSizeProperty, value);
344
                    OnPropertyChanged("DashSize");
345
                }
346
            }
347
        }
348
        public string UserID
349
        {
350
            get { return (string)GetValue(UserIDProperty); }
351
            set
352
            {
353
                if (this.UserID != value)
354
                {
355
                    SetValue(UserIDProperty, value);
356
                    OnPropertyChanged("UserID");
357
                }
358
            }
359
        }
360
        public List<Point> PointSet
361
        {
362
            get { return (List<Point>)GetValue(PointSetProperty); }
363
            set { SetValue(PointSetProperty, value);
364
            OnPropertyChanged("PointSet");
365
            }
366
        }        //public StylusPointSet PointC
367
        //{
368
        //    get { return (StylusPointSet)GetValue(StylusPointSetProperty); }
369
        //    set
370
        //    {
371
        //        SetValue(StylusPointSetProperty, value);
372
        //        OnPropertyChanged("PointC");
373
        //    }
374
        //}
375
376
377
        public double CenterX
378
        {
379
            get { return (double)GetValue(CenterXProperty); }
380
            set { SetValue(CenterXProperty, value);
381
            OnPropertyChanged("CenterX");
382
            }
383
        }
384
        public double CenterY
385
        {
386
            get
387
            {
388
                return (double)GetValue(CenterYProperty);
389
            }
390
            set
391
            {
392
                SetValue(CenterYProperty, value);
393
                OnPropertyChanged("CenterY");
394
            }
395
        }
396 4913851c humkyung
        public override SolidColorBrush StrokeColor
397 787a4489 KangIngu
        {
398
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
399
            set
400
            {
401
                if (this.StrokeColor != value)
402
                {
403
                    SetValue(StrokeColorProperty, value);
404
                    OnPropertyChanged("StrokeColor");
405
                }
406
            }
407
        }
408
        public Geometry PathData
409
        {
410
            get { return (Geometry)GetValue(PathDataProperty); }
411
            set
412
            {
413
                SetValue(PathDataProperty, value);
414
                OnPropertyChanged("PathData");
415
            }
416
        }
417
     
418 168f8027 taeseongkim
        //public double Angle
419
        //{
420
        //    get { return (double)GetValue(AngleProperty); }
421
        //    set
422
        //    {
423
        //        if (this.Angle != value)
424
        //        {
425
        //            SetValue(AngleProperty, value);
426
        //            OnPropertyChanged("Angle");
427
        //        }
428
        //    }
429
        //}
430 787a4489 KangIngu
431
        public Point EndPoint
432
        {
433
            get { return (Point)GetValue(EndPointProperty); }
434
            set
435
            {
436
                SetValue(EndPointProperty, value);
437
                OnPropertyChanged("EndPoint");
438
            }
439
        }
440
        public Point StartPoint
441
        {
442
            get { return (Point)GetValue(StartPointProperty); }
443
            set
444
            {
445
                SetValue(StartPointProperty, value);
446
                OnPropertyChanged("StartPoint");
447
            }
448
        }
449
        #endregion
450
451 0d00f9c8 humkyung
        public override void UpdateControl()
452 787a4489 KangIngu
        {
453
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
454
            this.EndPoint = new Point(this.PointSet[this.PointSet.Count - 1].X, this.PointSet[this.PointSet.Count - 1].Y);
455
456
            SetPolyPath();
457
        }
458
459 661b7416 humkyung
        private void SetPolyPath()
460 787a4489 KangIngu
        {
461
            if (Base_PolyPath != null)
462
            {
463
                Base_PolyPath.StrokeDashArray.Clear();
464
                foreach (var item in this.DashSize)
465
                {
466
                    Base_PolyPath.StrokeDashArray.Add(item);
467
                }
468
469
                PathGeometry pathGeometry = new PathGeometry();
470
                PathFigure pathFigure = new PathFigure();
471 4804a4fb humkyung
                PolyLineSegment instance = new PolyLineSegment(this.PointSet, true);
472 787a4489 KangIngu
               
473
                StartPoint = instance.Points.First();
474
                pathFigure.StartPoint = StartPoint;
475
                EndPoint = instance.Points.Last();
476
                pathFigure.Segments.Add(instance);
477
                pathGeometry.Figures.Add(pathFigure);
478
479
                //강인구 추가(Chain이 아닌 Polygon일때만 채우기 및 빗금 하기)
480
                if (ControlType == ControlType.PolygonControl)
481
                {
482
                    switch (this.Paint)
483
                    {
484
                        case PaintSet.None:
485
                            {
486 4804a4fb humkyung
                                pathFigure.IsFilled = false;
487 787a4489 KangIngu
                                //강인구 추가
488
                                Base_PolyPath.Fill = null;
489
                            }
490
                            break;
491
                        case PaintSet.Fill:
492
                            {
493
                                Base_PolyPath.Fill = this.StrokeColor;
494
                            }
495
                            break;
496
                        case PaintSet.Hatch:
497
                            {
498 92c9cab8 taeseongkim
                                var size = this.LineSize > 5 ? 5 : this.LineSize;
499
                                Base_PolyPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor, 3 * 0.1);
500 787a4489 KangIngu
                            }
501
                            break;
502
                        default:
503
                            break;
504
                    }
505
                }
506
507
                this.PathData = pathGeometry;
508 4804a4fb humkyung
                this.ApplyOverViewData();
509 787a4489 KangIngu
            }
510
        }
511
512
        public void ChangePaint(PaintSet state)
513
        {
514
515
        }
516 a6272c57 humkyung
517
        /// <summary>
518
        /// call when mouse is moving while drawing control
519
        /// </summary>
520
        /// <author>humkyung</author>
521
        /// <param name="pt"></param>
522
        /// <param name="bAxisLocked"></param>
523 233ef333 taeseongkim
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
524 a6272c57 humkyung
        {
525
            this.PointSet.RemoveAt(this.PointSet.Count - 1);
526
527
            Point tmp = pt;
528 168f8027 taeseongkim
529 233ef333 taeseongkim
            if (bAxisLocked)
530 a6272c57 humkyung
            {
531 233ef333 taeseongkim
                CommentAngle = MathSet.returnAngle(this.PointSet[this.PointSet.Count - 1], ref tmp, bAxisLocked);
532 a6272c57 humkyung
            }
533 168f8027 taeseongkim
534 7a3b7ef3 swate0609
            if (this.PointSet.Count > 2 && StartPoint == tmp)
535
            {
536
                this.IsCompleted = true;
537
538
                //var firstPoint = this.PointSet.First();
539
                //this.PointSet.Add(firstPoint);
540 a6272c57 humkyung
541 7a3b7ef3 swate0609
                //this.ApplyOverViewData();
542
543
                UpdateControl();
544
            }
545
            else
546
            {
547
548
                this.PointSet.Add(tmp);
549
550
                this.UpdateControl();
551
            }
552 a6272c57 humkyung
        }
553 d2114d3b humkyung
554
        /// <summary>
555
        /// move control point has same location of given pt along given delta
556
        /// </summary>
557
        /// <author>humkyung</author>
558
        /// <date>2019.06.20</date>
559
        /// <param name="pt"></param>
560
        /// <param name="dx"></param>
561
        /// <param name="dy"></param>
562 233ef333 taeseongkim
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
563 d2114d3b humkyung
        {
564 902faaea taeseongkim
            var pointSet = (this as IPath).PointSet;
565 233ef333 taeseongkim
566 902faaea taeseongkim
            Point selected = MathSet.getNearPoint(pointSet, pt);
567
568
            Point NearStartpoint = MathSet.getNearPoint(pointSet, pt);
569
570
            var tmpPointSet = pointSet.Select((x,inx)=> new { x,inx});
571
572
            var selectPoint = tmpPointSet.Where(x => x.x.Equals(pt));
573
574
            if(selectPoint.Count() > 0)
575
            {
576
                if (tmpPointSet.Count() > selectPoint.First().inx + 1)
577
                {
578
                    NearStartpoint = pointSet[selectPoint.First().inx + 1];
579
                }
580
                else
581
                {
582
                    NearStartpoint = pointSet[selectPoint.First().inx - 1];
583
                }
584
            }
585 233ef333 taeseongkim
586 d2114d3b humkyung
            selected.X += dx;
587
            selected.Y += dy;
588 233ef333 taeseongkim
589
            Point tmp = selected;
590
591
            CommentAngle = MathSet.returnAngle(NearStartpoint, ref tmp, bAxisLocked);
592
593
            if (bAxisLocked)
594
            {
595
                selected = tmp;
596
            }
597
598 d2114d3b humkyung
            for (int i = 0; i < (this as IPath).PointSet.Count; i++)
599
            {
600
                if (pt.Equals((this as IPath).PointSet[i]))
601
                {
602
                    (this as IPath).PointSet[i] = selected;
603
                }
604
            }
605 0d00f9c8 humkyung
            this.UpdateControl();
606 d2114d3b humkyung
        }
607 787a4489 KangIngu
608 036650a0 humkyung
        /// <summary>
609 91efe37a humkyung
        /// return Polygon's area
610
        /// </summary>
611
        /// <author>humkyung</author>
612
        /// <date>2019.06.13</date>
613
        public override Rect ItemRect
614
        {
615
            get
616
            {
617
                double dMinX = double.MaxValue;
618
                double dMinY = double.MaxValue;
619
                double dMaxX = double.MinValue;
620
                double dMaxY = double.MinValue;
621
                foreach (Point pt in this.PointSet)
622
                {
623
                    dMinX = Math.Min(dMinX, pt.X);
624
                    dMinY = Math.Min(dMinY, pt.Y);
625
                    dMaxX = Math.Max(dMaxX, pt.X);
626
                    dMaxY = Math.Max(dMaxY, pt.Y);
627
                }
628
629
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
630
            }
631
        }
632
633
        /// <summary>
634 036650a0 humkyung
        /// Serialize this
635
        /// </summary>
636
        /// <param name="sUserId"></param>
637
        /// <returns></returns>
638
        public override string Serialize()
639
        {
640 b2d0f316 humkyung
            using (S_PolyControl ctrl = new S_PolyControl())
641
            {
642
                ctrl.TransformPoint = "0|0";
643
                ctrl.SizeSet = String.Format("{0}", this.LineSize);
644
                ctrl.StrokeColor = this.StrokeColor.Color.ToString();
645
                //ctrl.StrokeColor = "#FF000FFF";
646
                ctrl.Name = this.GetType().Name.ToString();
647
                //ctrl.Toler = this.Toler;
648
                ctrl.PaintState = this.Paint;
649
                ctrl.Opac = this.Opacity;
650
                ctrl.UserID = this.UserID;
651
                ctrl.PaintState = this.Paint;
652 036650a0 humkyung
                //강인구 추가(Chain인지 Polygon인지 구분)
653 b2d0f316 humkyung
                ctrl.Type = this.ControlType;
654
                //ctrl.IsTrans = this.isTransOn;
655
                //ctrl.IsChain = this.isChain;
656
                ctrl.PointSet = new List<Point>();
657
                ctrl.DashSize = this.DashSize;
658
                ctrl.StartPoint = this.StartPoint;
659
                ctrl.EndPoint = this.EndPoint;
660
                ctrl.IsCompleted = this.IsCompleted;
661 036650a0 humkyung
                foreach (var point in this.PointSet)
662
                {
663 b2d0f316 humkyung
                    ctrl.PointSet.Add(point);
664 036650a0 humkyung
                }
665
                ///강인구 추가(2017.11.02)
666
                ///Memo 추가
667 b2d0f316 humkyung
                ctrl.Memo = this.Memo;
668 fd19a116 humkyung
                ctrl.Index = this.Index;
669 b2d0f316 humkyung
                ctrl.ZIndex = this.ZIndex;
670 e1b36bc0 humkyung
                ctrl.GroupID = this.GroupID;
671 b2d0f316 humkyung
672
                return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize()));
673 036650a0 humkyung
            }
674
        }
675
676 661b7416 humkyung
        /// <summary>
677
        /// create a polygoncontrol from given string
678
        /// </summary>
679
        /// <param name="str"></param>
680
        /// <returns></returns>
681
        public static PolygonControl FromString(string str, SolidColorBrush brush, string sProjectNo)
682
        {
683
            using (S_PolyControl s = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(str))
684
            {
685
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
686
                return new PolygonControl
687
                {
688
                    LineSize = Convert.ToDouble(data2.First()),
689
                    //Toler = s.Toler,
690
                    IsCompleted = s.IsCompleted,
691
                    //PointSet = new List<Point>(),
692
                    Opacity = s.Opac,
693
                    StrokeColor = brush,
694
                    //강인구 추가(Chain인지 Polygon인지 구분)
695
                    ControlType = s.Type,
696
                    DashSize = s.DashSize,
697
                    StartPoint = s.StartPoint,
698
                    EndPoint = s.EndPoint,
699
                    PointSet = s.PointSet,
700
                    UserID = s.UserID,
701
                    Paint = s.PaintState,
702 b2d0f316 humkyung
                    Memo = s.Memo,
703 fd19a116 humkyung
                    Index = s.Index,
704 e1b36bc0 humkyung
                    ZIndex = s.ZIndex,
705
                    GroupID = s.GroupID
706 661b7416 humkyung
                };
707
            }
708
        }
709 787a4489 KangIngu
710
711
        #region Dispose
712
        public void Dispose()
713
        {
714 a6f7f9b6 djkim
            //GC.Collect();
715 24c5e56c taeseongkim
            ////GC.SuppressFinalize(this);
716 a6f7f9b6 djkim
            this.Base_PolyPath = null;
717 787a4489 KangIngu
        }
718
        #endregion
719
720
        #region INotifyPropertyChanged
721
        private void OnPropertyChanged(string name)
722
        {
723
            if (PropertyChanged != null)
724
            {
725
                PropertyChanged(this, new PropertyChangedEventArgs(name));
726
            }
727
        }
728
729
        public event PropertyChangedEventHandler PropertyChanged;
730
        #endregion
731
    }
732
733
    public class StylusPointSet : INotifyPropertyChanged
734
    {
735
        public StylusPointSet()
736
        {
737
            if (pointSet == null)
738
                pointSet = new List<Point>();
739
        }
740
741
        public List<Point> _pointSet;
742
743
        public List<Point> pointSet
744
        {
745
            get
746
            {
747
                return _pointSet;
748
            }
749
            set
750
            {
751
                _pointSet = value;
752
                OnPropertyChanged("pointSet");
753
            }
754
        }
755
756
        #region INotifyPropertyChanged
757
        private void OnPropertyChanged(string name)
758
        {
759
            if (PropertyChanged != null)
760
            {
761
                PropertyChanged(this, new PropertyChangedEventArgs(name));
762
            }
763
        }
764
765
        public event PropertyChangedEventHandler PropertyChanged;
766
        #endregion
767
    }
768
}
클립보드 이미지 추가 (최대 크기: 500 MB)