프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Shape / TriControl.cs @ master

이력 | 보기 | 이력해설 | 다운로드 (23.2 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 787a4489 KangIngu
19
namespace MarkupToPDF.Controls.Shape
20
{
21
    //[TemplatePart(Name = "PART_TriPath", Type = typeof(Path))]
22 37eadd3f humkyung
    public class TriControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IShapeControl, IDashControl
23 787a4489 KangIngu
    {
24
        public Path Base_TriPath { get; set; }
25
        //public enum PaintSet { None, Fill, Hatch };
26
        private const string PART_TriPath = "PART_TriPath";
27
28
        //public Path Base_TriPath = null;
29
30
        static TriControl()
31
        {
32
            DefaultStyleKeyProperty.OverrideMetadata(typeof(TriControl), new FrameworkPropertyMetadata(typeof(TriControl)));
33 a6f7f9b6 djkim
            //ResourceDictionary dictionary = new ResourceDictionary();
34
            //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
35
            //Application.Current.Resources.MergedDictionaries.Add(dictionary);
36 787a4489 KangIngu
        }
37
38 37eadd3f humkyung
        public override void Copy(CommentUserInfo lhs)
39
        {
40
            if(lhs is TriControl item)
41
            {
42
                this.LineSize = item.LineSize;
43
                this.MidPoint = new Point(item.MidPoint.X, item.MidPoint.Y);
44
                this.StartPoint = new Point(item.StartPoint.X, item.StartPoint.Y);
45
                this.Paint = item.Paint;
46
                this.EndPoint = new Point(item.EndPoint.X, item.EndPoint.Y);
47
                this.Opacity = item.Opacity;
48
                this.CommentAngle = item.CommentAngle;
49
                this.DashSize = item.DashSize;
50
                this.PointSet = item.PointSet.ConvertAll(x => new Point(x.X, x.Y));
51
                this.StrokeColor = item.StrokeColor;
52
                this.UserID = item.UserID;
53
                this.Memo = item.Memo;
54 b2d0f316 humkyung
                this.ZIndex = item.ZIndex;
55 e1b36bc0 humkyung
                this.GroupID = item.GroupID;
56 37eadd3f humkyung
            }
57
        }
58
59
        public override CommentUserInfo Clone()
60
        {
61
            var clone = new TriControl();
62
            clone.Copy(this);
63
            return clone;
64
        }
65
66 787a4489 KangIngu
        #region Dependency Properties
67
68
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
69
        "OverViewPathData", typeof(Geometry), typeof(TriControl), new PropertyMetadata(null));
70
71
        public static readonly DependencyProperty IsSelectedProperty =
72
      DependencyProperty.Register("IsSelected", typeof(bool), typeof(TriControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
73
74
        public static readonly DependencyProperty ControlTypeProperty =
75
    DependencyProperty.Register("ControlType", typeof(ControlType), typeof(TriControl), new FrameworkPropertyMetadata(ControlType.Triangle));
76
77
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
78
         "LineSize", typeof(double), typeof(TriControl), new PropertyMetadata((Double)3));
79
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
80
                "UserID", typeof(string), typeof(TriControl), new PropertyMetadata(null));
81
        //강인구 추가
82
        public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register(
83
              "DashSize", typeof(DoubleCollection), typeof(TriControl), new PropertyMetadata(new DoubleCollection { 1, 1 }, PointValueChanged));
84
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
85
        "PathData", typeof(Geometry), typeof(TriControl), null);
86
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
87
         "StrokeColor", typeof(SolidColorBrush), typeof(TriControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
88
        public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register(
89
         "FillColor", typeof(SolidColorBrush), typeof(TriControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
90
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
91
            "EndPoint", typeof(Point), typeof(TriControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
92
        public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register(
93
            "MidPoint", typeof(Point), typeof(TriControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
94
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
95
            "StartPoint", typeof(Point), typeof(TriControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
96
        //강인구 추가
97
        public static readonly DependencyProperty PaintProperty = DependencyProperty.Register(
98
                "Paint", typeof(PaintSet), typeof(TriControl), new PropertyMetadata(PaintSet.None, PointValueChanged));
99
100
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
101
            "PointSet", typeof(List<Point>), typeof(TriControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
102
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(TriControl), new
103
            PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged)));
104
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(TriControl),
105
            new PropertyMetadata((double)0, OnCenterXYChanged));
106
107
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(TriControl),
108
            new PropertyMetadata((double)0, OnCenterXYChanged));
109
110
        #endregion
111
        #region PropertyChanged Method
112
113
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
114
        {
115
            //var instance = (TriControl)sender;
116
117
            //if (e.OldValue != e.NewValue && instance.Base_TriPath != null)
118
            //{
119
120
            //    instance.SetValue(e.Property, e.NewValue);
121
122
            //    if (instance.IsSelected)
123
            //    {
124
            //        instance.Base_TriPath.Stroke = new SolidColorBrush(Colors.Blue);
125
            //    }
126
            //    else
127
            //    {
128
            //        instance.Base_TriPath.Stroke = new SolidColorBrush(Colors.Red);
129
            //    }
130
            //}
131
        }
132
133
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
134
        {
135
            var instance = (TriControl)sender;
136
137
            if (e.OldValue != e.NewValue && instance.Base_TriPath != null)
138
            {
139
                instance.SetValue(e.Property, e.NewValue);
140
                instance.SetTri();
141
            }
142
        }
143
144
145
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
146
        {
147
            var instance = (TriControl)sender;
148
            if (e.OldValue != e.NewValue && instance.Base_TriPath != null)
149
            {
150
                instance.SetValue(e.Property, e.NewValue);
151
                instance.SetTri();
152
            }
153
        }
154
        public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
155
        {
156
            var instance = (TriControl)sender;
157
            if (e.OldValue != e.NewValue && instance.Base_TriPath != null)
158
            {
159
                instance.SetValue(e.Property, e.NewValue);
160
                instance.SetTri();
161
            }
162
        }
163
        #endregion
164
        #region Properties
165
166
        public Double LineSize
167
        {
168
            get { return (Double)GetValue(LineSizeProperty); }
169
            set
170
            {
171
                if (this.LineSize != value)
172
                {
173
                    SetValue(LineSizeProperty, value);
174
                }
175
            }
176
        }
177
        public string UserID
178
        {
179
            get { return (string)GetValue(UserIDProperty); }
180
            set
181
            {
182
                if (this.UserID != value)
183
                {
184
                    SetValue(UserIDProperty, value);
185
                    OnPropertyChanged("UserID");
186
                }
187
            }
188
        }
189
        public SolidColorBrush FillColor
190
        {
191
            get { return (SolidColorBrush)GetValue(FillColorProperty); }
192
            set
193
            {
194
                if (this.FillColor != value)
195
                {
196
                    SetValue(FillColorProperty, value);
197
                }
198
            }
199
        }
200
        public DoubleCollection DashSize
201
        {
202
            get { return (DoubleCollection)GetValue(DashSizeProperty); }
203
            set
204
            {
205
                if (this.DashSize != value)
206
                {
207
                    SetValue(DashSizeProperty, value);
208
                }
209
            }
210
        }
211
        public PaintSet Paint
212
        {
213
            get { return (PaintSet)GetValue(PaintProperty); }
214
            set
215
            {
216
                if (this.Paint != value)
217
                {
218
                    SetValue(PaintProperty, value);
219
                }
220
            }
221
        }
222
223
224 4913851c humkyung
        public override SolidColorBrush StrokeColor
225 787a4489 KangIngu
        {
226
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
227
            set
228
            {
229
                if (this.StrokeColor != value)
230
                {
231
                    SetValue(StrokeColorProperty, value);
232
                }
233
            }
234
        }
235
        public Geometry OverViewPathData
236
        {
237
            get
238
            {
239
                return (Geometry)GetValue(OverViewPathDataProperty);
240
            }
241
            set
242
            {
243
                SetValue(OverViewPathDataProperty, value);
244
                OnPropertyChanged("OverViewPathData");
245
            }
246
        }
247
        public Geometry PathData
248
        {
249
            get { return (Geometry)GetValue(PathDataProperty); }
250
            set { SetValue(PathDataProperty, value); }
251
        }
252
        public Point EndPoint
253
        {
254
            get { return (Point)GetValue(EndPointProperty); }
255
            set { SetValue(EndPointProperty, value); }
256
        }
257
        public Point StartPoint
258
        {
259
            get { return (Point)GetValue(StartPointProperty); }
260
            set { SetValue(StartPointProperty, value); }
261
        }
262
        public Point MidPoint
263
        {
264
            get { return (Point)GetValue(MidPointProperty); }
265
            set { SetValue(MidPointProperty, value); }
266
        }
267
        public List<Point> PointSet
268
        {
269
            get { return (List<Point>)GetValue(PointSetProperty); }
270
            set { SetValue(PointSetProperty, value); }
271
        }
272
273 959b3ef2 humkyung
        public override bool IsSelected
274 787a4489 KangIngu
        {
275
            get
276
            {
277
                return (bool)GetValue(IsSelectedProperty);
278
            }
279
            set
280
            {
281
                SetValue(IsSelectedProperty, value);
282
            }
283
        }
284
285 5529d2a2 humkyung
        public override ControlType ControlType
286 787a4489 KangIngu
        {
287
            get
288
            {
289
                return (ControlType)GetValue(ControlTypeProperty);
290
            }
291
            set
292
            {
293
                SetValue(ControlTypeProperty, value);
294
            }
295
        }
296
297
298 fa48eb85 taeseongkim
        public double CommentAngle
299 787a4489 KangIngu
        {
300
            get { return (double)GetValue(AngleProperty); }
301
            set
302
            {
303 fa48eb85 taeseongkim
                if (this.CommentAngle != value)
304 787a4489 KangIngu
                {
305
                    SetValue(AngleProperty, value);
306
                }
307
            }
308
        }
309
        public double CenterX
310
        {
311
            get { return (double)GetValue(CenterXProperty); }
312
            set { SetValue(CenterXProperty, value); }
313
        }
314
        public double CenterY
315
        {
316
            get { return (double)GetValue(CenterYProperty); }
317
            set { SetValue(CenterYProperty, value); }
318
        }
319
        #endregion
320
321
        #region Dependency PropertyChanged
322
        //public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
323
        //{
324
        //    var instance = (TriControl)sender;
325
326
        //    if (e.OldValue != e.NewValue && instance.Base_TriPath != null)
327
        //    {
328
329
        //        instance.SetValue(e.Property, e.NewValue);
330
331
        //        if (instance.IsSelected)
332
        //        {
333
        //            instance.Base_TriPath.Stroke = new SolidColorBrush(Colors.Blue);
334
        //        }
335
        //        else
336
        //        {
337
        //            instance.Base_TriPath.Stroke = new SolidColorBrush(Colors.Red);
338
        //        }
339
        //    }
340
        //}
341
342
        #endregion Dependency PropertyChanged
343
344
        public override void OnApplyTemplate()
345
        {
346
            base.OnApplyTemplate();
347
            Base_TriPath = GetTemplateChild(PART_TriPath) as Path;
348
349
            if (Base_TriPath == null)
350
            {
351
                return;
352
            }
353
354
            this.SetTri();
355
        }
356 6d1a8228 humkyung
357 661b7416 humkyung
        private void SetTri()
358 787a4489 KangIngu
        {
359
            this.ApplyTemplate();
360 8295a079 이지연
           
361 787a4489 KangIngu
            Base_TriPath.StrokeDashArray.Clear();
362
            foreach (var item in this.DashSize)
363
            {
364
                Base_TriPath.StrokeDashArray.Add(item);
365
            }
366
            Base_TriPath.StrokeDashCap = PenLineCap.Square;
367
            PathFigure pathFigure = new PathFigure();
368
369
            //this.FillColor = this.StrokeColor;
370
            ////Base_TriPath.Fill = this.FillColor;
371
            //Base_TriPath.Fill = Brushes.Red;
372
            //pathFigure.IsFilled = true;
373
374
            switch (this.Paint)
375
            {
376
                case PaintSet.None:
377
                    this.FillColor = null;
378
                    pathFigure.IsFilled = false;
379
                    break;
380
                case PaintSet.Fill:
381
                    this.FillColor = this.StrokeColor;
382
                    Base_TriPath.Fill = this.FillColor;
383
                    pathFigure.IsFilled = true;
384
                    break;
385
                case PaintSet.Hatch:
386
                    Base_TriPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor);
387
                    pathFigure.IsFilled = true;
388
                    break;
389
                default:
390
                    break;
391
            }
392
            pathFigure.StartPoint = this.StartPoint;
393
394 6d1a8228 humkyung
            List<Point> points = new List<Point>() { this.StartPoint };
395
            if (MidPoint.X != 0 && MidPoint.Y != 0) points.Add(this.MidPoint);
396
            points.Add(this.EndPoint);
397
            PolyLineSegment polyline = new PolyLineSegment(points , true);
398
            pathFigure.Segments.Add(polyline);
399 8295a079 이지연
            //polyline.IsSmoothJoin 끝이 둥글해짐
400
         
401 787a4489 KangIngu
            PathGeometry pathGeometry = new PathGeometry();
402
            pathGeometry.Figures = new PathFigureCollection();
403 8295a079 이지연
            if(points.Count == 3)
404
                pathFigure.IsClosed = true;
405 787a4489 KangIngu
            pathGeometry.Figures.Add(pathFigure);
406
407
            this.PathData = pathGeometry;
408
            ApplyOverViewData();
409
410
        }
411
        public void Dispose()
412
        {
413 a6f7f9b6 djkim
            //GC.Collect();
414 24c5e56c taeseongkim
            ////GC.SuppressFinalize(this);
415 a6f7f9b6 djkim
            this.Base_TriPath = null;
416 787a4489 KangIngu
        }
417
        public event PropertyChangedEventHandler PropertyChanged;
418
        protected void OnPropertyChanged(string propName)
419
        {
420
            if (PropertyChanged != null)
421
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
422
        }
423
424 f513c215 humkyung
        public override void ApplyOverViewData()
425 787a4489 KangIngu
        {
426
            this.OverViewPathData = this.PathData;
427
        }
428
429 0d00f9c8 humkyung
        public override void UpdateControl()
430 787a4489 KangIngu
        {
431
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
432
            this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
433
            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
434
        }
435
436 036650a0 humkyung
        /// <summary>
437 a6272c57 humkyung
        /// call when mouse is moving while drawing control
438
        /// </summary>
439
        /// <param name="pt"></param>
440
        /// <param name="bAxisLocked"></param>
441 233ef333 taeseongkim
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
442 a6272c57 humkyung
        {
443
            this.EndPoint = pt;
444
445
            if (bAxisLocked)
446
            {
447
                Point tmp = this.EndPoint;
448
                string angle = MathSet.returnAngleString(this.StartPoint, ref tmp, true);
449
                this.EndPoint = tmp;
450 233ef333 taeseongkim
          
451 a6272c57 humkyung
                List<Point> Points = this.GetRegularTrianglePoints(this.StartPoint, this.EndPoint);
452 26417dc9 humkyung
                if (2 == Points.Count)
453 a6272c57 humkyung
                {
454
                    this.MidPoint = Points[0];
455
                    this.EndPoint = Points[1];
456
                }
457
            }
458
459
            this.PointSet = new List<Point>
460
            {
461
                this.StartPoint,
462
                this.MidPoint,
463
                this.EndPoint,
464
            };
465
        }
466
467
        /// <summary>
468 d2114d3b humkyung
        /// move control point has same location of given pt along given delta
469
        /// </summary>
470
        /// <author>humkyung</author>
471
        /// <date>2019.06.20</date>
472
        /// <param name="pt"></param>
473
        /// <param name="delta"></param>
474 233ef333 taeseongkim
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
475 d2114d3b humkyung
        {
476 025ebf74 humkyung
            Point selected = MathSet.getNearPoint((this as IPath).PointSet, pt);    ///TODO: 위험 요소를 가지고 있음.
477 d2114d3b humkyung
            selected.X += dx;
478
            selected.Y += dy;
479 efd9be38 swate0609
480 26417dc9 humkyung
            int iIndex = (this as IPath).PointSet.FindIndex(x => x == pt);
481
            if (bAxisLocked)
482 efd9be38 swate0609
            {
483 26417dc9 humkyung
                this.StartPoint = selected;
484 efd9be38 swate0609
485 26417dc9 humkyung
                int PrevIdx = (iIndex + this.PointSet.Count - 1) % this.PointSet.Count;
486
                int NextIdx = (iIndex + 1) % this.PointSet.Count;
487
                var end = new Point((PointSet[PrevIdx].X + PointSet[NextIdx].X) * 0.5, (PointSet[PrevIdx].Y + PointSet[NextIdx].Y) * 0.5);
488
489
                List<Point> Points = this.GetRegularTrianglePoints(selected, end);
490
                if (2 == Points.Count)
491
                {
492
                    PointSet[PrevIdx] = Points[0];
493
                    PointSet[iIndex] = selected;
494
                    PointSet[NextIdx] = Points[1];
495
                }
496
            }
497
            else
498 d2114d3b humkyung
            {
499 26417dc9 humkyung
                for (int i = 0; i < (this as IPath).PointSet.Count; i++)
500 d2114d3b humkyung
                {
501 26417dc9 humkyung
                    if (i == iIndex)
502 efd9be38 swate0609
                    {
503 26417dc9 humkyung
                        if (pt.Equals((this as IPath).PointSet[i]))
504
                        {
505
                            (this as IPath).PointSet[i] = selected;
506
                        }
507 efd9be38 swate0609
                    }
508 d2114d3b humkyung
                }
509
            }
510 26417dc9 humkyung
511 0d00f9c8 humkyung
            this.UpdateControl();
512 d2114d3b humkyung
        }
513
514
        /// <summary>
515 91efe37a humkyung
        /// return tricontrols' area
516
        /// </summary>
517
        /// <author>humkyung</author>
518
        /// <date>2019.06.13</date>
519
        public override Rect ItemRect
520
        {
521
            get
522
            {
523
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
524
                dMinX = Math.Min(this.MidPoint.X, dMinX);
525
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
526
                dMinY = Math.Min(this.MidPoint.Y, dMinY);
527
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
528
                dMaxX = Math.Max(this.MidPoint.X, dMaxX);
529
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
530
                dMaxY = Math.Max(this.MidPoint.Y, dMaxY);
531
532
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
533
            }
534
        }
535
536
        /// <summary>
537 036650a0 humkyung
        /// Serialize this
538
        /// </summary>
539
        /// <param name="sUserId"></param>
540
        /// <returns></returns>
541
        public override string Serialize()
542
        {
543 b2d0f316 humkyung
            using (S_TriControl ctrl = new S_TriControl())
544 036650a0 humkyung
            {
545 b2d0f316 humkyung
                ctrl.TransformPoint = "0|0";
546
                ctrl.Paint = this.Paint;
547
                ctrl.SizeSet = String.Format("{0}", this.LineSize);
548
                //ctrl.StrokeColor = "#FF00FF00";
549
                ctrl.StrokeColor = this.StrokeColor.Color.ToString();
550 036650a0 humkyung
                if (this.FillColor != null)
551
                {
552 b2d0f316 humkyung
                    ctrl.FillColor = this.FillColor.Color.ToString();
553 036650a0 humkyung
                }
554 b2d0f316 humkyung
                ctrl.StartPoint = this.StartPoint;
555
                ctrl.EndPoint = this.EndPoint;
556
                ctrl.MidPoint = this.MidPoint;
557
                ctrl.Opac = this.Opacity;
558
                ctrl.UserID = this.UserID;
559
                ctrl.PointSet = this.PointSet;
560
                ctrl.Angle = this.CommentAngle;
561
                ctrl.DashSize = this.DashSize;
562
                ctrl.Name = this.GetType().Name.ToString();
563 036650a0 humkyung
                ///강인구 추가(2017.11.02)
564
                ///Memo 추가
565 b2d0f316 humkyung
                ctrl.Memo = this.Memo;
566 fd19a116 humkyung
                ctrl.Index = this.Index;
567 b2d0f316 humkyung
                ctrl.ZIndex = this.ZIndex;
568 e1b36bc0 humkyung
                ctrl.GroupID = this.GroupID;
569 b2d0f316 humkyung
570
                return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize()));
571 036650a0 humkyung
            }
572
        }
573
574 661b7416 humkyung
        /// <summary>
575
        /// create a tricontrol from given string
576
        /// </summary>
577
        /// <param name="str"></param>
578
        /// <returns></returns>
579
        public static TriControl FromString(string str, SolidColorBrush brush, string sProjectNo)
580
        {
581
            using (S_TriControl s = JsonSerializerHelper.JsonDeserialize<S_TriControl>(str))
582
            {
583
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
584
                return new TriControl
585
                {
586
                    LineSize = Convert.ToDouble(data2.First()),
587
                    MidPoint = s.MidPoint,
588
                    StartPoint = s.StartPoint,
589
                    Paint = s.Paint,
590
                    EndPoint = s.EndPoint,
591
                    Opacity = s.Opac,
592 fa48eb85 taeseongkim
                    CommentAngle = s.Angle,
593 661b7416 humkyung
                    DashSize = s.DashSize,
594
                    PointSet = s.PointSet,
595
                    StrokeColor = brush,
596
                    UserID = s.UserID,
597 b2d0f316 humkyung
                    Memo = s.Memo,
598 fd19a116 humkyung
                    Index = s.Index,
599 e1b36bc0 humkyung
                    ZIndex = s.ZIndex,
600
                    GroupID = s.GroupID
601 661b7416 humkyung
                };
602
            }
603
        }
604
605 a6272c57 humkyung
        /// <summary>
606
        /// 정삼각형을 그리기위한 두 포인트를 계산하여 넘겨줌
607
        /// </summary>
608
        /// <author>humkyung</author>
609
        /// <date>2018.04.26</date>
610
        /// <param name="StartP"></param>
611
        /// <param name="EndP"></param>
612
        /// <returns></returns>
613
        /// <history>humkyung 2018.05.11 apply axis lock</history>
614
        private List<Point> GetRegularTrianglePoints(Point StartP, Point EndP, bool bCheckAxis = false)
615
        {
616
            List<Point> res = new List<Point>();
617
618
            double dx = EndP.X - StartP.X;
619
            double dy = EndP.Y - StartP.Y;
620
            double length = Math.Sqrt(dx * dx + dy * dy);
621
            double baseLength = length * Math.Tan(30.0 * Math.PI / 180.0);
622
            dx /= length;
623
            dy /= length;
624
            double tmp = dx;
625
            dx = -dy; dy = tmp; /// rotate by 90 degree
626
627
            res.Add(new Point(EndP.X + dx * baseLength, EndP.Y + dy * baseLength));
628
            res.Add(new Point(EndP.X - dx * baseLength, EndP.Y - dy * baseLength));
629
630
            return res;
631
        }
632 787a4489 KangIngu
    }
633
}
클립보드 이미지 추가 (최대 크기: 500 MB)