프로젝트

일반

사용자정보

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

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

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