프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Line / LineControl.cs @ b2d0f316

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

1
using System;
2
using System.Net;
3
using System.Windows;
4
using System.Windows.Controls;
5
using System.Windows.Documents;
6
using System.Windows.Ink;
7
using System.Windows.Input;
8
using System.Windows.Media;
9
using System.Windows.Media.Animation;
10
using System.Windows.Shapes;
11
using System.ComponentModel;
12
using System.Collections.Generic;
13
using MarkupToPDF.Controls.Common;
14
using MarkupToPDF.Common;
15
using MarkupToPDF.Serialize.S_Control;
16
using MarkupToPDF.Serialize.Core;
17
using System.Linq;
18

    
19
namespace MarkupToPDF.Controls.Line
20
{
21
    [TemplatePart(Name = "PART_LinePath", Type = typeof(Path))]
22
    public class LineControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IDashControl
23
    {
24
        public event PropertyChangedEventHandler PropertyChanged;
25

    
26
        private const string PART_LinePath = "PART_LinePath";
27
        public Path Base_LinePath = null;
28

    
29
        static LineControl()
30
        {
31
            DefaultStyleKeyProperty.OverrideMetadata(typeof(LineControl), new FrameworkPropertyMetadata(typeof(LineControl)));
32
            //Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary);
33
            //ResourceDictionary dictionary = new ResourceDictionary();
34

    
35
            //dictionary.Source = new Uri("/MarkupToPDF;component/Themes/generic.xaml", UriKind.RelativeOrAbsolute);
36
            //Application.Current.Resources.MergedDictionaries.Add(dictionary);
37
             //System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count);
38
        }
39

    
40
        public double DimSize
41
        {
42
            get { return (double)GetValue(DimSizeProperty); }
43
            set
44
            {
45
                if (this.DimSize != value)
46
                {
47
                    SetValue(DimSizeProperty, value);
48
                    OnPropertyChanged("DimSize");
49
                }
50
            }
51
        }
52

    
53
        public LineControl()
54
        {
55
            //this.DefaultStyleKey = typeof(LineControl);
56
        }
57

    
58
        public override void Copy(CommentUserInfo lhs)
59
        {
60
            if (lhs is LineControl item)
61
            {
62
                this.LineStyleSet = item.LineStyleSet;
63
                this.StartPoint = new Point(item.StartPoint.X, item.StartPoint.Y);
64
                this.DimSize = item.DimSize;
65
                this.EndPoint = new Point(item.EndPoint.X, item.EndPoint.Y);
66
                this.DashSize = item.DashSize;
67
                this.Interval = item.Interval;
68
                this.PointSet = item.PointSet.ConvertAll(x => new Point(x.X, x.Y));
69
                this.Opacity = item.Opacity;
70
                this.StrokeColor = item.StrokeColor;
71
                this.UserID = item.UserID;
72
                this.LineSize = item.LineSize;
73
                this.ZIndex = item.ZIndex;
74
            }
75
        }
76

    
77
        public override CommentUserInfo Clone()
78
        {
79
            var clone = new LineControl();
80
            clone.Copy(this);
81
            return clone ;
82
        }
83

    
84
        public void Dispose()
85
        {
86
            //GC.Collect();
87
            ////GC.SuppressFinalize(this);
88
            this.Base_LinePath = null;
89
        }
90
        protected void OnPropertyChanged(string propName)
91
        {
92
            if (PropertyChanged != null)
93
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
94
        }
95
        #region Dependency Properties
96

    
97
        public static readonly DependencyProperty IsSelectedProperty =
98
     DependencyProperty.Register("IsSelected", typeof(bool), typeof(LineControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
99

    
100
        public static readonly DependencyProperty ControlTypeProperty =
101
    DependencyProperty.Register("ControlType", typeof(ControlType), typeof(LineControl), new FrameworkPropertyMetadata(ControlType.SingleLine));
102

    
103
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
104
                "OverViewPathData", typeof(Geometry), typeof(LineControl), new PropertyMetadata(null));
105

    
106
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
107
                "UserID", typeof(string), typeof(LineControl), new PropertyMetadata(null));
108

    
109
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
110
                "LineSize", typeof(double), typeof(LineControl), new PropertyMetadata((Double)3, PointValueChanged));
111

    
112
        public static readonly DependencyProperty IntervalProperty = DependencyProperty.Register(
113
                "Interval", typeof(double), typeof(LineControl), new PropertyMetadata((Double)10, PointValueChanged));
114

    
115
//강인구 추가
116
        public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register(
117
                "DashSize", typeof(DoubleCollection), typeof(LineControl), new PropertyMetadata(new DoubleCollection { 1, 1 }, PointValueChanged));
118
        //public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register(
119
        //        "DashSize", typeof(DoubleCollection), typeof(LineControl), new PropertyMetadata(new DoubleCollection { 1, 1 }));
120

    
121
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
122
               "StrokeColor", typeof(SolidColorBrush), typeof(LineControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
123

    
124
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
125
              "PathData", typeof(Geometry), typeof(LineControl), null);
126

    
127
        public static readonly DependencyProperty LineStyleProperty = DependencyProperty.Register(
128
               "LineStyleSet", typeof(LineStyleSet), typeof(LineControl), new PropertyMetadata(LineStyleSet.SingleLine));
129

    
130
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
131
               "StartPoint", typeof(Point), typeof(LineControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
132

    
133
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
134
               "EndPoint", typeof(Point), typeof(LineControl), new PropertyMetadata(new Point(100, 100), PointValueChanged));
135

    
136
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
137
                "PointSet", typeof(List<Point>), typeof(LineControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
138
        
139
        
140
        public static readonly DependencyProperty MiddlePointProperty = DependencyProperty.Register(
141
                "MiddlePoint", typeof(Point), typeof(LineControl), new PropertyMetadata(new Point(0, 0)));
142
        public static readonly DependencyProperty DimSizeProperty = DependencyProperty.Register(
143
                "DimSize", typeof(double), typeof(LineControl), new PropertyMetadata((double)5));
144

    
145
        public static readonly DependencyProperty AngleProperty =
146
            DependencyProperty.Register("AngleValue", typeof(double), typeof(LineControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged)));
147

    
148
        public static readonly DependencyProperty CenterXProperty =
149
            DependencyProperty.Register("CenterX", typeof(double), typeof(LineControl), new PropertyMetadata((double)0, OnCenterXYChanged));
150

    
151
        public static readonly DependencyProperty CenterYProperty =
152
            DependencyProperty.Register("CenterY", typeof(double), typeof(LineControl), new PropertyMetadata((double)0, OnCenterXYChanged));
153
        #endregion
154
        #region PropertyChanged Method
155

    
156
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
157
        {
158
            //var instance = (LineControl)sender;
159

    
160
            //if (e.OldValue != e.NewValue && instance.Base_LinePath != null)
161
            //{
162

    
163
            //    instance.SetValue(e.Property, e.NewValue);
164

    
165
            //    if (instance.IsSelected)
166
            //    {
167
            //        instance.Base_LinePath.Stroke = new SolidColorBrush(Colors.Blue);
168
            //    }
169
            //    else
170
            //    {
171
            //        instance.Base_LinePath.Stroke = new SolidColorBrush(Colors.Red); 
172
            //    }
173
            //}
174
        }
175

    
176
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
177
        {
178
            var instance = (LineControl)sender;
179
            if (e.OldValue != e.NewValue && instance.Base_LinePath != null)
180
            {
181
                instance.SetValue(e.Property, e.NewValue);
182
                instance.SetLinePath();
183
            }
184
        }
185
        public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
186
        {
187
            var instance = (LineControl)sender;
188
            if (e.OldValue != e.NewValue && instance.Base_LinePath != null)
189
            {
190
                instance.SetValue(e.Property, e.NewValue);
191
                instance.SetLinePath();
192
            }
193
        }
194
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
195
        {
196
            var instance = (LineControl)sender;
197
            if (e.OldValue != e.NewValue && instance.Base_LinePath != null)
198
            {
199
                instance.SetValue(e.Property, e.NewValue);
200
                instance.SetLinePath();
201
            }
202
        }
203

    
204
        #endregion
205
        #region Properties
206
        public string UserID
207
        {
208
            get { return (string)GetValue(UserIDProperty); }
209
            set
210
            {
211
                if (this.UserID != value)
212
                {
213
                    SetValue(UserIDProperty, value);
214
                    OnPropertyChanged("UserID");
215
                }
216
            }
217
        }
218

    
219
        public Double Interval
220
        {
221
            get { return (Double)GetValue(IntervalProperty); }
222
            set
223
            {
224
                if (this.Interval != value)
225
                {
226
                    SetValue(IntervalProperty, value);
227
                    OnPropertyChanged("Interval");
228
                }
229
            }
230
        }
231
        public Double LineSize
232
        {
233
            get { return (Double)GetValue(LineSizeProperty); }
234
            set
235
            {
236
                if (this.LineSize != value)
237
                {
238
                    SetValue(LineSizeProperty, value);
239
                }
240
            }
241
        }
242
        public DoubleCollection DashSize
243
        {
244
            get { return (DoubleCollection)GetValue(DashSizeProperty); }
245
            set
246
            {
247
                if (this.DashSize != value)
248
                {
249
                    SetValue(DashSizeProperty, value);
250
                }
251
            }
252
        }
253
        public List<Point> PointSet
254
        {
255
            get { return (List<Point>)GetValue(PointSetProperty); }
256
            set { SetValue(PointSetProperty, value); }
257
        }
258
        public double CenterX
259
        {
260
            get { return (double)GetValue(CenterXProperty); }
261
            set { SetValue(CenterXProperty, value); }
262
        }
263
        public double CenterY
264
        {
265
            get { return (double)GetValue(CenterYProperty); }
266
            set { SetValue(CenterYProperty, value); }
267
        }
268
        public override SolidColorBrush StrokeColor
269
        {
270
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
271
            set
272
            {
273
                if (this.StrokeColor != value)
274
                {
275
                    SetValue(StrokeColorProperty, value);
276
                }
277
            }
278
        }
279

    
280

    
281
        public Geometry PathData
282
        {
283
            get { return (Geometry)GetValue(PathDataProperty); }
284
            set
285
            {
286
                SetValue(PathDataProperty, value);
287
                OnPropertyChanged("PathData");
288
            }
289
        }
290

    
291

    
292

    
293
        public Geometry OverViewPathData
294
        {
295
            get
296
            {
297
                return (Geometry)GetValue(OverViewPathDataProperty);
298
            }
299
            set
300
            {
301
                SetValue(OverViewPathDataProperty, value);
302
                OnPropertyChanged("OverViewPathData");
303
            }
304
        }
305

    
306
        public override bool IsSelected
307
        {
308
            get
309
            {
310
                return (bool)GetValue(IsSelectedProperty);
311
            }
312
            set
313
            {
314
                SetValue(IsSelectedProperty, value);
315
            }
316
        }
317

    
318
        public LineStyleSet LineStyleSet
319
        {
320
            get
321
            {
322
                return (LineStyleSet)GetValue(LineStyleProperty);
323
            }
324
            set
325
            {
326
                SetValue(LineStyleProperty, value);
327
            }
328
        }
329

    
330
        public override ControlType ControlType
331
        {
332
            get
333
            {
334
                return (ControlType)GetValue(ControlTypeProperty);
335
            }
336
            set
337
            {
338
                SetValue(ControlTypeProperty, value);
339
            }
340
        }
341

    
342
        public double AngleValue
343
        {
344
            get { return (double)GetValue(AngleProperty); }
345
            set { SetValue(AngleProperty, value); }
346
        }
347
        //public double Angle
348
        //{
349
        //    get { return (double)GetValue(AngleProperty); }
350
        //    set
351
        //    {
352
        //        if (this.Angle != value)
353
        //        {
354
        //            SetValue(AngleProperty, value);
355
        //        }
356
        //    }
357
        //}
358
        public Point EndPoint
359
        {
360
            get { return (Point)GetValue(EndPointProperty); }
361
            set
362
            {
363
                SetValue(EndPointProperty, value);
364
                OnPropertyChanged("EndPoint");
365
            }
366
        }
367
        public Point StartPoint
368
        {
369
            get { return (Point)GetValue(StartPointProperty); }
370
            set
371
            {
372
                SetValue(StartPointProperty, value);
373
                OnPropertyChanged("StartPoint");
374
            }
375
        }
376
        GeometryGroup instanceGroup = new GeometryGroup();
377
        LineGeometry connectorGeometry = new LineGeometry();
378

    
379
        #endregion
380
        public override void OnApplyTemplate()
381
        {
382
            base.OnApplyTemplate();
383
            Base_LinePath = GetTemplateChild("PART_LinePath") as Path;
384
            SetLinePath();
385
        }
386

    
387
        public override void UpdateControl()
388
        {
389
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
390
            this.EndPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
391
        }
392

    
393
        public static List<LineGeometry> DimAllow(Point p1, Point p2, Double lineSize, double DimSize)
394
        {
395
            //lineSize = 2;
396
            List<LineGeometry> GeometrySet = new List<LineGeometry>();
397
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
398

    
399

    
400
            LineGeometry ld = new LineGeometry();
401
            //ld.StartPoint = new Point(p2.X + lineSize, p2.Y - lineSize * 4 - DimSize);
402
            //ld.EndPoint = new Point(p2.X + lineSize, p2.Y + lineSize * 4 + DimSize);
403
            ld.StartPoint = new Point(p2.X + lineSize, p2.Y - lineSize * 4);
404
            ld.EndPoint = new Point(p2.X + lineSize, p2.Y + lineSize * 4 + DimSize);
405

    
406
            RotateTransform transform3 = new RotateTransform();
407
            transform3.Angle = theta;
408
            transform3.CenterX = p2.X;
409
            transform3.CenterY = p2.Y;
410
            ld.Transform = transform3;
411
            GeometrySet.Add(ld);
412

    
413
            LineGeometry ld1 = new LineGeometry();
414
            //ld1.StartPoint = new Point(p1.X - lineSize, p1.Y - lineSize * 4 - DimSize);
415
            //ld1.EndPoint = new Point(p1.X - lineSize, p1.Y + lineSize * 4 + DimSize);
416
            ld1.StartPoint = new Point(p1.X - lineSize, p1.Y - lineSize * 4);
417
            ld1.EndPoint = new Point(p1.X - lineSize, p1.Y + lineSize * 4 + DimSize);
418

    
419
            RotateTransform transform4 = new RotateTransform();
420
            transform4.Angle = theta;
421
            transform4.CenterX = p1.X;
422
            transform4.CenterY = p1.Y;
423
            ld1.Transform = transform4;
424
            GeometrySet.Add(ld1);
425
            return GeometrySet;
426
        }
427

    
428

    
429
        public override void ApplyOverViewData()
430
        {
431
            this.OverViewPathData = this.PathData;
432
        }
433

    
434
        private void SetLinePath()
435
        {
436
            this.ApplyTemplate();           
437
            if (this.DashSize != null)
438
            {
439
                Base_LinePath.StrokeDashArray.Clear();
440
                foreach (var item in this.DashSize)
441
                {
442
                    Base_LinePath.StrokeDashArray.Add(item);
443
                }
444
                Base_LinePath.StrokeDashCap = PenLineCap.Square;
445
            }
446

    
447
            PathFigure pathFigure = new PathFigure(); 
448
            pathFigure.StartPoint = this.StartPoint;
449
            LineSegment lineSegment0 = new LineSegment();
450
            lineSegment0.Point = this.EndPoint;
451
            pathFigure.Segments.Add(lineSegment0);
452
            PathGeometry pathGeometry = new PathGeometry();
453
            pathGeometry.Figures = new PathFigureCollection();
454
            pathGeometry.Figures.Add(pathFigure);
455

    
456
            
457

    
458
            instanceGroup.Children.Clear();
459
            switch (LineStyleSet)
460
            {
461
                case LineStyleSet.ArrowLine:
462
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.StartPoint, this.EndPoint, this.LineSize));
463
                    break;
464
                case LineStyleSet.TwinLine:
465
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.StartPoint, this.EndPoint, this.LineSize));
466
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.EndPoint, this.StartPoint, this.LineSize));
467
                    break;
468
                case LineStyleSet.DimLine:
469
                    List<LineGeometry> metrySet = DimAllow(this.StartPoint, this.EndPoint, this.LineSize, this.DimSize);
470
                    instanceGroup.Children.Add(metrySet[0]);
471
                    instanceGroup.Children.Add(metrySet[1]);
472
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.StartPoint, this.EndPoint, this.LineSize));
473
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.EndPoint, this.StartPoint, this.LineSize));
474
                    break;
475
                case LineStyleSet.CancelLine:
476
                    PathFigure pathFigure_Multi = new PathFigure();
477
                    LineSegment lineSegment1 = new LineSegment();
478

    
479
                    var x = Math.Abs((Math.Abs(this.StartPoint.X) - Math.Abs(this.EndPoint.X)));
480
                    var y = Math.Abs((Math.Abs(this.StartPoint.Y) - Math.Abs(this.EndPoint.Y)));
481

    
482
                    if (x > y)
483
                    {
484
                        pathFigure_Multi.StartPoint = new Point(this.StartPoint.X, this.StartPoint.Y + (this.Interval));
485
                        lineSegment1.Point = new Point(this.EndPoint.X, this.EndPoint.Y + (this.Interval));
486
                    }
487
                    else
488
                    {
489
                        pathFigure_Multi.StartPoint = new Point(this.StartPoint.X + (this.Interval), this.StartPoint.Y);
490
                        lineSegment1.Point = new Point(this.EndPoint.X + (this.Interval), this.EndPoint.Y);
491
                    }
492
                    pathFigure_Multi.Segments.Add(lineSegment1);
493
                    pathGeometry.Figures.Add(pathFigure_Multi);
494

    
495
                    this.PathData = pathGeometry;
496
                    this.OverViewPathData = PathData;
497

    
498
                    break;
499
                default:
500
                    break;
501
            }
502
            
503

    
504
            if (PathData != pathGeometry)
505
            {
506
                connectorGeometry.StartPoint = new Point(this.StartPoint.X, this.StartPoint.Y);
507
                connectorGeometry.EndPoint = new Point(this.EndPoint.X, this.EndPoint.Y);
508

    
509
                instanceGroup.Children.Add(connectorGeometry);
510

    
511
                this.PathData = instanceGroup;
512
                this.OverViewPathData = PathData;
513
            }
514
        }
515

    
516
        /// <summary>
517
        /// call when mouse is moving while drawing control
518
        /// </summary>
519
        /// <author>humkyung</author>
520
        /// <param name="pt"></param>
521
        /// <param name="bAxisLocked"></param>
522
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
523
        {
524
            if (this.ControlType == ControlType.DimLine)
525
                this.LineStyleSet = LineStyleSet.DimLine;
526
            else if (this.ControlType == ControlType.TwinLine)
527
                this.LineStyleSet = LineStyleSet.TwinLine;
528
            else if(this.ControlType == ControlType.ArrowLine)
529
                this.LineStyleSet = LineStyleSet.ArrowLine;
530
            else if(this.ControlType == ControlType.CancelLine)
531
                this.LineStyleSet = LineStyleSet.CancelLine;
532
            else if(this.ControlType == ControlType.SingleLine)
533
                this.LineStyleSet = LineStyleSet.SingleLine;
534

    
535
            this.EndPoint = pt;
536

    
537
            Point tmp = this.EndPoint;
538
            CommentAngle = MathSet.returnAngle(this.StartPoint, ref tmp, bAxisLocked);
539

    
540
            if (bAxisLocked)
541
            {
542
                this.EndPoint = tmp;
543
            }
544

    
545
            this.PointSet = new List<Point>
546
            {
547
                this.StartPoint,
548
                this.EndPoint,
549
            };
550
        }
551

    
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
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy,bool bAxisLocked = false)
561
        {
562
            Point selected = MathSet.getNearPoint((this as IPath).PointSet, pt);
563

    
564
            var tmpPointSet = (this as IPath).PointSet.Where(x => !x.Equals(selected));
565
            Point NearStartpoint = MathSet.getNearPoint(tmpPointSet.ToList(), pt);
566

    
567
            selected.X += dx;
568
            selected.Y += dy;
569

    
570
            Point tmp = selected;
571

    
572
            CommentAngle = MathSet.returnAngle(NearStartpoint, ref tmp, bAxisLocked);
573

    
574
            if (bAxisLocked)
575
            {
576
                selected = tmp;
577
            }
578

    
579
            for (int i = 0; i < (this as IPath).PointSet.Count; i++)
580
            {
581
                if (pt.Equals((this as IPath).PointSet[i]))
582
                {
583
                    (this as IPath).PointSet[i] = selected;
584
                }
585
            }
586
            this.UpdateControl();
587
        }
588

    
589
        /// <summary>
590
        /// return linecontrols' area
591
        /// </summary>
592
        /// <author>humkyung</author>
593
        /// <date>2019.06.13</date>
594
        public override Rect ItemRect
595
        {
596
            get
597
            {
598
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
599
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
600
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
601
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
602

    
603
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
604
            }
605
        }
606

    
607
        /// <summary>
608
        /// Serialize this
609
        /// </summary>
610
        /// <param name="sUserId"></param>
611
        /// <returns></returns>
612
        public override string Serialize()
613
        {
614
            using (S_LineControl ctrl = new S_LineControl())
615
            {
616
                ctrl.TransformPoint = "0|0";
617
                ctrl.PointSet = this.PointSet;
618
                ctrl.SizeSet = String.Format("{0}", this.LineSize);
619
                ctrl.LineStyleSet = this.LineStyleSet;
620
                //ctrl.StrokeColor = "#FF00FF00";
621
                ctrl.StrokeColor = this.StrokeColor.Color.ToString();
622
                ctrl.StartPoint = this.StartPoint;
623
                ctrl.EndPoint = this.EndPoint;
624
                ctrl.UserID = this.UserID;
625
                ctrl.Opac = this.Opacity;
626
                ctrl.DashSize = this.DashSize;
627
                ctrl.Interval = this.Interval;
628
                ctrl.DimSize = this.DimSize;
629
                ctrl.Name = this.GetType().Name.ToString();
630

    
631
                ///강인구 추가(2017.11.02)
632
                ///Memo 추가
633
                ctrl.Memo = this.Memo;
634

    
635
                ctrl.ZIndex = this.ZIndex;
636

    
637
                return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize()));
638
            }
639
        }
640

    
641
        /// <summary>
642
        /// create a linecontrol from given string
643
        /// </summary>
644
        /// <param name="str"></param>
645
        /// <returns></returns>
646
        public static LineControl FromString(string str, SolidColorBrush brush, string sProjectNo)
647
        {
648
            LineControl instance = null;
649
            using (S_LineControl ctrl = JsonSerializerHelper.JsonDeserialize<S_LineControl>(str))
650
            {
651
                string[] data2 = ctrl.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
652
                instance = new LineControl()
653
                {
654
                    LineStyleSet = ctrl.LineStyleSet,
655
                    StartPoint = ctrl.StartPoint,
656
                    DimSize = ctrl.DimSize,
657
                    EndPoint = ctrl.EndPoint,
658
                    DashSize = ctrl.DashSize,
659
                    Interval = ctrl.Interval,
660
                    PointSet = ctrl.PointSet,
661
                    Opacity = ctrl.Opac,
662
                    StrokeColor = brush,
663
                    UserID = ctrl.UserID,
664
                    LineSize = Convert.ToDouble(data2.First()),
665
                    ZIndex = ctrl.ZIndex
666
                };
667
            }
668

    
669
            return instance;
670
        }
671
    }
672
}
클립보드 이미지 추가 (최대 크기: 500 MB)