프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Text / ArrowTextControl.cs @ 1b2cf911

이력 | 보기 | 이력해설 | 다운로드 (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
            this.IsEditingMode = true;
242
        }
243

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

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

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

    
276

    
277
        #endregion
278

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

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

    
308

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

    
321
        public PathGeometry SubPathData
322
        {
323
            get { return (PathGeometry)GetValue(SubPathDataProperty); }
324
            set
325
            {
326
                if (this.SubPathData != value)
327
                {
328
                    SetValue(SubPathDataProperty, value);
329
                }
330
            }
331
        }
332

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

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

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

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

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

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

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

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

    
402

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

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

    
421

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
551
                OnPropertyChanged("OverViewPathData");
552

    
553
            }
554
        }
555

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

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

    
582
        public string OverViewArrowText
583
        {
584

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

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

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

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

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

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

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

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

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

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

    
703

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

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

    
720
        #endregion
721

    
722
        #region Dependency Properties
723

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
815

    
816

    
817
        //, new PropertyChangedCallback(TextChanged)
818

    
819

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

    
824

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

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

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

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

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

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

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

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

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

    
853
        #endregion
854

    
855
        #endregion
856

    
857
        #region CallBack Method
858

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

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

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

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

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

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

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

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

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

    
909

    
910

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

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

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

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

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

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

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

    
969
        #region Internal Method
970

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

    
977

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

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

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

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

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

    
1001
            //VisualPageAngle = 0;
1002

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1234

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

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

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

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

    
1348
                    break;
1349
            }
1350

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

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

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

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

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

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

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

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

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

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

    
1409
                MoveCustomCaret();
1410
            }
1411
        }
1412

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

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

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

    
1462
        }
1463

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

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

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

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

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

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

    
1547
        #endregion
1548

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

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

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

    
1590
            return pathFigure;
1591
        }
1592

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

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

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

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

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

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

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

    
1638

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

    
1643
            return _pathGeometry;
1644
        }
1645

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

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

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

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

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

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

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

    
1694
            return _pathGeometry;
1695
        }
1696

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1911
            return instance;
1912
        }
1913

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

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

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