프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Line / ArcControl.cs @ e1b36bc0

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

1 787a4489 KangIngu
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 036650a0 humkyung
using MarkupToPDF.Serialize.S_Control;
16
using MarkupToPDF.Serialize.Core;
17 661b7416 humkyung
using System.Linq;
18 787a4489 KangIngu
19
namespace MarkupToPDF.Controls.Line
20
{
21
22 37eadd3f humkyung
    public class ArcControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IDashControl
23 787a4489 KangIngu
    {
24
        #region 초기선언
25
        public event PropertyChangedEventHandler PropertyChanged;
26
        private const string PART_ArcPath = "PART_ArcPath";
27
        public Path Base_ArcPath = null;
28
        #endregion
29
        static ArcControl()
30
        {
31
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ArcControl), new FrameworkPropertyMetadata(typeof(ArcControl)));
32
            //Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary);
33 a6f7f9b6 djkim
            //ResourceDictionary dictionary = new ResourceDictionary();
34
            //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
35
            //Application.Current.Resources.MergedDictionaries.Add(dictionary);
36 787a4489 KangIngu
             //System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count);
37
        }
38
39
        public ArcControl()
40
        {
41 a6f7f9b6 djkim
            //this.DefaultStyleKey = typeof(ArcControl);
42 787a4489 KangIngu
        }
43
44 37eadd3f humkyung
        public override void Copy(CommentUserInfo lhs)
45
        {
46 e1b36bc0 humkyung
            if (lhs is ArcControl item)
47
            {
48
                this.StartPoint = new Point(item.StartPoint.X, item.StartPoint.Y);
49
                this.EndPoint = new Point(item.EndPoint.X, item.EndPoint.Y);
50
                this.DashSize = item.DashSize;
51
                this.PointSet = item.PointSet.ConvertAll(x => new Point(x.X, x.Y));
52
                this.isTransOn = item.isTransOn;
53
                this.MidPoint = new Point(item.MidPoint.X, item.MidPoint.Y);
54
                this.StrokeColor = item.StrokeColor;
55
                this.Opacity = item.Opacity;
56
                this.Clock = item.Clock;
57
                this.LineSize = item.LineSize;
58
                this.UserID = item.UserID;
59
                this.Memo = item.Memo;
60
                ZIndex = item.ZIndex;
61
                GroupID = item.GroupID;
62 37eadd3f humkyung
            }
63
        }
64
65
        public override CommentUserInfo Clone()
66
        {
67
            var clone = new ArcControl();
68
            clone.Copy(this);
69
            return clone;
70
        }
71
72 787a4489 KangIngu
        public void Dispose()
73
        {
74 a6f7f9b6 djkim
            //GC.Collect();
75 24c5e56c taeseongkim
            ////GC.SuppressFinalize(this);
76 a6f7f9b6 djkim
            //Control control = new Control();
77
            this.Base_ArcPath = null;
78 787a4489 KangIngu
        }
79
        protected void OnPropertyChanged(string propName)
80
        {
81
            if (PropertyChanged != null)
82
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
83
        }
84
85
        #region Dependency Properties
86
87
        
88
89
        public static readonly DependencyProperty IsSelectedProperty =
90
    DependencyProperty.Register("IsSelected", typeof(bool), typeof(ArcControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
91
92
        public static readonly DependencyProperty ControlTypeProperty =
93
    DependencyProperty.Register("ControlType", typeof(ControlType), typeof(ArcControl), new FrameworkPropertyMetadata(ControlType.ArcLine));
94
95
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
96
                "OverViewPathData", typeof(Geometry), typeof(ArcControl), new PropertyMetadata(null));
97
98
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
99
                "UserID", typeof(string), typeof(ArcControl), new PropertyMetadata(null));
100
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
101
              "LineSize", typeof(double), typeof(ArcControl), new PropertyMetadata((Double)3));
102
103
//강인구 추가
104
        public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register(
105
              "DashSize", typeof(DoubleCollection), typeof(ArcControl), new PropertyMetadata(new DoubleCollection { 99999999 }, PointValueChanged));
106
107
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
108
               "StrokeColor", typeof(SolidColorBrush), typeof(ArcControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
109
110
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
111
              "PathData", typeof(Geometry), typeof(ArcControl), null);
112
113
        //public static readonly DependencyProperty ClockProperty = DependencyProperty.Register(
114
        //       "Clock", typeof(SweepDirection), typeof(ArcControl), new PropertyMetadata(SweepDirection.Clockwise));
115
        public static readonly DependencyProperty ClockProperty = DependencyProperty.Register(
116
               "Clock", typeof(bool), typeof(ArcControl), new PropertyMetadata(false));
117
118
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
119
               "StartPoint", typeof(Point), typeof(ArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
120
        public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register(
121
               "MidPoint", typeof(Point), typeof(ArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
122
123
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
124
               "EndPoint", typeof(Point), typeof(ArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
125
        
126
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
127
                "PointSet", typeof(List<Point>), typeof(ArcControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
128
129
        public static readonly DependencyProperty isTransOnProperty = DependencyProperty.Register(
130
                "isTransOn", typeof(bool), typeof(ArcControl), new PropertyMetadata(false));
131
132
        public static readonly DependencyProperty AngleProperty =
133
            DependencyProperty.Register("AngleValue", typeof(double), typeof(ArcControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback
134
                (AngleValueChanged)));
135
136
        public static readonly DependencyProperty CenterXProperty =
137
            DependencyProperty.Register("CenterX", typeof(double), typeof(ArcControl), new PropertyMetadata((double)0, OnCenterXYChanged));
138
139
        public static readonly DependencyProperty CenterYProperty =
140
            DependencyProperty.Register("CenterY", typeof(double), typeof(ArcControl), new PropertyMetadata((double)0, OnCenterXYChanged));
141
        #endregion
142
        #region PropertyChanged Method
143
        
144
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
145
        {
146
            //var instance = (ArcControl)sender;
147
148
            //if (e.OldValue != e.NewValue && instance.Base_ArcPath != null)
149
            //{
150
151
            //    instance.SetValue(e.Property, e.NewValue);
152
153
            //    if (instance.IsSelected)
154
            //    {
155
            //        instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Blue);
156
            //    }
157
            //    else
158
            //    {
159
            //        instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Red);
160
            //    }
161
            //}
162
        }
163
164
165
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
166
        {
167
            var instance = (ArcControl)sender;
168
            if (e.OldValue != e.NewValue && instance.Base_ArcPath != null)
169
            {
170
                instance.SetValue(e.Property, e.NewValue);
171
                instance.SetArcPath();
172
            }
173
        }
174
        public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
175
        {
176
            var instance = (ArcControl)sender;
177
            if (e.OldValue != e.NewValue && instance.Base_ArcPath != null)
178
            {
179
                instance.SetValue(e.Property, e.NewValue);
180
                instance.SetArcPath();
181
            }
182
        }
183
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
184
        {
185
            var instance = (ArcControl)sender;
186
            if (e.OldValue != e.NewValue && instance.Base_ArcPath != null)
187
            {
188
                instance.SetValue(e.Property, e.NewValue);
189
                instance.SetArcPath();
190
            }
191
        }
192
193
      
194
195
        #endregion
196
        #region Properties
197
        public string UserID
198
        {
199
            get { return (string)GetValue(UserIDProperty); }
200
            set
201
            {
202
                if (this.UserID != value)
203
                {
204
                    SetValue(UserIDProperty, value);
205
                    OnPropertyChanged("UserID");
206
                }
207
            }
208
        }
209
        public Double LineSize
210
        {
211
            get { return (Double)GetValue(LineSizeProperty); }
212
            set
213
            {
214
                if (this.LineSize != value)
215
                {
216
                    SetValue(LineSizeProperty, value);
217
                }
218
            }
219
        }
220
221
222
        public bool Clock
223
        {
224
            get { return (bool)GetValue(ClockProperty); }
225
            set
226
            {
227
                if (this.Clock != value)
228
                {
229
                    SetValue(ClockProperty, value);
230
                    OnPropertyChanged("Clock");
231
                }
232
            }
233
        }
234
235
        //public SweepDirection Clock
236
        //{
237
        //    get { return (SweepDirection)GetValue(ClockProperty); }
238
        //    set
239
        //    {
240
        //        if (this.Clock != value)
241
        //        {
242
        //            SetValue(ClockProperty, value);
243
        //            OnPropertyChanged("Clock");
244
        //        }
245
        //    }
246
        //}
247
        public DoubleCollection DashSize
248
        {
249
            get { return (DoubleCollection)GetValue(DashSizeProperty); }
250
            set
251
            {
252
                if (this.DashSize != value)
253
                {
254
                    SetValue(DashSizeProperty, value);
255
                }
256
            }
257
        }
258
        public List<Point> PointSet
259
        {
260
            get { return (List<Point>)GetValue(PointSetProperty); }
261
            set { SetValue(PointSetProperty, value); }
262
        }
263
        public double CenterX
264
        {
265
            get { return (double)GetValue(CenterXProperty); }
266
            set { SetValue(CenterXProperty, value); }
267
        }
268
        public double CenterY
269
        {
270
            get { return (double)GetValue(CenterYProperty); }
271
            set { SetValue(CenterYProperty, value); }
272
        }
273 4913851c humkyung
        public override SolidColorBrush StrokeColor
274 787a4489 KangIngu
        {
275
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
276
            set
277
            {
278
                if (this.StrokeColor != value)
279
                {
280
                    SetValue(StrokeColorProperty, value);
281
                }
282
            }
283
        }
284
285
        public Geometry OverViewPathData
286
        {
287
            get
288
            {
289
                return (Geometry)GetValue(OverViewPathDataProperty);
290
            }
291
            set
292
            {
293
                SetValue(OverViewPathDataProperty, value);
294
                OnPropertyChanged("OverViewPathData");
295
            }
296
        }
297
298
        public Geometry PathData
299
        {
300
            get { return (Geometry)GetValue(PathDataProperty); }
301
            set
302
            {
303
                SetValue(PathDataProperty, value);
304
                OnPropertyChanged("PathData");
305
            }
306
        }
307 959b3ef2 humkyung
        public override bool IsSelected
308 787a4489 KangIngu
        {
309
            get
310
            {
311
                return (bool)GetValue(IsSelectedProperty);
312
            }
313
            set
314
            {
315
                SetValue(IsSelectedProperty, value);
316
            }
317
        }
318
319 5529d2a2 humkyung
        public override ControlType ControlType
320 787a4489 KangIngu
        {
321
            get
322
            {
323
                return (ControlType)GetValue(ControlTypeProperty);
324
            }
325
            set
326
            {
327
                SetValue(ControlTypeProperty, value);
328
                OnPropertyChanged("ControlType");
329
            }
330
        }
331
        public double AngleValue
332
        {
333
            get { return (double)GetValue(AngleProperty); }
334
            set { SetValue(AngleProperty, value); }
335
        }
336 168f8027 taeseongkim
337
338
        // CommentUserInfo에서 상속받기때문에 제거.
339
340
        //public double Angle
341
        //{
342
        //    get { return (double)GetValue(AngleProperty); }
343
        //    set
344
        //    {
345
        //        if (this.Angle != value)
346
        //        {
347
        //            SetValue(AngleProperty, value);
348
        //        }
349
        //    }
350
        //}
351
352 787a4489 KangIngu
        public Point EndPoint
353
        {
354
            get { return (Point)GetValue(EndPointProperty); }
355
            set
356
            {
357
                SetValue(EndPointProperty, value);
358
                OnPropertyChanged("EndPoint");
359
            }
360
        }
361
        public Point StartPoint
362
        {
363
            get { return (Point)GetValue(StartPointProperty); }
364
            set
365
            {
366
                SetValue(StartPointProperty, value);
367
                OnPropertyChanged("StartPoint");
368
            }
369
        }
370
        public Point MidPoint
371
        {
372
            get { return (Point)GetValue(MidPointProperty); }
373
            set
374
            {
375
                SetValue(MidPointProperty, value);
376
                OnPropertyChanged("MidPoint");
377
            }
378
        }
379
        public bool isTransOn
380
        {
381
            get { return (bool)GetValue(isTransOnProperty); }
382
            set
383
            {
384
                SetValue(isTransOnProperty, value);
385
                OnPropertyChanged("isTransOn");
386
            }
387
        }
388
389
        #endregion
390
        #region Object & Variable
391
        PathGeometry pathGeometry = new PathGeometry();
392
        GeometryGroup instanceGroup = new GeometryGroup();
393
        #endregion
394
        public override void OnApplyTemplate()
395
        {
396
            base.OnApplyTemplate();
397
            Base_ArcPath = GetTemplateChild(PART_ArcPath) as Path;
398
            SetArcPath();
399
        }
400 0d00f9c8 humkyung
401
        public override void UpdateControl()
402 787a4489 KangIngu
        {
403
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
404
            this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
405
            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
406
        }
407
408
        public void setClock()
409
        {
410
            if (Clock)
411
            {
412
                this.Clock = false;
413
            }
414
            else
415
            {
416
                this.Clock = true;
417
            }
418
        }
419
420
        //public void setClock()
421
        //{
422
        //    if(this.Clock == SweepDirection.Clockwise)
423
        //    {
424
        //        this.Clock = SweepDirection.Counterclockwise;
425
        //    }
426
        //    else
427
        //    {
428
        //        this.Clock =SweepDirection.Clockwise;
429
        //    }
430
        //}
431 661b7416 humkyung
        private void SetArcPath()
432 787a4489 KangIngu
        {
433
            this.ApplyTemplate();
434
435
436
            //강인구 추가
437
            Base_ArcPath.StrokeDashArray.Clear();
438
            foreach (var item in this.DashSize)
439
            {
440
                Base_ArcPath.StrokeDashArray.Add(item);
441
            }
442
            instanceGroup.Children.Clear();
443
444
445
            PathFigure pathFigure = new PathFigure();
446
447
            pathFigure.StartPoint = this.StartPoint;
448
            QuadraticBezierSegment qb = new QuadraticBezierSegment();
449
450
451
          
452
453
454
            
455
            
456
457
458
            if (MidPoint != null)
459
            {
460
                if (MidPoint == new Point(0,0))
461
                {
462
                    double xSharp = 0;
463
                    double ySharp = 0;
464
465
                    //Point t_start = new Point(0, 0);
466
                    //Point t_end = new Point(30, 10);
467
468
                    var midP = MathSet.getMiddlePoint(StartPoint, EndPoint);
469
                    Point normalV = MathSet.GetNormVectorBetween(StartPoint, EndPoint);
470
                    var dis = MathSet.DistanceTo(StartPoint, EndPoint);
471
472
                    if (!this.Clock)
473
                    {
474
                        xSharp = -normalV.Y;
475
                        ySharp = normalV.X;
476
                    }
477
                    else
478
                    {
479
                        xSharp = normalV.Y;
480
                        ySharp = -normalV.X;
481
                    }
482
483
                    var pointN = new Point(xSharp * dis, ySharp * dis);
484
                    MidPoint = new Point(pointN.X + midP.X, pointN.Y + midP.Y);
485
                }
486
                ////System.Diagnostics.Debug.WriteLine(this.MidPoint.ToString());
487
                //qb.Point1 = new Point(200, 200);
488
                //qb.Point1 = this.MidPoint;
489
                qb.Point1 = this.MidPoint;
490
            }
491
492
            qb.Point2 = this.EndPoint;
493
            pathFigure.Segments.Add(qb);
494
            pathGeometry.Figures = new PathFigureCollection();
495
            pathGeometry.Figures.Add(pathFigure);
496
            pathFigure.IsFilled = false;
497
            pathFigure.IsClosed = false;
498
            instanceGroup.Children.Add(pathGeometry);
499
500
            //Arc Arrow
501
            //if(ControlType == ControlType.ArcArrow)
502
            if (isTransOn)
503
            {
504
                //isTransOn = true;
505 d251456f humkyung
                instanceGroup.Children.Add(DrawSet.DrawArrow(this.MidPoint, this.StartPoint, this.LineSize));
506
                instanceGroup.Children.Add(DrawSet.DrawArrow(this.EndPoint, this.MidPoint, this.LineSize));
507 787a4489 KangIngu
                this.Base_ArcPath.Fill = this.StrokeColor;
508
            }
509
            //Base_ArcPath.StrokeThickness = 3;
510
511
            instanceGroup.FillRule = FillRule.Nonzero;
512
            this.PathData = instanceGroup;
513
            this.OverViewPathData = PathData;
514
515
        }
516
517
        public static PathGeometry ConverseAllow(Point p2, Point p1, double lineSize)
518
        {
519
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
520
            PathGeometry pathGeometry2 = new PathGeometry();
521
            PathFigure pathFigure2 = new PathFigure();
522
            pathFigure2.StartPoint = p2;
523
524
            Point lpoint2 = new Point(p2.X + lineSize * 2, p2.Y + lineSize * 4);
525
            Point rpoint2 = new Point(p2.X - lineSize * 2, p2.Y + lineSize * 4);
526
            LineSegment seg1_1 = new LineSegment();
527
            seg1_1.Point = lpoint2;
528
            pathFigure2.Segments.Add(seg1_1);
529
530
            LineSegment seg2_1 = new LineSegment();
531
            seg2_1.Point = rpoint2;
532
            pathFigure2.Segments.Add(seg2_1);
533
534
            LineSegment seg3_1 = new LineSegment();
535
            seg3_1.Point = p2;
536
            pathFigure2.Segments.Add(seg3_1);
537
538
            LineSegment seg4_1 = new LineSegment();
539
540
            seg4_1.Point = new Point(lpoint2.X, lpoint2.Y);
541
            pathFigure2.Segments.Add(seg4_1);
542
543
            //pathFigure2.IsFilled = true;
544
            //pathFigure2.IsClosed = true;
545
546
            RotateTransform transform2 = new RotateTransform();
547
            transform2.Angle = theta + 90;
548
            transform2.CenterX = p2.X;
549
            transform2.CenterY = p2.Y;
550
            pathGeometry2.Figures.Add(pathFigure2);
551
            pathGeometry2.Transform = transform2;
552
            return pathGeometry2;
553
        }
554
555 f513c215 humkyung
        public override void ApplyOverViewData()
556 787a4489 KangIngu
        {
557
            this.OverViewPathData = this.PathData;
558
        }
559 036650a0 humkyung
560
        /// <summary>
561 a6272c57 humkyung
        /// call when mouse is moving while drawing control
562
        /// </summary>
563
        /// <author>humkyung</author>
564
        /// <param name="pt"></param>
565
        /// <param name="bAxisLocked"></param>
566 233ef333 taeseongkim
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
567 a6272c57 humkyung
        {
568
            this.isTransOn = false;
569
            this.EndPoint = pt;
570
            this.MidPoint = new Point(0, 0);
571
572 168f8027 taeseongkim
            Point tmp = this.EndPoint;
573 233ef333 taeseongkim
            CommentAngle = MathSet.returnAngle(this.StartPoint, ref tmp, bAxisLocked);
574 168f8027 taeseongkim
575 233ef333 taeseongkim
            if (bAxisLocked)
576 a6272c57 humkyung
            {
577
                this.EndPoint = tmp;
578
            }
579
580
            this.PointSet = new List<Point>
581
            {
582
                this.StartPoint,
583
                this.MidPoint,
584
                this.EndPoint,
585
            };
586
        }
587
588
        /// <summary>
589 d2114d3b humkyung
        /// move control point has same location of given pt along given delta
590
        /// </summary>
591
        /// <author>humkyung</author>
592
        /// <date>2019.06.20</date>
593
        /// <param name="pt"></param>
594
        /// <param name="dx"></param>
595
        /// <param name="dy"></param>
596 233ef333 taeseongkim
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
597 d2114d3b humkyung
        {
598
            Point selected = MathSet.getNearPoint((this as IPath).PointSet, pt);
599 233ef333 taeseongkim
600
            var tmpPointSet = (this as IPath).PointSet.Where(x => !x.Equals(selected));
601
            Point NearStartpoint = MathSet.getNearPoint(tmpPointSet.ToList(), pt);
602
603 d2114d3b humkyung
            selected.X += dx;
604
            selected.Y += dy;
605 233ef333 taeseongkim
606
            Point tmp = selected;
607
608
            CommentAngle = MathSet.returnAngle(NearStartpoint, ref tmp, bAxisLocked);
609
610
            if (bAxisLocked)
611
            {
612
                selected = tmp;
613
            }
614
615 d2114d3b humkyung
            for (int i = 0; i < (this as IPath).PointSet.Count; i++)
616
            {
617
                if (pt.Equals((this as IPath).PointSet[i]))
618
                {
619
                    (this as IPath).PointSet[i] = selected;
620
                }
621
            }
622 0d00f9c8 humkyung
            this.UpdateControl();
623 d2114d3b humkyung
        }
624
625
        /// <summary>
626 91efe37a humkyung
        /// return Arc's area
627
        /// </summary>
628
        /// <author>humkyung</author>
629
        /// <date>2019.06.13</date>
630
        public override Rect ItemRect
631
        {
632
            get
633
            {
634
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
635
                dMinX = Math.Min(this.MidPoint.X, dMinX);
636
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
637
                dMinY = Math.Min(this.MidPoint.Y, dMinY);
638
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
639
                dMaxX = Math.Max(this.MidPoint.X, dMaxX);
640
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
641
                dMaxY = Math.Max(this.MidPoint.Y, dMaxY);
642
643
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
644
            }
645
        }
646
647
        /// <summary>
648 036650a0 humkyung
        /// Serialize this
649
        /// </summary>
650
        /// <param name="sUserId"></param>
651
        /// <returns></returns>
652
        public override string Serialize()
653
        {
654 b2d0f316 humkyung
            using (S_ArcControl ctrl = new S_ArcControl())
655
            {
656
                ctrl.TransformPoint = "0|0";
657
                ctrl.PointSet = this.PointSet;
658
                ctrl.SizeSet = String.Format("{0}", this.LineSize);
659
                //ctrl.StrokeColor = "#FF000FFF";
660
                ctrl.StrokeColor = this.StrokeColor.Color.ToString();
661
                ctrl.StartPoint = this.StartPoint;
662
                ctrl.UserID = this.UserID;
663
                ctrl.Opac = this.Opacity;
664
                ctrl.MidPoint = this.MidPoint;
665
                ctrl.EndPoint = this.EndPoint;
666
                ctrl.IsTransOn = this.isTransOn;
667
                ctrl.DashSize = this.DashSize;
668
                ctrl.Clock = this.Clock;
669
                //ctrl.ArcStyleSet = instance.ControlType;
670
                ctrl.Name = this.GetType().Name.ToString();
671 036650a0 humkyung
672
                ///강인구 추가(2017.11.02)
673
                ///Memo 추가
674 b2d0f316 humkyung
                ctrl.Memo = this.Memo;
675 036650a0 humkyung
676 b2d0f316 humkyung
                ctrl.ZIndex = this.ZIndex;
677 e1b36bc0 humkyung
                ctrl.GroupID = this.GroupID;
678 b2d0f316 humkyung
679
                return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize()));
680 036650a0 humkyung
            }
681
        }
682 661b7416 humkyung
683
        /// <summary>
684
        /// create a arccontrol from given string
685
        /// </summary>
686
        /// <param name="str"></param>
687
        /// <returns></returns>
688
        public static ArcControl FromString(string str, SolidColorBrush brush, string sProjectNo)
689
        {
690
            ArcControl instance = null;
691
            using (S_ArcControl s = JsonSerializerHelper.JsonDeserialize<S_ArcControl>(str))
692
            {
693
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
694
                instance = new ArcControl()
695
                {
696
                    StartPoint = s.StartPoint,
697
                    EndPoint = s.EndPoint,
698
                    DashSize = s.DashSize,
699
                    PointSet = s.PointSet,
700
                    isTransOn = s.IsTransOn,
701
                    MidPoint = s.MidPoint,
702
                    StrokeColor = brush,
703
                    Opacity = s.Opac,
704
                    Clock = s.Clock,
705
                    LineSize = Convert.ToDouble(data2.First()),
706
                    UserID = s.UserID,
707 b2d0f316 humkyung
                    Memo = s.Memo,
708 e1b36bc0 humkyung
                    ZIndex = s.ZIndex,
709
                    GroupID = s.GroupID
710 661b7416 humkyung
                };
711
            }
712
713
            return instance;
714
        }
715 787a4489 KangIngu
    }
716
}
클립보드 이미지 추가 (최대 크기: 500 MB)