프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Text / ArrowTextControl.cs @ 3b938959

이력 | 보기 | 이력해설 | 다운로드 (80.3 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,ICommentRect
21
    {
22
        private const string PART_ArrowPath = "PART_ArrowPath";
23
        private const string PART_TextBox = "PART_ArrowTextBox";
24
        //private const string PART_TextBlock = "PART_ArrowTextBlock";
25
        private const string PART_ArrowSubPath = "PART_ArrowSubPath";
26
        private const string PART_Border = "PART_Border";
27
        private const string PART_BaseTextbox_Caret = "Caret";
28

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

    
36

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

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

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

    
48
        #endregion
49

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

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

    
64
        public override void 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
            Base_TextBox.FontFamily = this.TextFamily;
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
                
77
                if (this.ArrowTextStyle == ArrowTextStyleSet.Cloud)
78
                {
79
                    
80
                }
81

    
82
                this.Base_TextBox.ApplyTemplate();
83
                this.Base_TextBox.Text = this.ArrowText;
84

    
85
                MoveCustomCaret();
86

    
87
                Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged);
88
                Base_TextBox.GotFocus += new RoutedEventHandler(Base_TextBox_GotFocus);
89
                Base_TextBox.LostFocus += new RoutedEventHandler(Base_TextBox_LostFocus);
90
                Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret();
91
                this.KeyDown += ArrowTextControl_KeyDown;
92

    
93
                SetArrowTextPath(true);
94

    
95
                Base_TextBox.IsTabStop = true;
96
            }
97
        }
98

    
99
        private void ArrowTextControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
100
        {
101
           if(e.Key == System.Windows.Input.Key.Escape)
102
            {
103
                if(string.IsNullOrEmpty(Base_TextBox.Text))
104
                {
105
                    this.Visibility = Visibility.Collapsed;
106
                }
107

    
108
                EditEnd();
109
            }
110
        }
111

    
112
        public void SetFontFamily(FontFamily fontFamily)
113
        {
114
            if (this.Base_TextBlock != null)
115
            {
116
                this.Base_TextBlock.FontFamily = fontFamily;
117
            }
118

    
119
            if (this.Base_TextBox != null)
120
            {
121
                this.Base_TextBox.FontFamily = fontFamily;
122
            }
123
            this.FontFamily = fontFamily;
124
            this.TextFamily = fontFamily;
125
        }
126

    
127
        /// <summary>
128
        /// Moves the custom caret on the canvas.
129
        /// </summary>
130
        public void MoveCustomCaret()
131
        {
132
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
133

    
134
            var angle = Math.Abs(this.PageAngle);
135
            //angle = 0;
136
            System.Diagnostics.Debug.WriteLine("Page Angle : " +  this.PageAngle);
137

    
138
            if (!double.IsInfinity(caretLocation.X))
139
            {
140
                if (angle == 90)
141
                {
142
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.Y);
143
                }
144
                else if (angle == 180)
145
                {
146
                    
147
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X+ this.Base_TextBox.ActualWidth) - caretLocation.X) ;
148
                    System.Diagnostics.Debug.WriteLine("Caret X : " + ((this.EndPoint.X + this.Base_TextBox.ActualWidth) - caretLocation.X));
149
                } 
150
                else if (angle == 270)
151
                {
152
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X) - caretLocation.Y);
153
                }
154
                else
155
                {
156
                    System.Diagnostics.Debug.WriteLine("Caret X : " + (this.EndPoint.X - caretLocation.X));
157
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.X);
158
                } 
159
            }
160

    
161
            if (!double.IsInfinity(caretLocation.Y))
162
            {
163
                if (angle == 90)
164
                {
165
                    Canvas.SetTop(this.BaseTextbox_Caret, this.EndPoint.Y - caretLocation.X);
166
                }
167
                else if (angle == 180)
168
                {//보정치40
169
                    Canvas.SetTop(this.BaseTextbox_Caret, ((this.EndPoint.Y -40) + this.Base_TextBox.ActualHeight)- caretLocation.Y );
170
                    System.Diagnostics.Debug.WriteLine("Caret Y : " + (((this.EndPoint.Y - 40) + this.Base_TextBox.ActualHeight) - caretLocation.Y));
171
                }
172
                else if (angle == 270)
173
                {
174
                    Canvas.SetTop(this.BaseTextbox_Caret, (this.EndPoint.Y) + caretLocation.X);
175
                }
176
                else
177
                {
178
                    Canvas.SetTop(this.BaseTextbox_Caret, this.EndPoint.Y  + caretLocation.Y);
179
                    System.Diagnostics.Debug.WriteLine("Caret Y : " + (this.EndPoint.Y + caretLocation.Y - BaseTextbox_Caret.ActualHeight));
180
                }
181
            }
182
        }
183

    
184
        public void MoveCustomCaret(Point point)
185
        {
186

    
187
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
188

    
189
            if (!double.IsInfinity(caretLocation.X))
190
            {
191
                if (Math.Abs(this.PageAngle) == 90)
192
                {
193
                    Canvas.SetLeft(this.BaseTextbox_Caret, point.X + caretLocation.Y);
194
                }
195
                else if (Math.Abs(this.PageAngle) == 180)
196
                {
197

    
198
                    Canvas.SetLeft(this.BaseTextbox_Caret, (point.X + this.Base_TextBox.ActualWidth) - caretLocation.X);
199
                }
200
                else if (Math.Abs(this.PageAngle) == 270)
201
                {
202
                    Canvas.SetLeft(this.BaseTextbox_Caret, (point.X) - caretLocation.Y);
203
                }
204
                else
205
                {
206
                    Canvas.SetLeft(this.BaseTextbox_Caret, point.X + caretLocation.X);
207
                }
208
            }
209

    
210
            if (!double.IsInfinity(caretLocation.Y))
211
            {
212
                if (Math.Abs(this.PageAngle) == 90)
213
                {
214
                    Canvas.SetTop(this.BaseTextbox_Caret, point.Y - caretLocation.X);
215
                }
216
                else if (Math.Abs(this.PageAngle) == 180)
217
                {
218
                    Canvas.SetTop(this.BaseTextbox_Caret, (point.Y + this.Base_TextBox.ActualHeight) - caretLocation.Y);
219
                }
220
                else if (Math.Abs(this.CommentAngle) == 270)
221
                {
222
                    Canvas.SetTop(this.BaseTextbox_Caret, (point.Y) + caretLocation.X);
223
                }
224
                else
225
                {
226
                    Canvas.SetTop(this.BaseTextbox_Caret, point.Y + caretLocation.Y);
227
                }
228
            }
229
        }
230

    
231

    
232
        void Base_TextBox_LostFocus(object sender, RoutedEventArgs e)
233
        {
234
            EditEnd();
235
        }
236

    
237
        private void EditEnd()
238
        { 
239
            this.ArrowText = Base_TextBox.Text;
240
            Base_TextBox.Focusable = false;
241
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
242
            this.IsEditingMode = false;
243
            ApplyOverViewData();
244

    
245
            if(EditEnded != null)
246
            {
247
                EditEnded(this, new EventArgs());
248
            }
249

    
250
        }
251

    
252
        void Base_TextBox_GotFocus(object sender, RoutedEventArgs e)
253
        {
254
            this.BaseTextbox_Caret.Visibility = Visibility.Visible;
255
            MoveCustomCaret();
256
            Base_TextBox.Focus();
257
            this.IsEditingMode = true;
258
        }
259

    
260
        void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e)
261
        {
262
            if(this.IsEditingMode)
263
            {
264
                if (Base_TextBox.Text.Contains("|OR||DZ|"))
265
                {
266
                    Base_TextBox.Text = this.ArrowText;
267
                }
268

    
269
                this.ArrowText = Base_TextBox.Text;
270
                
271
            }
272
            BoxWidth = e.NewSize.Width;
273
            BoxHeight = e.NewSize.Height;
274
            SetArrowTextPath();
275
        }
276

    
277
        #region Properties
278
        private bool _IsEditingMode;
279
        public bool IsEditingMode
280
        {
281
            get
282
            {
283
                return _IsEditingMode;
284
            }
285
            set
286
            {
287
                _IsEditingMode = value;
288
                OnPropertyChanged("IsEditingMode");
289
            }
290
        }
291

    
292

    
293
        #endregion
294

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

    
310
        //강인구 주석 풀기
311
        public Visibility TextBlockVisibility
312
        {
313
            get { return (Visibility)GetValue(TextBlockVisibilityProperty); }
314
            set
315
            {
316
                if (this.TextBlockVisibility != value)
317
                {
318
                    SetValue(TextBlockVisibilityProperty, value);
319
                    OnPropertyChanged("TextBlockVisibility");
320
                }
321
            }
322
        }
323

    
324

    
325
        public override SolidColorBrush StrokeColor
326
        {
327
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
328
            set
329
            {
330
                if (this.StrokeColor != value)
331
                {
332
                    SetValue(StrokeColorProperty, value);
333
                }
334
            }
335
        }
336

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

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

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

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

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

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

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

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

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

    
418

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

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

    
437

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

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

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

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

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

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

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

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

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

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

    
535
                OnPropertyChanged("PathData");
536
            }
537
        }
538

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

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

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

    
567
                OnPropertyChanged("OverViewPathData");
568

    
569
            }
570
        }
571

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

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

    
598
        public string OverViewArrowText
599
        {
600

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

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

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

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

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

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

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

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

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

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

    
719

    
720
        //강인구 추가 주석풀기
721
       
722

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

    
736
        #endregion
737

    
738
        #region Dependency Properties
739

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
831

    
832

    
833
        //, new PropertyChangedCallback(TextChanged)
834

    
835

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

    
840

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

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

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

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

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

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

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

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

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

    
869
        #endregion
870

    
871
        #endregion
872

    
873
        #region CallBack Method
874

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

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

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

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

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

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

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

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

    
919
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
920
            {
921
                instance.SetArrowTextPath();
922
            }
923
        }
924

    
925

    
926

    
927
        public static void TextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
928
        {
929
            var instance = (ArrowTextControl)sender;
930
            
931
            if (e.OldValue != e.NewValue)
932
            {
933
                instance.SetValue(e.Property, e.NewValue);
934
                //instance.BoxWidth = instance.Base_TextBox.ActualWidth;
935
                //instance.BoxHeight = instance.Base_TextBox.ActualHeight;
936
            }
937
        }
938

    
939
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
940
        {
941
            var instance = (ArrowTextControl)sender;
942
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
943
            {
944
                instance.SetValue(e.Property, e.NewValue);
945
                instance.SetArrowTextPath();
946
            }
947
        }
948

    
949
        public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
950
        {
951
            var instance = (ArrowTextControl)sender;
952

    
953
            if (e.OldValue != e.NewValue && instance != null)
954
            {
955
                instance.SetValue(e.Property, e.NewValue);
956
                //Canvas.SetLeft(instance, instance.CanvasX);
957
                //Canvas.SetTop(instance, instance.CanvasY);
958
            }
959
        }
960

    
961
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
962
        {
963
            //var instance = (ArrowTextControl)sender;
964

    
965
            //if (e.OldValue != e.NewValue)
966
            //{
967
            //    instance.SetValue(e.Property, e.NewValue);
968

    
969
            //    if (instance.IsSelected && instance.Base_TextBox != null)
970
            //    {
971
            //        instance.BorderSize = new Thickness(1);
972
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Blue);
973
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Blue);
974
            //    }
975
            //    else
976
            //    {
977
            //        instance.BorderSize = new Thickness(0);
978
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Transparent);
979
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Transparent);
980
            //    }
981
            //}
982
        }
983
        #endregion
984

    
985
        #region Internal Method
986

    
987
        //강인구 주석 풀기
988
        public void EditingMode()
989
        {
990
            TextBoxVisibility = Visibility.Visible;
991
            TextBlockVisibility = Visibility.Collapsed;
992

    
993

    
994
            //강인구 언더라인 추가
995
            if (UnderLine != null)
996
                Base_TextBlock.TextDecorations = UnderLine;
997
        }
998
        //강인구 주석 풀기
999
        public void UnEditingMode()
1000
        {
1001
            TextBoxVisibility = Visibility.Collapsed;
1002
            TextBlockVisibility = Visibility.Visible;
1003

    
1004
            if (Base_TextBlock != null)
1005
            {
1006
                if (UnderLine != null)
1007
                    Base_TextBlock.TextDecorations = UnderLine;
1008

    
1009
                Base_TextBlock.Margin =
1010
                     new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4,
1011
                         Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4);
1012
            }
1013

    
1014
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
1015
        }
1016

    
1017
        private void SetArrowTextPath(bool IsInit = false)
1018
        {
1019
            instanceGroup.Children.Clear();
1020

    
1021
            //VisualPageAngle = 0;
1022

    
1023
            if (Math.Abs(PageAngle).ToString() == "90")
1024
            {
1025
                VisualPageAngle = 270;
1026
            }
1027
            else if (Math.Abs(PageAngle).ToString() == "270")
1028
            {
1029
                VisualPageAngle = 90;
1030
            }
1031
            else
1032
            {
1033
                VisualPageAngle = PageAngle;
1034
            }
1035

    
1036
            connectorSMGeometry.StartPoint = this.StartPoint;
1037
            connectorSMGeometry.EndPoint = this.MidPoint;
1038
            connectorMEGeometry.StartPoint = this.MidPoint; //핵심
1039

    
1040
            /// 텍스트박스의 좌표 설정
1041
            Canvas.SetLeft(Base_TextBox, this.EndPoint.X);
1042
            Canvas.SetTop(Base_TextBox, this.EndPoint.Y);
1043
            //System.Diagnostics.Debug.WriteLine($"TextBox Set {this.EndPoint.X},{this.EndPoint.Y}");
1044
            
1045

    
1046
            List<Point> ps = new List<Point>();
1047
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox))); //상단
1048
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox) + this.BoxHeight)); // 하단
1049
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2)); //좌단
1050
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2));  //우단
1051

    
1052
            if (isTrans)
1053
            {
1054
                switch (Math.Abs(this.PageAngle).ToString())
1055
                {
1056
                    case "90":
1057
                        {
1058
                            ps.Clear();
1059
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1060
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1061
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1062

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

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

    
1069
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간
1070
                        }
1071
                        break;
1072
                    case "270":
1073
                        {
1074
                            ps.Clear();
1075
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1076
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1077
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1078

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

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

    
1085
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간
1086
                        }
1087
                        break;
1088
                    default:
1089
                        break;
1090
                }
1091
                
1092
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1093

    
1094
                //20180911 LJY 꺾이는 부분 수정
1095
                Point testP = endP;                
1096
                switch (Math.Abs(this.PageAngle).ToString())
1097
                {
1098
                    case "90":
1099
                        testP = new Point(endP.X + 50, endP.Y);
1100
                        break;
1101
                    case "270":
1102
                        testP = new Point(endP.X - 50, endP.Y);
1103
                        break;
1104
                }                
1105

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

    
1204
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1205
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1206
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1207

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

    
1211
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); //중간 하단
1212
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 하단
1213
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간 
1214
                        }
1215
                        break;
1216
                    case "270":
1217
                        {
1218
                            ps.Clear();
1219
                            
1220
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1221
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1222
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1223

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

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

    
1230
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1231
                        }
1232
                        break;
1233
                    //case "180":
1234
                    //    {
1235
                    //        ps.Clear();
1236

    
1237
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1238
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1239
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1240

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

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

    
1247
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1248
                    //    }
1249
                    //    break;
1250
                    default:
1251
                        break;
1252
                }
1253

    
1254

    
1255
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1256
                connectorMEGeometry.EndPoint = endP; //최상단
1257
                                                     //connectorMEGeometry.EndPoint = this.EndPoint; //핵심
1258
                                                     //this.MidPoint= MathSet.getMiddlePoint(this.StartPoint, endP);
1259
                #region 보정치
1260
                Point testP = endP;
1261

    
1262
                //20180910 LJY 각도에 따라.
1263
                switch (Math.Abs(this.PageAngle).ToString())
1264
                {
1265
                    case "90":
1266
                        if (isFixed)
1267
                        {
1268
                            if (ps[0] == endP) //상단
1269
                            {
1270
                                testP = new Point(endP.X - 50, endP.Y);
1271
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1272
                            }
1273
                            else if (ps[1] == endP) //하단
1274
                            {
1275
                                testP = new Point(endP.X + 50, endP.Y);
1276
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1277
                            }
1278
                            else if (ps[2] == endP) //좌단
1279
                            {
1280
                                testP = new Point(endP.X - 50, endP.Y);
1281
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1282
                            }
1283
                            else if (ps[3] == endP) //우단
1284
                            {
1285
                                testP = new Point(endP.X + 50 , endP.Y);
1286
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1287
                            }
1288
                        }
1289
                        break;
1290
                    case "270":
1291
                        if (isFixed)
1292
                        {
1293
                            if (ps[0] == endP) //상단
1294
                            {
1295
                                testP = new Point(endP.X + 50, endP.Y);
1296
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1297
                            }
1298
                            else if (ps[1] == endP) //하단
1299
                            {
1300
                                testP = new Point(endP.X - 50, endP.Y);
1301
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1302
                            }
1303
                            else if (ps[2] == endP) //좌단
1304
                            {
1305
                                testP = new Point(endP.X + 50, endP.Y);
1306
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1307
                            }
1308
                            else if (ps[3] == endP) //우단
1309
                            {
1310
                                testP = new Point(endP.X + 50, endP.Y );
1311
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1312
                            }
1313
                        }
1314
                        break;
1315
                    default:
1316
                        if (isFixed)
1317
                        {
1318
                            if (ps[0] == endP) //상단
1319
                            {
1320
                                testP = new Point(endP.X, endP.Y - 50);
1321
                                //System.Diagnostics.Debug.WriteLine("상단");
1322
                            }
1323
                            else if (ps[1] == endP) //하단
1324
                            {
1325
                                testP = new Point(endP.X, endP.Y + 50);
1326
                                //System.Diagnostics.Debug.WriteLine("하단");
1327
                            }
1328
                            else if (ps[2] == endP) //좌단
1329
                            {
1330
                                testP = new Point(endP.X - 50, endP.Y);
1331
                                //System.Diagnostics.Debug.WriteLine("좌단");
1332
                            }
1333
                            else if (ps[3] == endP) //우단
1334
                            {
1335
                                testP = new Point(endP.X + 50, endP.Y);
1336
                                //System.Diagnostics.Debug.WriteLine("우단");
1337
                            }
1338
                        }
1339
                        break;
1340
                }
1341
                  
1342

    
1343
                connectorSMGeometry.EndPoint = testP;
1344
                connectorMEGeometry.StartPoint = testP;
1345
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1346
                instanceGroup.FillRule = FillRule.Nonzero;
1347
                this.Base_ArrowPath.Fill = this.StrokeColor;
1348
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1349
                #endregion
1350
            }
1351

    
1352
            switch (this.ArrowTextStyle)
1353
            {
1354
                case ArrowTextStyleSet.Normal:
1355
                    this.BorderSize = new Thickness(0);
1356
                    DrawingRect();
1357
                    break;
1358
                case ArrowTextStyleSet.Cloud:
1359
                    this.BorderSize = new Thickness(0);
1360
                    DrawingCloud();
1361
                    break;
1362
                default:
1363
                    {
1364
                        this.BorderSize = new Thickness(LineSize);
1365
                        DrawingRect();
1366
                    }
1367

    
1368
                    break;
1369
            }
1370

    
1371
            if (isHighLight)
1372
            {
1373
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1374
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1375

    
1376
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1377
            }
1378
            else
1379
            {
1380
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1381
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1382
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1), Colors.White.R, Colors.White.G, Colors.White.B));
1383
            }
1384

    
1385
            instanceGroup.Children.Add(connectorSMGeometry);
1386
            instanceGroup.Children.Add(connectorMEGeometry);
1387

    
1388
            this.PathData = instanceGroup;
1389
            OverViewPathData = PathData;
1390
            OverViewArrowText = ArrowText;
1391
            OverViewEndPoint = connectorMEGeometry.EndPoint;
1392
            OverViewStartPoint = connectorSMGeometry.StartPoint;
1393

    
1394
            var tempAngle = Math.Abs(this.VisualPageAngle);
1395

    
1396
            if (tempAngle == Convert.ToDouble(90) || tempAngle == Convert.ToDouble(270))
1397
            {
1398
                this.RenderTransformOrigin = new Point(0.5, 0.5);
1399
                this.Base_ArrowPath.RenderTransformOrigin = new Point(0, 0);
1400
                this.Base_ArrowSubPath.RenderTransformOrigin = new Point(0, 0);
1401

    
1402
                Base_TextBox.RenderTransformOrigin = new Point(0, 0);
1403
                BaseTextbox_Caret.RenderTransformOrigin = new Point(0, 0);
1404
            }
1405

    
1406
            Base_TextBox.RenderTransform = new RotateTransform
1407
            {
1408
                Angle = this.VisualPageAngle,
1409
                CenterX = this.CenterX,
1410
                CenterY = this.CenterY,
1411
            };
1412

    
1413
            Base_ArrowSubPath.RenderTransform = new RotateTransform
1414
            {
1415
                Angle = this.VisualPageAngle,
1416
                CenterX = this.EndPoint.X,
1417
                CenterY = this.EndPoint.Y,
1418
            };
1419

    
1420
            if (BaseTextbox_Caret.Visibility == Visibility.Visible)
1421
            {
1422
                BaseTextbox_Caret.RenderTransform = new RotateTransform
1423
                {
1424
                    Angle = this.VisualPageAngle,
1425
                    CenterX = this.CenterX,
1426
                    CenterY = this.CenterY,
1427
                };
1428

    
1429
                MoveCustomCaret();
1430
            }
1431
        }
1432

    
1433
        private void DrawingCloud()
1434
        {
1435
            //20180906 LJY Textbox guide
1436
            string angle = Math.Abs(this.PageAngle).ToString();
1437
            if (angle == "180")
1438
            {
1439
                List<Point> pCloud = new List<Point>()
1440
                {
1441
                     new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1442
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxHeight), //왼쪽 아래
1443
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox) - BoxHeight),
1444
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox)),
1445
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1446
                };
1447
                SubPathData = (Generate(pCloud));
1448
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1449
            
1450
            }//20180906 LJY Textbox guide
1451
            else
1452
            {
1453
                var boxWidth = BoxWidth;
1454
                System.Diagnostics.Debug.WriteLine("disp Width : " + BoxWidth);
1455
                //boxWidth = boxWidth + Base_TextBox.Margin.Left + Base_TextBox.Margin.Right + Base_TextBox.Padding.Left + Base_TextBox.Padding.Right;
1456

    
1457
                List<Point> pCloud = new List<Point>()
1458
                {
1459
    #if SILVERLIGHT
1460
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1461
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1462
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1463
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1464
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1465

    
1466
    #else
1467
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1468
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1469
                    new Point(Canvas.GetLeft(Base_TextBox)+ boxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1470
                    new Point(Canvas.GetLeft(Base_TextBox) + boxWidth, Canvas.GetTop(Base_TextBox)),
1471
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1472

    
1473
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1474
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1475
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1476
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1477
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1478
    #endif
1479
                };
1480
                //instanceGroup.Children.Add(Generate(pCloud));
1481
                SubPathData = (Generate(pCloud));
1482
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1483
                //   }
1484
            }
1485

    
1486
        }
1487

    
1488
        private void DrawingRect()
1489
        {
1490
            //20180906 LJY Textbox guide
1491
            if(this.ArrowTextStyle == ArrowTextStyleSet.Normal)
1492
            {
1493
                this.Base_TextBox.BorderBrush = Brushes.Transparent;
1494
            }
1495
            
1496
            if (Math.Abs(this.PageAngle).ToString() == "90")
1497
            {
1498
                List<Point> pCloud = new List<Point>()
1499
                {
1500
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1501
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxWidth), //왼쪽 아래
1502
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox) - BoxWidth),
1503
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox)),
1504
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1505
                };
1506
                PathDataInner = (GenerateInner(pCloud));
1507
            }
1508
            else if(Math.Abs(this.PageAngle).ToString() == "270")
1509
            {
1510
                List<Point> pCloud = new List<Point>()
1511
                {
1512
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1513
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + BoxWidth), //왼쪽 아래
1514
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox) + BoxWidth),
1515
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox)),
1516
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1517
                };
1518
                PathDataInner = (GenerateInner(pCloud));
1519
            }//20180906 LJY Textbox guide
1520
            else
1521
            { 
1522
                List<Point> pCloud = new List<Point>()
1523
                {
1524
    #if SILVERLIGHT
1525
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1526
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1527
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1528
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1529
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1530

    
1531
    #else
1532
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1533
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1534
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1535
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1536
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1537

    
1538
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1539
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1540
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1541
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1542
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1543
    #endif
1544
                };
1545
                //instanceGroup.Children.Add(Generate(pCloud));
1546
                PathDataInner = (GenerateInner(pCloud));
1547
            }
1548
        }
1549

    
1550
        public override void UpdateControl()
1551
        {
1552
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
1553
            this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
1554
            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
1555
        }
1556

    
1557
        public override void ApplyOverViewData()
1558
        {
1559
            this.OverViewPathData = this.PathData;
1560
            if (ArrowText == "")
1561
            {
1562
                this.OverViewArrowText = "";
1563
                this.ArrowText = this.OverViewArrowText;
1564
            }
1565
            else
1566
                this.OverViewArrowText = this.ArrowText;
1567
            this.OverViewStartPoint = this.StartPoint;
1568
            this.OverViewEndPoint = this.EndPoint;
1569
        }
1570

    
1571
        #endregion
1572

    
1573
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
1574
        {
1575
            PathFigure pathFigure = new PathFigure();
1576
            pathFigure.StartPoint = p1;
1577

    
1578
            double arcLength = arcLength_;
1579
            /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung 
1580
            double dx = p2.X - p1.X;
1581
            double dy = p2.Y - p1.Y;
1582
            double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2
1583
            double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
1584
            Point lastPt = new Point(p1.X, p1.Y);
1585
            double count = l / arcLength;
1586
            /// normalize
1587
            dx /= l;
1588
            dy /= l;
1589
            Double j = 1;
1590
            for (j = 1; j < (count - 1); j++) 
1591
            {
1592
                ArcSegment arcSeg = new ArcSegment();
1593
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);						/// x size and y size of arc
1594
                arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);	/// end point of arc
1595
                lastPt = arcSeg.Point;  /// save last point
1596
                arcSeg.RotationAngle = theta + 90;
1597
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1598
                pathFigure.Segments.Add(arcSeg);
1599
            }
1600

    
1601
            /// draw arc between last point and end point
1602
            if ((count > j) || (count > 0))
1603
            {
1604
                arcLength = MathSet.DistanceTo(lastPt, p2);
1605
                ArcSegment arcSeg = new ArcSegment();
1606
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);	/// x size and y size of arc
1607
                arcSeg.Point = new Point(p2.X, p2.Y);						/// end point of arc
1608
                arcSeg.RotationAngle = theta;
1609
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1610
                pathFigure.Segments.Add(arcSeg);
1611
            }
1612
            /// up to here
1613

    
1614
            return pathFigure;
1615
        }
1616

    
1617
        public static PathGeometry Generate(List<Point> pData)
1618
        {
1619
            var _pathGeometry = new PathGeometry();
1620
            
1621
            double area = MathSet.AreaOf(pData);
1622
            bool reverse = (area > 0);
1623
            int count = pData.Count;
1624
            for (int i = 0; i < (count - 1); i++)
1625
            {
1626
                PathFigure pathFigure = Polygon.CloudControl.GenerateLineWithCloud(pData[i], pData[i + 1], 20, reverse);
1627
                pathFigure.IsClosed = false;
1628
                pathFigure.IsFilled = false;
1629
                _pathGeometry.Figures.Add(pathFigure);
1630
            }
1631
            
1632
            return _pathGeometry;
1633
        }
1634

    
1635
        
1636
        public static PathGeometry GenerateInner(List<Point> pData)
1637
        {
1638
            var _pathGeometry = new PathGeometry();
1639
            double area = MathSet.AreaOf(pData);
1640
            bool reverse = (area > 0);
1641
            int count = pData.Count;
1642

    
1643
            PathFigure pathFigur2 = new PathFigure();
1644
            pathFigur2.StartPoint = pData[0];
1645

    
1646
            LineSegment lineSegment0 = new LineSegment();
1647
            lineSegment0.Point = pData[0];
1648
            pathFigur2.Segments.Add(lineSegment0);
1649

    
1650
            LineSegment lineSegment1 = new LineSegment();
1651
            lineSegment1.Point = pData[1];
1652
            pathFigur2.Segments.Add(lineSegment1);
1653

    
1654
            LineSegment lineSegment2 = new LineSegment();
1655
            lineSegment2.Point = pData[2];
1656
            pathFigur2.Segments.Add(lineSegment2);
1657

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

    
1662

    
1663
            pathFigur2.IsClosed = true;
1664
            pathFigur2.IsFilled = true;
1665
            _pathGeometry.Figures.Add(pathFigur2);           
1666

    
1667
            return _pathGeometry;
1668
        }
1669

    
1670
        //20180910 LJY Cloud rotation 추가
1671
        public static PathGeometry GenerateInnerCloud(List<Point> pData, string angle)
1672
        {
1673
            var _pathGeometry = new PathGeometry();
1674
            double area = MathSet.AreaOf(pData);
1675
            bool reverse = (area > 0);
1676
            int count = pData.Count;
1677

    
1678
            PathFigure pathFigur2 = new PathFigure();
1679
            pathFigur2.StartPoint = pData[0];
1680

    
1681
            LineSegment lineSegment0 = new LineSegment();
1682
            lineSegment0.Point = pData[0];
1683
            pathFigur2.Segments.Add(lineSegment0);
1684

    
1685
            LineSegment lineSegment1 = new LineSegment();
1686
            lineSegment1.Point = pData[1];
1687
            pathFigur2.Segments.Add(lineSegment1);
1688

    
1689
            LineSegment lineSegment2 = new LineSegment();
1690
            lineSegment2.Point = pData[2];
1691
            pathFigur2.Segments.Add(lineSegment2);
1692

    
1693
            LineSegment lineSegment3 = new LineSegment();
1694
            lineSegment3.Point = pData[3];
1695
            pathFigur2.Segments.Add(lineSegment3);
1696
            
1697
            RotateTransform transform = new RotateTransform();
1698
            switch (angle)
1699
            {
1700
                case "90":
1701
                    transform.Angle = -90;
1702
                    break;
1703
                case "180":
1704
                    transform.Angle = -180;
1705
                    break;
1706
                case "270":
1707
                    transform.Angle = -270;
1708
                    break;
1709
            }
1710
            transform.CenterX = pData[0].X;
1711
            transform.CenterY = pData[0].Y;
1712
            _pathGeometry.Transform = transform;
1713

    
1714
            pathFigur2.IsClosed = true;
1715
            pathFigur2.IsFilled = true;
1716
            _pathGeometry.Figures.Add(pathFigur2);
1717

    
1718
            return _pathGeometry;
1719
        }
1720

    
1721
        /// <summary>
1722
        /// call when mouse is moving while drawing control
1723
        /// </summary>
1724
        /// <author>humkyung</author>
1725
        /// <param name="pt"></param>
1726
        /// <param name="bAxisLocked"></param>
1727
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
1728
        {
1729
            this.EndPoint = pt;
1730

    
1731
            Point tempPoint = this.EndPoint;
1732
            CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1733

    
1734
            if (bAxisLocked)
1735
            {
1736
                this.EndPoint = tempPoint;
1737
            }
1738

    
1739
            this.MidPoint = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint);
1740
            this.isFixed = (this.ControlType == ControlType.ArrowTransTextControl) || 
1741
                (this.ControlType == ControlType.ArrowTransTextBorderControl) || (this.ControlType == ControlType.ArrowTransTextCloudControl);
1742

    
1743
            this.PointSet = new List<Point>
1744
            {
1745
                this.StartPoint,
1746
                this.MidPoint,
1747
                this.EndPoint,
1748
            };
1749
        }
1750

    
1751
        /// <summary>
1752
        /// move control point has same location of given pt along given delta
1753
        /// </summary>
1754
        /// <author>humkyung</author>
1755
        /// <date>2019.06.20</date>
1756
        /// <param name="pt"></param>
1757
        /// <param name="dx"></param>
1758
        /// <param name="dy"></param>
1759
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
1760
        {
1761
            IPath path = (this as IPath);
1762

    
1763
            Point selected = MathSet.getNearPoint(path.PointSet, pt);
1764

    
1765
            //StartPoint에 표시된 Thumb는 dx,dy가 +로 더해줘야한다.
1766
            if (path.PointSet.IndexOf(selected) != 0)
1767
            {
1768
                double radian = this.CommentAngle * Math.PI / 180;
1769
                double cos = Math.Cos(radian);
1770
                double sin = Math.Sin(radian);
1771

    
1772
                double _dx = dx * cos - dy * sin;
1773
                double _dy = dx * sin + dy * cos;
1774

    
1775
                //var transform = new RotateTransform() { Angle = CommentAngle, CenterX = dx, CenterY = dy };
1776
                //var transformedPoint = transform.Transform(pt);
1777
                //selected = transformedPoint;
1778

    
1779
                selected.X += _dx;
1780
                selected.Y += _dy;
1781
            }
1782
            else
1783
            {
1784
                selected.X += dx;
1785
                selected.Y += dy;
1786
            }
1787

    
1788
    int i = 0;
1789
            for (i = 0; i < (this as IPath).PointSet.Count; i++)
1790
            {
1791
                if (pt.Equals((this as IPath).PointSet[i])) break;
1792
            }
1793

    
1794
            List<Point> pts = path.PointSet;
1795
            if ((pts[0].X > pts[1].X && dx > 0) || (pts[0].X < pts[1].X && dx < 0))
1796
            {
1797
                pts[1] = new Point(pts[1].X + dx, pts[1].Y);
1798
            }
1799
            if ((pts[0].Y > pts[1].Y && dy > 0) || (pts[0].Y < pts[1].Y && dy < 0))
1800
            {
1801
                pts[1] = new Point(pts[1].X, pts[1].Y + dy);
1802
            }
1803

    
1804
            path.PointSet[1] = pts[1];
1805

    
1806
            if (path.PointSet.Count > i) {
1807
                path.PointSet[i] = selected;
1808
            }
1809
            //System.Diagnostics.Debug.WriteLine($"OnMoveCtrlPoint end : {path.PointSet[1].X},{path.PointSet[1].Y}");
1810
            this.UpdateControl();
1811
        }
1812

    
1813
        /// <summary>
1814
        /// return ArrowTextControl's area
1815
        /// </summary>
1816
        /// <author>humkyung</author>
1817
        /// <date>2019.06.13</date>
1818
        public override Rect ItemRect
1819
        {
1820
            get
1821
            {
1822
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
1823
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
1824
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
1825
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
1826

    
1827
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
1828
            }
1829
        }
1830

    
1831
        /// <summary>
1832
        /// Serialize this
1833
        /// </summary>
1834
        /// <param name="sUserId"></param>
1835
        /// <returns></returns>
1836
        public override string Serialize()
1837
        {
1838
            using (S_ArrowTextControl STemp = new S_ArrowTextControl())
1839
            {
1840
                STemp.TransformPoint = "0|0";
1841
                STemp.PointSet = this.PointSet;
1842
                STemp.SizeSet = String.Format("{0}", this.LineSize);
1843
                STemp.StrokeColor = this.StrokeColor.Color.ToString();
1844
                STemp.StartPoint = this.StartPoint;
1845
                STemp.ArrowStyle = this.ArrowTextStyle;
1846
                //STemp.StrokeColor = "#FF00FF00";
1847
                STemp.UserID = this.UserID;
1848
                STemp.ArrowText = this.Base_TextBox.Text;
1849
                STemp.BorderSize = this.BorderSize;
1850
                STemp.isHighLight = this.isHighLight;
1851
                STemp.BoxHeight = this.BoxHeight;
1852
                STemp.BoxWidth = this.BoxWidth;
1853
                STemp.Opac = this.Opacity;
1854
                STemp.EndPoint = this.EndPoint;
1855
                STemp.isFixed = this.isFixed;
1856
                //STemp.DashSize = this.DashSize;
1857
                STemp.Name = this.GetType().Name.ToString();
1858
                STemp.isTrans = this.isTrans;
1859
                STemp.MidPoint = this.MidPoint;
1860
                STemp.Angle = this.PageAngle;
1861
                STemp.fontConfig = new List<string>()
1862
                            {
1863
                                this.TextFamily.FontName(),
1864
                                this.TextStyle.ToString(),
1865
                                this.TextWeight.ToString(),
1866
                                this.TextSize.ToString(),
1867
                            };
1868

    
1869
                if (this.UnderLine != null)
1870
                {
1871
                    STemp.fontConfig.Add("true");
1872
                }
1873

    
1874
                ///강인구 추가(2017.11.02)
1875
                ///Memo 추가
1876
                STemp.Memo = this.Memo;
1877
                STemp.BorderSize = this.BorderSize;
1878
                return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize()));
1879
            };
1880
        }
1881

    
1882
        /// <summary>
1883
        /// create a arrowtextcontrol from given string
1884
        /// </summary>
1885
        /// <param name="str"></param>
1886
        /// <returns></returns>
1887
        public static ArrowTextControl FromString(string str, SolidColorBrush brush, string sProjectNo,double PageAngle)
1888
        {
1889
            ArrowTextControl instance = null;
1890
            using (S_ArrowTextControl s = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(str))
1891
            {
1892
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1893
                instance = new ArrowTextControl();
1894
                instance.PageAngle = s.Angle;
1895
                instance.LineSize = Convert.ToDouble(data2.First());
1896
                instance.PointSet = s.PointSet;
1897
                instance.StartPoint = s.StartPoint;
1898
                instance.EndPoint = s.EndPoint;
1899
                instance.StrokeColor = brush;
1900
                //instance.DashSize = s.DashSize; 
1901
                instance.ArrowTextStyle = s.ArrowStyle;
1902
                instance.isHighLight = s.isHighLight;
1903
                instance.ArrowText = s.ArrowText;
1904
                instance.Opacity = s.Opac;
1905
                instance.BorderSize = s.BorderSize;
1906
                instance.BoxWidth = s.BoxWidth;
1907
                instance.BoxHeight = s.BoxHeight;
1908
                instance.isFixed = s.isFixed;
1909
                //instance.VisualPageAngle = s.Angle;
1910
                instance.UserID = s.UserID;
1911
                instance.isTrans = s.isTrans;
1912
                instance.MidPoint = s.MidPoint;
1913
                instance.Memo = s.Memo;
1914
                if (s.fontConfig == null || s.fontConfig.ToList().Count == 0)
1915
                {
1916
                    s.fontConfig = new List<string>();
1917

    
1918
                    s.fontConfig.Add("Arial");
1919
                    s.fontConfig.Add("Normal");
1920
                    s.fontConfig.Add("Normal");
1921
                    s.fontConfig.Add("30");
1922
                }
1923
                instance.TextFamily = Markus.Fonts.FontHelper.GetFontFamily(s.fontConfig[0]);
1924
                //인구 추가(2018.04.17)
1925
                instance.TextStyle = StringToFont.ConFontStyle(s.fontConfig[1]);
1926
                instance.TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]);
1927
                instance.TextSize = Convert.ToDouble(s.fontConfig[3]);
1928

    
1929
                if (s.fontConfig.Count() == 5)
1930
                {
1931
                    instance.UnderLine = TextDecorations.Underline;
1932
                }
1933
            }
1934

    
1935
            return instance;
1936
        }
1937

    
1938
        #region Dispose
1939
        public void Dispose()
1940
        {
1941
            //GC.Collect();
1942
            ////GC.SuppressFinalize(this);
1943
            this.BaseTextbox_Caret = null;
1944
            this.Base_ArrowPath = null;
1945
            this.Base_ArrowSubPath = null;
1946
            this.Base_TextBlock = null;
1947
            this.Base_TextBox = null;
1948
        } 
1949
        #endregion
1950

    
1951
        #region INotifyPropertyChanged
1952
        private void OnPropertyChanged(string name)
1953
        {
1954
            if (PropertyChanged != null)
1955
            {
1956
                PropertyChanged(this, new PropertyChangedEventArgs(name));
1957
            }
1958
        }
1959

    
1960
        public Rect GetCommentRect()
1961
        {
1962
            Rect rect = new Rect();
1963

    
1964
            rect.Location = new Point();
1965
            rect.Size = new Size();
1966

    
1967
            List<Point> points = new List<Point>();
1968

    
1969
            points.AddRange(this.PointSet);
1970

    
1971
            var boxTopleft = new Point(Canvas.GetTop(Base_TextBox), Canvas.GetLeft(Base_TextBox));
1972
            points.Add(boxTopleft);
1973

    
1974
            var boxBottomRight =new Point(boxTopleft.X + Base_TextBox.ActualWidth, boxTopleft.Y + Base_TextBox.ActualHeight);
1975
            points.Add(boxBottomRight);
1976

    
1977
            rect = CommentMath.CalculateBoundingRect(points);
1978

    
1979
            return rect;
1980
        }
1981

    
1982
        public event PropertyChangedEventHandler PropertyChanged; 
1983
        #endregion
1984
    }
1985
}
클립보드 이미지 추가 (최대 크기: 500 MB)