프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Shape / RectCloudControl.cs @ 873011c4

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