프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (84.7 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
using System.Runtime.CompilerServices;
18
using System.Windows.Controls.Primitives;
19

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

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

    
37
        private const double _CloudArcDepth = 0.8;  /// 2018.05.14 added by humkyung
38
        private const int _BendingLineLength = 50;
39

    
40
        #region Object & Variable
41
        GeometryGroup instanceGroup { get; } = new GeometryGroup();
42
        LineGeometry connectorSMGeometry { get; } = new LineGeometry();
43
        LineGeometry connectorMEGeometry { get; } = new LineGeometry();
44

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

    
47
        #endregion
48

    
49
        static ArrowTextControl()
50
        {
51
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ArrowTextControl), new FrameworkPropertyMetadata(typeof(ArrowTextControl)));
52
        }
53

    
54
        public ArrowTextControl() : base()
55
        {
56
        }
57

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

    
91
        public override CommentUserInfo Clone()
92
        {
93
            var clone = new ArrowTextControl();
94
            clone.Copy(this);
95
            return clone;
96
        }
97

    
98
        public override void OnApplyTemplate()
99
        {
100
            base.OnApplyTemplate();
101
            Base_ArrowPath = GetTemplateChild(PART_ArrowPath) as Path;
102
            Base_ArrowSubPath = GetTemplateChild(PART_ArrowSubPath) as Path;
103
            Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox;
104
            BaseTextbox_Caret = GetTemplateChild(PART_BaseTextbox_Caret) as Border;
105
            Base_TextBox.FontFamily = this.TextFamily;
106
            if (Base_TextBox != null)
107
            {
108
                this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length;
109
                this.Base_TextBox.CaretBrush = new SolidColorBrush(Colors.Transparent);
110
                
111
                if (this.ArrowTextStyle == ArrowTextStyleSet.Cloud)
112
                {
113
                    
114
                }
115

    
116
                this.Base_TextBox.ApplyTemplate();
117
                this.Base_TextBox.Text = this.ArrowText;
118

    
119
                MoveCustomCaret();
120

    
121
                Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged);
122
                Base_TextBox.GotFocus += new RoutedEventHandler(Base_TextBox_GotFocus);
123
                Base_TextBox.LostFocus += new RoutedEventHandler(Base_TextBox_LostFocus);
124
                Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret();
125
                this.KeyDown += ArrowTextControl_KeyDown;
126

    
127
                SetArrowTextPath(true);
128

    
129
                Base_TextBox.IsTabStop = true;
130
            }
131
        }
132

    
133
        private void ArrowTextControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
134
        {
135
           if(e.Key == System.Windows.Input.Key.Escape)
136
            {
137
                if(string.IsNullOrEmpty(Base_TextBox.Text))
138
                {
139
                    this.Visibility = Visibility.Collapsed;
140
                }
141

    
142
                EditEnd();
143
            }
144
        }
145

    
146
        public void SetFontFamily(FontFamily fontFamily)
147
        {
148
            if (this.Base_TextBlock != null)
149
            {
150
                this.Base_TextBlock.FontFamily = fontFamily;
151
            }
152

    
153
            if (this.Base_TextBox != null)
154
            {
155
                this.Base_TextBox.FontFamily = fontFamily;
156
            }
157
            this.FontFamily = fontFamily;
158
            this.TextFamily = fontFamily;
159
        }
160

    
161
        /// <summary>
162
        /// Moves the custom caret on the canvas.
163
        /// </summary>
164
        public void MoveCustomCaret()
165
        {
166
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
167

    
168
            var angle = Math.Abs(this.PageAngle);
169
            //angle = 0;
170
            System.Diagnostics.Debug.WriteLine("Page Angle : " +  this.PageAngle);
171

    
172
            if (!double.IsInfinity(caretLocation.X))
173
            {
174
                if (angle == 90)
175
                {
176
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.Y);
177
                }
178
                else if (angle == 180)
179
                {
180
                    
181
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X+ this.Base_TextBox.ActualWidth) - caretLocation.X) ;
182
                    System.Diagnostics.Debug.WriteLine("Caret X : " + ((this.EndPoint.X + this.Base_TextBox.ActualWidth) - caretLocation.X));
183
                } 
184
                else if (angle == 270)
185
                {
186
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X) - caretLocation.Y);
187
                }
188
                else
189
                {
190
                    System.Diagnostics.Debug.WriteLine("Caret X : " + (this.EndPoint.X - caretLocation.X));
191
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.X);
192
                } 
193
            }
194

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

    
218
        void Base_TextBox_LostFocus(object sender, RoutedEventArgs e)
219
        {
220
            EditEnd();
221
        }
222

    
223
        private void EditEnd()
224
        { 
225
            this.ArrowText = Base_TextBox.Text;
226
            Base_TextBox.Focusable = false;
227
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
228
            this.IsEditingMode = false;
229
            ApplyOverViewData();
230

    
231
            if(EditEnded != null)
232
            {
233
                EditEnded(this, new EventArgs());
234
            }
235
        }
236

    
237
        void Base_TextBox_GotFocus(object sender, RoutedEventArgs e)
238
        {
239
            this.BaseTextbox_Caret.Visibility = Visibility.Visible;
240
            MoveCustomCaret();
241
            Base_TextBox.Focus();
242
            this.IsEditingMode = true;
243
        }
244

    
245
        void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e)
246
        {
247
            if(this.IsEditingMode)
248
            {
249
                if (Base_TextBox.Text.Contains("|OR||DZ|"))
250
                {
251
                    Base_TextBox.Text = this.ArrowText;
252
                }
253

    
254
                this.ArrowText = Base_TextBox.Text;
255
                
256
            }
257
            BoxWidth = e.NewSize.Width;
258
            BoxHeight = e.NewSize.Height;
259
            SetArrowTextPath();
260
        }
261

    
262
        #region Properties
263
        private bool _IsEditingMode;
264
        public bool IsEditingMode
265
        {
266
            get
267
            {
268
                return _IsEditingMode;
269
            }
270
            set
271
            {
272
                _IsEditingMode = value;
273
                OnPropertyChanged("IsEditingMode");
274
            }
275
        }
276

    
277

    
278
        #endregion
279

    
280
        #region dp Properties
281
        //강인구 주석 풀기
282
        public Visibility TextBoxVisibility
283
        {
284
            get { return (Visibility)GetValue(TextBoxVisibilityProperty); }
285
            set
286
            {
287
                if (this.TextBoxVisibility != value)
288
                {
289
                    SetValue(TextBoxVisibilityProperty, value);
290
                    OnPropertyChanged("TextBoxVisibility");
291
                }
292
            }
293
        }
294

    
295
        //강인구 주석 풀기
296
        public Visibility TextBlockVisibility
297
        {
298
            get { return (Visibility)GetValue(TextBlockVisibilityProperty); }
299
            set
300
            {
301
                if (this.TextBlockVisibility != value)
302
                {
303
                    SetValue(TextBlockVisibilityProperty, value);
304
                    OnPropertyChanged("TextBlockVisibility");
305
                }
306
            }
307
        }
308

    
309

    
310
        public override SolidColorBrush StrokeColor
311
        {
312
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
313
            set
314
            {
315
                if (this.StrokeColor != value)
316
                {
317
                    SetValue(StrokeColorProperty, value);
318
                }
319
            }
320
        }
321

    
322
        public Double ArcLength
323
        {
324
            get { return (Double)GetValue(ArcLengthProperty); }
325
            set
326
            {
327
                if (this.ArcLength != value)
328
                {
329
                    SetValue(ArcLengthProperty, value);
330
                    OnPropertyChanged("ArcLength");
331
                }
332
            }
333
        }
334

    
335
        public PathGeometry SubPathData
336
        {
337
            get { return (PathGeometry)GetValue(SubPathDataProperty); }
338
            set
339
            {
340
                if (this.SubPathData != value)
341
                {
342
                    SetValue(SubPathDataProperty, value);
343
                }
344
            }
345
        }
346

    
347
        public string UserID
348
        {
349
            get { return (string)GetValue(UserIDProperty); }
350
            set
351
            {
352
                if (this.UserID != value)
353
                {
354
                    SetValue(UserIDProperty, value);
355
                    OnPropertyChanged("UserID");
356
                }
357
            }
358
        }
359

    
360
        public List<Point> PointSet
361
        {
362
            get { return (List<Point>)GetValue(PointSetProperty); }
363
            set { SetValue(PointSetProperty, value); }
364
        }
365

    
366
        public override bool IsSelected
367
        {
368
            get
369
            {
370
                return (bool)GetValue(IsSelectedProperty);
371
            }
372
            set
373
            {
374
                SetValue(IsSelectedProperty, value);
375
                OnPropertyChanged("IsSelected");
376
            }
377
        }
378

    
379
        public override ControlType ControlType
380
        {
381
            set
382
            {
383
                SetValue(ControlTypeProperty, value);
384
                OnPropertyChanged("ControlType");
385
            }
386
            get
387
            {
388
                return (ControlType)GetValue(ControlTypeProperty);
389
            }
390
        }
391

    
392
        public Point StartPoint
393
        {
394
            get { return (Point)GetValue(StartPointProperty); }
395
            set { SetValue(StartPointProperty, value); }
396
        }
397

    
398
        public Point EndPoint
399
        {
400
            get { return (Point)GetValue(EndPointProperty); }
401
            set { SetValue(EndPointProperty, value); }
402
        }
403

    
404
        public Point OverViewStartPoint
405
        {
406
            get { return (Point)GetValue(OverViewStartPointProperty); }
407
            set { SetValue(OverViewStartPointProperty, value); }
408
        }
409

    
410
        public Point OverViewEndPoint
411
        {
412
            get { return (Point)GetValue(OverViewEndPointProperty); }
413
            set { SetValue(OverViewEndPointProperty, value); }
414
        }
415

    
416

    
417
        //public double Angle
418
        //{
419
        //    get { return (double)GetValue(AngleProperty); }
420
        //    set { SetValue(AngleProperty, value); }
421
        //}
422

    
423
        public Thickness BorderSize
424
        {
425
            get { return (Thickness)GetValue(BorderSizeProperty); }
426
            set
427
            {
428
                if (this.BorderSize != value)
429
                {
430
                    SetValue(BorderSizeProperty, value);
431
                }
432
            }
433
        }
434

    
435

    
436
        public Point MidPoint
437
        {
438
            get { return (Point)GetValue(MidPointProperty); }
439
            set { SetValue(MidPointProperty, value); }
440
        }
441

    
442
        public bool isFixed
443
        {
444
            get { return (bool)GetValue(IsFixedProperty); }
445
            set { SetValue(IsFixedProperty, value); }
446
        }
447

    
448
        public bool isTrans
449
        {
450
            get { return (bool)GetValue(TransformerProperty); }
451
            set { SetValue(TransformerProperty, value); }
452
        }
453

    
454
        public bool isHighLight
455
        {
456
            get { return (bool)GetValue(isHighlightProperty); }
457
            set
458
            {
459
                if (this.isHighLight != value)
460
                {
461
                    SetValue(isHighlightProperty, value);
462
                    OnPropertyChanged("isHighLight");
463
                }
464
            }
465
        }
466

    
467
        public FontWeight TextWeight
468
        {
469
            get { return (FontWeight)GetValue(TextWeightProperty); }
470
            set
471
            {
472
                if (this.TextWeight != value)
473
                {
474
                    SetValue(TextWeightProperty, value);
475
                    OnPropertyChanged("TextWeight");
476
                }
477
            }
478
        }
479

    
480
        public Double LineSize
481
        {
482
            get { return (Double)GetValue(LineSizeProperty); }
483
            set
484
            {
485
                if (this.LineSize != value)
486
                {
487
                    SetValue(LineSizeProperty, value);
488
                }
489
            }
490
        }
491

    
492
        public Double BoxWidth
493
        {
494
            get { return (Double)GetValue(BoxWidthProperty); }
495
            set
496
            {
497
                if (this.BoxWidth != value)
498
                {
499
                    SetValue(BoxWidthProperty, value);
500
                }
501
            }
502
        }
503

    
504
        public Double BoxHeight
505
        {
506
            get { return (Double)GetValue(BoxHeightProperty); }
507
            set
508
            {
509
                if (this.BoxHeight != value)
510
                {
511
                    SetValue(BoxHeightProperty, value);
512
                }
513
            }
514
        }
515

    
516
        public ArrowTextStyleSet ArrowTextStyle
517
        {
518
            get { return (ArrowTextStyleSet)GetValue(ArrowTextStyleProperty); }
519
            set
520
            {
521
                if (this.ArrowTextStyle != value)
522
                {
523
                    SetValue(ArrowTextStyleProperty, value);
524
                }
525
            }
526
        }
527

    
528
        public Geometry PathData
529
        {
530
            get { return (Geometry)GetValue(PathDataProperty); }
531
            set { SetValue(PathDataProperty, value);
532

    
533
                OnPropertyChanged("PathData");
534
            }
535
        }
536

    
537
        public SolidColorBrush BackInnerColor
538
        {
539
            get { return (SolidColorBrush)GetValue(BackInnerColorProperty); }
540
            set
541
            {
542
                if (this.BackInnerColor != value)
543
                {
544
                    SetValue(BackInnerColorProperty, value);
545
                    OnPropertyChanged("BackInnerColor");
546
                }
547
            }
548
        }
549

    
550
        public Geometry PathDataInner
551
        {
552
            get { return (Geometry)GetValue(PathDataInnerProperty); }
553
            set
554
            {
555
                SetValue(PathDataInnerProperty, value);
556
                OnPropertyChanged("PathDataInner");
557
            }
558
        }
559

    
560
        public Geometry OverViewPathData
561
        {
562
            get { return (Geometry)GetValue(OverViewPathDataProperty); }
563
            set { SetValue(OverViewPathDataProperty, value);
564

    
565
                OnPropertyChanged("OverViewPathData");
566

    
567
            }
568
        }
569

    
570
        public FontFamily TextFamily
571
        {
572
            get { return (FontFamily)GetValue(TextFamilyProperty); }
573
            set
574
            {
575
                if (this.TextFamily != value)
576
                {
577
                    SetValue(TextFamilyProperty, value);
578
                    OnPropertyChanged("TextFamily");
579
                }
580
            }
581
        }
582

    
583
        public string ArrowText
584
        {
585
            get { return (string)GetValue(ArrowTextProperty); }
586
            set
587
            {
588
                if (this.ArrowText != value)
589
                {
590
                    SetValue(ArrowTextProperty, value);
591
                    OnPropertyChanged("ArrowText");
592
                }
593
            }
594
        }
595

    
596
        public string OverViewArrowText
597
        {
598

    
599
            get { return (string)GetValue(OverViewArrowTextProperty);
600
            }
601
            set
602
            {
603
                if (this.OverViewArrowText != value)
604
                {
605
                    SetValue(OverViewArrowTextProperty, value);
606
                    OnPropertyChanged("OverViewArrowText");
607
                }
608
            }
609
        }
610

    
611
        public Double TextSize
612
        {
613
            get { return (Double)GetValue(TextSizeProperty); }
614
            set
615
            {
616
                if (this.TextSize != value)
617
                {
618
                    SetValue(TextSizeProperty, value);
619
                    OnPropertyChanged("TextSize");
620
                }
621
            }
622
        }
623

    
624
        public FontStyle TextStyle
625
        {
626
            get { return (FontStyle)GetValue(TextStyleProperty); }
627
            set
628
            {
629
                if (this.TextStyle != value)
630
                {
631
                    SetValue(TextStyleProperty, value);
632
                    OnPropertyChanged("TextStyle");
633
                }
634
            }
635
        }
636

    
637
        //강인구 추가
638
        public TextDecorationCollection UnderLine
639
        {
640
            get
641
            {
642
                return (TextDecorationCollection)GetValue(UnderLineProperty);
643
            }
644
            set
645
            {
646
                if (this.UnderLine != value)
647
                {
648
                    SetValue(UnderLineProperty, value);
649
                    OnPropertyChanged("UnderLine");
650
                }
651
            }
652
        }
653

    
654
        public double CanvasX
655
        {
656
            get { return (double)GetValue(CanvasXProperty); }
657
            set
658
            {
659
                if (this.CanvasX != value)
660
                {
661
                    SetValue(CanvasXProperty, value);
662
                    OnPropertyChanged("CanvasX");
663
                }
664
            }
665
        }
666

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

    
680
        public double CenterX
681
        {
682
            get { return (double)GetValue(CenterXProperty); }
683
            set { SetValue(CenterXProperty, value);
684
            OnPropertyChanged("CenterX");
685
            
686
            }
687
        }
688

    
689
        public double CenterY
690
        {
691
            get { return (double)GetValue(CenterYProperty); }
692
            set { SetValue(CenterYProperty, value);
693
            OnPropertyChanged("CenterY");
694
            }
695
        }
696

    
697
        public Brush SubPathFill
698
        {
699
            get { return (Brush)GetValue(SubPathFillProperty); }
700
            set
701
            {
702
                SetValue(SubPathFillProperty, value);
703
                OnPropertyChanged("SubPathFill");
704
            }
705
        }
706

    
707
        public Brush TextBoxBackground
708
        {
709
            get { return (Brush)GetValue(TextBoxBackgroundProperty); }
710
            set
711
            {
712
                SetValue(TextBoxBackgroundProperty, value);
713
                OnPropertyChanged("TextBoxBackground");
714
            }
715
        }
716

    
717

    
718
        //강인구 추가 주석풀기
719
       
720

    
721
        public bool EnableEditing
722
        {
723
            get { return (bool)GetValue(EnableEditingProperty); }
724
            set
725
            {
726
                if (this.EnableEditing != value)
727
                {
728
                    SetValue(EnableEditingProperty, value);
729
                    OnPropertyChanged("EnableEditing");
730
                }
731
            }
732
        }
733

    
734
        #endregion
735

    
736
        #region Dependency Properties
737

    
738
        public static readonly DependencyProperty BoxWidthProperty = DependencyProperty.Register(
739
                "BoxWidth", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
740

    
741
        public static readonly DependencyProperty BoxHeightProperty = DependencyProperty.Register(
742
                "BoxHeight", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
743

    
744
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
745
                "UserID", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
746

    
747
        public static readonly DependencyProperty ArrowTextStyleProperty = DependencyProperty.Register(
748
               "ArrowTextStyle", typeof(ArrowTextStyleSet), typeof(ArrowTextControl), new PropertyMetadata(ArrowTextStyleSet.Normal));
749

    
750
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register(
751
                "CenterX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
752

    
753
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register(
754
                "CenterY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
755

    
756
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register(
757
                "Angle", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(PointValueChanged)));
758
        
759
        public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
760
                "CanvasX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
761

    
762
        public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
763
                "CanvasY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
764

    
765
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
766
                "PointSet", typeof(List<Point>), typeof(ArrowTextControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
767

    
768
        public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register(
769
                "TextFamily", typeof(FontFamily), typeof(ArrowTextControl), new PropertyMetadata(new FontFamily("Arial"), TextChanged));
770

    
771
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
772
                "PathData", typeof(Geometry), typeof(ArrowTextControl), null);
773

    
774
        //강인구 추가
775
        public static readonly DependencyProperty UnderLineProperty = DependencyProperty.Register(
776
    "UnderLine", typeof(TextDecorationCollection), typeof(ArrowTextControl), new PropertyMetadata(null, PointValueChanged));
777

    
778
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
779
               "LineSize", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)3, PointValueChanged));
780

    
781
        public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register(
782
                "TextStyle", typeof(FontStyle), typeof(ArrowTextControl), new PropertyMetadata(FontStyles.Normal));
783

    
784
        public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register(
785
                "TextSize", typeof(Double), typeof(ArrowTextControl), new PropertyMetadata((Double)30, PointValueChanged));
786

    
787
        public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register(
788
                "TextWeight", typeof(FontWeight), typeof(ArrowTextControl), new PropertyMetadata(FontWeights.Normal));
789

    
790
        public static readonly DependencyProperty IsFixedProperty = DependencyProperty.Register(
791
                "isFixed", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
792

    
793
        public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
794
                "IsSelected", typeof(bool), typeof(ArrowTextControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
795

    
796
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
797
                "StrokeColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
798

    
799
        public static readonly DependencyProperty ArcLengthProperty = DependencyProperty.Register(
800
            "ArcLength", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)10, PointValueChanged));
801

    
802
        public static readonly DependencyProperty ControlTypeProperty = DependencyProperty.Register(
803
                "ControlType", typeof(ControlType), typeof(ArrowTextControl), new FrameworkPropertyMetadata(ControlType.ArrowTextControl));
804

    
805
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
806
                "StartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
807

    
808
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
809
                "EndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
810

    
811
        public static readonly DependencyProperty BackInnerColorProperty = DependencyProperty.Register(
812
            "BackInnerColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.White)));
813

    
814
        public static readonly DependencyProperty PathDataInnerProperty = DependencyProperty.Register(
815
    "PathDataInner", typeof(Geometry), typeof(ArrowTextControl), null);
816

    
817
        public static readonly DependencyProperty isHighlightProperty = DependencyProperty.Register(
818
                "isHighlight", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
819

    
820
        public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register(
821
                "MidPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
822

    
823
        public static readonly DependencyProperty TransformerProperty = DependencyProperty.Register(
824
                "isTrans", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
825

    
826
        public static readonly DependencyProperty BorderSizeProperty = DependencyProperty.Register(
827
                "BorderSize", typeof(Thickness), typeof(ArrowTextControl), new PropertyMetadata(new Thickness(0), PointValueChanged));
828
    
829
        public static readonly DependencyProperty ArrowTextProperty = DependencyProperty.Register(
830
              "ArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
831

    
832

    
833

    
834
        //, new PropertyChangedCallback(TextChanged)
835

    
836

    
837
        #region 추가 사항
838
        public static readonly DependencyProperty SubPathDataProperty = DependencyProperty.Register(
839
                "SubPathData", typeof(Geometry), typeof(ArrowTextControl), null);
840

    
841

    
842
        public static readonly DependencyProperty SubPathFillProperty = DependencyProperty.Register(
843
                "SubPathFill", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(null));
844

    
845
        public static readonly DependencyProperty TextBoxBackgroundProperty = DependencyProperty.Register(
846
                "TextBoxBackground", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(Brushes.White));
847

    
848
        public static readonly DependencyProperty OverViewArrowTextProperty = DependencyProperty.Register(
849
                "OverViewArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null, new PropertyChangedCallback(TextChanged)));
850

    
851
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
852
                "OverViewPathData", typeof(Geometry), typeof(ArrowTextControl), null);
853

    
854
        public static readonly DependencyProperty OverViewStartPointProperty = DependencyProperty.Register(
855
                "OverViewStartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
856

    
857
        public static readonly DependencyProperty OverViewEndPointProperty = DependencyProperty.Register(
858
                "OverViewEndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
859

    
860
        public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register(
861
            "TextBoxVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged));
862

    
863
        //강인구 추가(주석풀기)
864
        public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register(
865
            "TextBlockVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged));
866

    
867
        public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register(
868
           "EnableEditing", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata((true), new PropertyChangedCallback(OnIsEditingChanged)));
869

    
870
        #endregion
871

    
872
        #endregion
873

    
874
        #region CallBack Method
875

    
876
        //강인구 추가(주석풀기)
877
        public static void OnIsEditingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
878
        {
879
            var instance = (ArrowTextControl)sender;
880

    
881
            if (e.OldValue != e.NewValue && instance.Base_TextBlock != null)
882
            {
883
                instance.SetValue(e.Property, e.NewValue);
884

    
885
                if (instance.EnableEditing)
886
                {
887
                    instance.EditingMode();
888
                }
889
                else
890
                {
891
                    instance.UnEditingMode();
892
                }
893
            }
894
        }
895

    
896
        public static void OnTextBoxVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
897
        {
898
            var instance = (ArrowTextControl)sender;
899

    
900
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
901
            {
902
                instance.SetValue(e.Property, e.NewValue);
903
            }
904
        }
905

    
906
        public static void OnTextBlockVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
907
        {
908
            var instance = (ArrowTextControl)sender;
909

    
910
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
911
            {
912
                instance.SetValue(e.Property, e.NewValue);
913
            }
914
        }
915

    
916
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
917
        {
918
            var instance = (ArrowTextControl)sender;
919

    
920
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
921
            {
922
                if (e.Property.Name == "StartPoint" || e.Property.Name == "EndPoint")
923
                {
924
                    var connections = instance.GetConnectionPointList();
925
                    var near = MathSet.getNearPoint(connections, instance.StartPoint);
926
                    if (!near.Equals(instance.connectorMEGeometry.EndPoint))
927
                    {
928
                        var BendingPoint = instance.GetBendingPoint(connections, instance.StartPoint, null);
929
                        if (BendingPoint.HasValue) instance.MidPoint = BendingPoint.Value;
930
                    }
931

    
932
                    instance.SetArrowTextPath();
933
                }
934
                else if(e.Property.Name == "MidPoint")
935
                {
936
                    instance.SetArrowTextPath();
937
                }
938
            }
939
        }
940

    
941

    
942
        public static void TextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
943
        {
944
            var instance = (ArrowTextControl)sender;
945
            
946
            if (e.OldValue != e.NewValue)
947
            {
948
                instance.SetValue(e.Property, e.NewValue);
949
                //instance.BoxWidth = instance.Base_TextBox.ActualWidth;
950
                //instance.BoxHeight = instance.Base_TextBox.ActualHeight;
951
            }
952
        }
953

    
954
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
955
        {
956
            var instance = (ArrowTextControl)sender;
957
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
958
            {
959
                instance.SetValue(e.Property, e.NewValue);
960
                instance.SetArrowTextPath();
961
            }
962
        }
963

    
964
        public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
965
        {
966
            var instance = (ArrowTextControl)sender;
967

    
968
            if (e.OldValue != e.NewValue && instance != null)
969
            {
970
                instance.SetValue(e.Property, e.NewValue);
971
                //Canvas.SetLeft(instance, instance.CanvasX);
972
                //Canvas.SetTop(instance, instance.CanvasY);
973
            }
974
        }
975

    
976
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
977
        {
978
            //var instance = (ArrowTextControl)sender;
979

    
980
            //if (e.OldValue != e.NewValue)
981
            //{
982
            //    instance.SetValue(e.Property, e.NewValue);
983

    
984
            //    if (instance.IsSelected && instance.Base_TextBox != null)
985
            //    {
986
            //        instance.BorderSize = new Thickness(1);
987
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Blue);
988
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Blue);
989
            //    }
990
            //    else
991
            //    {
992
            //        instance.BorderSize = new Thickness(0);
993
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Transparent);
994
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Transparent);
995
            //    }
996
            //}
997
        }
998
        #endregion
999

    
1000
        #region Internal Method
1001

    
1002
        //강인구 주석 풀기
1003
        public void EditingMode()
1004
        {
1005
            TextBoxVisibility = Visibility.Visible;
1006
            TextBlockVisibility = Visibility.Collapsed;
1007

    
1008

    
1009
            //강인구 언더라인 추가
1010
            if (UnderLine != null)
1011
                Base_TextBlock.TextDecorations = UnderLine;
1012
        }
1013
        //강인구 주석 풀기
1014
        public void UnEditingMode()
1015
        {
1016
            TextBoxVisibility = Visibility.Collapsed;
1017
            TextBlockVisibility = Visibility.Visible;
1018

    
1019
            if (Base_TextBlock != null)
1020
            {
1021
                if (UnderLine != null)
1022
                    Base_TextBlock.TextDecorations = UnderLine;
1023

    
1024
                Base_TextBlock.Margin =
1025
                     new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4,
1026
                         Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4);
1027
            }
1028

    
1029
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
1030
        }
1031

    
1032
        /// <summary>
1033
        /// 연결점 리스트를 리턴한다.
1034
        /// </summary>
1035
        /// <returns></returns>
1036
        private List<Point> GetConnectionPointList()
1037
        {
1038
            List<Point> res = new List<Point>();
1039

    
1040
            double AxisX = 1;
1041
            double AxisY = 1;
1042
            double _BoxWidth = this.BoxWidth;
1043
            double _BoxHeight = this.BoxHeight;
1044

    
1045
            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth * 0.5, Canvas.GetTop(Base_TextBox))); //상단
1046
            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth * 0.5, Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight)); // 하단
1047
            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + AxisY * this.BoxHeight * 0.5)); //좌단
1048
            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth, Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight * 0.5));  //우단
1049

    
1050
            if (isTrans)
1051
            {
1052
                switch (Math.Abs(this.PageAngle).ToString())
1053
                {
1054
                    case "90":
1055
                        {
1056
                            _BoxWidth = this.BoxHeight;
1057
                            _BoxHeight = this.BoxWidth;
1058
                            AxisX = 1;
1059
                            AxisY = -1;
1060

    
1061
                            res.Clear();
1062

    
1063
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth * 0.5, Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight)); ///상단
1064
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth * 0.5, Canvas.GetTop(Base_TextBox))); /// 하단
1065
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight * 0.5)); /// 좌단
1066
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth, Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight * 0.5)); /// 우단
1067
                        }
1068
                        break;
1069
                    case "270":
1070
                        {
1071
                            _BoxWidth = this.BoxHeight;
1072
                            _BoxHeight = this.BoxWidth;
1073
                            AxisX = -1;
1074
                            AxisY = 1;
1075

    
1076
                            res.Clear();
1077

    
1078
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth * 0.5, Canvas.GetTop(Base_TextBox))); //상단
1079
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth * 0.5, Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight)); // 하단
1080
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth , Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight * 0.5)); //왼쪽 아래
1081
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight * 0.5));
1082
                        }
1083
                        break;
1084
                    default:
1085
                        break;
1086
                }
1087
            }
1088
            else
1089
            {
1090
                switch (Math.Abs(this.PageAngle).ToString())
1091
                {
1092
                    case "90":
1093
                        {
1094
                            _BoxWidth = this.BoxHeight;
1095
                            _BoxHeight = this.BoxWidth;
1096
                            AxisX = 1;
1097
                            AxisY = -1;
1098

    
1099
                            res.Clear();
1100

    
1101
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth * 0.5, Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight)); ///상단
1102
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth * 0.5, Canvas.GetTop(Base_TextBox))); /// 하단
1103
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight * 0.5)); /// 좌단
1104
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth, Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight * 0.5)); /// 우단
1105
                        }
1106
                        break;
1107
                    case "270":
1108
                        {
1109
                            _BoxWidth = this.BoxHeight;
1110
                            _BoxHeight = this.BoxWidth;
1111
                            AxisX = -1;
1112
                            AxisY = 1;
1113

    
1114
                            res.Clear();
1115

    
1116
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth * 0.5, Canvas.GetTop(Base_TextBox))); //상단
1117
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth * 0.5, Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight)); // 하단
1118
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + AxisX * _BoxWidth, Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight * 0.5)); //왼쪽 아래
1119
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + AxisY * _BoxHeight * 0.5));
1120
                        }
1121
                        break;
1122
                    default:
1123
                        break;
1124
                }
1125
            }
1126

    
1127
            return res;
1128
        }
1129

    
1130
        /// <summary>
1131
        /// connection을 이용하여 꺽인점의 위치를 구한다.
1132
        /// </summary>
1133
        /// <returns></returns>
1134
        private Point? GetBendingPoint(List<Point> ConnectionPointList, Point pt, Point? MidPoint)
1135
        {
1136
            Point? BendingPoint = null;
1137

    
1138
            var connection = MathSet.getNearPoint(ConnectionPointList, pt);
1139
            if (isTrans)
1140
            {
1141
                ///if (!pt.Equals(this.MidPoint) && Point.Subtract(this.connectorMEGeometry.EndPoint, connection).Length == 0) return MidPoint; 
1142

    
1143
                //20180910 LJY 각도에 따라.
1144
                Vector offset = MidPoint.HasValue ? Point.Subtract(MidPoint.Value, connection) : new Vector(0, 0);
1145
                switch (Math.Abs(this.PageAngle).ToString())
1146
                {
1147
                    case "90":
1148
                        if (isFixed)
1149
                        {
1150
                            if (ConnectionPointList[0] == connection) //상단
1151
                            {
1152
                                Vector dir = new Vector(0, -1);
1153
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1154
                                BendingPoint = connection + dir * BendingLength;
1155
                            }
1156
                            else if (ConnectionPointList[1] == connection) //하단
1157
                            {
1158
                                Vector dir = new Vector(0, 1);
1159
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1160
                                BendingPoint = connection + dir * BendingLength;
1161
                            }
1162
                            else if (ConnectionPointList[2] == connection) //좌단
1163
                            {
1164
                                Vector dir = new Vector(-1, 0);
1165
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1166
                                BendingPoint = connection + dir * BendingLength;
1167
                            }
1168
                            else if (ConnectionPointList[3] == connection) //우단
1169
                            {
1170
                                Vector dir = new Vector(1, 0);
1171
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1172
                                BendingPoint = connection + dir * BendingLength;
1173
                            }
1174
                        }
1175
                        else
1176
                        {
1177
                            BendingPoint = connection;
1178
                        }
1179
                        break;
1180
                    case "270":
1181
                        if (isFixed)
1182
                        {
1183
                            if (ConnectionPointList[0] == connection) //상단
1184
                            {
1185
                                Vector dir = new Vector(0, -1);
1186
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1187
                                BendingPoint = connection + dir * BendingLength;
1188
                            }
1189
                            else if (ConnectionPointList[1] == connection) //하단
1190
                            {
1191
                                Vector dir = new Vector(0, 1);
1192
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1193
                                BendingPoint = connection + dir * BendingLength;
1194
                            }
1195
                            else if (ConnectionPointList[2] == connection) //좌단
1196
                            {
1197
                                Vector dir = new Vector(-1, 0);
1198
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1199
                                BendingPoint = connection + dir * BendingLength;
1200
                            }
1201
                            else if (ConnectionPointList[3] == connection) //우단
1202
                            {
1203
                                Vector dir = new Vector(1, 0);
1204
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1205
                                BendingPoint = connection + dir * BendingLength;
1206
                            }
1207
                        }
1208
                        else
1209
                        {
1210
                            BendingPoint = connection;
1211
                        }
1212
                        break;
1213
                    default:
1214
                        if (isFixed)
1215
                        {
1216
                            if (ConnectionPointList[0] == connection) //상단
1217
                            {
1218
                                Vector dir = new Vector(0, -1);
1219
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1220
                                BendingPoint = connection + dir * BendingLength;
1221
                            }
1222
                            else if (ConnectionPointList[1] == connection) //하단
1223
                            {
1224
                                Vector dir = new Vector(0, 1);
1225
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1226
                                BendingPoint = connection + dir * BendingLength;
1227
                            }
1228
                            else if (ConnectionPointList[2] == connection) //좌단
1229
                            {
1230
                                Vector dir = new Vector(-1, 0);
1231
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1232
                                BendingPoint = connection + dir * BendingLength;
1233
                            }
1234
                            else if (ConnectionPointList[3] == connection) //우단
1235
                            {
1236
                                Vector dir = new Vector(1, 0);
1237
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1238
                                BendingPoint = connection + dir * BendingLength;
1239
                            }
1240
                        }
1241
                        else
1242
                        {
1243
                            BendingPoint = connection;
1244
                        }
1245
                        break;
1246
                }
1247
            }
1248
            else
1249
            {
1250
                //20180910 LJY 각도에 따라.
1251
                Vector offset = MidPoint.HasValue ? Point.Subtract(MidPoint.Value, connection) : new Vector(0, 0);
1252
                switch (Math.Abs(this.PageAngle).ToString())
1253
                {
1254
                    case "90":
1255
                        if (isFixed)
1256
                        {
1257
                            if (ConnectionPointList[0] == connection) //상단
1258
                            {
1259
                                Vector dir = new Vector(0, -1);
1260
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1261
                                BendingPoint = connection + dir * BendingLength;
1262
                            }
1263
                            else if (ConnectionPointList[1] == connection) //하단
1264
                            {
1265
                                Vector dir = new Vector(0, 1);
1266
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1267
                                BendingPoint = connection + dir * BendingLength;
1268
                            }
1269
                            else if (ConnectionPointList[2] == connection) //좌단
1270
                            {
1271
                                Vector dir = new Vector(-1, 0);
1272
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1273
                                BendingPoint = connection + dir * BendingLength;
1274
                            }
1275
                            else if (ConnectionPointList[3] == connection) //우단
1276
                            {
1277
                                Vector dir = new Vector(1, 0);
1278
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1279
                                BendingPoint = connection + dir * BendingLength;
1280
                            }
1281
                        }
1282
                        else
1283
                        {
1284
                            BendingPoint = connection;
1285
                        }
1286
                        break;
1287
                    case "270":
1288
                        if (isFixed)
1289
                        {
1290
                            if (ConnectionPointList[0] == connection) //상단
1291
                            {
1292
                                Vector dir = new Vector(0, -1);
1293
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1294
                                BendingPoint = connection + dir * BendingLength;
1295
                            }
1296
                            else if (ConnectionPointList[1] == connection) //하단
1297
                            {
1298
                                Vector dir = new Vector(0, 1);
1299
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1300
                                BendingPoint = connection + dir * BendingLength;
1301
                            }
1302
                            else if (ConnectionPointList[2] == connection) //좌단
1303
                            {
1304
                                Vector dir = new Vector(-1, 0);
1305
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1306
                                BendingPoint = connection + dir * BendingLength;
1307
                            }
1308
                            else if (ConnectionPointList[3] == connection) //우단
1309
                            {
1310
                                Vector dir = new Vector(1, 0);
1311
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1312
                                BendingPoint = connection + dir * BendingLength;
1313
                            }
1314
                        }
1315
                        else
1316
                        {
1317
                            BendingPoint = connection;
1318
                        }
1319
                        break;
1320
                    default:
1321
                        if (isFixed)
1322
                        {
1323
                            if (ConnectionPointList[0] == connection) //상단
1324
                            {
1325
                                Vector dir = new Vector(0, -1);
1326
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1327
                                BendingPoint = connection + dir * BendingLength;
1328
                            }
1329
                            else if (ConnectionPointList[1] == connection) //하단
1330
                            {
1331
                                Vector dir = new Vector(0, 1);
1332
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1333
                                BendingPoint = connection + dir * BendingLength;
1334
                            }
1335
                            else if (ConnectionPointList[2] == connection) //좌단
1336
                            {
1337
                                Vector dir = new Vector(-1, 0);
1338
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1339
                                BendingPoint = connection + dir * BendingLength;
1340
                            }
1341
                            else if (ConnectionPointList[3] == connection) //우단
1342
                            {
1343
                                Vector dir = new Vector(1, 0);
1344
                                double BendingLength = offset.Length == 0 ? _BendingLineLength : Math.Abs(dir.Dot(offset));
1345
                                BendingPoint = connection + dir * BendingLength;
1346
                            }
1347
                        }
1348
                        else
1349
                        {
1350
                            BendingPoint = connection;
1351
                        }
1352
                        break;
1353
                }
1354
            }
1355

    
1356
            return BendingPoint;
1357
        }
1358
        
1359
        /// <summary>
1360
        /// 형상을 생성한다.
1361
        /// </summary>
1362
        /// <param name="IsInit"></param>
1363
        private void SetArrowTextPath(bool IsInit = false)
1364
        {
1365
            instanceGroup.Children.Clear();
1366

    
1367
            if (Math.Abs(PageAngle).ToString() == "90")
1368
            {
1369
                VisualPageAngle = 270;
1370
            }
1371
            else if (Math.Abs(PageAngle).ToString() == "270")
1372
            {
1373
                VisualPageAngle = 90;
1374
            }
1375
            else
1376
            {
1377
                VisualPageAngle = PageAngle;
1378
            }
1379

    
1380
            connectorSMGeometry.StartPoint = this.StartPoint;
1381
            connectorSMGeometry.EndPoint = this.MidPoint;
1382
            connectorMEGeometry.StartPoint = this.MidPoint; //핵심
1383

    
1384
            /// 텍스트박스의 좌표 설정
1385
            Canvas.SetLeft(Base_TextBox, this.EndPoint.X);
1386
            Canvas.SetTop(Base_TextBox, this.EndPoint.Y);
1387

    
1388
            List<Point> ps = GetConnectionPointList();
1389
            if (isTrans)
1390
            {
1391
                var ConnectionPoint = MathSet.getNearPoint(ps, this.MidPoint);
1392
                Point? BendingPoint = GetBendingPoint(ps, this.MidPoint, this.MidPoint);
1393
                if (BendingPoint.HasValue)
1394
                {
1395
                    connectorSMGeometry.EndPoint = BendingPoint.Value;
1396
                    connectorMEGeometry.StartPoint = BendingPoint.Value;
1397
                    connectorMEGeometry.EndPoint = ConnectionPoint;
1398

    
1399
                    //20180910 LJY 각도에 따라.
1400
                    this.MidPoint = BendingPoint.Value;
1401
                    instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint.Value, this.StartPoint, this.LineSize));
1402
                }
1403
                instanceGroup.FillRule = FillRule.Nonzero;
1404
                this.Base_ArrowPath.Fill = this.StrokeColor;
1405
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1406
            }
1407
            else
1408
            {
1409
                var ConnectionPoint = MathSet.getNearPoint(ps, this.MidPoint);
1410
                #region 보정치
1411
                Point? BendingPoint = GetBendingPoint(ps, this.MidPoint, this.MidPoint);
1412
                if (BendingPoint.HasValue)
1413
                {
1414
                    connectorSMGeometry.EndPoint = BendingPoint.Value;
1415
                    connectorMEGeometry.StartPoint = BendingPoint.Value;
1416
                    connectorMEGeometry.EndPoint = ConnectionPoint;
1417

    
1418
                    instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint.Value, this.StartPoint, this.LineSize));
1419
                    instanceGroup.FillRule = FillRule.Nonzero;
1420
                    this.Base_ArrowPath.Fill = this.StrokeColor;
1421
                    this.Base_ArrowSubPath.Fill = this.StrokeColor;
1422
                }
1423
                #endregion
1424
            }
1425

    
1426
            switch (this.ArrowTextStyle)
1427
            {
1428
                case ArrowTextStyleSet.Normal:
1429
                    this.BorderSize = new Thickness(0);
1430
                    DrawingRect();
1431
                    break;
1432
                case ArrowTextStyleSet.Cloud:
1433
                    this.BorderSize = new Thickness(0);
1434
                    DrawingCloud();
1435
                    break;
1436
                default:
1437
                    {
1438
                        this.BorderSize = new Thickness(LineSize);
1439
                        DrawingRect();
1440
                    }
1441

    
1442
                    break;
1443
            }
1444

    
1445
            if (isHighLight)
1446
            {
1447
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1448
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1449

    
1450
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1451
            }
1452
            else
1453
            {
1454
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1455
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1456
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1), Colors.White.R, Colors.White.G, Colors.White.B));
1457
            }
1458

    
1459
            instanceGroup.Children.Add(connectorSMGeometry);
1460
            instanceGroup.Children.Add(connectorMEGeometry);
1461

    
1462
            this.PathData = instanceGroup;
1463
            OverViewPathData = PathData;
1464
            OverViewArrowText = ArrowText;
1465
            OverViewEndPoint = connectorMEGeometry.EndPoint;
1466
            OverViewStartPoint = connectorSMGeometry.StartPoint;
1467

    
1468
            var tempAngle = Math.Abs(this.VisualPageAngle);
1469

    
1470
            if (tempAngle == Convert.ToDouble(90) || tempAngle == Convert.ToDouble(270))
1471
            {
1472
                this.RenderTransformOrigin = new Point(0.5, 0.5);
1473
                this.Base_ArrowPath.RenderTransformOrigin = new Point(0, 0);
1474
                this.Base_ArrowSubPath.RenderTransformOrigin = new Point(0, 0);
1475

    
1476
                Base_TextBox.RenderTransformOrigin = new Point(0, 0);
1477
                BaseTextbox_Caret.RenderTransformOrigin = new Point(0, 0);
1478
            }
1479

    
1480
            Base_TextBox.RenderTransform = new RotateTransform
1481
            {
1482
                Angle = this.VisualPageAngle,
1483
                CenterX = this.CenterX,
1484
                CenterY = this.CenterY,
1485
            };
1486

    
1487
            Base_ArrowSubPath.RenderTransform = new RotateTransform
1488
            {
1489
                Angle = this.VisualPageAngle,
1490
                CenterX = this.EndPoint.X,
1491
                CenterY = this.EndPoint.Y,
1492
            };
1493

    
1494
            if (BaseTextbox_Caret.Visibility == Visibility.Visible)
1495
            {
1496
                BaseTextbox_Caret.RenderTransform = new RotateTransform
1497
                {
1498
                    Angle = this.VisualPageAngle,
1499
                    CenterX = this.CenterX,
1500
                    CenterY = this.CenterY,
1501
                };
1502

    
1503
                MoveCustomCaret();
1504
            }
1505
        }
1506

    
1507
        private void DrawingCloud()
1508
        {
1509
            //20180906 LJY Textbox guide
1510
            string angle = Math.Abs(this.PageAngle).ToString();
1511
            //방지
1512
            if (this.ArcLength == 0) this.ArcLength = 10;
1513
            if (angle == "180")
1514
            {
1515
                List<Point> pCloud = new List<Point>()
1516
                {
1517
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1518
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxHeight), //왼쪽 아래
1519
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox) - BoxHeight),
1520
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox)),
1521
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1522
                };
1523
                SubPathData = Generate(pCloud, this.ArcLength);
1524
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1525
            
1526
            }//20180906 LJY Textbox guide
1527
            else
1528
            {
1529
                var boxWidth = BoxWidth;
1530
                System.Diagnostics.Debug.WriteLine("disp Width : " + BoxWidth);
1531
                //boxWidth = boxWidth + Base_TextBox.Margin.Left + Base_TextBox.Margin.Right + Base_TextBox.Padding.Left + Base_TextBox.Padding.Right;
1532

    
1533
                List<Point> pCloud = new List<Point>()
1534
                {
1535
    #if SILVERLIGHT
1536
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1537
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1538
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1539
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1540
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1541

    
1542
    #else
1543
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize ), Canvas.GetTop(Base_TextBox) -(this.LineSize)), //위
1544
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize ), Canvas.GetTop(Base_TextBox)+ BoxHeight+(this.LineSize)), //왼쪽 아래
1545
                    new Point(Canvas.GetLeft(Base_TextBox)+ boxWidth+(this.LineSize ), Canvas.GetTop(Base_TextBox) + BoxHeight+(this.LineSize)),
1546
                    new Point(Canvas.GetLeft(Base_TextBox) + boxWidth+(this.LineSize ), Canvas.GetTop(Base_TextBox)-(this.LineSize)),
1547
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize), Canvas.GetTop(Base_TextBox)-(this.LineSize)), //위  
1548

    
1549
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1550
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1551
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1552
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1553
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1554
    #endif
1555
                };
1556
                //instanceGroup.Children.Add(Generate(pCloud));
1557
                SubPathData = Generate(pCloud, this.ArcLength);
1558
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1559
                //   }
1560
            }
1561

    
1562
        }
1563

    
1564
        private void DrawingRect()
1565
        {
1566
            //20180906 LJY Textbox guide
1567
            if(this.ArrowTextStyle == ArrowTextStyleSet.Normal)
1568
            {
1569
                this.Base_TextBox.BorderBrush = Brushes.Transparent;
1570
            }
1571
            
1572
            if (Math.Abs(this.PageAngle).ToString() == "90")
1573
            {
1574
                List<Point> pCloud = new List<Point>()
1575
                {
1576
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1577
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxWidth), //왼쪽 아래
1578
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox) - BoxWidth),
1579
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox)),
1580
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1581
                };
1582
                PathDataInner = (GenerateInner(pCloud));
1583
            }
1584
            else if(Math.Abs(this.PageAngle).ToString() == "270")
1585
            {
1586
                List<Point> pCloud = new List<Point>()
1587
                {
1588
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1589
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + BoxWidth), //왼쪽 아래
1590
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox) + BoxWidth),
1591
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox)),
1592
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1593
                };
1594
                PathDataInner = (GenerateInner(pCloud));
1595
            }//20180906 LJY Textbox guide
1596
            else
1597
            { 
1598
                List<Point> pCloud = new List<Point>()
1599
                {
1600
    #if SILVERLIGHT
1601
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1602
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1603
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1604
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1605
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1606

    
1607
    #else
1608
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1609
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1610
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1611
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1612
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1613

    
1614
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1615
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1616
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1617
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1618
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1619
    #endif
1620
                };
1621
                //instanceGroup.Children.Add(Generate(pCloud));
1622
                PathDataInner = (GenerateInner(pCloud));
1623
            }
1624
        }
1625

    
1626
        public override void UpdateControl()
1627
        {
1628
            if(!this.StartPoint.Equals(this.PointSet[0])) 
1629
                this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
1630
            if (!this.MidPoint.Equals(this.PointSet[1]))
1631
                this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
1632
            if (!this.EndPoint.Equals(this.PointSet[2]))
1633
                this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
1634
        }
1635

    
1636
        public override void ApplyOverViewData()
1637
        {
1638
            this.OverViewPathData = this.PathData;
1639
            if (ArrowText == "")
1640
            {
1641
                this.OverViewArrowText = "";
1642
                this.ArrowText = this.OverViewArrowText;
1643
            }
1644
            else
1645
                this.OverViewArrowText = this.ArrowText;
1646
            this.OverViewStartPoint = this.StartPoint;
1647
            this.OverViewEndPoint = this.EndPoint;
1648
        }
1649

    
1650
        #endregion
1651

    
1652
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
1653
        {
1654
            PathFigure pathFigure = new PathFigure();
1655
            pathFigure.StartPoint = p1;
1656

    
1657
            double arcLength = arcLength_;
1658
            /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung 
1659
            double dx = p2.X - p1.X;
1660
            double dy = p2.Y - p1.Y;
1661
            double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2
1662
            double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
1663
            Point lastPt = new Point(p1.X, p1.Y);
1664
            double count = l / arcLength;
1665
            /// normalize
1666
            dx /= l;
1667
            dy /= l;
1668
            Double j = 1;
1669
            for (j = 1; j < (count - 1); j++) 
1670
            {
1671
                ArcSegment arcSeg = new ArcSegment();
1672
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);						/// x size and y size of arc
1673
                arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);	/// end point of arc
1674
                lastPt = arcSeg.Point;  /// save last point
1675
                arcSeg.RotationAngle = theta + 90;
1676
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1677
                pathFigure.Segments.Add(arcSeg);
1678
            }
1679

    
1680
            /// draw arc between last point and end point
1681
            if ((count > j) || (count > 0))
1682
            {
1683
                arcLength = MathSet.DistanceTo(lastPt, p2);
1684
                ArcSegment arcSeg = new ArcSegment();
1685
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);	/// x size and y size of arc
1686
                arcSeg.Point = new Point(p2.X, p2.Y);						/// end point of arc
1687
                arcSeg.RotationAngle = theta;
1688
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1689
                pathFigure.Segments.Add(arcSeg);
1690
            }
1691
            /// up to here
1692

    
1693
            return pathFigure;
1694
        }
1695

    
1696
        public static PathGeometry Generate(List<Point> pData, double _ArcLength)
1697
        {
1698
            var _pathGeometry = new PathGeometry();
1699
            
1700
            double area = MathSet.AreaOf(pData);
1701
            bool reverse = (area > 0);
1702
            int count = pData.Count;
1703
            for (int i = 0; i < (count - 1); i++)
1704
            {
1705
                PathFigure pathFigure = Polygon.CloudControl.GenerateLineWithCloud(pData[i], pData[i + 1], _ArcLength, reverse);
1706
                pathFigure.IsClosed = false;
1707
                pathFigure.IsFilled = false;
1708
                _pathGeometry.Figures.Add(pathFigure);
1709
            }
1710
            
1711
            return _pathGeometry;
1712
        }
1713

    
1714
        
1715
        public static PathGeometry GenerateInner(List<Point> pData)
1716
        {
1717
            var _pathGeometry = new PathGeometry();
1718
            double area = MathSet.AreaOf(pData);
1719
            bool reverse = (area > 0);
1720
            int count = pData.Count;
1721

    
1722
            PathFigure pathFigur2 = new PathFigure();
1723
            pathFigur2.StartPoint = pData[0];
1724

    
1725
            LineSegment lineSegment0 = new LineSegment();
1726
            lineSegment0.Point = pData[0];
1727
            pathFigur2.Segments.Add(lineSegment0);
1728

    
1729
            LineSegment lineSegment1 = new LineSegment();
1730
            lineSegment1.Point = pData[1];
1731
            pathFigur2.Segments.Add(lineSegment1);
1732

    
1733
            LineSegment lineSegment2 = new LineSegment();
1734
            lineSegment2.Point = pData[2];
1735
            pathFigur2.Segments.Add(lineSegment2);
1736

    
1737
            LineSegment lineSegment3 = new LineSegment();
1738
            lineSegment3.Point = pData[3];
1739
            pathFigur2.Segments.Add(lineSegment3);
1740

    
1741

    
1742
            pathFigur2.IsClosed = true;
1743
            pathFigur2.IsFilled = true;
1744
            _pathGeometry.Figures.Add(pathFigur2);           
1745

    
1746
            return _pathGeometry;
1747
        }
1748

    
1749
        //20180910 LJY Cloud rotation 추가
1750
        public static PathGeometry GenerateInnerCloud(List<Point> pData, string angle)
1751
        {
1752
            var _pathGeometry = new PathGeometry();
1753
            double area = MathSet.AreaOf(pData);
1754
            bool reverse = (area > 0);
1755
            int count = pData.Count;
1756

    
1757
            PathFigure pathFigur2 = new PathFigure();
1758
            pathFigur2.StartPoint = pData[0];
1759

    
1760
            LineSegment lineSegment0 = new LineSegment();
1761
            lineSegment0.Point = pData[0];
1762
            pathFigur2.Segments.Add(lineSegment0);
1763

    
1764
            LineSegment lineSegment1 = new LineSegment();
1765
            lineSegment1.Point = pData[1];
1766
            pathFigur2.Segments.Add(lineSegment1);
1767

    
1768
            LineSegment lineSegment2 = new LineSegment();
1769
            lineSegment2.Point = pData[2];
1770
            pathFigur2.Segments.Add(lineSegment2);
1771

    
1772
            LineSegment lineSegment3 = new LineSegment();
1773
            lineSegment3.Point = pData[3];
1774
            pathFigur2.Segments.Add(lineSegment3);
1775
            
1776
            RotateTransform transform = new RotateTransform();
1777
            switch (angle)
1778
            {
1779
                case "90":
1780
                    transform.Angle = -90;
1781
                    break;
1782
                case "180":
1783
                    transform.Angle = -180;
1784
                    break;
1785
                case "270":
1786
                    transform.Angle = -270;
1787
                    break;
1788
            }
1789
            transform.CenterX = pData[0].X;
1790
            transform.CenterY = pData[0].Y;
1791
            _pathGeometry.Transform = transform;
1792

    
1793
            pathFigur2.IsClosed = true;
1794
            pathFigur2.IsFilled = true;
1795
            _pathGeometry.Figures.Add(pathFigur2);
1796

    
1797
            return _pathGeometry;
1798
        }
1799

    
1800
        /// <summary>
1801
        /// call when mouse is moving while drawing control
1802
        /// </summary>
1803
        /// <author>humkyung</author>
1804
        /// <param name="pt"></param>
1805
        /// <param name="bAxisLocked"></param>
1806
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
1807
        {
1808
            this.EndPoint = pt;
1809

    
1810
            Point tempPoint = this.EndPoint;
1811
            CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1812

    
1813
            if (bAxisLocked)
1814
            {
1815
                this.EndPoint = tempPoint;
1816
            }
1817

    
1818
            this.MidPoint = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint);
1819
            this.isFixed = (this.ControlType == ControlType.ArrowTransTextControl) ||
1820
                (this.ControlType == ControlType.ArrowTransTextBorderControl) || (this.ControlType == ControlType.ArrowTransTextCloudControl);
1821

    
1822
            this.PointSet = new List<Point>
1823
            {
1824
                this.StartPoint,
1825
                this.MidPoint,
1826
                this.EndPoint,
1827
            };
1828
        }
1829

    
1830
        /// <summary>
1831
        /// move control point has same location of given pt along given delta
1832
        /// </summary>
1833
        /// <author>humkyung</author>
1834
        /// <date>2019.06.20</date>
1835
        /// <param name="pt"></param>
1836
        /// <param name="dx"></param>
1837
        /// <param name="dy"></param>
1838
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
1839
        {
1840
            IPath path = (this as IPath);
1841

    
1842
            Point selected = MathSet.getNearPoint(path.PointSet, pt);
1843
            selected.X += dx;
1844
            selected.Y += dy;
1845

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

    
1852
            #region 끝점을 이동할때
1853
            if (i == 0)
1854
            {
1855
                #region 끝점을 기준으로 중간점을 계산한다.
1856
                var connections = GetConnectionPointList();
1857
                var connection = MathSet.getNearPoint(connections, selected);
1858
                #region 연결점이 바뀌지 않으면 중간점을 그대로 그렇지 않으면 중간점을 재계산한다.
1859
                Point? bending = null;
1860
                if (connectorMEGeometry.EndPoint.Equals(connection))
1861
                {
1862
                    bending = GetBendingPoint(connections, selected, this.MidPoint);
1863
                }
1864
                else
1865
                {
1866
                    bending = GetBendingPoint(connections, selected, null);
1867
                }
1868
                #endregion
1869
                if (bending.HasValue) path.PointSet[1] = bending.Value;
1870
                #endregion
1871
            }
1872
            #endregion
1873
            #region 중간점을 이동할때
1874
            else if (i == 1)
1875
            {
1876
                path.PointSet[1] = selected;
1877
            }
1878
            #endregion
1879
            #region 텍스트 박스를 이동할때
1880
            else
1881
            {
1882
                var connections = GetConnectionPointList();
1883
                var connection = MathSet.getNearPoint(connections, this.StartPoint);
1884
                if (!connectorMEGeometry.EndPoint.Equals(connection))
1885
                {
1886
                    var bending = GetBendingPoint(connections, this.StartPoint, null);
1887
                    if (bending.HasValue) path.PointSet[1] = bending.Value;
1888
                }
1889
                else
1890
                {
1891
                    var bending = GetBendingPoint(connections, this.StartPoint, this.MidPoint);
1892
                    if (bending.HasValue) path.PointSet[1] = bending.Value;
1893
                }
1894
            }
1895
            #endregion
1896

    
1897
            if (path.PointSet.Count > i) {
1898
                path.PointSet[i] = selected;
1899
            }
1900

    
1901
            this.UpdateControl();
1902
        }
1903

    
1904
        /// <summary>
1905
        /// return ArrowTextControl's area
1906
        /// </summary>
1907
        /// <author>humkyung</author>
1908
        /// <date>2019.06.13</date>
1909
        public override Rect ItemRect
1910
        {
1911
            get
1912
            {
1913
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
1914
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
1915
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
1916
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
1917

    
1918
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
1919
            }
1920
        }
1921

    
1922
        /// <summary>
1923
        /// Serialize this
1924
        /// </summary>
1925
        /// <param name="sUserId"></param>
1926
        /// <returns></returns>
1927
        public override string Serialize()
1928
        {
1929
            using (S_ArrowTextControl ctrl = new S_ArrowTextControl())
1930
            {
1931
                ctrl.TransformPoint = "0|0";
1932
                ctrl.PointSet = this.PointSet;
1933
                ctrl.SizeSet = String.Format("{0}", this.LineSize);
1934
                ctrl.StrokeColor = this.StrokeColor.Color.ToString();
1935
                ctrl.StartPoint = this.StartPoint;
1936
                ctrl.ArrowStyle = this.ArrowTextStyle;
1937
                ctrl.UserID = this.UserID;
1938
                ctrl.ArrowText = this.Base_TextBox.Text;
1939
                ctrl.BorderSize = this.BorderSize;
1940
                ctrl.isHighLight = this.isHighLight;
1941
                ctrl.BoxHeight = this.BoxHeight;
1942
                ctrl.BoxWidth = this.BoxWidth;
1943
                ctrl.Opac = this.Opacity;
1944
                ctrl.EndPoint = this.EndPoint;
1945
                ctrl.isFixed = this.isFixed;
1946
                ctrl.ControlType = this.ControlType;
1947
                ctrl.Name = this.GetType().Name.ToString();
1948
                ctrl.isTrans = this.isTrans;
1949
                ctrl.MidPoint = this.MidPoint;
1950
                ctrl.Angle = this.PageAngle;
1951
                ctrl.fontConfig = new List<string>()
1952
                {
1953
                    this.TextFamily.FontName(),
1954
                    this.TextStyle.ToString(),
1955
                    this.TextWeight.ToString(),
1956
                    this.TextSize.ToString(),
1957
                };
1958

    
1959
                if (this.UnderLine != null)
1960
                {
1961
                    ctrl.fontConfig.Add("true");
1962
                }
1963

    
1964
                ctrl.Memo = this.Memo;
1965
                ctrl.BorderSize = this.BorderSize;
1966
                ctrl.ArcLength = this.ArcLength;
1967
                ctrl.Index = this.Index;
1968
                ctrl.ZIndex = this.ZIndex;
1969
                ctrl.GroupID = this.GroupID;
1970

    
1971
                return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize()));
1972
            };
1973
        }
1974

    
1975
        /// <summary>
1976
        /// create a arrowtextcontrol from given string
1977
        /// </summary>
1978
        /// <param name="str"></param>
1979
        /// <returns></returns>
1980
        public static ArrowTextControl FromString(string str, SolidColorBrush brush, string sProjectNo,double PageAngle)
1981
        {
1982
            ArrowTextControl instance = null;
1983
            using (S_ArrowTextControl s = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(str))
1984
            {
1985
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1986
                instance = new ArrowTextControl();
1987
                instance.PageAngle = s.Angle;
1988
                instance.LineSize = Convert.ToDouble(data2.First());
1989
                instance.PointSet = s.PointSet;
1990
                instance.StartPoint = s.StartPoint;
1991
                instance.EndPoint = s.EndPoint;
1992
                instance.StrokeColor = brush;
1993
                instance.ArrowTextStyle = s.ArrowStyle;
1994
                instance.isHighLight = s.isHighLight;
1995
                instance.ArrowText = s.ArrowText;
1996
                instance.Opacity = s.Opac;
1997
                instance.BorderSize = s.BorderSize;
1998
                instance.BoxWidth = s.BoxWidth;
1999
                instance.BoxHeight = s.BoxHeight;
2000
                instance.isFixed = s.isFixed;
2001
                instance.ControlType = s.ControlType;
2002
                instance.UserID = s.UserID;
2003
                instance.isTrans = s.isTrans;
2004
                instance.MidPoint = s.MidPoint;
2005
                instance.Memo = s.Memo;
2006
                instance.Index = s.Index;
2007
                instance.ZIndex = s.ZIndex;
2008
                instance.GroupID = s.GroupID;
2009
                if (s.fontConfig == null || s.fontConfig.ToList().Count == 0)
2010
                {
2011
                    s.fontConfig = new List<string>();
2012

    
2013
                    s.fontConfig.Add("Arial");
2014
                    s.fontConfig.Add("Normal");
2015
                    s.fontConfig.Add("Normal");
2016
                    s.fontConfig.Add("30");
2017
                }
2018
                instance.TextFamily = Markus.Fonts.FontHelper.GetFontFamily(s.fontConfig[0]);
2019
                //인구 추가(2018.04.17)
2020
                instance.TextStyle = StringToFont.ConFontStyle(s.fontConfig[1]);
2021
                instance.TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]);
2022
                instance.TextSize = Convert.ToDouble(s.fontConfig[3]);
2023
                instance.ArcLength = s.ArcLength;
2024
                if (s.fontConfig.Count == 5)
2025
                {
2026
                    instance.UnderLine = TextDecorations.Underline;
2027
                }
2028
            }
2029

    
2030
            return instance;
2031
        }
2032

    
2033
        #region Dispose
2034
        public void Dispose()
2035
        {
2036
            //GC.Collect();
2037
            ////GC.SuppressFinalize(this);
2038
            this.BaseTextbox_Caret = null;
2039
            this.Base_ArrowPath = null;
2040
            this.Base_ArrowSubPath = null;
2041
            this.Base_TextBlock = null;
2042
            this.Base_TextBox = null;
2043
        } 
2044
        #endregion
2045

    
2046
        #region INotifyPropertyChanged
2047
        private void OnPropertyChanged(string name)
2048
        {
2049
            if (PropertyChanged != null)
2050
            {
2051
                PropertyChanged(this, new PropertyChangedEventArgs(name));
2052
            }
2053
        }
2054

    
2055
        public Rect GetCommentRect()
2056
        {
2057
            Rect rect = new Rect();
2058

    
2059
            rect.Location = new Point();
2060
            rect.Size = new Size();
2061

    
2062
            List<Point> points = new List<Point>();
2063

    
2064
            points.AddRange(this.PointSet);
2065

    
2066
            var boxTopleft = new Point(Canvas.GetTop(Base_TextBox), Canvas.GetLeft(Base_TextBox));
2067
            points.Add(boxTopleft);
2068

    
2069
            var boxBottomRight =new Point(boxTopleft.X + Base_TextBox.ActualWidth, boxTopleft.Y + Base_TextBox.ActualHeight);
2070
            points.Add(boxBottomRight);
2071

    
2072
            rect = CommentMath.CalculateBoundingRect(points);
2073

    
2074
            return rect;
2075
        }
2076

    
2077
        public event PropertyChangedEventHandler PropertyChanged; 
2078
        #endregion
2079
    }
2080

    
2081
    public static class Extension
2082
    {
2083
        public static double Dot(this Vector lhs,  Vector rhs)
2084
        {
2085
            return lhs.X * rhs.X + lhs.Y * rhs.Y;
2086
        }
2087
    }
2088
}
클립보드 이미지 추가 (최대 크기: 500 MB)