프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Text / ArrowTextControl.cs @ 1305c420

이력 | 보기 | 이력해설 | 다운로드 (78.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

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

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

    
36

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

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

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

    
48
        #endregion
49

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

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

    
64
        public override void OnApplyTemplate()
65
        {
66
            base.OnApplyTemplate();
67
            Base_ArrowPath = GetTemplateChild(PART_ArrowPath) as Path;
68
            Base_ArrowSubPath = GetTemplateChild(PART_ArrowSubPath) as Path;
69
            Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox;
70
            BaseTextbox_Caret = GetTemplateChild(PART_BaseTextbox_Caret) as Border;
71

    
72
            if (Base_TextBox != null)
73
            {
74
                this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length;
75
                this.Base_TextBox.CaretBrush = new SolidColorBrush(Colors.Transparent);
76
                this.Base_TextBox.ApplyTemplate();
77
                this.Base_TextBox.Text = this.ArrowText;
78

    
79
                MoveCustomCaret();
80

    
81
                Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged);
82
                Base_TextBox.GotFocus += new RoutedEventHandler(Base_TextBox_GotFocus);
83
                Base_TextBox.LostFocus += new RoutedEventHandler(Base_TextBox_LostFocus);
84
                Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret();
85
                this.KeyDown += ArrowTextControl_KeyDown;
86

    
87
                SetArrowTextPath(true);
88

    
89
                Base_TextBox.IsTabStop = true;
90
            }
91
        }
92

    
93
        private void ArrowTextControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
94
        {
95
           if(e.Key == System.Windows.Input.Key.Escape)
96
            {
97
                if(string.IsNullOrEmpty(Base_TextBox.Text))
98
                {
99
                    this.Visibility = Visibility.Collapsed;
100
                }
101

    
102
                EditEnd();
103
            }
104
        }
105

    
106
        public void SetFontFamily(FontFamily fontFamily)
107
        {
108
            this.FontFamily = fontFamily;
109
            this.TextFamily = fontFamily;
110
        }
111

    
112
        /// <summary>
113
        /// Moves the custom caret on the canvas.
114
        /// </summary>
115
        public void MoveCustomCaret()
116
        {
117
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
118

    
119
            var angle = Math.Abs(this.PageAngle);
120
            //angle = 0;
121
            System.Diagnostics.Debug.WriteLine("Page Angle : " +  this.PageAngle);
122

    
123
            if (!double.IsInfinity(caretLocation.X))
124
            {
125
                if (angle == 90)
126
                {
127
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.Y);
128
                }
129
                else if (angle == 180)
130
                {
131
                    
132
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X+ this.Base_TextBox.ActualWidth) - caretLocation.X) ;
133
                    System.Diagnostics.Debug.WriteLine("Caret X : " + ((this.EndPoint.X + this.Base_TextBox.ActualWidth) - caretLocation.X));
134
                } 
135
                else if (angle == 270)
136
                {
137
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X) - caretLocation.Y);
138
                }
139
                else
140
                {
141
                    System.Diagnostics.Debug.WriteLine("Caret X : " + (this.EndPoint.X - caretLocation.X));
142
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.X);
143
                } 
144
            }
145

    
146
            if (!double.IsInfinity(caretLocation.Y))
147
            {
148
                if (angle == 90)
149
                {
150
                    Canvas.SetTop(this.BaseTextbox_Caret, this.EndPoint.Y - caretLocation.X);
151
                }
152
                else if (angle == 180)
153
                {//보정치40
154
                    Canvas.SetTop(this.BaseTextbox_Caret, ((this.EndPoint.Y -40) + this.Base_TextBox.ActualHeight)- caretLocation.Y );
155
                    System.Diagnostics.Debug.WriteLine("Caret Y : " + (((this.EndPoint.Y - 40) + this.Base_TextBox.ActualHeight) - caretLocation.Y));
156
                }
157
                else if (angle == 270)
158
                {
159
                    Canvas.SetTop(this.BaseTextbox_Caret, (this.EndPoint.Y) + caretLocation.X);
160
                }
161
                else
162
                {
163
                    Canvas.SetTop(this.BaseTextbox_Caret, this.EndPoint.Y  + caretLocation.Y);
164
                    System.Diagnostics.Debug.WriteLine("Caret Y : " + (this.EndPoint.Y + caretLocation.Y - BaseTextbox_Caret.ActualHeight));
165
                }
166
            }
167
        }
168

    
169
        public void MoveCustomCaret(Point point)
170
        {
171

    
172
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
173

    
174
            if (!double.IsInfinity(caretLocation.X))
175
            {
176
                if (Math.Abs(this.PageAngle) == 90)
177
                {
178
                    Canvas.SetLeft(this.BaseTextbox_Caret, point.X + caretLocation.Y);
179
                }
180
                else if (Math.Abs(this.PageAngle) == 180)
181
                {
182

    
183
                    Canvas.SetLeft(this.BaseTextbox_Caret, (point.X + this.Base_TextBox.ActualWidth) - caretLocation.X);
184
                }
185
                else if (Math.Abs(this.PageAngle) == 270)
186
                {
187
                    Canvas.SetLeft(this.BaseTextbox_Caret, (point.X) - caretLocation.Y);
188
                }
189
                else
190
                {
191
                    Canvas.SetLeft(this.BaseTextbox_Caret, point.X + caretLocation.X);
192
                }
193
            }
194

    
195
            if (!double.IsInfinity(caretLocation.Y))
196
            {
197
                if (Math.Abs(this.PageAngle) == 90)
198
                {
199
                    Canvas.SetTop(this.BaseTextbox_Caret, point.Y - caretLocation.X);
200
                }
201
                else if (Math.Abs(this.PageAngle) == 180)
202
                {
203
                    Canvas.SetTop(this.BaseTextbox_Caret, (point.Y + this.Base_TextBox.ActualHeight) - caretLocation.Y);
204
                }
205
                else if (Math.Abs(this.CommentAngle) == 270)
206
                {
207
                    Canvas.SetTop(this.BaseTextbox_Caret, (point.Y) + caretLocation.X);
208
                }
209
                else
210
                {
211
                    Canvas.SetTop(this.BaseTextbox_Caret, point.Y + caretLocation.Y);
212
                }
213
            }
214
        }
215

    
216

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

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

    
230
            if(EditEnded != null)
231
            {
232
                EditEnded(this, new EventArgs());
233
            }
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 PathGeometry SubPathData
323
        {
324
            get { return (PathGeometry)GetValue(SubPathDataProperty); }
325
            set
326
            {
327
                if (this.SubPathData != value)
328
                {
329
                    SetValue(SubPathDataProperty, value);
330
                }
331
            }
332
        }
333

    
334
        public string UserID
335
        {
336
            get { return (string)GetValue(UserIDProperty); }
337
            set
338
            {
339
                if (this.UserID != value)
340
                {
341
                    SetValue(UserIDProperty, value);
342
                    OnPropertyChanged("UserID");
343
                }
344
            }
345
        }
346

    
347
        public List<Point> PointSet
348
        {
349
            get { return (List<Point>)GetValue(PointSetProperty); }
350
            set { SetValue(PointSetProperty, value); }
351
        }
352

    
353
        public override bool IsSelected
354
        {
355
            get
356
            {
357
                return (bool)GetValue(IsSelectedProperty);
358
            }
359
            set
360
            {
361
                SetValue(IsSelectedProperty, value);
362
                OnPropertyChanged("IsSelected");
363
            }
364
        }
365

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

    
379
        public Point StartPoint
380
        {
381
            get { return (Point)GetValue(StartPointProperty); }
382
            set { SetValue(StartPointProperty, value); }
383
        }
384

    
385
        public Point EndPoint
386
        {
387
            get { return (Point)GetValue(EndPointProperty); }
388
            set { SetValue(EndPointProperty, value); }
389
        }
390

    
391
        public Point OverViewStartPoint
392
        {
393
            get { return (Point)GetValue(OverViewStartPointProperty); }
394
            set { SetValue(OverViewStartPointProperty, value); }
395
        }
396

    
397
        public Point OverViewEndPoint
398
        {
399
            get { return (Point)GetValue(OverViewEndPointProperty); }
400
            set { SetValue(OverViewEndPointProperty, value); }
401
        }
402

    
403

    
404
        //public double Angle
405
        //{
406
        //    get { return (double)GetValue(AngleProperty); }
407
        //    set { SetValue(AngleProperty, value); }
408
        //}
409

    
410
        public Thickness BorderSize
411
        {
412
            get { return (Thickness)GetValue(BorderSizeProperty); }
413
            set
414
            {
415
                if (this.BorderSize != value)
416
                {
417
                    SetValue(BorderSizeProperty, value);
418
                }
419
            }
420
        }
421

    
422

    
423
        public Point MidPoint
424
        {
425
            get { return (Point)GetValue(MidPointProperty); }
426
            set { SetValue(MidPointProperty, value); }
427
        }
428

    
429
        public bool isFixed
430
        {
431
            get { return (bool)GetValue(IsFixedProperty); }
432
            set { SetValue(IsFixedProperty, value); }
433
        }
434

    
435
        public bool isTrans
436
        {
437
            get { return (bool)GetValue(TransformerProperty); }
438
            set { SetValue(TransformerProperty, value); }
439
        }
440

    
441
        public bool isHighLight
442
        {
443
            get { return (bool)GetValue(isHighlightProperty); }
444
            set
445
            {
446
                if (this.isHighLight != value)
447
                {
448
                    SetValue(isHighlightProperty, value);
449
                    OnPropertyChanged("isHighLight");
450
                }
451
            }
452
        }
453

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

    
467
        public Double LineSize
468
        {
469
            get { return (Double)GetValue(LineSizeProperty); }
470
            set
471
            {
472
                if (this.LineSize != value)
473
                {
474
                    SetValue(LineSizeProperty, value);
475
                }
476
            }
477
        }
478

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

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

    
503
        public ArrowTextStyleSet ArrowTextStyle
504
        {
505
            get { return (ArrowTextStyleSet)GetValue(ArrowTextStyleProperty); }
506
            set
507
            {
508
                if (this.ArrowTextStyle != value)
509
                {
510
                    SetValue(ArrowTextStyleProperty, value);
511
                }
512
            }
513
        }
514

    
515
        public Geometry PathData
516
        {
517
            get { return (Geometry)GetValue(PathDataProperty); }
518
            set { SetValue(PathDataProperty, value);
519

    
520
                OnPropertyChanged("PathData");
521
            }
522
        }
523

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

    
537
        public Geometry PathDataInner
538
        {
539
            get { return (Geometry)GetValue(PathDataInnerProperty); }
540
            set
541
            {
542
                SetValue(PathDataInnerProperty, value);
543
                OnPropertyChanged("PathDataInner");
544
            }
545
        }
546

    
547
        public Geometry OverViewPathData
548
        {
549
            get { return (Geometry)GetValue(OverViewPathDataProperty); }
550
            set { SetValue(OverViewPathDataProperty, value);
551

    
552
                OnPropertyChanged("OverViewPathData");
553

    
554
            }
555
        }
556

    
557
        public FontFamily TextFamily
558
        {
559
            get { return (FontFamily)GetValue(TextFamilyProperty); }
560
            set
561
            {
562
                if (this.TextFamily != value)
563
                {
564
                    SetValue(TextFamilyProperty, value);
565
                    OnPropertyChanged("TextFamily");
566
                }
567
            }
568
        }
569

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

    
583
        public string OverViewArrowText
584
        {
585

    
586
            get { return (string)GetValue(OverViewArrowTextProperty);
587
            }
588
            set
589
            {
590
                if (this.OverViewArrowText != value)
591
                {
592
                    SetValue(OverViewArrowTextProperty, value);
593
                    OnPropertyChanged("OverViewArrowText");
594
                }
595
            }
596
        }
597

    
598
        public Double TextSize
599
        {
600
            get { return (Double)GetValue(TextSizeProperty); }
601
            set
602
            {
603
                if (this.TextSize != value)
604
                {
605
                    SetValue(TextSizeProperty, value);
606
                    OnPropertyChanged("TextSize");
607
                }
608
            }
609
        }
610

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

    
624
        //강인구 추가
625
        public TextDecorationCollection UnderLine
626
        {
627
            get
628
            {
629
                return (TextDecorationCollection)GetValue(UnderLineProperty);
630
            }
631
            set
632
            {
633
                if (this.UnderLine != value)
634
                {
635
                    SetValue(UnderLineProperty, value);
636
                    OnPropertyChanged("UnderLine");
637
                }
638
            }
639
        }
640

    
641
        public double CanvasX
642
        {
643
            get { return (double)GetValue(CanvasXProperty); }
644
            set
645
            {
646
                if (this.CanvasX != value)
647
                {
648
                    SetValue(CanvasXProperty, value);
649
                    OnPropertyChanged("CanvasX");
650
                }
651
            }
652
        }
653

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

    
667
        public double CenterX
668
        {
669
            get { return (double)GetValue(CenterXProperty); }
670
            set { SetValue(CenterXProperty, value);
671
            OnPropertyChanged("CenterX");
672
            
673
            }
674
        }
675

    
676
        public double CenterY
677
        {
678
            get { return (double)GetValue(CenterYProperty); }
679
            set { SetValue(CenterYProperty, value);
680
            OnPropertyChanged("CenterY");
681
            }
682
        }
683

    
684
        public Brush SubPathFill
685
        {
686
            get { return (Brush)GetValue(SubPathFillProperty); }
687
            set
688
            {
689
                SetValue(SubPathFillProperty, value);
690
                OnPropertyChanged("SubPathFill");
691
            }
692
        }
693

    
694
        public Brush TextBoxBackground
695
        {
696
            get { return (Brush)GetValue(TextBoxBackgroundProperty); }
697
            set
698
            {
699
                SetValue(TextBoxBackgroundProperty, value);
700
                OnPropertyChanged("TextBoxBackground");
701
            }
702
        }
703

    
704

    
705
        //강인구 추가 주석풀기
706
       
707

    
708
        public bool EnableEditing
709
        {
710
            get { return (bool)GetValue(EnableEditingProperty); }
711
            set
712
            {
713
                if (this.EnableEditing != value)
714
                {
715
                    SetValue(EnableEditingProperty, value);
716
                    OnPropertyChanged("EnableEditing");
717
                }
718
            }
719
        }
720

    
721
        #endregion
722

    
723
        #region Dependency Properties
724

    
725
        public static readonly DependencyProperty BoxWidthProperty = DependencyProperty.Register(
726
                "BoxWidth", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
727

    
728
        public static readonly DependencyProperty BoxHeightProperty = DependencyProperty.Register(
729
                "BoxHeight", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
730

    
731
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
732
                "UserID", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
733

    
734
        public static readonly DependencyProperty ArrowTextStyleProperty = DependencyProperty.Register(
735
               "ArrowTextStyle", typeof(ArrowTextStyleSet), typeof(ArrowTextControl), new PropertyMetadata(ArrowTextStyleSet.Normal));
736

    
737
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register(
738
                "CenterX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
739

    
740
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register(
741
                "CenterY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
742

    
743
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register(
744
                "Angle", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(PointValueChanged)));
745
        
746
        public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
747
                "CanvasX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
748

    
749
        public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
750
                "CanvasY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
751

    
752
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
753
                "PointSet", typeof(List<Point>), typeof(ArrowTextControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
754

    
755
        public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register(
756
                "TextFamily", typeof(FontFamily), typeof(ArrowTextControl), new PropertyMetadata(new FontFamily("Arial"), TextChanged));
757

    
758
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
759
                "PathData", typeof(Geometry), typeof(ArrowTextControl), null);
760

    
761
        //강인구 추가
762
        public static readonly DependencyProperty UnderLineProperty = DependencyProperty.Register(
763
    "UnderLine", typeof(TextDecorationCollection), typeof(ArrowTextControl), new PropertyMetadata(null, PointValueChanged));
764

    
765
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
766
               "LineSize", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)3, PointValueChanged));
767

    
768
        public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register(
769
                "TextStyle", typeof(FontStyle), typeof(ArrowTextControl), new PropertyMetadata(FontStyles.Normal));
770

    
771
        public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register(
772
                "TextSize", typeof(Double), typeof(ArrowTextControl), new PropertyMetadata((Double)30, PointValueChanged));
773

    
774
        public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register(
775
                "TextWeight", typeof(FontWeight), typeof(ArrowTextControl), new PropertyMetadata(FontWeights.Normal));
776

    
777
        public static readonly DependencyProperty IsFixedProperty = DependencyProperty.Register(
778
                "isFixed", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
779

    
780
        public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
781
                "IsSelected", typeof(bool), typeof(ArrowTextControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
782

    
783
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
784
                "StrokeColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
785

    
786
        public static readonly DependencyProperty ControlTypeProperty = DependencyProperty.Register(
787
                "ControlType", typeof(ControlType), typeof(ArrowTextControl), new FrameworkPropertyMetadata(ControlType.ArrowTextControl));
788

    
789
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
790
                "StartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
791

    
792
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
793
                "EndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
794

    
795
        public static readonly DependencyProperty BackInnerColorProperty = DependencyProperty.Register(
796
            "BackInnerColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.White)));
797

    
798
        public static readonly DependencyProperty PathDataInnerProperty = DependencyProperty.Register(
799
    "PathDataInner", typeof(Geometry), typeof(ArrowTextControl), null);
800

    
801
        public static readonly DependencyProperty isHighlightProperty = DependencyProperty.Register(
802
                "isHighlight", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
803

    
804
        public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register(
805
                "MidPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
806

    
807
        public static readonly DependencyProperty TransformerProperty = DependencyProperty.Register(
808
                "isTrans", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
809

    
810
        public static readonly DependencyProperty BorderSizeProperty = DependencyProperty.Register(
811
                "BorderSize", typeof(Thickness), typeof(ArrowTextControl), new PropertyMetadata(new Thickness(0), PointValueChanged));
812
    
813
        public static readonly DependencyProperty ArrowTextProperty = DependencyProperty.Register(
814
              "ArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
815

    
816

    
817

    
818
        //, new PropertyChangedCallback(TextChanged)
819

    
820

    
821
        #region 추가 사항
822
        public static readonly DependencyProperty SubPathDataProperty = DependencyProperty.Register(
823
                "SubPathData", typeof(Geometry), typeof(ArrowTextControl), null);
824

    
825

    
826
        public static readonly DependencyProperty SubPathFillProperty = DependencyProperty.Register(
827
                "SubPathFill", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(null));
828

    
829
        public static readonly DependencyProperty TextBoxBackgroundProperty = DependencyProperty.Register(
830
                "TextBoxBackground", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(Brushes.White));
831

    
832
        public static readonly DependencyProperty OverViewArrowTextProperty = DependencyProperty.Register(
833
                "OverViewArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null, new PropertyChangedCallback(TextChanged)));
834

    
835
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
836
                "OverViewPathData", typeof(Geometry), typeof(ArrowTextControl), null);
837

    
838
        public static readonly DependencyProperty OverViewStartPointProperty = DependencyProperty.Register(
839
                "OverViewStartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
840

    
841
        public static readonly DependencyProperty OverViewEndPointProperty = DependencyProperty.Register(
842
                "OverViewEndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
843

    
844
        public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register(
845
            "TextBoxVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged));
846

    
847
        //강인구 추가(주석풀기)
848
        public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register(
849
            "TextBlockVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged));
850

    
851
        public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register(
852
           "EnableEditing", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata((true), new PropertyChangedCallback(OnIsEditingChanged)));
853

    
854
        #endregion
855

    
856
        #endregion
857

    
858
        #region CallBack Method
859

    
860
        //강인구 추가(주석풀기)
861
        public static void OnIsEditingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
862
        {
863
            var instance = (ArrowTextControl)sender;
864

    
865
            if (e.OldValue != e.NewValue && instance.Base_TextBlock != null)
866
            {
867
                instance.SetValue(e.Property, e.NewValue);
868

    
869
                if (instance.EnableEditing)
870
                {
871
                    instance.EditingMode();
872
                }
873
                else
874
                {
875
                    instance.UnEditingMode();
876
                }
877
            }
878
        }
879

    
880
        public static void OnTextBoxVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
881
        {
882
            var instance = (ArrowTextControl)sender;
883

    
884
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
885
            {
886
                instance.SetValue(e.Property, e.NewValue);
887
            }
888
        }
889

    
890
        public static void OnTextBlockVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
891
        {
892
            var instance = (ArrowTextControl)sender;
893

    
894
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
895
            {
896
                instance.SetValue(e.Property, e.NewValue);
897
            }
898
        }
899

    
900
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
901
        {
902
            var instance = (ArrowTextControl)sender;
903

    
904
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
905
            {
906
                instance.SetArrowTextPath();
907
            }
908
        }
909

    
910

    
911

    
912
        public static void TextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
913
        {
914
            var instance = (ArrowTextControl)sender;
915
            
916
            if (e.OldValue != e.NewValue)
917
            {
918
                instance.SetValue(e.Property, e.NewValue);
919
                //instance.BoxWidth = instance.Base_TextBox.ActualWidth;
920
                //instance.BoxHeight = instance.Base_TextBox.ActualHeight;
921
            }
922
        }
923

    
924
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
925
        {
926
            var instance = (ArrowTextControl)sender;
927
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
928
            {
929
                instance.SetValue(e.Property, e.NewValue);
930
                instance.SetArrowTextPath();
931
            }
932
        }
933

    
934
        public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
935
        {
936
            var instance = (ArrowTextControl)sender;
937

    
938
            if (e.OldValue != e.NewValue && instance != null)
939
            {
940
                instance.SetValue(e.Property, e.NewValue);
941
                //Canvas.SetLeft(instance, instance.CanvasX);
942
                //Canvas.SetTop(instance, instance.CanvasY);
943
            }
944
        }
945

    
946
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
947
        {
948
            //var instance = (ArrowTextControl)sender;
949

    
950
            //if (e.OldValue != e.NewValue)
951
            //{
952
            //    instance.SetValue(e.Property, e.NewValue);
953

    
954
            //    if (instance.IsSelected && instance.Base_TextBox != null)
955
            //    {
956
            //        instance.BorderSize = new Thickness(1);
957
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Blue);
958
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Blue);
959
            //    }
960
            //    else
961
            //    {
962
            //        instance.BorderSize = new Thickness(0);
963
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Transparent);
964
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Transparent);
965
            //    }
966
            //}
967
        }
968
        #endregion
969

    
970
        #region Internal Method
971

    
972
        //강인구 주석 풀기
973
        public void EditingMode()
974
        {
975
            TextBoxVisibility = Visibility.Visible;
976
            TextBlockVisibility = Visibility.Collapsed;
977

    
978

    
979
            //강인구 언더라인 추가
980
            if (UnderLine != null)
981
                Base_TextBlock.TextDecorations = UnderLine;
982
        }
983
        //강인구 주석 풀기
984
        public void UnEditingMode()
985
        {
986

    
987
            TextBoxVisibility = Visibility.Collapsed;
988
            TextBlockVisibility = Visibility.Visible;
989

    
990
            if (UnderLine != null)
991
                Base_TextBlock.TextDecorations = UnderLine;
992

    
993
            Base_TextBlock.Margin =
994
                 new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4,
995
                     Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4);
996
        }
997

    
998
        private void SetArrowTextPath(bool IsInit = false)
999
        {
1000
            instanceGroup.Children.Clear();
1001

    
1002
            //VisualPageAngle = 0;
1003

    
1004
            if (Math.Abs(PageAngle).ToString() == "90")
1005
            {
1006
                VisualPageAngle = 270;
1007
            }
1008
            else if (Math.Abs(PageAngle).ToString() == "270")
1009
            {
1010
                VisualPageAngle = 90;
1011
            }
1012
            else
1013
            {
1014
                VisualPageAngle = PageAngle;
1015
            }
1016

    
1017
            connectorSMGeometry.StartPoint = this.StartPoint;
1018
            connectorSMGeometry.EndPoint = this.MidPoint;
1019
            connectorMEGeometry.StartPoint = this.MidPoint; //핵심
1020

    
1021
            /// 텍스트박스의 좌표 설정
1022
            Canvas.SetLeft(Base_TextBox, this.EndPoint.X);
1023
            Canvas.SetTop(Base_TextBox, this.EndPoint.Y);
1024
            //System.Diagnostics.Debug.WriteLine($"TextBox Set {this.EndPoint.X},{this.EndPoint.Y}");
1025
            
1026

    
1027
            List<Point> ps = new List<Point>();
1028
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox))); //상단
1029
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox) + this.BoxHeight)); // 하단
1030
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2)); //좌단
1031
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2));  //우단
1032

    
1033
            if (isTrans)
1034
            {
1035
                switch (Math.Abs(this.PageAngle).ToString())
1036
                {
1037
                    case "90":
1038
                        {
1039
                            ps.Clear();
1040
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1041
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1042
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1043

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

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

    
1050
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간
1051
                        }
1052
                        break;
1053
                    case "270":
1054
                        {
1055
                            ps.Clear();
1056
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1057
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1058
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1059

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

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

    
1066
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간
1067
                        }
1068
                        break;
1069
                    default:
1070
                        break;
1071
                }
1072
                
1073
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1074

    
1075
                //20180911 LJY 꺾이는 부분 수정
1076
                Point testP = endP;                
1077
                switch (Math.Abs(this.PageAngle).ToString())
1078
                {
1079
                    case "90":
1080
                        testP = new Point(endP.X + 50, endP.Y);
1081
                        break;
1082
                    case "270":
1083
                        testP = new Point(endP.X - 50, endP.Y);
1084
                        break;
1085
                }                
1086

    
1087
                //20180910 LJY 각도에 따라.
1088
                switch (Math.Abs(this.PageAngle).ToString())
1089
                {
1090
                    case "90":
1091
                        if (isFixed)
1092
                        {
1093
                            if (ps[0] == endP) //상단
1094
                            {
1095
                                testP = new Point(endP.X , endP.Y + 50);
1096
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1097
                            }
1098
                            else if (ps[1] == endP) //하단
1099
                            {
1100
                                testP = new Point(endP.X , endP.Y - 50);
1101
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1102
                            }
1103
                            else if (ps[2] == endP) //좌단
1104
                            {
1105
                                testP = new Point(endP.X - 50, endP.Y);
1106
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1107
                            }
1108
                            else if (ps[3] == endP) //우단
1109
                            {
1110
                                testP = new Point(endP.X + 50, endP.Y);
1111
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1112
                            }
1113
                        }
1114
                        break;
1115
                    case "270":
1116
                        if (isFixed)
1117
                        {
1118
                            if (ps[0] == endP) //상단
1119
                            {
1120
                                testP = new Point(endP.X , endP.Y - 50);
1121
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1122
                            }
1123
                            else if (ps[1] == endP) //하단
1124
                            {
1125
                                testP = new Point(endP.X, endP.Y + 50);
1126
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1127
                            }
1128
                            else if (ps[2] == endP) //좌단
1129
                            {
1130
                                testP = new Point(endP.X + 50, endP.Y);
1131
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1132
                            }
1133
                            else if (ps[3] == endP) //우단
1134
                            {
1135
                                testP = new Point(endP.X - 50, endP.Y);
1136
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1137
                            }
1138
                        }
1139
                        break;
1140
                    default:
1141
                        if (isFixed)
1142
                        {
1143
                            if (ps[0] == endP) //상단
1144
                            {
1145
                                testP = new Point(endP.X, endP.Y - 50);
1146
                                //System.Diagnostics.Debug.WriteLine("상단");
1147
                            }
1148
                            else if (ps[1] == endP) //하단
1149
                            {
1150
                                testP = new Point(endP.X, endP.Y + 50);
1151
                                //System.Diagnostics.Debug.WriteLine("하단");
1152
                            }
1153
                            else if (ps[2] == endP) //좌단
1154
                            {
1155
                                testP = new Point(endP.X - 50, endP.Y);
1156
                                //System.Diagnostics.Debug.WriteLine("좌단");
1157
                            }
1158
                            else if (ps[3] == endP) //우단
1159
                            {
1160
                                testP = new Point(endP.X + 50, endP.Y);
1161
                                //System.Diagnostics.Debug.WriteLine("우단");
1162
                            }
1163
                        }
1164
                        break;
1165
                }
1166
                connectorMEGeometry.EndPoint = endP;
1167
                connectorSMGeometry.EndPoint = testP;
1168
                connectorMEGeometry.StartPoint = testP;
1169
                
1170
                //20180910 LJY 각도에 따라.
1171
                this.MidPoint = testP;
1172
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1173
                instanceGroup.FillRule = FillRule.Nonzero;
1174
                this.Base_ArrowPath.Fill = this.StrokeColor;
1175
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1176
            }
1177
            else
1178
            {
1179
                switch (Math.Abs(this.PageAngle).ToString())
1180
                {
1181
                    case "90":
1182
                        {
1183
                            ps.Clear();
1184

    
1185
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1186
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1187
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1188

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

    
1192
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); //중간 하단
1193
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 하단
1194
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간 
1195
                        }
1196
                        break;
1197
                    case "270":
1198
                        {
1199
                            ps.Clear();
1200
                            
1201
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1202
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1203
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1204

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

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

    
1211
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1212
                        }
1213
                        break;
1214
                    //case "180":
1215
                    //    {
1216
                    //        ps.Clear();
1217

    
1218
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1219
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1220
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1221

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

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

    
1228
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1229
                    //    }
1230
                    //    break;
1231
                    default:
1232
                        break;
1233
                }
1234

    
1235

    
1236
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1237
                connectorMEGeometry.EndPoint = endP; //최상단
1238
                                                     //connectorMEGeometry.EndPoint = this.EndPoint; //핵심
1239
                                                     //this.MidPoint= MathSet.getMiddlePoint(this.StartPoint, endP);
1240
                #region 보정치
1241
                Point testP = endP;
1242

    
1243
                //20180910 LJY 각도에 따라.
1244
                switch (Math.Abs(this.PageAngle).ToString())
1245
                {
1246
                    case "90":
1247
                        if (isFixed)
1248
                        {
1249
                            if (ps[0] == endP) //상단
1250
                            {
1251
                                testP = new Point(endP.X - 50, endP.Y);
1252
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1253
                            }
1254
                            else if (ps[1] == endP) //하단
1255
                            {
1256
                                testP = new Point(endP.X + 50, endP.Y);
1257
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1258
                            }
1259
                            else if (ps[2] == endP) //좌단
1260
                            {
1261
                                testP = new Point(endP.X - 50, endP.Y);
1262
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1263
                            }
1264
                            else if (ps[3] == endP) //우단
1265
                            {
1266
                                testP = new Point(endP.X + 50 , endP.Y);
1267
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1268
                            }
1269
                        }
1270
                        break;
1271
                    case "270":
1272
                        if (isFixed)
1273
                        {
1274
                            if (ps[0] == endP) //상단
1275
                            {
1276
                                testP = new Point(endP.X + 50, endP.Y);
1277
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1278
                            }
1279
                            else if (ps[1] == endP) //하단
1280
                            {
1281
                                testP = new Point(endP.X - 50, endP.Y);
1282
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1283
                            }
1284
                            else if (ps[2] == endP) //좌단
1285
                            {
1286
                                testP = new Point(endP.X + 50, endP.Y);
1287
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1288
                            }
1289
                            else if (ps[3] == endP) //우단
1290
                            {
1291
                                testP = new Point(endP.X + 50, endP.Y );
1292
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1293
                            }
1294
                        }
1295
                        break;
1296
                    default:
1297
                        if (isFixed)
1298
                        {
1299
                            if (ps[0] == endP) //상단
1300
                            {
1301
                                testP = new Point(endP.X, endP.Y - 50);
1302
                                //System.Diagnostics.Debug.WriteLine("상단");
1303
                            }
1304
                            else if (ps[1] == endP) //하단
1305
                            {
1306
                                testP = new Point(endP.X, endP.Y + 50);
1307
                                //System.Diagnostics.Debug.WriteLine("하단");
1308
                            }
1309
                            else if (ps[2] == endP) //좌단
1310
                            {
1311
                                testP = new Point(endP.X - 50, endP.Y);
1312
                                //System.Diagnostics.Debug.WriteLine("좌단");
1313
                            }
1314
                            else if (ps[3] == endP) //우단
1315
                            {
1316
                                testP = new Point(endP.X + 50, endP.Y);
1317
                                //System.Diagnostics.Debug.WriteLine("우단");
1318
                            }
1319
                        }
1320
                        break;
1321
                }
1322
                  
1323

    
1324
                connectorSMGeometry.EndPoint = testP;
1325
                connectorMEGeometry.StartPoint = testP;
1326
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1327
                instanceGroup.FillRule = FillRule.Nonzero;
1328
                this.Base_ArrowPath.Fill = this.StrokeColor;
1329
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1330
                #endregion
1331
            }
1332

    
1333
            switch (this.ArrowTextStyle)
1334
            {
1335
                case ArrowTextStyleSet.Normal:
1336
                    this.BorderSize = new Thickness(0);
1337
                    DrawingRect();
1338
                    break;
1339
                case ArrowTextStyleSet.Cloud:
1340
                    this.BorderSize = new Thickness(0);
1341
                    DrawingCloud();
1342
                    break;
1343
                default:
1344
                    {
1345
                        this.BorderSize = new Thickness(LineSize); //올라
1346
                        DrawingRect();
1347
                    }
1348

    
1349
                    break;
1350
            }
1351

    
1352
            if (isHighLight)
1353
            {
1354
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1355
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1356

    
1357
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1358
            }
1359
            else
1360
            {
1361
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1362
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1363
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1), Colors.White.R, Colors.White.G, Colors.White.B));
1364
            }
1365

    
1366
            instanceGroup.Children.Add(connectorSMGeometry);
1367
            instanceGroup.Children.Add(connectorMEGeometry);
1368

    
1369
            this.PathData = instanceGroup;
1370
            OverViewPathData = PathData;
1371
            OverViewArrowText = ArrowText;
1372
            OverViewEndPoint = connectorMEGeometry.EndPoint;
1373
            OverViewStartPoint = connectorSMGeometry.StartPoint;
1374

    
1375
            var tempAngle = Math.Abs(this.VisualPageAngle);
1376

    
1377
            if (tempAngle == Convert.ToDouble(90) || tempAngle == Convert.ToDouble(270))
1378
            {
1379
                this.RenderTransformOrigin = new Point(0.5, 0.5);
1380
                this.Base_ArrowPath.RenderTransformOrigin = new Point(0, 0);
1381
                this.Base_ArrowSubPath.RenderTransformOrigin = new Point(0, 0);
1382

    
1383
                Base_TextBox.RenderTransformOrigin = new Point(0, 0);
1384
                BaseTextbox_Caret.RenderTransformOrigin = new Point(0, 0);
1385
            }
1386

    
1387
            Base_TextBox.RenderTransform = new RotateTransform
1388
            {
1389
                Angle = this.VisualPageAngle,
1390
                CenterX = this.CenterX,
1391
                CenterY = this.CenterY,
1392
            };
1393

    
1394
            Base_ArrowSubPath.RenderTransform = new RotateTransform
1395
            {
1396
                Angle = this.VisualPageAngle,
1397
                CenterX = this.EndPoint.X,
1398
                CenterY = this.EndPoint.Y,
1399
            };
1400

    
1401
            if (BaseTextbox_Caret.Visibility == Visibility.Visible)
1402
            {
1403
                BaseTextbox_Caret.RenderTransform = new RotateTransform
1404
                {
1405
                    Angle = this.VisualPageAngle,
1406
                    CenterX = this.CenterX,
1407
                    CenterY = this.CenterY,
1408
                };
1409

    
1410
                MoveCustomCaret();
1411
            }
1412
        }
1413

    
1414
        private void DrawingCloud()
1415
        {
1416
            //20180906 LJY Textbox guide
1417
            string angle = Math.Abs(this.PageAngle).ToString();
1418
            if (angle == "180")
1419
            {
1420
                List<Point> pCloud = new List<Point>()
1421
                {
1422
                     new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1423
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxHeight), //왼쪽 아래
1424
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox) - BoxHeight),
1425
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox)),
1426
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1427
                };
1428
                SubPathData = (Generate(pCloud));
1429
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1430
            
1431
            }//20180906 LJY Textbox guide
1432
            else
1433
            {            
1434
                List<Point> pCloud = new List<Point>()
1435
                {
1436
    #if SILVERLIGHT
1437
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1438
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1439
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1440
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1441
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1442

    
1443
    #else
1444
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1445
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1446
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1447
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1448
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1449

    
1450
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1451
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1452
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1453
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1454
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1455
    #endif
1456
                };
1457
                //instanceGroup.Children.Add(Generate(pCloud));
1458
                SubPathData = (Generate(pCloud));
1459
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1460
                //   }
1461
            }
1462

    
1463
        }
1464

    
1465
        private void DrawingRect()
1466
        {
1467
            //20180906 LJY Textbox guide
1468
            if(this.ArrowTextStyle == ArrowTextStyleSet.Normal)
1469
            {
1470
                this.Base_TextBox.BorderBrush = Brushes.Transparent;
1471
            }
1472

    
1473
            if (Math.Abs(this.PageAngle).ToString() == "90")
1474
            {
1475
                List<Point> pCloud = new List<Point>()
1476
                {
1477
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1478
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxWidth), //왼쪽 아래
1479
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox) - BoxWidth),
1480
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox)),
1481
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1482
                };
1483
                PathDataInner = (GenerateInner(pCloud));
1484
            }
1485
            else if(Math.Abs(this.PageAngle).ToString() == "270")
1486
            {
1487
                List<Point> pCloud = new List<Point>()
1488
                {
1489
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1490
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + BoxWidth), //왼쪽 아래
1491
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox) + BoxWidth),
1492
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox)),
1493
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1494
                };
1495
                PathDataInner = (GenerateInner(pCloud));
1496
            }//20180906 LJY Textbox guide
1497
            else
1498
            { 
1499
                List<Point> pCloud = new List<Point>()
1500
                {
1501
    #if SILVERLIGHT
1502
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1503
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1504
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1505
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1506
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1507

    
1508
    #else
1509
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1510
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1511
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1512
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1513
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1514

    
1515
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1516
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1517
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1518
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1519
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1520
    #endif
1521
                };
1522
                //instanceGroup.Children.Add(Generate(pCloud));
1523
                PathDataInner = (GenerateInner(pCloud));
1524
            }
1525
        }
1526

    
1527
        public override void UpdateControl()
1528
        {
1529
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
1530
            this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
1531
            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
1532
        }
1533

    
1534
        public override void ApplyOverViewData()
1535
        {
1536
            this.OverViewPathData = this.PathData;
1537
            if (ArrowText == "")
1538
            {
1539
                this.OverViewArrowText = "";
1540
                this.ArrowText = this.OverViewArrowText;
1541
            }
1542
            else
1543
                this.OverViewArrowText = this.ArrowText;
1544
            this.OverViewStartPoint = this.StartPoint;
1545
            this.OverViewEndPoint = this.EndPoint;
1546
        }
1547

    
1548
        #endregion
1549

    
1550
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
1551
        {
1552
            PathFigure pathFigure = new PathFigure();
1553
            pathFigure.StartPoint = p1;
1554

    
1555
            double arcLength = arcLength_;
1556
            /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung 
1557
            double dx = p2.X - p1.X;
1558
            double dy = p2.Y - p1.Y;
1559
            double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2
1560
            double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
1561
            Point lastPt = new Point(p1.X, p1.Y);
1562
            double count = l / arcLength;
1563
            /// normalize
1564
            dx /= l;
1565
            dy /= l;
1566
            Double j = 1;
1567
            for (j = 1; j < (count - 1); j++) 
1568
            {
1569
                ArcSegment arcSeg = new ArcSegment();
1570
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);						/// x size and y size of arc
1571
                arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);	/// end point of arc
1572
                lastPt = arcSeg.Point;  /// save last point
1573
                arcSeg.RotationAngle = theta + 90;
1574
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1575
                pathFigure.Segments.Add(arcSeg);
1576
            }
1577

    
1578
            /// draw arc between last point and end point
1579
            if ((count > j) || (count > 0))
1580
            {
1581
                arcLength = MathSet.DistanceTo(lastPt, p2);
1582
                ArcSegment arcSeg = new ArcSegment();
1583
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);	/// x size and y size of arc
1584
                arcSeg.Point = new Point(p2.X, p2.Y);						/// end point of arc
1585
                arcSeg.RotationAngle = theta;
1586
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1587
                pathFigure.Segments.Add(arcSeg);
1588
            }
1589
            /// up to here
1590

    
1591
            return pathFigure;
1592
        }
1593

    
1594
        public static PathGeometry Generate(List<Point> pData)
1595
        {
1596
            var _pathGeometry = new PathGeometry();
1597
            
1598
            double area = MathSet.AreaOf(pData);
1599
            bool reverse = (area > 0);
1600
            int count = pData.Count;
1601
            for (int i = 0; i < (count - 1); i++)
1602
            {
1603
                PathFigure pathFigure = GenerateLineWithCloud(pData[i], pData[i + 1], 20, reverse);
1604
                pathFigure.IsClosed = false;
1605
                pathFigure.IsFilled = true;
1606
                _pathGeometry.Figures.Add(pathFigure);
1607
            }
1608
            
1609
            return _pathGeometry;
1610
        }
1611

    
1612
        
1613
        public static PathGeometry GenerateInner(List<Point> pData)
1614
        {
1615
            var _pathGeometry = new PathGeometry();
1616
            double area = MathSet.AreaOf(pData);
1617
            bool reverse = (area > 0);
1618
            int count = pData.Count;
1619

    
1620
            PathFigure pathFigur2 = new PathFigure();
1621
            pathFigur2.StartPoint = pData[0];
1622

    
1623
            LineSegment lineSegment0 = new LineSegment();
1624
            lineSegment0.Point = pData[0];
1625
            pathFigur2.Segments.Add(lineSegment0);
1626

    
1627
            LineSegment lineSegment1 = new LineSegment();
1628
            lineSegment1.Point = pData[1];
1629
            pathFigur2.Segments.Add(lineSegment1);
1630

    
1631
            LineSegment lineSegment2 = new LineSegment();
1632
            lineSegment2.Point = pData[2];
1633
            pathFigur2.Segments.Add(lineSegment2);
1634

    
1635
            LineSegment lineSegment3 = new LineSegment();
1636
            lineSegment3.Point = pData[3];
1637
            pathFigur2.Segments.Add(lineSegment3);
1638

    
1639

    
1640
            pathFigur2.IsClosed = true;
1641
            pathFigur2.IsFilled = true;
1642
            _pathGeometry.Figures.Add(pathFigur2);           
1643

    
1644
            return _pathGeometry;
1645
        }
1646

    
1647
        //20180910 LJY Cloud rotation 추가
1648
        public static PathGeometry GenerateInnerCloud(List<Point> pData, string angle)
1649
        {
1650
            var _pathGeometry = new PathGeometry();
1651
            double area = MathSet.AreaOf(pData);
1652
            bool reverse = (area > 0);
1653
            int count = pData.Count;
1654

    
1655
            PathFigure pathFigur2 = new PathFigure();
1656
            pathFigur2.StartPoint = pData[0];
1657

    
1658
            LineSegment lineSegment0 = new LineSegment();
1659
            lineSegment0.Point = pData[0];
1660
            pathFigur2.Segments.Add(lineSegment0);
1661

    
1662
            LineSegment lineSegment1 = new LineSegment();
1663
            lineSegment1.Point = pData[1];
1664
            pathFigur2.Segments.Add(lineSegment1);
1665

    
1666
            LineSegment lineSegment2 = new LineSegment();
1667
            lineSegment2.Point = pData[2];
1668
            pathFigur2.Segments.Add(lineSegment2);
1669

    
1670
            LineSegment lineSegment3 = new LineSegment();
1671
            lineSegment3.Point = pData[3];
1672
            pathFigur2.Segments.Add(lineSegment3);
1673
            
1674
            RotateTransform transform = new RotateTransform();
1675
            switch (angle)
1676
            {
1677
                case "90":
1678
                    transform.Angle = -90;
1679
                    break;
1680
                case "180":
1681
                    transform.Angle = -180;
1682
                    break;
1683
                case "270":
1684
                    transform.Angle = -270;
1685
                    break;
1686
            }
1687
            transform.CenterX = pData[0].X;
1688
            transform.CenterY = pData[0].Y;
1689
            _pathGeometry.Transform = transform;
1690

    
1691
            pathFigur2.IsClosed = true;
1692
            pathFigur2.IsFilled = true;
1693
            _pathGeometry.Figures.Add(pathFigur2);
1694

    
1695
            return _pathGeometry;
1696
        }
1697

    
1698
        /// <summary>
1699
        /// call when mouse is moving while drawing control
1700
        /// </summary>
1701
        /// <author>humkyung</author>
1702
        /// <param name="pt"></param>
1703
        /// <param name="bAxisLocked"></param>
1704
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
1705
        {
1706
            this.EndPoint = pt;
1707

    
1708
            Point tempPoint = this.EndPoint;
1709
            CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1710

    
1711
            if (bAxisLocked)
1712
            {
1713
                this.EndPoint = tempPoint;
1714
            }
1715

    
1716
            this.MidPoint = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint);
1717
            this.isFixed = (this.ControlType == ControlType.ArrowTransTextControl) || 
1718
                (this.ControlType == ControlType.ArrowTransTextBorderControl) || (this.ControlType == ControlType.ArrowTransTextCloudControl);
1719

    
1720
            this.PointSet = new List<Point>
1721
            {
1722
                this.StartPoint,
1723
                this.MidPoint,
1724
                this.EndPoint,
1725
            };
1726
        }
1727

    
1728
        /// <summary>
1729
        /// move control point has same location of given pt along given delta
1730
        /// </summary>
1731
        /// <author>humkyung</author>
1732
        /// <date>2019.06.20</date>
1733
        /// <param name="pt"></param>
1734
        /// <param name="dx"></param>
1735
        /// <param name="dy"></param>
1736
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
1737
        {
1738
            IPath path = (this as IPath);
1739

    
1740
            Point selected = MathSet.getNearPoint(path.PointSet, pt);
1741

    
1742
            //StartPoint에 표시된 Thumb는 dx,dy가 +로 더해줘야한다.
1743
            if (path.PointSet.IndexOf(selected) != 0)
1744
            {
1745
                double radian = this.CommentAngle * Math.PI / 180;
1746
                double cos = Math.Cos(radian);
1747
                double sin = Math.Sin(radian);
1748

    
1749
                double _dx = dx * cos - dy * sin;
1750
                double _dy = dx * sin + dy * cos;
1751

    
1752
                //var transform = new RotateTransform() { Angle = CommentAngle, CenterX = dx, CenterY = dy };
1753
                //var transformedPoint = transform.Transform(pt);
1754
                //selected = transformedPoint;
1755

    
1756
                selected.X += _dx;
1757
                selected.Y += _dy;
1758
            }
1759
            else
1760
            {
1761
                selected.X += dx;
1762
                selected.Y += dy;
1763
            }
1764

    
1765
    int i = 0;
1766
            for (i = 0; i < (this as IPath).PointSet.Count; i++)
1767
            {
1768
                if (pt.Equals((this as IPath).PointSet[i])) break;
1769
            }
1770

    
1771
            List<Point> pts = path.PointSet;
1772
            if ((pts[0].X > pts[1].X && dx > 0) || (pts[0].X < pts[1].X && dx < 0))
1773
            {
1774
                pts[1] = new Point(pts[1].X + dx, pts[1].Y);
1775
            }
1776
            if ((pts[0].Y > pts[1].Y && dy > 0) || (pts[0].Y < pts[1].Y && dy < 0))
1777
            {
1778
                pts[1] = new Point(pts[1].X, pts[1].Y + dy);
1779
            }
1780

    
1781
            path.PointSet[1] = pts[1];
1782

    
1783
            if (path.PointSet.Count > i) {
1784
                path.PointSet[i] = selected;
1785
            }
1786
            //System.Diagnostics.Debug.WriteLine($"OnMoveCtrlPoint end : {path.PointSet[1].X},{path.PointSet[1].Y}");
1787
            this.UpdateControl();
1788
        }
1789

    
1790
        /// <summary>
1791
        /// return ArrowTextControl's area
1792
        /// </summary>
1793
        /// <author>humkyung</author>
1794
        /// <date>2019.06.13</date>
1795
        public override Rect ItemRect
1796
        {
1797
            get
1798
            {
1799
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
1800
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
1801
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
1802
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
1803

    
1804
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
1805
            }
1806
        }
1807

    
1808
        /// <summary>
1809
        /// Serialize this
1810
        /// </summary>
1811
        /// <param name="sUserId"></param>
1812
        /// <returns></returns>
1813
        public override string Serialize()
1814
        {
1815
            using (S_ArrowTextControl STemp = new S_ArrowTextControl())
1816
            {
1817
                STemp.TransformPoint = "0|0";
1818
                STemp.PointSet = this.PointSet;
1819
                STemp.SizeSet = String.Format("{0}", this.LineSize);
1820
                STemp.StrokeColor = this.StrokeColor.Color.ToString();
1821
                STemp.StartPoint = this.StartPoint;
1822
                STemp.ArrowStyle = this.ArrowTextStyle;
1823
                //STemp.StrokeColor = "#FF00FF00";
1824
                STemp.UserID = this.UserID;
1825
                STemp.ArrowText = this.Base_TextBox.Text;
1826
                STemp.BorderSize = this.BorderSize;
1827
                STemp.isHighLight = this.isHighLight;
1828
                STemp.BoxHeight = this.BoxHeight;
1829
                STemp.BoxWidth = this.BoxWidth;
1830
                STemp.Opac = this.Opacity;
1831
                STemp.EndPoint = this.EndPoint;
1832
                STemp.isFixed = this.isFixed;
1833
                //STemp.DashSize = this.DashSize;
1834
                STemp.Name = this.GetType().Name.ToString();
1835
                STemp.isTrans = this.isTrans;
1836
                STemp.MidPoint = this.MidPoint;
1837
                STemp.Angle = this.PageAngle;
1838
                STemp.fontConfig = new List<string>()
1839
                            {
1840
                                this.TextFamily.FontName(),
1841
                                this.TextStyle.ToString(),
1842
                                this.TextWeight.ToString(),
1843
                                this.TextSize.ToString(),
1844
                            };
1845

    
1846
                if (this.UnderLine != null)
1847
                {
1848
                    STemp.fontConfig.Add("true");
1849
                }
1850

    
1851
                ///강인구 추가(2017.11.02)
1852
                ///Memo 추가
1853
                STemp.Memo = this.Memo;
1854
                STemp.BorderSize = this.BorderSize;
1855
                return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize()));
1856
            };
1857
        }
1858

    
1859
        /// <summary>
1860
        /// create a arrowtextcontrol from given string
1861
        /// </summary>
1862
        /// <param name="str"></param>
1863
        /// <returns></returns>
1864
        public static ArrowTextControl FromString(string str, SolidColorBrush brush, string sProjectNo,double PageAngle)
1865
        {
1866
            ArrowTextControl instance = null;
1867
            using (S_ArrowTextControl s = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(str))
1868
            {
1869
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1870
                instance = new ArrowTextControl();
1871
                instance.PageAngle = s.Angle;
1872
                instance.LineSize = Convert.ToDouble(data2.First());
1873
                instance.PointSet = s.PointSet;
1874
                instance.StartPoint = s.StartPoint;
1875
                instance.EndPoint = s.EndPoint;
1876
                instance.StrokeColor = brush;
1877
                //instance.DashSize = s.DashSize;
1878
                instance.ArrowTextStyle = s.ArrowStyle;
1879
                instance.isHighLight = s.isHighLight;
1880
                instance.ArrowText = s.ArrowText;
1881
                instance.Opacity = s.Opac;
1882
                instance.BorderSize = s.BorderSize;
1883
                instance.BoxWidth = s.BoxWidth;
1884
                instance.BoxHeight = s.BoxHeight;
1885
                instance.isFixed = s.isFixed;
1886
                //instance.VisualPageAngle = s.Angle;
1887
                instance.UserID = s.UserID;
1888
                instance.isTrans = s.isTrans;
1889
                instance.MidPoint = s.MidPoint;
1890
                instance.Memo = s.Memo;
1891
                if (s.fontConfig == null || s.fontConfig.ToList().Count == 0)
1892
                {
1893
                    s.fontConfig = new List<string>();
1894

    
1895
                    s.fontConfig.Add("Arial");
1896
                    s.fontConfig.Add("Normal");
1897
                    s.fontConfig.Add("Normal");
1898
                    s.fontConfig.Add("30");
1899
                }
1900
                instance.TextFamily = Markus.Fonts.FontHelper.GetFontFamily(s.fontConfig[0]);
1901
                //인구 추가(2018.04.17)
1902
                instance.TextStyle = StringToFont.ConFontStyle(s.fontConfig[1]);
1903
                instance.TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]);
1904
                instance.TextSize = Convert.ToDouble(s.fontConfig[3]);
1905

    
1906
                if (s.fontConfig.Count() == 5)
1907
                {
1908
                    instance.UnderLine = TextDecorations.Underline;
1909
                }
1910
            }
1911

    
1912
            return instance;
1913
        }
1914

    
1915
        #region Dispose
1916
        public void Dispose()
1917
        {
1918
            //GC.Collect();
1919
            ////GC.SuppressFinalize(this);
1920
            this.BaseTextbox_Caret = null;
1921
            this.Base_ArrowPath = null;
1922
            this.Base_ArrowSubPath = null;
1923
            this.Base_TextBlock = null;
1924
            this.Base_TextBox = null;
1925
        } 
1926
        #endregion
1927

    
1928
        #region INotifyPropertyChanged
1929
        private void OnPropertyChanged(string name)
1930
        {
1931
            if (PropertyChanged != null)
1932
            {
1933
                PropertyChanged(this, new PropertyChangedEventArgs(name));
1934
            }
1935
        }
1936

    
1937
        public event PropertyChangedEventHandler PropertyChanged; 
1938
        #endregion
1939
    }
1940
}
클립보드 이미지 추가 (최대 크기: 500 MB)