프로젝트

일반

사용자정보

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

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

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