프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Text / ArrowTextControl.cs @ e1b36bc0

이력 | 보기 | 이력해설 | 다운로드 (83 KB)

1
using MarkupToPDF.Controls.Common;
2
using System;
3
using System.Collections.Generic;
4
using System.ComponentModel;
5
using System.Linq;
6
using System.Text;
7
using System.Threading.Tasks;
8
using System.Windows;
9
using System.Windows.Controls;
10
using System.Windows.Media;
11
using System.Windows.Shapes;
12
using MarkupToPDF.Controls.Custom;
13
using MarkupToPDF.Common;
14
using MarkupToPDF.Serialize.Core;
15
using MarkupToPDF.Serialize.S_Control;
16
using Markus.Fonts;
17

    
18
namespace MarkupToPDF.Controls.Text
19
{
20
    public class ArrowTextControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, ITextControl, IMarkupControlData,ICommentRect
21
    {
22
        private const string PART_ArrowPath = "PART_ArrowPath";
23
        private const string PART_TextBox = "PART_ArrowTextBox";
24
        //private const string PART_TextBlock = "PART_ArrowTextBlock";
25
        private const string PART_ArrowSubPath = "PART_ArrowSubPath";
26
        private const string PART_Border = "PART_Border";
27
        private const string PART_BaseTextbox_Caret = "Caret";
28

    
29
        public Path Base_ArrowPath = null;
30
        public Path Base_ArrowSubPath = null;
31
        public TextBox Base_TextBox = null;
32
        public TextBlock Base_TextBlock = null;
33
        public Border BaseTextbox_Caret = null;
34
        public event EventHandler<EventArgs> EditEnded;
35

    
36

    
37
        private const double _CloudArcDepth = 0.8;  /// 2018.05.14 added by humkyung
38

    
39
        #region Object & Variable
40
        GeometryGroup instanceGroup = new GeometryGroup();
41
        
42
        Path Cemy = new Path();
43
        LineGeometry connectorSMGeometry = new LineGeometry();
44
        LineGeometry connectorMEGeometry = new LineGeometry();
45

    
46
        public enum ArrowTextStyleSet { Normal, Cloud, Rect };
47

    
48
        #endregion
49

    
50
        static ArrowTextControl()
51
        {
52
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ArrowTextControl), new FrameworkPropertyMetadata(typeof(ArrowTextControl)));
53
            //ResourceDictionary dictionary = new ResourceDictionary();
54
            //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
55
            //if(!Application.Current.Resources.MergedDictionaries.Any(x=>x.Source == dictionary.Source))
56
            //    Application.Current.Resources.MergedDictionaries.Add(dictionary);
57
        }
58

    
59
        public ArrowTextControl() :base()
60
        {
61
            //this.DefaultStyleKey = typeof(ArrowTextControl);
62
        }
63

    
64
        public override void Copy(CommentUserInfo lhs)
65
        {
66
            if (lhs is ArrowTextControl item)
67
            {
68
                this.PageAngle = item.PageAngle;
69
                this.LineSize = item.LineSize;
70
                this.PointSet = item.PointSet.ConvertAll(x => new Point(x.X, x.Y));
71
                this.StartPoint = new Point(item.StartPoint.X, item.StartPoint.Y);
72
                this.EndPoint = new Point(item.EndPoint.X, item.EndPoint.Y);
73
                this.StrokeColor = item.StrokeColor;
74
                this.ArcLength = item.ArcLength;
75
                //this.DashSize = s.DashSize; 
76
                this.ArrowTextStyle = item.ArrowTextStyle;
77
                this.isHighLight = item.isHighLight;
78
                this.ArrowText = item.ArrowText;
79
                this.Opacity = item.Opacity;
80
                this.BorderSize = item.BorderSize;
81
                this.BoxWidth = item.BoxWidth;
82
                this.BoxHeight = item.BoxHeight;
83
                this.isFixed = item.isFixed;
84
                //this.VisualPageAngle = s.Angle;
85
                this.UserID = item.UserID;
86
                this.isTrans = item.isTrans;
87
                this.MidPoint = item.MidPoint;
88
                this.Memo = item.Memo;
89
                this.TextFamily = item.TextFamily;
90
                this.TextStyle = item.TextStyle;
91
                this.TextWeight = item.TextWeight;
92
                this.TextSize = item.TextSize;
93
                this.UnderLine = item.UnderLine;
94
                this.GroupID = item.GroupID;
95
            }
96
        }
97

    
98
        public override CommentUserInfo Clone()
99
        {
100
            var clone = new ArrowTextControl();
101
            clone.Copy(this);
102
            return clone;
103
        }
104

    
105
        public override void OnApplyTemplate()
106
        {
107
            base.OnApplyTemplate();
108
            Base_ArrowPath = GetTemplateChild(PART_ArrowPath) as Path;
109
            Base_ArrowSubPath = GetTemplateChild(PART_ArrowSubPath) as Path;
110
            Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox;
111
            BaseTextbox_Caret = GetTemplateChild(PART_BaseTextbox_Caret) as Border;
112
            Base_TextBox.FontFamily = this.TextFamily;
113
            if (Base_TextBox != null)
114
            {
115
                this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length;
116
                this.Base_TextBox.CaretBrush = new SolidColorBrush(Colors.Transparent);
117
                
118
                if (this.ArrowTextStyle == ArrowTextStyleSet.Cloud)
119
                {
120
                    
121
                }
122

    
123
                this.Base_TextBox.ApplyTemplate();
124
                this.Base_TextBox.Text = this.ArrowText;
125

    
126
                MoveCustomCaret();
127

    
128
                Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged);
129
                Base_TextBox.GotFocus += new RoutedEventHandler(Base_TextBox_GotFocus);
130
                Base_TextBox.LostFocus += new RoutedEventHandler(Base_TextBox_LostFocus);
131
                Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret();
132
                this.KeyDown += ArrowTextControl_KeyDown;
133

    
134
                SetArrowTextPath(true);
135

    
136
                Base_TextBox.IsTabStop = true;
137
            }
138
        }
139

    
140
        private void ArrowTextControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
141
        {
142
           if(e.Key == System.Windows.Input.Key.Escape)
143
            {
144
                if(string.IsNullOrEmpty(Base_TextBox.Text))
145
                {
146
                    this.Visibility = Visibility.Collapsed;
147
                }
148

    
149
                EditEnd();
150
            }
151
        }
152

    
153
        public void SetFontFamily(FontFamily fontFamily)
154
        {
155
            if (this.Base_TextBlock != null)
156
            {
157
                this.Base_TextBlock.FontFamily = fontFamily;
158
            }
159

    
160
            if (this.Base_TextBox != null)
161
            {
162
                this.Base_TextBox.FontFamily = fontFamily;
163
            }
164
            this.FontFamily = fontFamily;
165
            this.TextFamily = fontFamily;
166
        }
167

    
168
        /// <summary>
169
        /// Moves the custom caret on the canvas.
170
        /// </summary>
171
        public void MoveCustomCaret()
172
        {
173
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
174

    
175
            var angle = Math.Abs(this.PageAngle);
176
            //angle = 0;
177
            System.Diagnostics.Debug.WriteLine("Page Angle : " +  this.PageAngle);
178

    
179
            if (!double.IsInfinity(caretLocation.X))
180
            {
181
                if (angle == 90)
182
                {
183
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.Y);
184
                }
185
                else if (angle == 180)
186
                {
187
                    
188
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X+ this.Base_TextBox.ActualWidth) - caretLocation.X) ;
189
                    System.Diagnostics.Debug.WriteLine("Caret X : " + ((this.EndPoint.X + this.Base_TextBox.ActualWidth) - caretLocation.X));
190
                } 
191
                else if (angle == 270)
192
                {
193
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X) - caretLocation.Y);
194
                }
195
                else
196
                {
197
                    System.Diagnostics.Debug.WriteLine("Caret X : " + (this.EndPoint.X - caretLocation.X));
198
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.X);
199
                } 
200
            }
201

    
202
            if (!double.IsInfinity(caretLocation.Y))
203
            {
204
                if (angle == 90)
205
                {
206
                    Canvas.SetTop(this.BaseTextbox_Caret, this.EndPoint.Y - caretLocation.X);
207
                }
208
                else if (angle == 180)
209
                {//보정치40
210
                    Canvas.SetTop(this.BaseTextbox_Caret, ((this.EndPoint.Y -40) + this.Base_TextBox.ActualHeight)- caretLocation.Y );
211
                    System.Diagnostics.Debug.WriteLine("Caret Y : " + (((this.EndPoint.Y - 40) + this.Base_TextBox.ActualHeight) - caretLocation.Y));
212
                }
213
                else if (angle == 270)
214
                {
215
                    Canvas.SetTop(this.BaseTextbox_Caret, (this.EndPoint.Y) + caretLocation.X);
216
                }
217
                else
218
                {
219
                    Canvas.SetTop(this.BaseTextbox_Caret, this.EndPoint.Y  + caretLocation.Y);
220
                    System.Diagnostics.Debug.WriteLine("Caret Y : " + (this.EndPoint.Y + caretLocation.Y - BaseTextbox_Caret.ActualHeight));
221
                }
222
            }
223
        }
224

    
225
        public void MoveCustomCaret(Point point)
226
        {
227

    
228
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
229

    
230
            if (!double.IsInfinity(caretLocation.X))
231
            {
232
                if (Math.Abs(this.PageAngle) == 90)
233
                {
234
                    Canvas.SetLeft(this.BaseTextbox_Caret, point.X + caretLocation.Y);
235
                }
236
                else if (Math.Abs(this.PageAngle) == 180)
237
                {
238

    
239
                    Canvas.SetLeft(this.BaseTextbox_Caret, (point.X + this.Base_TextBox.ActualWidth) - caretLocation.X);
240
                }
241
                else if (Math.Abs(this.PageAngle) == 270)
242
                {
243
                    Canvas.SetLeft(this.BaseTextbox_Caret, (point.X) - caretLocation.Y);
244
                }
245
                else
246
                {
247
                    Canvas.SetLeft(this.BaseTextbox_Caret, point.X + caretLocation.X);
248
                }
249
            }
250

    
251
            if (!double.IsInfinity(caretLocation.Y))
252
            {
253
                if (Math.Abs(this.PageAngle) == 90)
254
                {
255
                    Canvas.SetTop(this.BaseTextbox_Caret, point.Y - caretLocation.X);
256
                }
257
                else if (Math.Abs(this.PageAngle) == 180)
258
                {
259
                    Canvas.SetTop(this.BaseTextbox_Caret, (point.Y + this.Base_TextBox.ActualHeight) - caretLocation.Y);
260
                }
261
                else if (Math.Abs(this.CommentAngle) == 270)
262
                {
263
                    Canvas.SetTop(this.BaseTextbox_Caret, (point.Y) + caretLocation.X);
264
                }
265
                else
266
                {
267
                    Canvas.SetTop(this.BaseTextbox_Caret, point.Y + caretLocation.Y);
268
                }
269
            }
270
        }
271

    
272

    
273
        void Base_TextBox_LostFocus(object sender, RoutedEventArgs e)
274
        {
275
            EditEnd();
276
        }
277

    
278
        private void EditEnd()
279
        { 
280
            this.ArrowText = Base_TextBox.Text;
281
            Base_TextBox.Focusable = false;
282
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
283
            this.IsEditingMode = false;
284
            ApplyOverViewData();
285

    
286
            if(EditEnded != null)
287
            {
288
                EditEnded(this, new EventArgs());
289
            }
290

    
291
        }
292

    
293
        void Base_TextBox_GotFocus(object sender, RoutedEventArgs e)
294
        {
295
            this.BaseTextbox_Caret.Visibility = Visibility.Visible;
296
            MoveCustomCaret();
297
            Base_TextBox.Focus();
298
            this.IsEditingMode = true;
299
        }
300

    
301
        void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e)
302
        {
303
            if(this.IsEditingMode)
304
            {
305
                if (Base_TextBox.Text.Contains("|OR||DZ|"))
306
                {
307
                    Base_TextBox.Text = this.ArrowText;
308
                }
309

    
310
                this.ArrowText = Base_TextBox.Text;
311
                
312
            }
313
            BoxWidth = e.NewSize.Width;
314
            BoxHeight = e.NewSize.Height;
315
            SetArrowTextPath();
316
        }
317

    
318
        #region Properties
319
        private bool _IsEditingMode;
320
        public bool IsEditingMode
321
        {
322
            get
323
            {
324
                return _IsEditingMode;
325
            }
326
            set
327
            {
328
                _IsEditingMode = value;
329
                OnPropertyChanged("IsEditingMode");
330
            }
331
        }
332

    
333

    
334
        #endregion
335

    
336
        #region dp Properties
337
        //강인구 주석 풀기
338
        public Visibility TextBoxVisibility
339
        {
340
            get { return (Visibility)GetValue(TextBoxVisibilityProperty); }
341
            set
342
            {
343
                if (this.TextBoxVisibility != value)
344
                {
345
                    SetValue(TextBoxVisibilityProperty, value);
346
                    OnPropertyChanged("TextBoxVisibility");
347
                }
348
            }
349
        }
350

    
351
        //강인구 주석 풀기
352
        public Visibility TextBlockVisibility
353
        {
354
            get { return (Visibility)GetValue(TextBlockVisibilityProperty); }
355
            set
356
            {
357
                if (this.TextBlockVisibility != value)
358
                {
359
                    SetValue(TextBlockVisibilityProperty, value);
360
                    OnPropertyChanged("TextBlockVisibility");
361
                }
362
            }
363
        }
364

    
365

    
366
        public override SolidColorBrush StrokeColor
367
        {
368
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
369
            set
370
            {
371
                if (this.StrokeColor != value)
372
                {
373
                    SetValue(StrokeColorProperty, value);
374
                }
375
            }
376
        }
377

    
378
        public Double ArcLength
379
        {
380
            get { return (Double)GetValue(ArcLengthProperty); }
381
            set
382
            {
383
                if (this.ArcLength != value)
384
                {
385
                    SetValue(ArcLengthProperty, value);
386
                    OnPropertyChanged("ArcLength");
387
                }
388
            }
389
        }
390

    
391
        public PathGeometry SubPathData
392
        {
393
            get { return (PathGeometry)GetValue(SubPathDataProperty); }
394
            set
395
            {
396
                if (this.SubPathData != value)
397
                {
398
                    SetValue(SubPathDataProperty, value);
399
                }
400
            }
401
        }
402

    
403
        public string UserID
404
        {
405
            get { return (string)GetValue(UserIDProperty); }
406
            set
407
            {
408
                if (this.UserID != value)
409
                {
410
                    SetValue(UserIDProperty, value);
411
                    OnPropertyChanged("UserID");
412
                }
413
            }
414
        }
415

    
416
        public List<Point> PointSet
417
        {
418
            get { return (List<Point>)GetValue(PointSetProperty); }
419
            set { SetValue(PointSetProperty, value); }
420
        }
421

    
422
        public override bool IsSelected
423
        {
424
            get
425
            {
426
                return (bool)GetValue(IsSelectedProperty);
427
            }
428
            set
429
            {
430
                SetValue(IsSelectedProperty, value);
431
                OnPropertyChanged("IsSelected");
432
            }
433
        }
434

    
435
        public override ControlType ControlType
436
        {
437
            set
438
            {
439
                SetValue(ControlTypeProperty, value);
440
                OnPropertyChanged("ControlType");
441
            }
442
            get
443
            {
444
                return (ControlType)GetValue(ControlTypeProperty);
445
            }
446
        }
447

    
448
        public Point StartPoint
449
        {
450
            get { return (Point)GetValue(StartPointProperty); }
451
            set { SetValue(StartPointProperty, value); }
452
        }
453

    
454
        public Point EndPoint
455
        {
456
            get { return (Point)GetValue(EndPointProperty); }
457
            set { SetValue(EndPointProperty, value); }
458
        }
459

    
460
        public Point OverViewStartPoint
461
        {
462
            get { return (Point)GetValue(OverViewStartPointProperty); }
463
            set { SetValue(OverViewStartPointProperty, value); }
464
        }
465

    
466
        public Point OverViewEndPoint
467
        {
468
            get { return (Point)GetValue(OverViewEndPointProperty); }
469
            set { SetValue(OverViewEndPointProperty, value); }
470
        }
471

    
472

    
473
        //public double Angle
474
        //{
475
        //    get { return (double)GetValue(AngleProperty); }
476
        //    set { SetValue(AngleProperty, value); }
477
        //}
478

    
479
        public Thickness BorderSize
480
        {
481
            get { return (Thickness)GetValue(BorderSizeProperty); }
482
            set
483
            {
484
                if (this.BorderSize != value)
485
                {
486
                    SetValue(BorderSizeProperty, value);
487
                }
488
            }
489
        }
490

    
491

    
492
        public Point MidPoint
493
        {
494
            get { return (Point)GetValue(MidPointProperty); }
495
            set { SetValue(MidPointProperty, value); }
496
        }
497

    
498
        public bool isFixed
499
        {
500
            get { return (bool)GetValue(IsFixedProperty); }
501
            set { SetValue(IsFixedProperty, value); }
502
        }
503

    
504
        public bool isTrans
505
        {
506
            get { return (bool)GetValue(TransformerProperty); }
507
            set { SetValue(TransformerProperty, value); }
508
        }
509

    
510
        public bool isHighLight
511
        {
512
            get { return (bool)GetValue(isHighlightProperty); }
513
            set
514
            {
515
                if (this.isHighLight != value)
516
                {
517
                    SetValue(isHighlightProperty, value);
518
                    OnPropertyChanged("isHighLight");
519
                }
520
            }
521
        }
522

    
523
        public FontWeight TextWeight
524
        {
525
            get { return (FontWeight)GetValue(TextWeightProperty); }
526
            set
527
            {
528
                if (this.TextWeight != value)
529
                {
530
                    SetValue(TextWeightProperty, value);
531
                    OnPropertyChanged("TextWeight");
532
                }
533
            }
534
        }
535

    
536
        public Double LineSize
537
        {
538
            get { return (Double)GetValue(LineSizeProperty); }
539
            set
540
            {
541
                if (this.LineSize != value)
542
                {
543
                    SetValue(LineSizeProperty, value);
544
                }
545
            }
546
        }
547

    
548
        public Double BoxWidth
549
        {
550
            get { return (Double)GetValue(BoxWidthProperty); }
551
            set
552
            {
553
                if (this.BoxWidth != value)
554
                {
555
                    SetValue(BoxWidthProperty, value);
556
                }
557
            }
558
        }
559

    
560
        public Double BoxHeight
561
        {
562
            get { return (Double)GetValue(BoxHeightProperty); }
563
            set
564
            {
565
                if (this.BoxHeight != value)
566
                {
567
                    SetValue(BoxHeightProperty, value);
568
                }
569
            }
570
        }
571

    
572
        public ArrowTextStyleSet ArrowTextStyle
573
        {
574
            get { return (ArrowTextStyleSet)GetValue(ArrowTextStyleProperty); }
575
            set
576
            {
577
                if (this.ArrowTextStyle != value)
578
                {
579
                    SetValue(ArrowTextStyleProperty, value);
580
                }
581
            }
582
        }
583

    
584
        public Geometry PathData
585
        {
586
            get { return (Geometry)GetValue(PathDataProperty); }
587
            set { SetValue(PathDataProperty, value);
588

    
589
                OnPropertyChanged("PathData");
590
            }
591
        }
592

    
593
        public SolidColorBrush BackInnerColor
594
        {
595
            get { return (SolidColorBrush)GetValue(BackInnerColorProperty); }
596
            set
597
            {
598
                if (this.BackInnerColor != value)
599
                {
600
                    SetValue(BackInnerColorProperty, value);
601
                    OnPropertyChanged("BackInnerColor");
602
                }
603
            }
604
        }
605

    
606
        public Geometry PathDataInner
607
        {
608
            get { return (Geometry)GetValue(PathDataInnerProperty); }
609
            set
610
            {
611
                SetValue(PathDataInnerProperty, value);
612
                OnPropertyChanged("PathDataInner");
613
            }
614
        }
615

    
616
        public Geometry OverViewPathData
617
        {
618
            get { return (Geometry)GetValue(OverViewPathDataProperty); }
619
            set { SetValue(OverViewPathDataProperty, value);
620

    
621
                OnPropertyChanged("OverViewPathData");
622

    
623
            }
624
        }
625

    
626
        public FontFamily TextFamily
627
        {
628
            get { return (FontFamily)GetValue(TextFamilyProperty); }
629
            set
630
            {
631
                if (this.TextFamily != value)
632
                {
633
                    SetValue(TextFamilyProperty, value);
634
                    OnPropertyChanged("TextFamily");
635
                }
636
            }
637
        }
638

    
639
        public string ArrowText
640
        {
641
            get { return (string)GetValue(ArrowTextProperty); }
642
            set
643
            {
644
                if (this.ArrowText != value)
645
                {
646
                    SetValue(ArrowTextProperty, value);
647
                    OnPropertyChanged("ArrowText");
648
                }
649
            }
650
        }
651

    
652
        public string OverViewArrowText
653
        {
654

    
655
            get { return (string)GetValue(OverViewArrowTextProperty);
656
            }
657
            set
658
            {
659
                if (this.OverViewArrowText != value)
660
                {
661
                    SetValue(OverViewArrowTextProperty, value);
662
                    OnPropertyChanged("OverViewArrowText");
663
                }
664
            }
665
        }
666

    
667
        public Double TextSize
668
        {
669
            get { return (Double)GetValue(TextSizeProperty); }
670
            set
671
            {
672
                if (this.TextSize != value)
673
                {
674
                    SetValue(TextSizeProperty, value);
675
                    OnPropertyChanged("TextSize");
676
                }
677
            }
678
        }
679

    
680
        public FontStyle TextStyle
681
        {
682
            get { return (FontStyle)GetValue(TextStyleProperty); }
683
            set
684
            {
685
                if (this.TextStyle != value)
686
                {
687
                    SetValue(TextStyleProperty, value);
688
                    OnPropertyChanged("TextStyle");
689
                }
690
            }
691
        }
692

    
693
        //강인구 추가
694
        public TextDecorationCollection UnderLine
695
        {
696
            get
697
            {
698
                return (TextDecorationCollection)GetValue(UnderLineProperty);
699
            }
700
            set
701
            {
702
                if (this.UnderLine != value)
703
                {
704
                    SetValue(UnderLineProperty, value);
705
                    OnPropertyChanged("UnderLine");
706
                }
707
            }
708
        }
709

    
710
        public double CanvasX
711
        {
712
            get { return (double)GetValue(CanvasXProperty); }
713
            set
714
            {
715
                if (this.CanvasX != value)
716
                {
717
                    SetValue(CanvasXProperty, value);
718
                    OnPropertyChanged("CanvasX");
719
                }
720
            }
721
        }
722

    
723
        public double CanvasY
724
        {
725
            get { return (double)GetValue(CanvasYProperty); }
726
            set
727
            {
728
                if (this.CanvasY != value)
729
                {
730
                    SetValue(CanvasYProperty, value);
731
                    OnPropertyChanged("CanvasY");
732
                }
733
            }
734
        } 
735

    
736
        public double CenterX
737
        {
738
            get { return (double)GetValue(CenterXProperty); }
739
            set { SetValue(CenterXProperty, value);
740
            OnPropertyChanged("CenterX");
741
            
742
            }
743
        }
744

    
745
        public double CenterY
746
        {
747
            get { return (double)GetValue(CenterYProperty); }
748
            set { SetValue(CenterYProperty, value);
749
            OnPropertyChanged("CenterY");
750
            }
751
        }
752

    
753
        public Brush SubPathFill
754
        {
755
            get { return (Brush)GetValue(SubPathFillProperty); }
756
            set
757
            {
758
                SetValue(SubPathFillProperty, value);
759
                OnPropertyChanged("SubPathFill");
760
            }
761
        }
762

    
763
        public Brush TextBoxBackground
764
        {
765
            get { return (Brush)GetValue(TextBoxBackgroundProperty); }
766
            set
767
            {
768
                SetValue(TextBoxBackgroundProperty, value);
769
                OnPropertyChanged("TextBoxBackground");
770
            }
771
        }
772

    
773

    
774
        //강인구 추가 주석풀기
775
       
776

    
777
        public bool EnableEditing
778
        {
779
            get { return (bool)GetValue(EnableEditingProperty); }
780
            set
781
            {
782
                if (this.EnableEditing != value)
783
                {
784
                    SetValue(EnableEditingProperty, value);
785
                    OnPropertyChanged("EnableEditing");
786
                }
787
            }
788
        }
789

    
790
        #endregion
791

    
792
        #region Dependency Properties
793

    
794
        public static readonly DependencyProperty BoxWidthProperty = DependencyProperty.Register(
795
                "BoxWidth", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
796

    
797
        public static readonly DependencyProperty BoxHeightProperty = DependencyProperty.Register(
798
                "BoxHeight", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
799

    
800
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
801
                "UserID", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
802

    
803
        public static readonly DependencyProperty ArrowTextStyleProperty = DependencyProperty.Register(
804
               "ArrowTextStyle", typeof(ArrowTextStyleSet), typeof(ArrowTextControl), new PropertyMetadata(ArrowTextStyleSet.Normal));
805

    
806
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register(
807
                "CenterX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
808

    
809
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register(
810
                "CenterY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
811

    
812
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register(
813
                "Angle", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(PointValueChanged)));
814
        
815
        public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
816
                "CanvasX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
817

    
818
        public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
819
                "CanvasY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
820

    
821
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
822
                "PointSet", typeof(List<Point>), typeof(ArrowTextControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
823

    
824
        public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register(
825
                "TextFamily", typeof(FontFamily), typeof(ArrowTextControl), new PropertyMetadata(new FontFamily("Arial"), TextChanged));
826

    
827
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
828
                "PathData", typeof(Geometry), typeof(ArrowTextControl), null);
829

    
830
        //강인구 추가
831
        public static readonly DependencyProperty UnderLineProperty = DependencyProperty.Register(
832
    "UnderLine", typeof(TextDecorationCollection), typeof(ArrowTextControl), new PropertyMetadata(null, PointValueChanged));
833

    
834
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
835
               "LineSize", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)3, PointValueChanged));
836

    
837
        public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register(
838
                "TextStyle", typeof(FontStyle), typeof(ArrowTextControl), new PropertyMetadata(FontStyles.Normal));
839

    
840
        public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register(
841
                "TextSize", typeof(Double), typeof(ArrowTextControl), new PropertyMetadata((Double)30, PointValueChanged));
842

    
843
        public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register(
844
                "TextWeight", typeof(FontWeight), typeof(ArrowTextControl), new PropertyMetadata(FontWeights.Normal));
845

    
846
        public static readonly DependencyProperty IsFixedProperty = DependencyProperty.Register(
847
                "isFixed", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
848

    
849
        public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
850
                "IsSelected", typeof(bool), typeof(ArrowTextControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
851

    
852
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
853
                "StrokeColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
854

    
855
        public static readonly DependencyProperty ArcLengthProperty = DependencyProperty.Register(
856
            "ArcLength", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)10, PointValueChanged));
857

    
858
        public static readonly DependencyProperty ControlTypeProperty = DependencyProperty.Register(
859
                "ControlType", typeof(ControlType), typeof(ArrowTextControl), new FrameworkPropertyMetadata(ControlType.ArrowTextControl));
860

    
861
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
862
                "StartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
863

    
864
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
865
                "EndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
866

    
867
        public static readonly DependencyProperty BackInnerColorProperty = DependencyProperty.Register(
868
            "BackInnerColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.White)));
869

    
870
        public static readonly DependencyProperty PathDataInnerProperty = DependencyProperty.Register(
871
    "PathDataInner", typeof(Geometry), typeof(ArrowTextControl), null);
872

    
873
        public static readonly DependencyProperty isHighlightProperty = DependencyProperty.Register(
874
                "isHighlight", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
875

    
876
        public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register(
877
                "MidPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
878

    
879
        public static readonly DependencyProperty TransformerProperty = DependencyProperty.Register(
880
                "isTrans", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
881

    
882
        public static readonly DependencyProperty BorderSizeProperty = DependencyProperty.Register(
883
                "BorderSize", typeof(Thickness), typeof(ArrowTextControl), new PropertyMetadata(new Thickness(0), PointValueChanged));
884
    
885
        public static readonly DependencyProperty ArrowTextProperty = DependencyProperty.Register(
886
              "ArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
887

    
888

    
889

    
890
        //, new PropertyChangedCallback(TextChanged)
891

    
892

    
893
        #region 추가 사항
894
        public static readonly DependencyProperty SubPathDataProperty = DependencyProperty.Register(
895
                "SubPathData", typeof(Geometry), typeof(ArrowTextControl), null);
896

    
897

    
898
        public static readonly DependencyProperty SubPathFillProperty = DependencyProperty.Register(
899
                "SubPathFill", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(null));
900

    
901
        public static readonly DependencyProperty TextBoxBackgroundProperty = DependencyProperty.Register(
902
                "TextBoxBackground", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(Brushes.White));
903

    
904
        public static readonly DependencyProperty OverViewArrowTextProperty = DependencyProperty.Register(
905
                "OverViewArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null, new PropertyChangedCallback(TextChanged)));
906

    
907
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
908
                "OverViewPathData", typeof(Geometry), typeof(ArrowTextControl), null);
909

    
910
        public static readonly DependencyProperty OverViewStartPointProperty = DependencyProperty.Register(
911
                "OverViewStartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
912

    
913
        public static readonly DependencyProperty OverViewEndPointProperty = DependencyProperty.Register(
914
                "OverViewEndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
915

    
916
        public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register(
917
            "TextBoxVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged));
918

    
919
        //강인구 추가(주석풀기)
920
        public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register(
921
            "TextBlockVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged));
922

    
923
        public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register(
924
           "EnableEditing", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata((true), new PropertyChangedCallback(OnIsEditingChanged)));
925

    
926
        #endregion
927

    
928
        #endregion
929

    
930
        #region CallBack Method
931

    
932
        //강인구 추가(주석풀기)
933
        public static void OnIsEditingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
934
        {
935
            var instance = (ArrowTextControl)sender;
936

    
937
            if (e.OldValue != e.NewValue && instance.Base_TextBlock != null)
938
            {
939
                instance.SetValue(e.Property, e.NewValue);
940

    
941
                if (instance.EnableEditing)
942
                {
943
                    instance.EditingMode();
944
                }
945
                else
946
                {
947
                    instance.UnEditingMode();
948
                }
949
            }
950
        }
951

    
952
        public static void OnTextBoxVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
953
        {
954
            var instance = (ArrowTextControl)sender;
955

    
956
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
957
            {
958
                instance.SetValue(e.Property, e.NewValue);
959
            }
960
        }
961

    
962
        public static void OnTextBlockVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
963
        {
964
            var instance = (ArrowTextControl)sender;
965

    
966
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
967
            {
968
                instance.SetValue(e.Property, e.NewValue);
969
            }
970
        }
971

    
972
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
973
        {
974
            var instance = (ArrowTextControl)sender;
975

    
976
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
977
            {
978
                instance.SetArrowTextPath();
979
            }
980
        }
981

    
982

    
983

    
984
        public static void TextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
985
        {
986
            var instance = (ArrowTextControl)sender;
987
            
988
            if (e.OldValue != e.NewValue)
989
            {
990
                instance.SetValue(e.Property, e.NewValue);
991
                //instance.BoxWidth = instance.Base_TextBox.ActualWidth;
992
                //instance.BoxHeight = instance.Base_TextBox.ActualHeight;
993
            }
994
        }
995

    
996
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
997
        {
998
            var instance = (ArrowTextControl)sender;
999
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
1000
            {
1001
                instance.SetValue(e.Property, e.NewValue);
1002
                instance.SetArrowTextPath();
1003
            }
1004
        }
1005

    
1006
        public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1007
        {
1008
            var instance = (ArrowTextControl)sender;
1009

    
1010
            if (e.OldValue != e.NewValue && instance != null)
1011
            {
1012
                instance.SetValue(e.Property, e.NewValue);
1013
                //Canvas.SetLeft(instance, instance.CanvasX);
1014
                //Canvas.SetTop(instance, instance.CanvasY);
1015
            }
1016
        }
1017

    
1018
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1019
        {
1020
            //var instance = (ArrowTextControl)sender;
1021

    
1022
            //if (e.OldValue != e.NewValue)
1023
            //{
1024
            //    instance.SetValue(e.Property, e.NewValue);
1025

    
1026
            //    if (instance.IsSelected && instance.Base_TextBox != null)
1027
            //    {
1028
            //        instance.BorderSize = new Thickness(1);
1029
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Blue);
1030
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Blue);
1031
            //    }
1032
            //    else
1033
            //    {
1034
            //        instance.BorderSize = new Thickness(0);
1035
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Transparent);
1036
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Transparent);
1037
            //    }
1038
            //}
1039
        }
1040
        #endregion
1041

    
1042
        #region Internal Method
1043

    
1044
        //강인구 주석 풀기
1045
        public void EditingMode()
1046
        {
1047
            TextBoxVisibility = Visibility.Visible;
1048
            TextBlockVisibility = Visibility.Collapsed;
1049

    
1050

    
1051
            //강인구 언더라인 추가
1052
            if (UnderLine != null)
1053
                Base_TextBlock.TextDecorations = UnderLine;
1054
        }
1055
        //강인구 주석 풀기
1056
        public void UnEditingMode()
1057
        {
1058
            TextBoxVisibility = Visibility.Collapsed;
1059
            TextBlockVisibility = Visibility.Visible;
1060

    
1061
            if (Base_TextBlock != null)
1062
            {
1063
                if (UnderLine != null)
1064
                    Base_TextBlock.TextDecorations = UnderLine;
1065

    
1066
                Base_TextBlock.Margin =
1067
                     new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4,
1068
                         Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4);
1069
            }
1070

    
1071
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
1072
        }
1073

    
1074
        private void SetArrowTextPath(bool IsInit = false)
1075
        {
1076
            instanceGroup.Children.Clear();
1077

    
1078
            //VisualPageAngle = 0;
1079

    
1080
            if (Math.Abs(PageAngle).ToString() == "90")
1081
            {
1082
                VisualPageAngle = 270;
1083
            }
1084
            else if (Math.Abs(PageAngle).ToString() == "270")
1085
            {
1086
                VisualPageAngle = 90;
1087
            }
1088
            else
1089
            {
1090
                VisualPageAngle = PageAngle;
1091
            }
1092

    
1093
            connectorSMGeometry.StartPoint = this.StartPoint;
1094
            connectorSMGeometry.EndPoint = this.MidPoint;
1095
            connectorMEGeometry.StartPoint = this.MidPoint; //핵심
1096

    
1097
            /// 텍스트박스의 좌표 설정
1098
            Canvas.SetLeft(Base_TextBox, this.EndPoint.X);
1099
            Canvas.SetTop(Base_TextBox, this.EndPoint.Y);
1100
            //System.Diagnostics.Debug.WriteLine($"TextBox Set {this.EndPoint.X},{this.EndPoint.Y}");
1101
            
1102

    
1103
            List<Point> ps = new List<Point>();
1104
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox))); //상단
1105
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox) + this.BoxHeight)); // 하단
1106
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2)); //좌단
1107
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2));  //우단
1108

    
1109
            if (isTrans)
1110
            {
1111
                switch (Math.Abs(this.PageAngle).ToString())
1112
                {
1113
                    case "90":
1114
                        {
1115
                            ps.Clear();
1116
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1117
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1118
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1119

    
1120
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1121
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1122

    
1123
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); //중간 하단
1124
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 하단
1125

    
1126
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간
1127
                        }
1128
                        break;
1129
                    case "270":
1130
                        {
1131
                            ps.Clear();
1132
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1133
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1134
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1135

    
1136
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1137
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1138

    
1139
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); //중간 하단
1140
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 하단
1141

    
1142
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간
1143
                        }
1144
                        break;
1145
                    default:
1146
                        break;
1147
                }
1148
                
1149
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1150

    
1151
                //20180911 LJY 꺾이는 부분 수정
1152
                Point testP = endP;                
1153
                switch (Math.Abs(this.PageAngle).ToString())
1154
                {
1155
                    case "90":
1156
                        testP = new Point(endP.X + 50, endP.Y);
1157
                        break;
1158
                    case "270":
1159
                        testP = new Point(endP.X - 50, endP.Y);
1160
                        break;
1161
                }                
1162

    
1163
                //20180910 LJY 각도에 따라.
1164
                switch (Math.Abs(this.PageAngle).ToString())
1165
                {
1166
                    case "90":
1167
                        if (isFixed)
1168
                        {
1169
                            if (ps[0] == endP) //상단
1170
                            {
1171
                                testP = new Point(endP.X , endP.Y + 50);
1172
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1173
                            }
1174
                            else if (ps[1] == endP) //하단
1175
                            {
1176
                                testP = new Point(endP.X , endP.Y - 50);
1177
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1178
                            }
1179
                            else if (ps[2] == endP) //좌단
1180
                            {
1181
                                testP = new Point(endP.X - 50, endP.Y);
1182
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1183
                            }
1184
                            else if (ps[3] == endP) //우단
1185
                            {
1186
                                testP = new Point(endP.X + 50, endP.Y);
1187
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1188
                            }
1189
                        }
1190
                        break;
1191
                    case "270":
1192
                        if (isFixed)
1193
                        {
1194
                            if (ps[0] == endP) //상단
1195
                            {
1196
                                testP = new Point(endP.X , endP.Y - 50);
1197
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1198
                            }
1199
                            else if (ps[1] == endP) //하단
1200
                            {
1201
                                testP = new Point(endP.X, endP.Y + 50);
1202
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1203
                            }
1204
                            else if (ps[2] == endP) //좌단
1205
                            {
1206
                                testP = new Point(endP.X + 50, endP.Y);
1207
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1208
                            }
1209
                            else if (ps[3] == endP) //우단
1210
                            {
1211
                                testP = new Point(endP.X - 50, endP.Y);
1212
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1213
                            }
1214
                        }
1215
                        break;
1216
                    default:
1217
                        if (isFixed)
1218
                        {
1219
                            if (ps[0] == endP) //상단
1220
                            {
1221
                                testP = new Point(endP.X, endP.Y - 50);
1222
                                //System.Diagnostics.Debug.WriteLine("상단");
1223
                            }
1224
                            else if (ps[1] == endP) //하단
1225
                            {
1226
                                testP = new Point(endP.X, endP.Y + 50);
1227
                                //System.Diagnostics.Debug.WriteLine("하단");
1228
                            }
1229
                            else if (ps[2] == endP) //좌단
1230
                            {
1231
                                testP = new Point(endP.X - 50, endP.Y);
1232
                                //System.Diagnostics.Debug.WriteLine("좌단");
1233
                            }
1234
                            else if (ps[3] == endP) //우단
1235
                            {
1236
                                testP = new Point(endP.X + 50, endP.Y);
1237
                                //System.Diagnostics.Debug.WriteLine("우단");
1238
                            }
1239
                        }
1240
                        break;
1241
                }
1242
                connectorMEGeometry.EndPoint = endP;
1243
                connectorSMGeometry.EndPoint = testP;
1244
                connectorMEGeometry.StartPoint = testP;
1245
                
1246
                //20180910 LJY 각도에 따라.
1247
                this.MidPoint = testP;
1248
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1249
                instanceGroup.FillRule = FillRule.Nonzero;
1250
                this.Base_ArrowPath.Fill = this.StrokeColor;
1251
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1252
            }
1253
            else
1254
            {
1255
                switch (Math.Abs(this.PageAngle).ToString())
1256
                {
1257
                    case "90":
1258
                        {
1259
                            ps.Clear();
1260

    
1261
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1262
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1263
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1264

    
1265
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1266
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1267

    
1268
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); //중간 하단
1269
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 하단
1270
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간 
1271
                        }
1272
                        break;
1273
                    case "270":
1274
                        {
1275
                            ps.Clear();
1276
                            
1277
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1278
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1279
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1280

    
1281
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1282
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1283

    
1284
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); //중간 하단
1285
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 하단
1286

    
1287
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1288
                        }
1289
                        break;
1290
                    //case "180":
1291
                    //    {
1292
                    //        ps.Clear();
1293

    
1294
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1295
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1296
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1297

    
1298
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1299
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1300

    
1301
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); //중간 하단
1302
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 하단
1303

    
1304
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1305
                    //    }
1306
                    //    break;
1307
                    default:
1308
                        break;
1309
                }
1310

    
1311

    
1312
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1313
                connectorMEGeometry.EndPoint = endP; //최상단
1314
                                                     //connectorMEGeometry.EndPoint = this.EndPoint; //핵심
1315
                                                     //this.MidPoint= MathSet.getMiddlePoint(this.StartPoint, endP);
1316
                #region 보정치
1317
                Point testP = endP;
1318

    
1319
                //20180910 LJY 각도에 따라.
1320
                switch (Math.Abs(this.PageAngle).ToString())
1321
                {
1322
                    case "90":
1323
                        if (isFixed)
1324
                        {
1325
                            if (ps[0] == endP) //상단
1326
                            {
1327
                                testP = new Point(endP.X - 50, endP.Y);
1328
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1329
                            }
1330
                            else if (ps[1] == endP) //하단
1331
                            {
1332
                                testP = new Point(endP.X + 50, endP.Y);
1333
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1334
                            }
1335
                            else if (ps[2] == endP) //좌단
1336
                            {
1337
                                testP = new Point(endP.X - 50, endP.Y);
1338
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1339
                            }
1340
                            else if (ps[3] == endP) //우단
1341
                            {
1342
                                testP = new Point(endP.X + 50 , endP.Y);
1343
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1344
                            }
1345
                        }
1346
                        break;
1347
                    case "270":
1348
                        if (isFixed)
1349
                        {
1350
                            if (ps[0] == endP) //상단
1351
                            {
1352
                                testP = new Point(endP.X + 50, endP.Y);
1353
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1354
                            }
1355
                            else if (ps[1] == endP) //하단
1356
                            {
1357
                                testP = new Point(endP.X - 50, endP.Y);
1358
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1359
                            }
1360
                            else if (ps[2] == endP) //좌단
1361
                            {
1362
                                testP = new Point(endP.X + 50, endP.Y);
1363
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1364
                            }
1365
                            else if (ps[3] == endP) //우단
1366
                            {
1367
                                testP = new Point(endP.X + 50, endP.Y );
1368
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1369
                            }
1370
                        }
1371
                        break;
1372
                    default:
1373
                        if (isFixed)
1374
                        {
1375
                            if (ps[0] == endP) //상단
1376
                            {
1377
                                testP = new Point(endP.X, endP.Y - 50);
1378
                                //System.Diagnostics.Debug.WriteLine("상단");
1379
                            }
1380
                            else if (ps[1] == endP) //하단
1381
                            {
1382
                                testP = new Point(endP.X, endP.Y + 50);
1383
                                //System.Diagnostics.Debug.WriteLine("하단");
1384
                            }
1385
                            else if (ps[2] == endP) //좌단
1386
                            {
1387
                                testP = new Point(endP.X - 50, endP.Y);
1388
                                //System.Diagnostics.Debug.WriteLine("좌단");
1389
                            }
1390
                            else if (ps[3] == endP) //우단
1391
                            {
1392
                                testP = new Point(endP.X + 50, endP.Y);
1393
                                //System.Diagnostics.Debug.WriteLine("우단");
1394
                            }
1395
                        }
1396
                        break;
1397
                }
1398
                  
1399

    
1400
                connectorSMGeometry.EndPoint = testP;
1401
                connectorMEGeometry.StartPoint = testP;
1402
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1403
                instanceGroup.FillRule = FillRule.Nonzero;
1404
                this.Base_ArrowPath.Fill = this.StrokeColor;
1405
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1406
                #endregion
1407
            }
1408

    
1409
            switch (this.ArrowTextStyle)
1410
            {
1411
                case ArrowTextStyleSet.Normal:
1412
                    this.BorderSize = new Thickness(0);
1413
                    DrawingRect();
1414
                    break;
1415
                case ArrowTextStyleSet.Cloud:
1416
                    this.BorderSize = new Thickness(0);
1417
                    DrawingCloud();
1418
                    break;
1419
                default:
1420
                    {
1421
                        this.BorderSize = new Thickness(LineSize);
1422
                        DrawingRect();
1423
                    }
1424

    
1425
                    break;
1426
            }
1427

    
1428
            if (isHighLight)
1429
            {
1430
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1431
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1432

    
1433
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1434
            }
1435
            else
1436
            {
1437
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1438
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1439
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1), Colors.White.R, Colors.White.G, Colors.White.B));
1440
            }
1441

    
1442
            instanceGroup.Children.Add(connectorSMGeometry);
1443
            instanceGroup.Children.Add(connectorMEGeometry);
1444

    
1445
            this.PathData = instanceGroup;
1446
            OverViewPathData = PathData;
1447
            OverViewArrowText = ArrowText;
1448
            OverViewEndPoint = connectorMEGeometry.EndPoint;
1449
            OverViewStartPoint = connectorSMGeometry.StartPoint;
1450

    
1451
            var tempAngle = Math.Abs(this.VisualPageAngle);
1452

    
1453
            if (tempAngle == Convert.ToDouble(90) || tempAngle == Convert.ToDouble(270))
1454
            {
1455
                this.RenderTransformOrigin = new Point(0.5, 0.5);
1456
                this.Base_ArrowPath.RenderTransformOrigin = new Point(0, 0);
1457
                this.Base_ArrowSubPath.RenderTransformOrigin = new Point(0, 0);
1458

    
1459
                Base_TextBox.RenderTransformOrigin = new Point(0, 0);
1460
                BaseTextbox_Caret.RenderTransformOrigin = new Point(0, 0);
1461
            }
1462

    
1463
            Base_TextBox.RenderTransform = new RotateTransform
1464
            {
1465
                Angle = this.VisualPageAngle,
1466
                CenterX = this.CenterX,
1467
                CenterY = this.CenterY,
1468
            };
1469

    
1470
            Base_ArrowSubPath.RenderTransform = new RotateTransform
1471
            {
1472
                Angle = this.VisualPageAngle,
1473
                CenterX = this.EndPoint.X,
1474
                CenterY = this.EndPoint.Y,
1475
            };
1476

    
1477
            if (BaseTextbox_Caret.Visibility == Visibility.Visible)
1478
            {
1479
                BaseTextbox_Caret.RenderTransform = new RotateTransform
1480
                {
1481
                    Angle = this.VisualPageAngle,
1482
                    CenterX = this.CenterX,
1483
                    CenterY = this.CenterY,
1484
                };
1485

    
1486
                MoveCustomCaret();
1487
            }
1488
        }
1489

    
1490
        private void DrawingCloud()
1491
        {
1492
            //20180906 LJY Textbox guide
1493
            string angle = Math.Abs(this.PageAngle).ToString();
1494
            //방지
1495
            if (this.ArcLength == 0) this.ArcLength = 10;
1496
            if (angle == "180")
1497
            {
1498
                List<Point> pCloud = new List<Point>()
1499
                {
1500
                     new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1501
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxHeight), //왼쪽 아래
1502
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox) - BoxHeight),
1503
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox)),
1504
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1505
                };
1506
                SubPathData = Generate(pCloud, this.ArcLength);
1507
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1508
            
1509
            }//20180906 LJY Textbox guide
1510
            else
1511
            {
1512
                var boxWidth = BoxWidth;
1513
                System.Diagnostics.Debug.WriteLine("disp Width : " + BoxWidth);
1514
                //boxWidth = boxWidth + Base_TextBox.Margin.Left + Base_TextBox.Margin.Right + Base_TextBox.Padding.Left + Base_TextBox.Padding.Right;
1515

    
1516
                List<Point> pCloud = new List<Point>()
1517
                {
1518
    #if SILVERLIGHT
1519
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1520
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1521
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1522
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1523
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1524

    
1525
    #else
1526
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize ), Canvas.GetTop(Base_TextBox) -(this.LineSize)), //위
1527
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize ), Canvas.GetTop(Base_TextBox)+ BoxHeight+(this.LineSize)), //왼쪽 아래
1528
                    new Point(Canvas.GetLeft(Base_TextBox)+ boxWidth+(this.LineSize ), Canvas.GetTop(Base_TextBox) + BoxHeight+(this.LineSize)),
1529
                    new Point(Canvas.GetLeft(Base_TextBox) + boxWidth+(this.LineSize ), Canvas.GetTop(Base_TextBox)-(this.LineSize)),
1530
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize), Canvas.GetTop(Base_TextBox)-(this.LineSize)), //위  
1531

    
1532
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1533
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1534
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1535
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1536
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1537
    #endif
1538
                };
1539
                //instanceGroup.Children.Add(Generate(pCloud));
1540
                SubPathData = Generate(pCloud, this.ArcLength);
1541
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1542
                //   }
1543
            }
1544

    
1545
        }
1546

    
1547
        private void DrawingRect()
1548
        {
1549
            //20180906 LJY Textbox guide
1550
            if(this.ArrowTextStyle == ArrowTextStyleSet.Normal)
1551
            {
1552
                this.Base_TextBox.BorderBrush = Brushes.Transparent;
1553
            }
1554
            
1555
            if (Math.Abs(this.PageAngle).ToString() == "90")
1556
            {
1557
                List<Point> pCloud = new List<Point>()
1558
                {
1559
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1560
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxWidth), //왼쪽 아래
1561
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox) - BoxWidth),
1562
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox)),
1563
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1564
                };
1565
                PathDataInner = (GenerateInner(pCloud));
1566
            }
1567
            else if(Math.Abs(this.PageAngle).ToString() == "270")
1568
            {
1569
                List<Point> pCloud = new List<Point>()
1570
                {
1571
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1572
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + BoxWidth), //왼쪽 아래
1573
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox) + BoxWidth),
1574
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox)),
1575
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1576
                };
1577
                PathDataInner = (GenerateInner(pCloud));
1578
            }//20180906 LJY Textbox guide
1579
            else
1580
            { 
1581
                List<Point> pCloud = new List<Point>()
1582
                {
1583
    #if SILVERLIGHT
1584
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1585
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1586
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1587
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1588
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1589

    
1590
    #else
1591
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1592
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1593
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1594
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1595
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1596

    
1597
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1598
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1599
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1600
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1601
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1602
    #endif
1603
                };
1604
                //instanceGroup.Children.Add(Generate(pCloud));
1605
                PathDataInner = (GenerateInner(pCloud));
1606
            }
1607
        }
1608

    
1609
        public override void UpdateControl()
1610
        {
1611
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
1612
            this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
1613
            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
1614
        }
1615

    
1616
        public override void ApplyOverViewData()
1617
        {
1618
            this.OverViewPathData = this.PathData;
1619
            if (ArrowText == "")
1620
            {
1621
                this.OverViewArrowText = "";
1622
                this.ArrowText = this.OverViewArrowText;
1623
            }
1624
            else
1625
                this.OverViewArrowText = this.ArrowText;
1626
            this.OverViewStartPoint = this.StartPoint;
1627
            this.OverViewEndPoint = this.EndPoint;
1628
        }
1629

    
1630
        #endregion
1631

    
1632
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
1633
        {
1634
            PathFigure pathFigure = new PathFigure();
1635
            pathFigure.StartPoint = p1;
1636

    
1637
            double arcLength = arcLength_;
1638
            /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung 
1639
            double dx = p2.X - p1.X;
1640
            double dy = p2.Y - p1.Y;
1641
            double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2
1642
            double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
1643
            Point lastPt = new Point(p1.X, p1.Y);
1644
            double count = l / arcLength;
1645
            /// normalize
1646
            dx /= l;
1647
            dy /= l;
1648
            Double j = 1;
1649
            for (j = 1; j < (count - 1); j++) 
1650
            {
1651
                ArcSegment arcSeg = new ArcSegment();
1652
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);						/// x size and y size of arc
1653
                arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);	/// end point of arc
1654
                lastPt = arcSeg.Point;  /// save last point
1655
                arcSeg.RotationAngle = theta + 90;
1656
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1657
                pathFigure.Segments.Add(arcSeg);
1658
            }
1659

    
1660
            /// draw arc between last point and end point
1661
            if ((count > j) || (count > 0))
1662
            {
1663
                arcLength = MathSet.DistanceTo(lastPt, p2);
1664
                ArcSegment arcSeg = new ArcSegment();
1665
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);	/// x size and y size of arc
1666
                arcSeg.Point = new Point(p2.X, p2.Y);						/// end point of arc
1667
                arcSeg.RotationAngle = theta;
1668
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1669
                pathFigure.Segments.Add(arcSeg);
1670
            }
1671
            /// up to here
1672

    
1673
            return pathFigure;
1674
        }
1675

    
1676
        public static PathGeometry Generate(List<Point> pData, double _ArcLength)
1677
        {
1678
            var _pathGeometry = new PathGeometry();
1679
            
1680
            double area = MathSet.AreaOf(pData);
1681
            bool reverse = (area > 0);
1682
            int count = pData.Count;
1683
            for (int i = 0; i < (count - 1); i++)
1684
            {
1685
                PathFigure pathFigure = Polygon.CloudControl.GenerateLineWithCloud(pData[i], pData[i + 1], _ArcLength, reverse);
1686
                pathFigure.IsClosed = false;
1687
                pathFigure.IsFilled = false;
1688
                _pathGeometry.Figures.Add(pathFigure);
1689
            }
1690
            
1691
            return _pathGeometry;
1692
        }
1693

    
1694
        
1695
        public static PathGeometry GenerateInner(List<Point> pData)
1696
        {
1697
            var _pathGeometry = new PathGeometry();
1698
            double area = MathSet.AreaOf(pData);
1699
            bool reverse = (area > 0);
1700
            int count = pData.Count;
1701

    
1702
            PathFigure pathFigur2 = new PathFigure();
1703
            pathFigur2.StartPoint = pData[0];
1704

    
1705
            LineSegment lineSegment0 = new LineSegment();
1706
            lineSegment0.Point = pData[0];
1707
            pathFigur2.Segments.Add(lineSegment0);
1708

    
1709
            LineSegment lineSegment1 = new LineSegment();
1710
            lineSegment1.Point = pData[1];
1711
            pathFigur2.Segments.Add(lineSegment1);
1712

    
1713
            LineSegment lineSegment2 = new LineSegment();
1714
            lineSegment2.Point = pData[2];
1715
            pathFigur2.Segments.Add(lineSegment2);
1716

    
1717
            LineSegment lineSegment3 = new LineSegment();
1718
            lineSegment3.Point = pData[3];
1719
            pathFigur2.Segments.Add(lineSegment3);
1720

    
1721

    
1722
            pathFigur2.IsClosed = true;
1723
            pathFigur2.IsFilled = true;
1724
            _pathGeometry.Figures.Add(pathFigur2);           
1725

    
1726
            return _pathGeometry;
1727
        }
1728

    
1729
        //20180910 LJY Cloud rotation 추가
1730
        public static PathGeometry GenerateInnerCloud(List<Point> pData, string angle)
1731
        {
1732
            var _pathGeometry = new PathGeometry();
1733
            double area = MathSet.AreaOf(pData);
1734
            bool reverse = (area > 0);
1735
            int count = pData.Count;
1736

    
1737
            PathFigure pathFigur2 = new PathFigure();
1738
            pathFigur2.StartPoint = pData[0];
1739

    
1740
            LineSegment lineSegment0 = new LineSegment();
1741
            lineSegment0.Point = pData[0];
1742
            pathFigur2.Segments.Add(lineSegment0);
1743

    
1744
            LineSegment lineSegment1 = new LineSegment();
1745
            lineSegment1.Point = pData[1];
1746
            pathFigur2.Segments.Add(lineSegment1);
1747

    
1748
            LineSegment lineSegment2 = new LineSegment();
1749
            lineSegment2.Point = pData[2];
1750
            pathFigur2.Segments.Add(lineSegment2);
1751

    
1752
            LineSegment lineSegment3 = new LineSegment();
1753
            lineSegment3.Point = pData[3];
1754
            pathFigur2.Segments.Add(lineSegment3);
1755
            
1756
            RotateTransform transform = new RotateTransform();
1757
            switch (angle)
1758
            {
1759
                case "90":
1760
                    transform.Angle = -90;
1761
                    break;
1762
                case "180":
1763
                    transform.Angle = -180;
1764
                    break;
1765
                case "270":
1766
                    transform.Angle = -270;
1767
                    break;
1768
            }
1769
            transform.CenterX = pData[0].X;
1770
            transform.CenterY = pData[0].Y;
1771
            _pathGeometry.Transform = transform;
1772

    
1773
            pathFigur2.IsClosed = true;
1774
            pathFigur2.IsFilled = true;
1775
            _pathGeometry.Figures.Add(pathFigur2);
1776

    
1777
            return _pathGeometry;
1778
        }
1779

    
1780
        /// <summary>
1781
        /// call when mouse is moving while drawing control
1782
        /// </summary>
1783
        /// <author>humkyung</author>
1784
        /// <param name="pt"></param>
1785
        /// <param name="bAxisLocked"></param>
1786
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
1787
        {
1788
            this.EndPoint = pt;
1789

    
1790
            Point tempPoint = this.EndPoint;
1791
            CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1792

    
1793
            if (bAxisLocked)
1794
            {
1795
                this.EndPoint = tempPoint;
1796
            }
1797

    
1798
            this.MidPoint = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint);
1799
            this.isFixed = (this.ControlType == ControlType.ArrowTransTextControl) || 
1800
                (this.ControlType == ControlType.ArrowTransTextBorderControl) || (this.ControlType == ControlType.ArrowTransTextCloudControl);
1801

    
1802
            this.PointSet = new List<Point>
1803
            {
1804
                this.StartPoint,
1805
                this.MidPoint,
1806
                this.EndPoint,
1807
            };
1808
        }
1809

    
1810
        /// <summary>
1811
        /// move control point has same location of given pt along given delta
1812
        /// </summary>
1813
        /// <author>humkyung</author>
1814
        /// <date>2019.06.20</date>
1815
        /// <param name="pt"></param>
1816
        /// <param name="dx"></param>
1817
        /// <param name="dy"></param>
1818
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
1819
        {
1820
            IPath path = (this as IPath);
1821

    
1822
            Point selected = MathSet.getNearPoint(path.PointSet, pt);
1823

    
1824
            //StartPoint에 표시된 Thumb는 dx,dy가 +로 더해줘야한다.
1825
            if (path.PointSet.IndexOf(selected) != 0)
1826
            {
1827
                double radian = this.CommentAngle * Math.PI / 180;
1828
                double cos = Math.Cos(radian);
1829
                double sin = Math.Sin(radian);
1830

    
1831
                double _dx = dx * cos - dy * sin;
1832
                double _dy = dx * sin + dy * cos;
1833

    
1834
                //var transform = new RotateTransform() { Angle = CommentAngle, CenterX = dx, CenterY = dy };
1835
                //var transformedPoint = transform.Transform(pt);
1836
                //selected = transformedPoint;
1837

    
1838
                selected.X += _dx;
1839
                selected.Y += _dy;
1840
            }
1841
            else
1842
            {
1843
                selected.X += dx;
1844
                selected.Y += dy;
1845
            }
1846

    
1847
            int i = 0;
1848
            for (i = 0; i < (this as IPath).PointSet.Count; i++)
1849
            {
1850
                if (pt.Equals((this as IPath).PointSet[i])) break;
1851
            }
1852

    
1853
            List<Point> pts = path.PointSet;
1854
            if ((pts[0].X > pts[1].X && dx > 0) || (pts[0].X < pts[1].X && dx < 0))
1855
            {
1856
                pts[1] = new Point(pts[1].X + dx, pts[1].Y);
1857
            }
1858
            if ((pts[0].Y > pts[1].Y && dy > 0) || (pts[0].Y < pts[1].Y && dy < 0))
1859
            {
1860
                pts[1] = new Point(pts[1].X, pts[1].Y + dy);
1861
            }
1862

    
1863
            path.PointSet[1] = pts[1];
1864

    
1865
            if (path.PointSet.Count > i) {
1866
                path.PointSet[i] = selected;
1867
            }
1868
            //System.Diagnostics.Debug.WriteLine($"OnMoveCtrlPoint end : {path.PointSet[1].X},{path.PointSet[1].Y}");
1869
            this.UpdateControl();
1870
        }
1871

    
1872
        /// <summary>
1873
        /// return ArrowTextControl's area
1874
        /// </summary>
1875
        /// <author>humkyung</author>
1876
        /// <date>2019.06.13</date>
1877
        public override Rect ItemRect
1878
        {
1879
            get
1880
            {
1881
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
1882
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
1883
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
1884
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
1885

    
1886
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
1887
            }
1888
        }
1889

    
1890
        /// <summary>
1891
        /// Serialize this
1892
        /// </summary>
1893
        /// <param name="sUserId"></param>
1894
        /// <returns></returns>
1895
        public override string Serialize()
1896
        {
1897
            using (S_ArrowTextControl ctrl = new S_ArrowTextControl())
1898
            {
1899
                ctrl.TransformPoint = "0|0";
1900
                ctrl.PointSet = this.PointSet;
1901
                ctrl.SizeSet = String.Format("{0}", this.LineSize);
1902
                ctrl.StrokeColor = this.StrokeColor.Color.ToString();
1903
                ctrl.StartPoint = this.StartPoint;
1904
                ctrl.ArrowStyle = this.ArrowTextStyle;
1905
                //ctrl.StrokeColor = "#FF00FF00";
1906
                ctrl.UserID = this.UserID;
1907
                ctrl.ArrowText = this.Base_TextBox.Text;
1908
                ctrl.BorderSize = this.BorderSize;
1909
                ctrl.isHighLight = this.isHighLight;
1910
                ctrl.BoxHeight = this.BoxHeight;
1911
                ctrl.BoxWidth = this.BoxWidth;
1912
                ctrl.Opac = this.Opacity;
1913
                ctrl.EndPoint = this.EndPoint;
1914
                ctrl.isFixed = this.isFixed;
1915
                //ctrl.DashSize = this.DashSize;
1916
                ctrl.Name = this.GetType().Name.ToString();
1917
                ctrl.isTrans = this.isTrans;
1918
                ctrl.MidPoint = this.MidPoint;
1919
                ctrl.Angle = this.PageAngle;
1920
                ctrl.fontConfig = new List<string>()
1921
                            {
1922
                                this.TextFamily.FontName(),
1923
                                this.TextStyle.ToString(),
1924
                                this.TextWeight.ToString(),
1925
                                this.TextSize.ToString(),
1926
                            };
1927

    
1928
                if (this.UnderLine != null)
1929
                {
1930
                    ctrl.fontConfig.Add("true");
1931
                }
1932

    
1933
                ///강인구 추가(2017.11.02)
1934
                ///Memo 추가
1935
                ctrl.Memo = this.Memo;
1936
                ctrl.BorderSize = this.BorderSize;
1937
                ctrl.ArcLength = this.ArcLength;
1938
                ctrl.ZIndex = this.ZIndex;
1939
                ctrl.GroupID = this.GroupID;
1940

    
1941
                return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize()));
1942
            };
1943
        }
1944

    
1945
        /// <summary>
1946
        /// create a arrowtextcontrol from given string
1947
        /// </summary>
1948
        /// <param name="str"></param>
1949
        /// <returns></returns>
1950
        public static ArrowTextControl FromString(string str, SolidColorBrush brush, string sProjectNo,double PageAngle)
1951
        {
1952
            ArrowTextControl instance = null;
1953
            using (S_ArrowTextControl s = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(str))
1954
            {
1955
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1956
                instance = new ArrowTextControl();
1957
                instance.PageAngle = s.Angle;
1958
                instance.LineSize = Convert.ToDouble(data2.First());
1959
                instance.PointSet = s.PointSet;
1960
                instance.StartPoint = s.StartPoint;
1961
                instance.EndPoint = s.EndPoint;
1962
                instance.StrokeColor = brush;
1963
                //instance.DashSize = s.DashSize; 
1964
                instance.ArrowTextStyle = s.ArrowStyle;
1965
                instance.isHighLight = s.isHighLight;
1966
                instance.ArrowText = s.ArrowText;
1967
                instance.Opacity = s.Opac;
1968
                instance.BorderSize = s.BorderSize;
1969
                instance.BoxWidth = s.BoxWidth;
1970
                instance.BoxHeight = s.BoxHeight;
1971
                instance.isFixed = s.isFixed;
1972
                //instance.VisualPageAngle = s.Angle;
1973
                instance.UserID = s.UserID;
1974
                instance.isTrans = s.isTrans;
1975
                instance.MidPoint = s.MidPoint;
1976
                instance.Memo = s.Memo;
1977
                instance.ZIndex = s.ZIndex;
1978
                instance.GroupID = s.GroupID;
1979
                if (s.fontConfig == null || s.fontConfig.ToList().Count == 0)
1980
                {
1981
                    s.fontConfig = new List<string>();
1982

    
1983
                    s.fontConfig.Add("Arial");
1984
                    s.fontConfig.Add("Normal");
1985
                    s.fontConfig.Add("Normal");
1986
                    s.fontConfig.Add("30");
1987
                }
1988
                instance.TextFamily = Markus.Fonts.FontHelper.GetFontFamily(s.fontConfig[0]);
1989
                //인구 추가(2018.04.17)
1990
                instance.TextStyle = StringToFont.ConFontStyle(s.fontConfig[1]);
1991
                instance.TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]);
1992
                instance.TextSize = Convert.ToDouble(s.fontConfig[3]);
1993
                instance.ArcLength = s.ArcLength;
1994
                if (s.fontConfig.Count() == 5)
1995
                {
1996
                    instance.UnderLine = TextDecorations.Underline;
1997
                }
1998
            }
1999

    
2000
            return instance;
2001
        }
2002

    
2003
        #region Dispose
2004
        public void Dispose()
2005
        {
2006
            //GC.Collect();
2007
            ////GC.SuppressFinalize(this);
2008
            this.BaseTextbox_Caret = null;
2009
            this.Base_ArrowPath = null;
2010
            this.Base_ArrowSubPath = null;
2011
            this.Base_TextBlock = null;
2012
            this.Base_TextBox = null;
2013
        } 
2014
        #endregion
2015

    
2016
        #region INotifyPropertyChanged
2017
        private void OnPropertyChanged(string name)
2018
        {
2019
            if (PropertyChanged != null)
2020
            {
2021
                PropertyChanged(this, new PropertyChangedEventArgs(name));
2022
            }
2023
        }
2024

    
2025
        public Rect GetCommentRect()
2026
        {
2027
            Rect rect = new Rect();
2028

    
2029
            rect.Location = new Point();
2030
            rect.Size = new Size();
2031

    
2032
            List<Point> points = new List<Point>();
2033

    
2034
            points.AddRange(this.PointSet);
2035

    
2036
            var boxTopleft = new Point(Canvas.GetTop(Base_TextBox), Canvas.GetLeft(Base_TextBox));
2037
            points.Add(boxTopleft);
2038

    
2039
            var boxBottomRight =new Point(boxTopleft.X + Base_TextBox.ActualWidth, boxTopleft.Y + Base_TextBox.ActualHeight);
2040
            points.Add(boxBottomRight);
2041

    
2042
            rect = CommentMath.CalculateBoundingRect(points);
2043

    
2044
            return rect;
2045
        }
2046

    
2047
        public event PropertyChangedEventHandler PropertyChanged; 
2048
        #endregion
2049
    }
2050
}
클립보드 이미지 추가 (최대 크기: 500 MB)