프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Shape / CircleControl.cs @ b2d0f316

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

1
using MarkupToPDF.Common;
2
using MarkupToPDF.Controls.Common;
3
using MarkupToPDF.Serialize.Core;
4
using MarkupToPDF.Serialize.S_Control;
5
using System;
6
using System.Collections.Generic;
7
using System.ComponentModel;
8
using System.Linq;
9
using System.Windows;
10
using System.Windows.Media;
11
using System.Windows.Shapes;
12

    
13
namespace MarkupToPDF.Controls.Shape
14
{
15
    [TemplatePart(Name = "PART_CirclePath", Type = typeof(Path))]
16
    public class CircleControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, ICircleControl, IDashControl
17
    {
18
        private const string PART_CirclePath = "PART_CirclePath";
19
        public Path Base_CirclePath = null;
20

    
21
        static CircleControl()
22
        {
23
            DefaultStyleKeyProperty.OverrideMetadata(typeof(CircleControl), new FrameworkPropertyMetadata(typeof(CircleControl)));
24
            //Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary);
25
            //ResourceDictionary dictionary = new ResourceDictionary();
26
            //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
27
            //Application.Current.Resources.MergedDictionaries.Add(dictionary);
28
        }
29

    
30
        public override void Copy(CommentUserInfo lhs)
31
        {
32
            if (lhs is CircleControl CircleCtrl)
33
            {
34
                this.LineSize = CircleCtrl.LineSize;
35
                this.Paint = CircleCtrl.Paint;
36
                this.StartPoint = new Point(CircleCtrl.StartPoint.X, CircleCtrl.StartPoint.Y);
37
                this.EndPoint = new Point(CircleCtrl.EndPoint.X, CircleCtrl.EndPoint.Y);
38
                this.LeftBottomPoint = new Point(CircleCtrl.LeftBottomPoint.X, CircleCtrl.LeftBottomPoint.Y);
39
                this.TopRightPoint = new Point(CircleCtrl.TopRightPoint.X, CircleCtrl.TopRightPoint.Y);
40
                this.Opacity = CircleCtrl.Opacity;
41
                this.CommentAngle = CircleCtrl.CommentAngle;
42
                this.DashSize = CircleCtrl.DashSize;
43
                this.PointSet = CircleCtrl.PointSet.ConvertAll(x => new Point(x.X, x.Y));
44
                this.StrokeColor = CircleCtrl.StrokeColor;
45
                this.UserID = CircleCtrl.UserID;
46
                this.Memo = CircleCtrl.Memo;
47
                this.ZIndex = CircleCtrl.ZIndex;
48
            }
49
        }
50

    
51
        public override CommentUserInfo Clone()
52
        {
53
            var clone = new CircleControl();
54
            clone.Copy(this);
55
            return clone;
56
        }
57

    
58
        #region Dependency Properties
59

    
60
        public static readonly DependencyProperty IsSelectedProperty =
61
      DependencyProperty.Register("IsSelected", typeof(bool), typeof(CircleControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
62

    
63
        public static readonly DependencyProperty ControlTypeProperty =
64
    DependencyProperty.Register("ControlType", typeof(ControlType), typeof(CircleControl), new FrameworkPropertyMetadata(ControlType.Circle));
65

    
66

    
67

    
68

    
69
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
70
                "OverViewPathData", typeof(Geometry), typeof(CircleControl), new PropertyMetadata(null));
71

    
72
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
73
                "LineSize", typeof(double), typeof(CircleControl), new PropertyMetadata((Double)3));
74
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
75
                "UserID", typeof(string), typeof(CircleControl), new PropertyMetadata(null));
76
				
77
        public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register(
78
                "FillColor", typeof(SolidColorBrush), typeof(CircleControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
79

    
80
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
81
                "StrokeColor", typeof(SolidColorBrush), typeof(CircleControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
82

    
83
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
84
                "PathData", typeof(Geometry), typeof(CircleControl), null);
85
        //강인구 추가
86
        public static readonly DependencyProperty PaintProperty = DependencyProperty.Register(
87
                "Paint", typeof(PaintSet), typeof(CircleControl), new PropertyMetadata(PaintSet.None, PointValueChanged));
88

    
89
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
90
                "EndPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
91

    
92
        //강인구 추가
93
        public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register(
94
                "DashSize", typeof(DoubleCollection), typeof(CircleControl), new PropertyMetadata(new DoubleCollection { 1, 1 }, PointValueChanged));
95

    
96
        public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register(
97
              "TopRightPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
98

    
99
        public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register(
100
                 "LeftBottomPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
101

    
102
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
103
                "StartPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
104
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
105
                 "PointSet", typeof(List<Point>), typeof(CircleControl), new PropertyMetadata(new List<Point>()));
106
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(CircleControl),
107
            new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged)));
108
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(CircleControl),
109
            new PropertyMetadata((double)0, OnCenterXYChanged));
110
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(CircleControl),
111
            new PropertyMetadata((double)0, OnCenterXYChanged));
112
        public static readonly DependencyProperty mousemodeProperty =
113
                        DependencyProperty.Register("mousemode", typeof(MouseMode), typeof(CircleControl), new PropertyMetadata(MouseMode.None, PointValueChanged));
114
        #endregion
115
        #region PropertyChanged Method
116

    
117
         public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
118
        {
119
            //var instance = (CircleControl)sender;
120

    
121
            //if (e.OldValue != e.NewValue && instance.Base_CirclePath != null)
122
            //{
123

    
124
            //    instance.SetValue(e.Property, e.NewValue);
125

    
126
            //    if (instance.IsSelected)
127
            //    {
128
            //        instance.Base_CirclePath.Stroke = new SolidColorBrush(Colors.Blue);
129
            //    }
130
            //    else
131
            //    {
132
            //        instance.Base_CirclePath.Stroke = new SolidColorBrush(Colors.Red);
133
            //    }
134
            //}
135
        }
136

    
137
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
138
        {
139
            var instance = (CircleControl)sender;
140
            if (e.OldValue != e.NewValue && instance.Base_CirclePath != null)
141
            {
142
                instance.SetValue(e.Property, e.NewValue);
143
                instance.SetCircle();
144
            }
145
        }
146

    
147
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
148
        {
149
            var instance = (CircleControl)sender;
150
            if (e.OldValue != e.NewValue && instance.Base_CirclePath != null)
151
            {
152
                instance.SetValue(e.Property, e.NewValue);
153
                instance.SetCircle();
154
            }
155
        }
156

    
157

    
158
        public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
159
        {
160
            var instance = (CircleControl)sender;
161
            if (e.OldValue != e.NewValue && instance.Base_CirclePath != null)
162
            {
163
                instance.SetValue(e.Property, e.NewValue);
164
                instance.SetCircle();
165
            }
166
        }
167
        #endregion
168
        #region Properties
169
        public string UserID
170
        {
171
            get { return (string)GetValue(UserIDProperty); }
172
            set
173
            {
174
                if (this.UserID != value)
175
                {
176
                    SetValue(UserIDProperty, value);
177
                    OnPropertyChanged("UserID");
178
                }
179
            }
180
        }
181
        public MouseMode mousemode
182
        {
183
            get
184
            {
185
                return (MouseMode)GetValue(mousemodeProperty);
186
            }
187
            set
188
            {
189
                SetValue(mousemodeProperty, value);
190
                OnPropertyChanged("mousemode");
191
            }
192
        }
193

    
194
        public Double LineSize
195
        {
196
            get { return (Double)GetValue(LineSizeProperty); }
197
            set
198
            {
199
                if (this.LineSize != value)
200
                {
201
                    SetValue(LineSizeProperty, value);
202
                }
203
            }
204
        }
205
        public DoubleCollection DashSize
206
        {
207
            get { return (DoubleCollection)GetValue(DashSizeProperty); }
208
            set
209
            {
210
                if (this.DashSize != value)
211
                {
212
                    SetValue(DashSizeProperty, value);
213
                }
214
            }
215
        }
216
        public SolidColorBrush FillColor
217
        {
218
            get { return (SolidColorBrush)GetValue(FillColorProperty); }
219
            set
220
            {
221
                if (this.FillColor != value)
222
                {
223
                    SetValue(FillColorProperty, value);
224
                }
225
            }
226
        }
227
        public Point TopRightPoint
228
        {
229
            get { return (Point)GetValue(TopRightPointProperty); }
230
            set
231
            {
232
                SetValue(TopRightPointProperty, value);
233
                OnPropertyChanged("TopRightPoint");
234
            }
235
        }
236
        public Point LeftBottomPoint
237
        {
238
            get { return (Point)GetValue(LeftBottomPointProperty); }
239
            set
240
            {
241
                SetValue(LeftBottomPointProperty, value);
242
                OnPropertyChanged("LeftBottomPoint");
243
            }
244
        }
245
        public override SolidColorBrush StrokeColor
246
        {
247
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
248
            set
249
            {
250
                if (this.StrokeColor != value)
251
                {
252
                    SetValue(StrokeColorProperty, value);
253
                }
254
            }
255
        }
256
        public Geometry PathData
257
        {
258
            get { return (Geometry)GetValue(PathDataProperty); }
259
            set { SetValue(PathDataProperty, value); }
260
        }
261

    
262
        public Geometry OverViewPathData
263
        {
264
            get
265
            {
266
                return (Geometry)GetValue(OverViewPathDataProperty);
267
            }
268
            set
269
            {
270
                SetValue(OverViewPathDataProperty, value);
271
                OnPropertyChanged("OverViewPathData");
272
            }
273
        }
274
        public PaintSet Paint
275
        {
276
            get { return (PaintSet)GetValue(PaintProperty); }
277
            set
278
            {
279
                if (this.Paint != value)
280
                {
281
                    SetValue(PaintProperty, value);
282
                }
283
            }
284
        }
285
        public Point EndPoint
286
        {
287
            get { return (Point)GetValue(EndPointProperty); }
288
            set { SetValue(EndPointProperty, value); }
289
        }
290
        public Point StartPoint
291
        {
292
            get { return (Point)GetValue(StartPointProperty); }
293
            set { SetValue(StartPointProperty, value); }
294
        }
295
        //public double CenterX
296
        //{
297
        //    get { return (double)GetValue(CenterXProperty); }
298
        //    set { SetValue(CenterXProperty, value); }
299
        //}
300
        //public double CenterY
301
        //{
302
        //    get { return (double)GetValue(CenterYProperty); }
303
        //    set { SetValue(CenterYProperty, value); }
304
        //}
305
        public double AngleValue
306
        {
307
            get { return (double)GetValue(AngleProperty); }
308
            set { SetValue(AngleProperty, value); }
309
        }
310
        public override double CommentAngle
311
        {
312
            get { return (double)GetValue(AngleProperty); }
313
            set
314
            {
315
                if (this.CommentAngle != value)
316
                {
317
                    SetValue(AngleProperty, value);
318
                }
319
            }
320
        }
321
        public List<Point> PointSet
322
        {
323
            get { return (List<Point>)GetValue(PointSetProperty); }
324
            set { SetValue(PointSetProperty, value); }
325
        }
326

    
327
        public override bool IsSelected
328
        {
329
            get
330
            {
331
                return (bool)GetValue(IsSelectedProperty);
332
            }
333
            set
334
            {
335
                SetValue(IsSelectedProperty, value);
336
            }
337
        }
338

    
339
        public override ControlType ControlType
340
        {
341
            get
342
            {
343
                return (ControlType)GetValue(ControlTypeProperty);
344
            }
345
            set
346
            {
347
                SetValue(ControlTypeProperty, value);
348
            }
349
        }
350

    
351
        public double CenterX
352
        {
353
            get { return (double)GetValue(CenterXProperty); }
354
            set { SetValue(CenterXProperty, value); }
355
        }
356
        public double CenterY
357
        {
358
            get { return (double)GetValue(CenterYProperty); }
359
            set { SetValue(CenterYProperty, value); }
360
        }
361
        #endregion
362
        #region Object & Variable
363
        EllipseGeometry instance = new EllipseGeometry();
364
        GeometryGroup CircleGroup = new GeometryGroup();
365

    
366
        #endregion
367
        public override void OnApplyTemplate()
368
        {
369
            base.OnApplyTemplate();
370
            Base_CirclePath = GetTemplateChild(PART_CirclePath) as Path;
371

    
372
            if (Base_CirclePath == null)
373
            {
374
                return;
375
            }
376
            this.SetCircle();
377
        }
378
        public void Dispose()
379
        {
380
            //GC.Collect();
381
            ////GC.SuppressFinalize(this);
382
            this.Base_CirclePath = null;
383
        }
384

    
385
        public event PropertyChangedEventHandler PropertyChanged;
386
        protected void OnPropertyChanged(string propName)
387
        {
388
            if (PropertyChanged != null)
389
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
390
        }
391
        
392
        /// <summary>
393
        /// Circle을 생성한다.
394
        /// </summary>
395
        private void SetCircle()
396
        {
397
            Base_CirclePath.StrokeDashArray.Clear();
398
            foreach (var item in this.DashSize)
399
            {
400
                Base_CirclePath.StrokeDashArray.Add(item);
401
            }
402
            Base_CirclePath.StrokeDashCap = PenLineCap.Square;
403

    
404
            Point middle = MathSet.getMiddlePoint(this.EndPoint, this.StartPoint);
405

    
406
            instance.RadiusX = (MathSet.DistanceTo(this.LeftBottomPoint, this.EndPoint) * 0.5);
407
            instance.RadiusY = (MathSet.DistanceTo(this.EndPoint, this.TopRightPoint) * 0.5);
408
            instance.Center = middle;
409
            #region 회전 적용
410
            var rot = new RotateTransform(this.CommentAngle, middle.X, middle.Y);
411
            instance.Transform = rot;
412
            #endregion
413

    
414
            switch (this.Paint)
415
            {
416
                case PaintSet.None:
417
                    this.FillColor = null;
418
                    Base_CirclePath.Fill = this.FillColor;
419
                    break;
420
                case PaintSet.Fill:
421
                    this.FillColor = this.StrokeColor;
422
                    Base_CirclePath.Fill = this.FillColor;
423
                    break;
424
                case PaintSet.Hatch:
425
                    Base_CirclePath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor);
426
                    break;
427
                default:
428
                    break;
429
            }
430

    
431
            CircleGroup.Children.Clear();
432
            CircleGroup.FillRule = FillRule.Nonzero;
433
            CircleGroup.Children.Add(instance);
434

    
435
            try
436
            {                
437
                this.Width = Math.Abs(this.CircleGroup.Bounds.Right + (this.LineSize * 0.5));
438
                this.Height = Math.Abs(this.CircleGroup.Bounds.Bottom + +(this.LineSize * 0.5)); 
439
            }
440
            catch (Exception)
441
            {
442
                
443
            } 
444

    
445
            CenterX = Math.Abs(this.CircleGroup.Bounds.X / 2);
446
            CenterY = Math.Abs(this.CircleGroup.Bounds.Y / 2);
447
            this.PathData = CircleGroup;
448
            ApplyOverViewData();
449
        }
450

    
451
        public override void UpdateControl()
452
        {
453
            if (this.PointSet.Any())
454
            {
455
                this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
456
                this.LeftBottomPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
457
                this.TopRightPoint = new Point(this.PointSet[3].X, this.PointSet[3].Y);
458
                this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
459
            }
460
        }
461

    
462
        public void SetCenterXY()
463
        {
464
            CenterX = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint).X;
465
            CenterY = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint).Y;
466
        }
467

    
468
        public override void ApplyOverViewData()
469
        {
470
            this.OverViewPathData = this.PathData;
471
        }
472

    
473
        public void ChangePaint(PaintSet state)
474
        {
475
            this.Paint = state;
476
            this.SetCircle();
477
        }
478

    
479
        /// <summary>
480
        /// call when mouse is moving while drawing control
481
        /// </summary>
482
        /// <param name="pt"></param>
483
        /// <param name="bAxisLocked"></param>
484
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
485
        {
486
            this.EndPoint = bAxisLocked ? this.GetSquareEndPoint(this.StartPoint, pt) : pt;
487
            this.LeftBottomPoint = new Point(this.StartPoint.X, this.EndPoint.Y);
488
            this.TopRightPoint = new Point(this.EndPoint.X, this.StartPoint.Y);
489

    
490
            this.PointSet = new List<Point>
491
            {
492
                this.StartPoint,
493
                this.LeftBottomPoint,
494
                this.EndPoint,
495
                this.TopRightPoint,
496
            };
497
        }
498

    
499
        /// <summary>
500
        /// move control point has same location of given pt along given delta
501
        /// </summary>
502
        /// <author>humkyung</author>
503
        /// <date>2019.06.20</date>
504
        /// <param name="pt"></param>
505
        /// <param name="dx"></param>
506
        /// <param name="dy"></param>
507
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
508
        {
509
            IPath path = (this as IPath);
510
            Point selected = MathSet.getNearPoint(path.PointSet, pt);
511
            selected.X += dx;
512
            selected.Y += dy;
513
            int i = 0;
514
            for (i = 0; i < (this as IPath).PointSet.Count; i++)
515
            {
516
                if (pt.Equals((this as IPath).PointSet[i]))
517
                {
518
                    (this as IPath).PointSet[i] = selected;
519
                    break;
520
                }
521
            }
522

    
523
            List<Point> newPointSet = new List<Point> { };
524
            Point middle = new Point(path.PathData.Bounds.X + path.PathData.Bounds.Width * 0.5, path.PathData.Bounds.Y + path.PathData.Bounds.Height * 0.5);
525
            foreach (Point _pt in path.PointSet)
526
            {
527
                newPointSet.Add(_pt);
528
            }
529
            var OppositeP = (i + newPointSet.Count / 2) % newPointSet.Count;
530
            var PreviousP = (i + (newPointSet.Count - 1)) % newPointSet.Count;
531
            var NextP = (i + 1) % newPointSet.Count;
532
            if (bAxisLocked)
533
            {
534
                double _dx = path.PointSet[i].X - path.PointSet[OppositeP].X;
535
                double _dy = path.PointSet[i].Y - path.PointSet[OppositeP].Y;
536
                double distance = Math.Max(Math.Abs(_dx), Math.Abs(_dy));
537

    
538
                var PreviousV = path.PointSet[PreviousP] - path.PointSet[OppositeP];
539
                PreviousV.Normalize();
540
                path.PointSet[PreviousP] = path.PointSet[OppositeP] + PreviousV * distance;
541

    
542
                var NextV = path.PointSet[NextP] - path.PointSet[OppositeP];
543
                NextV.Normalize();
544
                path.PointSet[NextP] = path.PointSet[OppositeP] + NextV * distance;
545

    
546
                path.PointSet[i] = path.PointSet[OppositeP] + PreviousV * distance + NextV * distance;
547
            }
548
            else
549
            {
550
                var PreviousV = MathSet.GetNormVectorBetween(newPointSet[OppositeP], newPointSet[PreviousP]);
551
                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, newPointSet[i].X - newPointSet[OppositeP].X,
552
                    newPointSet[i].Y - newPointSet[OppositeP].Y);
553

    
554
                Point pPrevious = new Point(newPointSet[OppositeP].X + PreviousV.X * l, newPointSet[OppositeP].Y
555
                    + PreviousV.Y * l);
556

    
557
                if (newPointSet.FindAll(x => x.Equals(pPrevious)).Count() == 0)
558
                {
559
                    newPointSet[PreviousP] = pPrevious;
560
                }
561

    
562
                var NextV = MathSet.GetNormVectorBetween(newPointSet[OppositeP], newPointSet[NextP]);
563
                l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[OppositeP].X, newPointSet[i].Y
564
                    - newPointSet[OppositeP].Y);
565

    
566
                Point pNext = new Point(newPointSet[OppositeP].X + NextV.X * l, newPointSet[OppositeP].Y + NextV.Y * l);
567

    
568
                if (newPointSet.FindAll(x => x.Equals(pNext)).Count() == 0)
569
                {
570
                    newPointSet[NextP] = pNext;
571
                }
572

    
573
                path.PointSet = newPointSet;
574
            }
575

    
576
            this.UpdateControl();
577
        }
578

    
579
        /// <summary>
580
        /// return circlecontrols' area
581
        /// </summary>
582
        /// <author>humkyung</author>
583
        /// <date>2019.06.13</date>
584
        public override Rect ItemRect
585
        {
586
            get
587
            {
588
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
589
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
590
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
591
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
592

    
593
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
594
            }
595
        }
596

    
597
        /// <summary>
598
        /// Serialize this
599
        /// </summary>
600
        /// <param name="sUserId"></param>
601
        /// <returns></returns>
602
        public override string Serialize()
603
        {
604
            using (S_CircleControl ctrl = new S_CircleControl())
605
            {
606
                ctrl.TransformPoint = "0|0";
607
                ctrl.SizeSet = String.Format("{0}", this.LineSize);
608
                ctrl.PaintState = this.Paint;
609
                //ctrl.StrokeColor = "#FF00FF00";
610
                ctrl.StrokeColor = this.StrokeColor.Color.ToString();
611
                if (this.FillColor != null)
612
                {
613
                    ctrl.FillColor = this.FillColor.Color.ToString();
614
                }
615
                ctrl.StartPoint = this.StartPoint;
616
                ctrl.UserID = this.UserID;
617
                ctrl.EndPoint = this.EndPoint;
618
                ctrl.TRP = this.TopRightPoint;
619
                ctrl.LBP = this.LeftBottomPoint;
620
                ctrl.Opac = this.Opacity;
621
                ctrl.Angle = this.CommentAngle;
622
                ctrl.PointSet = this.PointSet;
623
                ctrl.DashSize = this.DashSize;
624
                ctrl.Name = this.GetType().Name.ToString();
625
                ///강인구 추가(2017.11.02)
626
                ///Memo 추가
627
                ctrl.Memo = this.Memo;
628

    
629
                ctrl.ZIndex = this.ZIndex;
630

    
631
                return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize()));
632
            };
633
        }
634

    
635
        /// <summary>
636
        /// create a circlecontrol from given string
637
        /// </summary>
638
        /// <param name="str"></param>
639
        /// <returns></returns>
640
        public static CircleControl FromString(string str, SolidColorBrush brush, string sProjectNo)
641
        {
642
            using (S_CircleControl s = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(str))
643
            {
644
                string[] data2 = s.SizeSet.Split(CommentUserInfo.delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
645
                return new CircleControl
646
                {
647
                    LineSize = Convert.ToDouble(data2.First()),
648
                    Paint = s.PaintState,
649
                    StartPoint = s.StartPoint,
650
                    EndPoint = s.EndPoint,
651
                    LeftBottomPoint = s.LBP,
652
                    TopRightPoint = s.TRP,
653
                    Opacity = s.Opac,
654
                    CommentAngle = s.Angle,
655
                    DashSize = s.DashSize,
656
                    PointSet = s.PointSet,
657
                    StrokeColor = brush,
658
                    UserID = s.UserID,
659
                    Memo = s.Memo,
660
                    ZIndex = s.ZIndex
661
                };
662
            }
663
        }
664
    }
665
}
클립보드 이미지 추가 (최대 크기: 500 MB)