프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (25.1 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
            }
74
        }
75

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
279

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

    
290

    
291

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

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

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

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

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

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

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

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

    
398

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

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

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

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

    
427

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

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

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

    
455
            
456

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

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

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

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

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

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

    
508
                instanceGroup.Children.Add(connectorGeometry);
509

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

    
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
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
522
        {
523
            if (this.ControlType == ControlType.DimLine)
524
                this.LineStyleSet = LineStyleSet.DimLine;
525
            else if (this.ControlType == ControlType.TwinLine)
526
                this.LineStyleSet = LineStyleSet.TwinLine;
527
            else if(this.ControlType == ControlType.ArrowLine)
528
                this.LineStyleSet = LineStyleSet.ArrowLine;
529
            else if(this.ControlType == ControlType.CancelLine)
530
                this.LineStyleSet = LineStyleSet.CancelLine;
531
            else if(this.ControlType == ControlType.SingleLine)
532
                this.LineStyleSet = LineStyleSet.SingleLine;
533

    
534
            this.EndPoint = pt;
535

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

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

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

    
551
        /// <summary>
552
        /// move control point has same location of given pt along given delta
553
        /// </summary>
554
        /// <author>humkyung</author>
555
        /// <date>2019.06.20</date>
556
        /// <param name="pt"></param>
557
        /// <param name="dx"></param>
558
        /// <param name="dy"></param>
559
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy,bool bAxisLocked = false)
560
        {
561
            Point selected = MathSet.getNearPoint((this as IPath).PointSet, pt);
562

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

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

    
569
            Point tmp = selected;
570

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

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

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

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

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

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

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

    
634
                return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize()));
635
            }
636
        }
637

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

    
665
            return instance;
666
        }
667
    }
668
}
클립보드 이미지 추가 (최대 크기: 500 MB)