프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (25.4 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
    [TemplatePart(Name = "PART_LinePath", Type = typeof(Path))]
22 37eadd3f humkyung
    public class LineControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IDashControl
23 787a4489 KangIngu
    {
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 a6f7f9b6 djkim
            //ResourceDictionary dictionary = new ResourceDictionary();
34 787a4489 KangIngu
35 a6f7f9b6 djkim
            //dictionary.Source = new Uri("/MarkupToPDF;component/Themes/generic.xaml", UriKind.RelativeOrAbsolute);
36
            //Application.Current.Resources.MergedDictionaries.Add(dictionary);
37 787a4489 KangIngu
             //System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count);
38 a6f7f9b6 djkim
        }
39 787a4489 KangIngu
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 a6f7f9b6 djkim
            //this.DefaultStyleKey = typeof(LineControl);
56 787a4489 KangIngu
        }
57
58 37eadd3f humkyung
        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 b2d0f316 humkyung
                this.ZIndex = item.ZIndex;
74 e1b36bc0 humkyung
                GroupID = item.GroupID;
75 37eadd3f humkyung
            }
76
        }
77
78
        public override CommentUserInfo Clone()
79
        {
80
            var clone = new LineControl();
81
            clone.Copy(this);
82
            return clone ;
83
        }
84
85 787a4489 KangIngu
        public void Dispose()
86
        {
87 a6f7f9b6 djkim
            //GC.Collect();
88 24c5e56c taeseongkim
            ////GC.SuppressFinalize(this);
89 a6f7f9b6 djkim
            this.Base_LinePath = null;
90 787a4489 KangIngu
        }
91
        protected void OnPropertyChanged(string propName)
92
        {
93
            if (PropertyChanged != null)
94
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
95
        }
96
        #region Dependency Properties
97
98
        public static readonly DependencyProperty IsSelectedProperty =
99
     DependencyProperty.Register("IsSelected", typeof(bool), typeof(LineControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
100
101
        public static readonly DependencyProperty ControlTypeProperty =
102
    DependencyProperty.Register("ControlType", typeof(ControlType), typeof(LineControl), new FrameworkPropertyMetadata(ControlType.SingleLine));
103
104
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
105
                "OverViewPathData", typeof(Geometry), typeof(LineControl), new PropertyMetadata(null));
106
107
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
108
                "UserID", typeof(string), typeof(LineControl), new PropertyMetadata(null));
109
110
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
111 b3fb7321 ljiyeon
                "LineSize", typeof(double), typeof(LineControl), new PropertyMetadata((Double)3, PointValueChanged));
112 787a4489 KangIngu
113
        public static readonly DependencyProperty IntervalProperty = DependencyProperty.Register(
114 5ce56a3a KangIngu
                "Interval", typeof(double), typeof(LineControl), new PropertyMetadata((Double)10, PointValueChanged));
115 787a4489 KangIngu
116
//강인구 추가
117
        public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register(
118
                "DashSize", typeof(DoubleCollection), typeof(LineControl), new PropertyMetadata(new DoubleCollection { 1, 1 }, PointValueChanged));
119
        //public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register(
120
        //        "DashSize", typeof(DoubleCollection), typeof(LineControl), new PropertyMetadata(new DoubleCollection { 1, 1 }));
121
122
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
123
               "StrokeColor", typeof(SolidColorBrush), typeof(LineControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
124
125
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
126
              "PathData", typeof(Geometry), typeof(LineControl), null);
127
128
        public static readonly DependencyProperty LineStyleProperty = DependencyProperty.Register(
129
               "LineStyleSet", typeof(LineStyleSet), typeof(LineControl), new PropertyMetadata(LineStyleSet.SingleLine));
130
131
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
132
               "StartPoint", typeof(Point), typeof(LineControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
133
134
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
135
               "EndPoint", typeof(Point), typeof(LineControl), new PropertyMetadata(new Point(100, 100), PointValueChanged));
136
137
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
138
                "PointSet", typeof(List<Point>), typeof(LineControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
139
        
140
        
141
        public static readonly DependencyProperty MiddlePointProperty = DependencyProperty.Register(
142
                "MiddlePoint", typeof(Point), typeof(LineControl), new PropertyMetadata(new Point(0, 0)));
143
        public static readonly DependencyProperty DimSizeProperty = DependencyProperty.Register(
144
                "DimSize", typeof(double), typeof(LineControl), new PropertyMetadata((double)5));
145
146
        public static readonly DependencyProperty AngleProperty =
147
            DependencyProperty.Register("AngleValue", typeof(double), typeof(LineControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged)));
148
149
        public static readonly DependencyProperty CenterXProperty =
150
            DependencyProperty.Register("CenterX", typeof(double), typeof(LineControl), new PropertyMetadata((double)0, OnCenterXYChanged));
151
152
        public static readonly DependencyProperty CenterYProperty =
153
            DependencyProperty.Register("CenterY", typeof(double), typeof(LineControl), new PropertyMetadata((double)0, OnCenterXYChanged));
154
        #endregion
155
        #region PropertyChanged Method
156
157
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
158
        {
159
            //var instance = (LineControl)sender;
160
161
            //if (e.OldValue != e.NewValue && instance.Base_LinePath != null)
162
            //{
163
164
            //    instance.SetValue(e.Property, e.NewValue);
165
166
            //    if (instance.IsSelected)
167
            //    {
168
            //        instance.Base_LinePath.Stroke = new SolidColorBrush(Colors.Blue);
169
            //    }
170
            //    else
171
            //    {
172
            //        instance.Base_LinePath.Stroke = new SolidColorBrush(Colors.Red); 
173
            //    }
174
            //}
175
        }
176
177
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
178
        {
179
            var instance = (LineControl)sender;
180
            if (e.OldValue != e.NewValue && instance.Base_LinePath != null)
181
            {
182
                instance.SetValue(e.Property, e.NewValue);
183
                instance.SetLinePath();
184
            }
185
        }
186
        public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
187
        {
188
            var instance = (LineControl)sender;
189
            if (e.OldValue != e.NewValue && instance.Base_LinePath != null)
190
            {
191
                instance.SetValue(e.Property, e.NewValue);
192
                instance.SetLinePath();
193
            }
194
        }
195
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
196
        {
197
            var instance = (LineControl)sender;
198
            if (e.OldValue != e.NewValue && instance.Base_LinePath != null)
199
            {
200
                instance.SetValue(e.Property, e.NewValue);
201
                instance.SetLinePath();
202
            }
203
        }
204
205
        #endregion
206
        #region Properties
207
        public string UserID
208
        {
209
            get { return (string)GetValue(UserIDProperty); }
210
            set
211
            {
212
                if (this.UserID != value)
213
                {
214
                    SetValue(UserIDProperty, value);
215
                    OnPropertyChanged("UserID");
216
                }
217
            }
218
        }
219
220 5ce56a3a KangIngu
        public Double Interval
221 787a4489 KangIngu
        {
222 5ce56a3a KangIngu
            get { return (Double)GetValue(IntervalProperty); }
223 787a4489 KangIngu
            set
224
            {
225
                if (this.Interval != value)
226
                {
227
                    SetValue(IntervalProperty, value);
228
                    OnPropertyChanged("Interval");
229
                }
230
            }
231
        }
232
        public Double LineSize
233
        {
234
            get { return (Double)GetValue(LineSizeProperty); }
235
            set
236
            {
237
                if (this.LineSize != value)
238
                {
239
                    SetValue(LineSizeProperty, value);
240
                }
241
            }
242
        }
243
        public DoubleCollection DashSize
244
        {
245
            get { return (DoubleCollection)GetValue(DashSizeProperty); }
246
            set
247
            {
248
                if (this.DashSize != value)
249
                {
250
                    SetValue(DashSizeProperty, value);
251
                }
252
            }
253
        }
254
        public List<Point> PointSet
255
        {
256
            get { return (List<Point>)GetValue(PointSetProperty); }
257
            set { SetValue(PointSetProperty, value); }
258
        }
259
        public double CenterX
260
        {
261
            get { return (double)GetValue(CenterXProperty); }
262
            set { SetValue(CenterXProperty, value); }
263
        }
264
        public double CenterY
265
        {
266
            get { return (double)GetValue(CenterYProperty); }
267
            set { SetValue(CenterYProperty, value); }
268
        }
269 4913851c humkyung
        public override SolidColorBrush StrokeColor
270 787a4489 KangIngu
        {
271
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
272
            set
273
            {
274
                if (this.StrokeColor != value)
275
                {
276
                    SetValue(StrokeColorProperty, value);
277
                }
278
            }
279
        }
280
281
282
        public Geometry PathData
283
        {
284
            get { return (Geometry)GetValue(PathDataProperty); }
285
            set
286
            {
287
                SetValue(PathDataProperty, value);
288
                OnPropertyChanged("PathData");
289
            }
290
        }
291
292
293
294
        public Geometry OverViewPathData
295
        {
296
            get
297
            {
298
                return (Geometry)GetValue(OverViewPathDataProperty);
299
            }
300
            set
301
            {
302
                SetValue(OverViewPathDataProperty, value);
303
                OnPropertyChanged("OverViewPathData");
304
            }
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
        public LineStyleSet LineStyleSet
320
        {
321
            get
322
            {
323
                return (LineStyleSet)GetValue(LineStyleProperty);
324
            }
325
            set
326
            {
327
                SetValue(LineStyleProperty, value);
328
            }
329
        }
330
331 5529d2a2 humkyung
        public override ControlType ControlType
332 787a4489 KangIngu
        {
333
            get
334
            {
335
                return (ControlType)GetValue(ControlTypeProperty);
336
            }
337
            set
338
            {
339
                SetValue(ControlTypeProperty, value);
340
            }
341
        }
342
343
        public double AngleValue
344
        {
345
            get { return (double)GetValue(AngleProperty); }
346
            set { SetValue(AngleProperty, value); }
347
        }
348 168f8027 taeseongkim
        //public double Angle
349
        //{
350
        //    get { return (double)GetValue(AngleProperty); }
351
        //    set
352
        //    {
353
        //        if (this.Angle != value)
354
        //        {
355
        //            SetValue(AngleProperty, value);
356
        //        }
357
        //    }
358
        //}
359 787a4489 KangIngu
        public Point EndPoint
360
        {
361
            get { return (Point)GetValue(EndPointProperty); }
362
            set
363
            {
364
                SetValue(EndPointProperty, value);
365
                OnPropertyChanged("EndPoint");
366
            }
367
        }
368
        public Point StartPoint
369
        {
370
            get { return (Point)GetValue(StartPointProperty); }
371
            set
372
            {
373
                SetValue(StartPointProperty, value);
374
                OnPropertyChanged("StartPoint");
375
            }
376
        }
377
        GeometryGroup instanceGroup = new GeometryGroup();
378
        LineGeometry connectorGeometry = new LineGeometry();
379
380
        #endregion
381
        public override void OnApplyTemplate()
382
        {
383
            base.OnApplyTemplate();
384
            Base_LinePath = GetTemplateChild("PART_LinePath") as Path;
385
            SetLinePath();
386
        }
387 661b7416 humkyung
388 0d00f9c8 humkyung
        public override void UpdateControl()
389 787a4489 KangIngu
        {
390
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
391
            this.EndPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
392
        }
393
394
        public static List<LineGeometry> DimAllow(Point p1, Point p2, Double lineSize, double DimSize)
395
        {
396
            //lineSize = 2;
397
            List<LineGeometry> GeometrySet = new List<LineGeometry>();
398
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
399
400
401
            LineGeometry ld = new LineGeometry();
402
            //ld.StartPoint = new Point(p2.X + lineSize, p2.Y - lineSize * 4 - DimSize);
403
            //ld.EndPoint = new Point(p2.X + lineSize, p2.Y + lineSize * 4 + DimSize);
404
            ld.StartPoint = new Point(p2.X + lineSize, p2.Y - lineSize * 4);
405
            ld.EndPoint = new Point(p2.X + lineSize, p2.Y + lineSize * 4 + DimSize);
406
407
            RotateTransform transform3 = new RotateTransform();
408
            transform3.Angle = theta;
409
            transform3.CenterX = p2.X;
410
            transform3.CenterY = p2.Y;
411
            ld.Transform = transform3;
412
            GeometrySet.Add(ld);
413
414
            LineGeometry ld1 = new LineGeometry();
415
            //ld1.StartPoint = new Point(p1.X - lineSize, p1.Y - lineSize * 4 - DimSize);
416
            //ld1.EndPoint = new Point(p1.X - lineSize, p1.Y + lineSize * 4 + DimSize);
417
            ld1.StartPoint = new Point(p1.X - lineSize, p1.Y - lineSize * 4);
418
            ld1.EndPoint = new Point(p1.X - lineSize, p1.Y + lineSize * 4 + DimSize);
419
420
            RotateTransform transform4 = new RotateTransform();
421
            transform4.Angle = theta;
422
            transform4.CenterX = p1.X;
423
            transform4.CenterY = p1.Y;
424
            ld1.Transform = transform4;
425
            GeometrySet.Add(ld1);
426
            return GeometrySet;
427
        }
428
429
430 f513c215 humkyung
        public override void ApplyOverViewData()
431 787a4489 KangIngu
        {
432
            this.OverViewPathData = this.PathData;
433
        }
434
435 661b7416 humkyung
        private void SetLinePath()
436 787a4489 KangIngu
        {
437
            this.ApplyTemplate();           
438
            if (this.DashSize != null)
439
            {
440
                Base_LinePath.StrokeDashArray.Clear();
441
                foreach (var item in this.DashSize)
442
                {
443
                    Base_LinePath.StrokeDashArray.Add(item);
444
                }
445
                Base_LinePath.StrokeDashCap = PenLineCap.Square;
446
            }
447
448
            PathFigure pathFigure = new PathFigure(); 
449
            pathFigure.StartPoint = this.StartPoint;
450
            LineSegment lineSegment0 = new LineSegment();
451
            lineSegment0.Point = this.EndPoint;
452
            pathFigure.Segments.Add(lineSegment0);
453
            PathGeometry pathGeometry = new PathGeometry();
454
            pathGeometry.Figures = new PathFigureCollection();
455
            pathGeometry.Figures.Add(pathFigure);
456
457
            
458
459
            instanceGroup.Children.Clear();
460
            switch (LineStyleSet)
461
            {
462
                case LineStyleSet.ArrowLine:
463 d251456f humkyung
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.StartPoint, this.EndPoint, this.LineSize));
464 787a4489 KangIngu
                    break;
465
                case LineStyleSet.TwinLine:
466 d251456f humkyung
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.StartPoint, this.EndPoint, this.LineSize));
467
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.EndPoint, this.StartPoint, this.LineSize));
468 787a4489 KangIngu
                    break;
469
                case LineStyleSet.DimLine:
470
                    List<LineGeometry> metrySet = DimAllow(this.StartPoint, this.EndPoint, this.LineSize, this.DimSize);
471
                    instanceGroup.Children.Add(metrySet[0]);
472
                    instanceGroup.Children.Add(metrySet[1]);
473 d251456f humkyung
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.StartPoint, this.EndPoint, this.LineSize));
474
                    instanceGroup.Children.Add(DrawSet.DrawArrow(this.EndPoint, this.StartPoint, this.LineSize));
475 787a4489 KangIngu
                    break;
476
                case LineStyleSet.CancelLine:
477
                    PathFigure pathFigure_Multi = new PathFigure();
478
                    LineSegment lineSegment1 = new LineSegment();
479
480
                    var x = Math.Abs((Math.Abs(this.StartPoint.X) - Math.Abs(this.EndPoint.X)));
481
                    var y = Math.Abs((Math.Abs(this.StartPoint.Y) - Math.Abs(this.EndPoint.Y)));
482
483
                    if (x > y)
484
                    {
485
                        pathFigure_Multi.StartPoint = new Point(this.StartPoint.X, this.StartPoint.Y + (this.Interval));
486
                        lineSegment1.Point = new Point(this.EndPoint.X, this.EndPoint.Y + (this.Interval));
487
                    }
488
                    else
489
                    {
490
                        pathFigure_Multi.StartPoint = new Point(this.StartPoint.X + (this.Interval), this.StartPoint.Y);
491
                        lineSegment1.Point = new Point(this.EndPoint.X + (this.Interval), this.EndPoint.Y);
492
                    }
493
                    pathFigure_Multi.Segments.Add(lineSegment1);
494
                    pathGeometry.Figures.Add(pathFigure_Multi);
495
496
                    this.PathData = pathGeometry;
497
                    this.OverViewPathData = PathData;
498
499
                    break;
500
                default:
501
                    break;
502
            }
503
            
504
505
            if (PathData != pathGeometry)
506
            {
507
                connectorGeometry.StartPoint = new Point(this.StartPoint.X, this.StartPoint.Y);
508
                connectorGeometry.EndPoint = new Point(this.EndPoint.X, this.EndPoint.Y);
509
510
                instanceGroup.Children.Add(connectorGeometry);
511
512
                this.PathData = instanceGroup;
513
                this.OverViewPathData = PathData;
514
            }
515
        }
516 a6272c57 humkyung
517
        /// <summary>
518
        /// call when mouse is moving while drawing control
519
        /// </summary>
520
        /// <author>humkyung</author>
521
        /// <param name="pt"></param>
522
        /// <param name="bAxisLocked"></param>
523 233ef333 taeseongkim
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
524 a6272c57 humkyung
        {
525
            if (this.ControlType == ControlType.DimLine)
526
                this.LineStyleSet = LineStyleSet.DimLine;
527
            else if (this.ControlType == ControlType.TwinLine)
528
                this.LineStyleSet = LineStyleSet.TwinLine;
529
            else if(this.ControlType == ControlType.ArrowLine)
530
                this.LineStyleSet = LineStyleSet.ArrowLine;
531
            else if(this.ControlType == ControlType.CancelLine)
532
                this.LineStyleSet = LineStyleSet.CancelLine;
533
            else if(this.ControlType == ControlType.SingleLine)
534
                this.LineStyleSet = LineStyleSet.SingleLine;
535
536
            this.EndPoint = pt;
537 168f8027 taeseongkim
538
            Point tmp = this.EndPoint;
539 233ef333 taeseongkim
            CommentAngle = MathSet.returnAngle(this.StartPoint, ref tmp, bAxisLocked);
540 168f8027 taeseongkim
541 233ef333 taeseongkim
            if (bAxisLocked)
542 a6272c57 humkyung
            {
543
                this.EndPoint = tmp;
544
            }
545
546
            this.PointSet = new List<Point>
547
            {
548
                this.StartPoint,
549
                this.EndPoint,
550
            };
551
        }
552 d2114d3b humkyung
553
        /// <summary>
554
        /// move control point has same location of given pt along given delta
555
        /// </summary>
556
        /// <author>humkyung</author>
557
        /// <date>2019.06.20</date>
558
        /// <param name="pt"></param>
559
        /// <param name="dx"></param>
560
        /// <param name="dy"></param>
561 233ef333 taeseongkim
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy,bool bAxisLocked = false)
562 d2114d3b humkyung
        {
563
            Point selected = MathSet.getNearPoint((this as IPath).PointSet, pt);
564 233ef333 taeseongkim
565
            var tmpPointSet = (this as IPath).PointSet.Where(x => !x.Equals(selected));
566
            Point NearStartpoint = MathSet.getNearPoint(tmpPointSet.ToList(), pt);
567
568 d2114d3b humkyung
            selected.X += dx;
569
            selected.Y += dy;
570 233ef333 taeseongkim
571
            Point tmp = selected;
572
573
            CommentAngle = MathSet.returnAngle(NearStartpoint, ref tmp, bAxisLocked);
574
575
            if (bAxisLocked)
576
            {
577
                selected = tmp;
578
            }
579
580 d2114d3b humkyung
            for (int i = 0; i < (this as IPath).PointSet.Count; i++)
581
            {
582
                if (pt.Equals((this as IPath).PointSet[i]))
583
                {
584
                    (this as IPath).PointSet[i] = selected;
585
                }
586
            }
587 0d00f9c8 humkyung
            this.UpdateControl();
588 d2114d3b humkyung
        }
589 036650a0 humkyung
590
        /// <summary>
591 91efe37a humkyung
        /// return linecontrols' area
592
        /// </summary>
593
        /// <author>humkyung</author>
594
        /// <date>2019.06.13</date>
595
        public override Rect ItemRect
596
        {
597
            get
598
            {
599
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
600
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
601
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
602
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
603
604
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
605
            }
606
        }
607
608
        /// <summary>
609 036650a0 humkyung
        /// Serialize this
610
        /// </summary>
611
        /// <param name="sUserId"></param>
612
        /// <returns></returns>
613
        public override string Serialize()
614
        {
615 b2d0f316 humkyung
            using (S_LineControl ctrl = new S_LineControl())
616 036650a0 humkyung
            {
617 b2d0f316 humkyung
                ctrl.TransformPoint = "0|0";
618
                ctrl.PointSet = this.PointSet;
619
                ctrl.SizeSet = String.Format("{0}", this.LineSize);
620
                ctrl.LineStyleSet = this.LineStyleSet;
621
                //ctrl.StrokeColor = "#FF00FF00";
622
                ctrl.StrokeColor = this.StrokeColor.Color.ToString();
623
                ctrl.StartPoint = this.StartPoint;
624
                ctrl.EndPoint = this.EndPoint;
625
                ctrl.UserID = this.UserID;
626
                ctrl.Opac = this.Opacity;
627
                ctrl.DashSize = this.DashSize;
628
                ctrl.Interval = this.Interval;
629
                ctrl.DimSize = this.DimSize;
630
                ctrl.Name = this.GetType().Name.ToString();
631 036650a0 humkyung
632
                ///강인구 추가(2017.11.02)
633
                ///Memo 추가
634 b2d0f316 humkyung
                ctrl.Memo = this.Memo;
635 fd19a116 humkyung
                ctrl.Index = this.Index;
636 b2d0f316 humkyung
                ctrl.ZIndex = this.ZIndex;
637 e1b36bc0 humkyung
                ctrl.GroupID = this.GroupID;
638 b2d0f316 humkyung
639
                return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize()));
640 036650a0 humkyung
            }
641
        }
642 661b7416 humkyung
643
        /// <summary>
644
        /// create a linecontrol from given string
645
        /// </summary>
646
        /// <param name="str"></param>
647
        /// <returns></returns>
648
        public static LineControl FromString(string str, SolidColorBrush brush, string sProjectNo)
649
        {
650
            LineControl instance = null;
651 b2d0f316 humkyung
            using (S_LineControl ctrl = JsonSerializerHelper.JsonDeserialize<S_LineControl>(str))
652 661b7416 humkyung
            {
653 b2d0f316 humkyung
                string[] data2 = ctrl.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
654 661b7416 humkyung
                instance = new LineControl()
655
                {
656 b2d0f316 humkyung
                    LineStyleSet = ctrl.LineStyleSet,
657
                    StartPoint = ctrl.StartPoint,
658
                    DimSize = ctrl.DimSize,
659
                    EndPoint = ctrl.EndPoint,
660
                    DashSize = ctrl.DashSize,
661
                    Interval = ctrl.Interval,
662
                    PointSet = ctrl.PointSet,
663
                    Opacity = ctrl.Opac,
664 661b7416 humkyung
                    StrokeColor = brush,
665 b2d0f316 humkyung
                    UserID = ctrl.UserID,
666 661b7416 humkyung
                    LineSize = Convert.ToDouble(data2.First()),
667 fd19a116 humkyung
                    Index = ctrl.Index,
668 e1b36bc0 humkyung
                    ZIndex = ctrl.ZIndex,
669
                    GroupID = ctrl.GroupID
670 661b7416 humkyung
                };
671
            }
672
673
            return instance;
674
        }
675 787a4489 KangIngu
    }
676
}
클립보드 이미지 추가 (최대 크기: 500 MB)