프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Text / ArrowTextControl.cs @ 8ebd5302

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

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

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

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

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

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

    
43
        public enum ArrowTextStyleSet { Normal, Cloud, Rect };
44

    
45
        #endregion
46

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

    
52
        public ArrowTextControl() : base()
53
        {
54
        }
55

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

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

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

    
114
                this.Base_TextBox.ApplyTemplate();
115
                this.Base_TextBox.Text = this.ArrowText;
116

    
117
                MoveCustomCaret();
118

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

    
125
                SetArrowTextPath(true);
126

    
127
                Base_TextBox.IsTabStop = true;
128
            }
129
        }
130

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

    
140
                EditEnd();
141
            }
142
        }
143

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

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

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

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

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

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

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

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

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

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

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

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

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

    
275

    
276
        #endregion
277

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

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

    
307

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

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

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

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

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

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

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

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

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

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

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

    
414

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

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

    
433

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

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

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

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

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

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

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

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

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

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

    
531
                OnPropertyChanged("PathData");
532
            }
533
        }
534

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

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

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

    
563
                OnPropertyChanged("OverViewPathData");
564

    
565
            }
566
        }
567

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

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

    
594
        public string OverViewArrowText
595
        {
596

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

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

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

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

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

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

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

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

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

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

    
715

    
716
        //강인구 추가 주석풀기
717
       
718

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

    
732
        #endregion
733

    
734
        #region Dependency Properties
735

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
830

    
831

    
832
        //, new PropertyChangedCallback(TextChanged)
833

    
834

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

    
839

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

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

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

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

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

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

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

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

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

    
868
        #endregion
869

    
870
        #endregion
871

    
872
        #region CallBack Method
873

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

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

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

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

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

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

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

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

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

    
924

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

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

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

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

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

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

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

    
983
        #region Internal Method
984

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

    
991

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

    
1002
            if (Base_TextBlock != null)
1003
            {
1004
                if (UnderLine != null)
1005
                    Base_TextBlock.TextDecorations = UnderLine;
1006

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

    
1012
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
1013
        }
1014

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

    
1019
            if (Math.Abs(PageAngle).ToString() == "90")
1020
            {
1021
                VisualPageAngle = 270;
1022
            }
1023
            else if (Math.Abs(PageAngle).ToString() == "270")
1024
            {
1025
                VisualPageAngle = 90;
1026
            }
1027
            else
1028
            {
1029
                VisualPageAngle = PageAngle;
1030
            }
1031

    
1032
            connectorSMGeometry.StartPoint = this.StartPoint;
1033
            connectorSMGeometry.EndPoint = this.MidPoint;
1034
            connectorMEGeometry.StartPoint = this.MidPoint; //핵심
1035

    
1036
            /// 텍스트박스의 좌표 설정
1037
            Canvas.SetLeft(Base_TextBox, this.EndPoint.X);
1038
            Canvas.SetTop(Base_TextBox, this.EndPoint.Y);
1039

    
1040
            List<Point> ps = new List<Point>();
1041
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox))); //상단
1042
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox) + this.BoxHeight)); // 하단
1043
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2)); //좌단
1044
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2));  //우단
1045

    
1046
            if (isTrans)
1047
            {
1048
                switch (Math.Abs(this.PageAngle).ToString())
1049
                {
1050
                    case "90":
1051
                        {
1052
                            ps.Clear();
1053
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1054
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1055
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1056

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

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

    
1063
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간
1064
                        }
1065
                        break;
1066
                    case "270":
1067
                        {
1068
                            ps.Clear();
1069
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1070
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1071
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1072

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

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

    
1079
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간
1080
                        }
1081
                        break;
1082
                    default:
1083
                        break;
1084
                }
1085
                
1086
                var ConnectionPoint = MathSet.getNearPoint(ps, this.MidPoint);
1087

    
1088
                //20180911 LJY 꺾이는 부분 수정
1089
                Point BendingPoint = ConnectionPoint;                
1090
                switch (Math.Abs(this.PageAngle).ToString())
1091
                {
1092
                    case "90":
1093
                        BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1094
                        break;
1095
                    case "270":
1096
                        BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1097
                        break;
1098
                }                
1099

    
1100
                //20180910 LJY 각도에 따라.
1101
                switch (Math.Abs(this.PageAngle).ToString())
1102
                {
1103
                    case "90":
1104
                        if (isFixed)
1105
                        {
1106
                            if (ps[0] == ConnectionPoint) //상단
1107
                            {
1108
                                BendingPoint = new Point(ConnectionPoint.X , ConnectionPoint.Y + _BendingLineLength);
1109
                            }
1110
                            else if (ps[1] == ConnectionPoint) //하단
1111
                            {
1112
                                BendingPoint = new Point(ConnectionPoint.X , ConnectionPoint.Y - _BendingLineLength);
1113
                            }
1114
                            else if (ps[2] == ConnectionPoint) //좌단
1115
                            {
1116
                                BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1117
                            }
1118
                            else if (ps[3] == ConnectionPoint) //우단
1119
                            {
1120
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1121
                            }
1122
                        }
1123
                        break;
1124
                    case "270":
1125
                        if (isFixed)
1126
                        {
1127
                            if (ps[0] == ConnectionPoint) //상단
1128
                            {
1129
                                BendingPoint = new Point(ConnectionPoint.X , ConnectionPoint.Y - _BendingLineLength);
1130
                            }
1131
                            else if (ps[1] == ConnectionPoint) //하단
1132
                            {
1133
                                BendingPoint = new Point(ConnectionPoint.X, ConnectionPoint.Y + _BendingLineLength);
1134
                            }
1135
                            else if (ps[2] == ConnectionPoint) //좌단
1136
                            {
1137
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1138
                            }
1139
                            else if (ps[3] == ConnectionPoint) //우단
1140
                            {
1141
                                BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1142
                            }
1143
                        }
1144
                        break;
1145
                    default:
1146
                        if (isFixed)
1147
                        {
1148
                            if (ps[0] == ConnectionPoint) //상단
1149
                            {
1150
                                BendingPoint = new Point(ConnectionPoint.X, ConnectionPoint.Y - _BendingLineLength);
1151
                            }
1152
                            else if (ps[1] == ConnectionPoint) //하단
1153
                            {
1154
                                BendingPoint = new Point(ConnectionPoint.X, ConnectionPoint.Y + _BendingLineLength);
1155
                            }
1156
                            else if (ps[2] == ConnectionPoint) //좌단
1157
                            {
1158
                                BendingPoint = new Point(ConnectionPoint.X - _BendingLineLength, ConnectionPoint.Y);
1159
                            }
1160
                            else if (ps[3] == ConnectionPoint) //우단
1161
                            {
1162
                                BendingPoint = new Point(ConnectionPoint.X + _BendingLineLength, ConnectionPoint.Y);
1163
                            }
1164
                        }
1165
                        break;
1166
                }
1167

    
1168
                connectorSMGeometry.EndPoint = BendingPoint;
1169
                connectorMEGeometry.StartPoint = BendingPoint;
1170
                connectorMEGeometry.EndPoint = ConnectionPoint;
1171
                
1172
                //20180910 LJY 각도에 따라.
1173
                this.MidPoint = BendingPoint;
1174
                instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint, this.StartPoint, this.LineSize));
1175
                instanceGroup.FillRule = FillRule.Nonzero;
1176
                this.Base_ArrowPath.Fill = this.StrokeColor;
1177
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1178
            }
1179
            else
1180
            {
1181
                switch (Math.Abs(this.PageAngle).ToString())
1182
                {
1183
                    case "90":
1184
                        {
1185
                            ps.Clear();
1186

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

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

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

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

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

    
1213
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1214
                        }
1215
                        break;
1216
                    //case "180":
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
                    default:
1234
                        break;
1235
                }
1236

    
1237

    
1238
                var ConnectionPoint = MathSet.getNearPoint(ps, this.MidPoint);
1239
                #region 보정치
1240
                Point BendingPoint = ConnectionPoint;
1241

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

    
1310
                connectorSMGeometry.EndPoint = BendingPoint;
1311
                connectorMEGeometry.StartPoint = BendingPoint;
1312
                connectorMEGeometry.EndPoint = ConnectionPoint;
1313
                instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint, this.StartPoint, this.LineSize));
1314
                instanceGroup.FillRule = FillRule.Nonzero;
1315
                this.Base_ArrowPath.Fill = this.StrokeColor;
1316
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1317
                #endregion
1318
            }
1319

    
1320
            switch (this.ArrowTextStyle)
1321
            {
1322
                case ArrowTextStyleSet.Normal:
1323
                    this.BorderSize = new Thickness(0);
1324
                    DrawingRect();
1325
                    break;
1326
                case ArrowTextStyleSet.Cloud:
1327
                    this.BorderSize = new Thickness(0);
1328
                    DrawingCloud();
1329
                    break;
1330
                default:
1331
                    {
1332
                        this.BorderSize = new Thickness(LineSize);
1333
                        DrawingRect();
1334
                    }
1335

    
1336
                    break;
1337
            }
1338

    
1339
            if (isHighLight)
1340
            {
1341
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1342
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1343

    
1344
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1345
            }
1346
            else
1347
            {
1348
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1349
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1350
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1), Colors.White.R, Colors.White.G, Colors.White.B));
1351
            }
1352

    
1353
            instanceGroup.Children.Add(connectorSMGeometry);
1354
            instanceGroup.Children.Add(connectorMEGeometry);
1355

    
1356
            this.PathData = instanceGroup;
1357
            OverViewPathData = PathData;
1358
            OverViewArrowText = ArrowText;
1359
            OverViewEndPoint = connectorMEGeometry.EndPoint;
1360
            OverViewStartPoint = connectorSMGeometry.StartPoint;
1361

    
1362
            var tempAngle = Math.Abs(this.VisualPageAngle);
1363

    
1364
            if (tempAngle == Convert.ToDouble(90) || tempAngle == Convert.ToDouble(270))
1365
            {
1366
                this.RenderTransformOrigin = new Point(0.5, 0.5);
1367
                this.Base_ArrowPath.RenderTransformOrigin = new Point(0, 0);
1368
                this.Base_ArrowSubPath.RenderTransformOrigin = new Point(0, 0);
1369

    
1370
                Base_TextBox.RenderTransformOrigin = new Point(0, 0);
1371
                BaseTextbox_Caret.RenderTransformOrigin = new Point(0, 0);
1372
            }
1373

    
1374
            Base_TextBox.RenderTransform = new RotateTransform
1375
            {
1376
                Angle = this.VisualPageAngle,
1377
                CenterX = this.CenterX,
1378
                CenterY = this.CenterY,
1379
            };
1380

    
1381
            Base_ArrowSubPath.RenderTransform = new RotateTransform
1382
            {
1383
                Angle = this.VisualPageAngle,
1384
                CenterX = this.EndPoint.X,
1385
                CenterY = this.EndPoint.Y,
1386
            };
1387

    
1388
            if (BaseTextbox_Caret.Visibility == Visibility.Visible)
1389
            {
1390
                BaseTextbox_Caret.RenderTransform = new RotateTransform
1391
                {
1392
                    Angle = this.VisualPageAngle,
1393
                    CenterX = this.CenterX,
1394
                    CenterY = this.CenterY,
1395
                };
1396

    
1397
                MoveCustomCaret();
1398
            }
1399
        }
1400

    
1401
        private void DrawingCloud()
1402
        {
1403
            //20180906 LJY Textbox guide
1404
            string angle = Math.Abs(this.PageAngle).ToString();
1405
            //방지
1406
            if (this.ArcLength == 0) this.ArcLength = 10;
1407
            if (angle == "180")
1408
            {
1409
                List<Point> pCloud = new List<Point>()
1410
                {
1411
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1412
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxHeight), //왼쪽 아래
1413
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox) - BoxHeight),
1414
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox)),
1415
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1416
                };
1417
                SubPathData = Generate(pCloud, this.ArcLength);
1418
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1419
            
1420
            }//20180906 LJY Textbox guide
1421
            else
1422
            {
1423
                var boxWidth = BoxWidth;
1424
                System.Diagnostics.Debug.WriteLine("disp Width : " + BoxWidth);
1425
                //boxWidth = boxWidth + Base_TextBox.Margin.Left + Base_TextBox.Margin.Right + Base_TextBox.Padding.Left + Base_TextBox.Padding.Right;
1426

    
1427
                List<Point> pCloud = new List<Point>()
1428
                {
1429
    #if SILVERLIGHT
1430
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1431
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1432
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1433
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1434
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1435

    
1436
    #else
1437
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize ), Canvas.GetTop(Base_TextBox) -(this.LineSize)), //위
1438
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize ), Canvas.GetTop(Base_TextBox)+ BoxHeight+(this.LineSize)), //왼쪽 아래
1439
                    new Point(Canvas.GetLeft(Base_TextBox)+ boxWidth+(this.LineSize ), Canvas.GetTop(Base_TextBox) + BoxHeight+(this.LineSize)),
1440
                    new Point(Canvas.GetLeft(Base_TextBox) + boxWidth+(this.LineSize ), Canvas.GetTop(Base_TextBox)-(this.LineSize)),
1441
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize), Canvas.GetTop(Base_TextBox)-(this.LineSize)), //위  
1442

    
1443
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1444
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1445
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1446
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1447
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1448
    #endif
1449
                };
1450
                //instanceGroup.Children.Add(Generate(pCloud));
1451
                SubPathData = Generate(pCloud, this.ArcLength);
1452
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1453
                //   }
1454
            }
1455

    
1456
        }
1457

    
1458
        private void DrawingRect()
1459
        {
1460
            //20180906 LJY Textbox guide
1461
            if(this.ArrowTextStyle == ArrowTextStyleSet.Normal)
1462
            {
1463
                this.Base_TextBox.BorderBrush = Brushes.Transparent;
1464
            }
1465
            
1466
            if (Math.Abs(this.PageAngle).ToString() == "90")
1467
            {
1468
                List<Point> pCloud = new List<Point>()
1469
                {
1470
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1471
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxWidth), //왼쪽 아래
1472
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox) - BoxWidth),
1473
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox)),
1474
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1475
                };
1476
                PathDataInner = (GenerateInner(pCloud));
1477
            }
1478
            else if(Math.Abs(this.PageAngle).ToString() == "270")
1479
            {
1480
                List<Point> pCloud = new List<Point>()
1481
                {
1482
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1483
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + BoxWidth), //왼쪽 아래
1484
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox) + BoxWidth),
1485
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox)),
1486
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1487
                };
1488
                PathDataInner = (GenerateInner(pCloud));
1489
            }//20180906 LJY Textbox guide
1490
            else
1491
            { 
1492
                List<Point> pCloud = new List<Point>()
1493
                {
1494
    #if SILVERLIGHT
1495
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1496
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1497
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1498
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1499
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1500

    
1501
    #else
1502
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1503
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1504
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1505
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1506
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1507

    
1508
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1509
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1510
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1511
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1512
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1513
    #endif
1514
                };
1515
                //instanceGroup.Children.Add(Generate(pCloud));
1516
                PathDataInner = (GenerateInner(pCloud));
1517
            }
1518
        }
1519

    
1520
        public override void UpdateControl()
1521
        {
1522
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
1523
            this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
1524
            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
1525
        }
1526

    
1527
        public override void ApplyOverViewData()
1528
        {
1529
            this.OverViewPathData = this.PathData;
1530
            if (ArrowText == "")
1531
            {
1532
                this.OverViewArrowText = "";
1533
                this.ArrowText = this.OverViewArrowText;
1534
            }
1535
            else
1536
                this.OverViewArrowText = this.ArrowText;
1537
            this.OverViewStartPoint = this.StartPoint;
1538
            this.OverViewEndPoint = this.EndPoint;
1539
        }
1540

    
1541
        #endregion
1542

    
1543
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
1544
        {
1545
            PathFigure pathFigure = new PathFigure();
1546
            pathFigure.StartPoint = p1;
1547

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

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

    
1584
            return pathFigure;
1585
        }
1586

    
1587
        public static PathGeometry Generate(List<Point> pData, double _ArcLength)
1588
        {
1589
            var _pathGeometry = new PathGeometry();
1590
            
1591
            double area = MathSet.AreaOf(pData);
1592
            bool reverse = (area > 0);
1593
            int count = pData.Count;
1594
            for (int i = 0; i < (count - 1); i++)
1595
            {
1596
                PathFigure pathFigure = Polygon.CloudControl.GenerateLineWithCloud(pData[i], pData[i + 1], _ArcLength, reverse);
1597
                pathFigure.IsClosed = false;
1598
                pathFigure.IsFilled = false;
1599
                _pathGeometry.Figures.Add(pathFigure);
1600
            }
1601
            
1602
            return _pathGeometry;
1603
        }
1604

    
1605
        
1606
        public static PathGeometry GenerateInner(List<Point> pData)
1607
        {
1608
            var _pathGeometry = new PathGeometry();
1609
            double area = MathSet.AreaOf(pData);
1610
            bool reverse = (area > 0);
1611
            int count = pData.Count;
1612

    
1613
            PathFigure pathFigur2 = new PathFigure();
1614
            pathFigur2.StartPoint = pData[0];
1615

    
1616
            LineSegment lineSegment0 = new LineSegment();
1617
            lineSegment0.Point = pData[0];
1618
            pathFigur2.Segments.Add(lineSegment0);
1619

    
1620
            LineSegment lineSegment1 = new LineSegment();
1621
            lineSegment1.Point = pData[1];
1622
            pathFigur2.Segments.Add(lineSegment1);
1623

    
1624
            LineSegment lineSegment2 = new LineSegment();
1625
            lineSegment2.Point = pData[2];
1626
            pathFigur2.Segments.Add(lineSegment2);
1627

    
1628
            LineSegment lineSegment3 = new LineSegment();
1629
            lineSegment3.Point = pData[3];
1630
            pathFigur2.Segments.Add(lineSegment3);
1631

    
1632

    
1633
            pathFigur2.IsClosed = true;
1634
            pathFigur2.IsFilled = true;
1635
            _pathGeometry.Figures.Add(pathFigur2);           
1636

    
1637
            return _pathGeometry;
1638
        }
1639

    
1640
        //20180910 LJY Cloud rotation 추가
1641
        public static PathGeometry GenerateInnerCloud(List<Point> pData, string angle)
1642
        {
1643
            var _pathGeometry = new PathGeometry();
1644
            double area = MathSet.AreaOf(pData);
1645
            bool reverse = (area > 0);
1646
            int count = pData.Count;
1647

    
1648
            PathFigure pathFigur2 = new PathFigure();
1649
            pathFigur2.StartPoint = pData[0];
1650

    
1651
            LineSegment lineSegment0 = new LineSegment();
1652
            lineSegment0.Point = pData[0];
1653
            pathFigur2.Segments.Add(lineSegment0);
1654

    
1655
            LineSegment lineSegment1 = new LineSegment();
1656
            lineSegment1.Point = pData[1];
1657
            pathFigur2.Segments.Add(lineSegment1);
1658

    
1659
            LineSegment lineSegment2 = new LineSegment();
1660
            lineSegment2.Point = pData[2];
1661
            pathFigur2.Segments.Add(lineSegment2);
1662

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

    
1684
            pathFigur2.IsClosed = true;
1685
            pathFigur2.IsFilled = true;
1686
            _pathGeometry.Figures.Add(pathFigur2);
1687

    
1688
            return _pathGeometry;
1689
        }
1690

    
1691
        /// <summary>
1692
        /// call when mouse is moving while drawing control
1693
        /// </summary>
1694
        /// <author>humkyung</author>
1695
        /// <param name="pt"></param>
1696
        /// <param name="bAxisLocked"></param>
1697
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
1698
        {
1699
            this.EndPoint = pt;
1700

    
1701
            Point tempPoint = this.EndPoint;
1702
            CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1703

    
1704
            if (bAxisLocked)
1705
            {
1706
                this.EndPoint = tempPoint;
1707
            }
1708

    
1709
            this.MidPoint = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint);
1710
            this.isFixed = (this.ControlType == ControlType.ArrowTransTextControl) ||
1711
                (this.ControlType == ControlType.ArrowTransTextBorderControl) || (this.ControlType == ControlType.ArrowTransTextCloudControl);
1712

    
1713
            this.PointSet = new List<Point>
1714
            {
1715
                this.StartPoint,
1716
                this.MidPoint,
1717
                this.EndPoint,
1718
            };
1719
        }
1720

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

    
1733
            Point selected = MathSet.getNearPoint(path.PointSet, pt);
1734
            selected.X += dx;
1735
            selected.Y += dy;
1736

    
1737
            int i = 0;
1738
            for (i = 0; i < (this as IPath).PointSet.Count; i++)
1739
            {
1740
                if (pt.Equals((this as IPath).PointSet[i])) break;
1741
            }
1742

    
1743
            List<Point> pts = path.PointSet;
1744
            #region 끝점을 이동할때
1745
            if (i == 0)
1746
            {
1747
                if ((pts[0].X > pts[1].X && dx > 0) || (pts[0].X < pts[1].X && dx < 0))
1748
                {
1749
                    pts[1] = new Point(pts[1].X + dx, pts[1].Y);
1750
                }
1751
                if ((pts[0].Y > pts[1].Y && dy > 0) || (pts[0].Y < pts[1].Y && dy < 0))
1752
                {
1753
                    pts[1] = new Point(pts[1].X, pts[1].Y + dy);
1754
                }
1755

    
1756
                path.PointSet[1] = pts[1];
1757
            }
1758
            #endregion
1759
            #region 중간점을 이동할때
1760
            else if (i == 1)
1761
            {
1762
                path.PointSet[1] = selected;
1763
            }
1764
            #endregion
1765

    
1766
            if (path.PointSet.Count > i) {
1767
                path.PointSet[i] = selected;
1768
            }
1769

    
1770
            this.UpdateControl();
1771
        }
1772

    
1773
        /// <summary>
1774
        /// return ArrowTextControl's area
1775
        /// </summary>
1776
        /// <author>humkyung</author>
1777
        /// <date>2019.06.13</date>
1778
        public override Rect ItemRect
1779
        {
1780
            get
1781
            {
1782
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
1783
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
1784
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
1785
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
1786

    
1787
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
1788
            }
1789
        }
1790

    
1791
        /// <summary>
1792
        /// Serialize this
1793
        /// </summary>
1794
        /// <param name="sUserId"></param>
1795
        /// <returns></returns>
1796
        public override string Serialize()
1797
        {
1798
            using (S_ArrowTextControl ctrl = new S_ArrowTextControl())
1799
            {
1800
                ctrl.TransformPoint = "0|0";
1801
                ctrl.PointSet = this.PointSet;
1802
                ctrl.SizeSet = String.Format("{0}", this.LineSize);
1803
                ctrl.StrokeColor = this.StrokeColor.Color.ToString();
1804
                ctrl.StartPoint = this.StartPoint;
1805
                ctrl.ArrowStyle = this.ArrowTextStyle;
1806
                ctrl.UserID = this.UserID;
1807
                ctrl.ArrowText = this.Base_TextBox.Text;
1808
                ctrl.BorderSize = this.BorderSize;
1809
                ctrl.isHighLight = this.isHighLight;
1810
                ctrl.BoxHeight = this.BoxHeight;
1811
                ctrl.BoxWidth = this.BoxWidth;
1812
                ctrl.Opac = this.Opacity;
1813
                ctrl.EndPoint = this.EndPoint;
1814
                ctrl.isFixed = this.isFixed;
1815
                ctrl.ControlType = this.ControlType;
1816
                ctrl.Name = this.GetType().Name.ToString();
1817
                ctrl.isTrans = this.isTrans;
1818
                ctrl.MidPoint = this.MidPoint;
1819
                ctrl.Angle = this.PageAngle;
1820
                ctrl.fontConfig = new List<string>()
1821
                {
1822
                    this.TextFamily.FontName(),
1823
                    this.TextStyle.ToString(),
1824
                    this.TextWeight.ToString(),
1825
                    this.TextSize.ToString(),
1826
                };
1827

    
1828
                if (this.UnderLine != null)
1829
                {
1830
                    ctrl.fontConfig.Add("true");
1831
                }
1832

    
1833
                ///강인구 추가(2017.11.02)
1834
                ///Memo 추가
1835
                ctrl.Memo = this.Memo;
1836
                ctrl.BorderSize = this.BorderSize;
1837
                ctrl.ArcLength = this.ArcLength;
1838
                ctrl.ZIndex = this.ZIndex;
1839
                ctrl.GroupID = this.GroupID;
1840

    
1841
                return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize()));
1842
            };
1843
        }
1844

    
1845
        /// <summary>
1846
        /// create a arrowtextcontrol from given string
1847
        /// </summary>
1848
        /// <param name="str"></param>
1849
        /// <returns></returns>
1850
        public static ArrowTextControl FromString(string str, SolidColorBrush brush, string sProjectNo,double PageAngle)
1851
        {
1852
            ArrowTextControl instance = null;
1853
            using (S_ArrowTextControl s = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(str))
1854
            {
1855
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1856
                instance = new ArrowTextControl();
1857
                instance.PageAngle = s.Angle;
1858
                instance.LineSize = Convert.ToDouble(data2.First());
1859
                instance.PointSet = s.PointSet;
1860
                instance.StartPoint = s.StartPoint;
1861
                instance.EndPoint = s.EndPoint;
1862
                instance.StrokeColor = brush;
1863
                instance.ArrowTextStyle = s.ArrowStyle;
1864
                instance.isHighLight = s.isHighLight;
1865
                instance.ArrowText = s.ArrowText;
1866
                instance.Opacity = s.Opac;
1867
                instance.BorderSize = s.BorderSize;
1868
                instance.BoxWidth = s.BoxWidth;
1869
                instance.BoxHeight = s.BoxHeight;
1870
                instance.isFixed = s.isFixed;
1871
                instance.ControlType = s.ControlType;
1872
                instance.UserID = s.UserID;
1873
                instance.isTrans = s.isTrans;
1874
                instance.MidPoint = s.MidPoint;
1875
                instance.Memo = s.Memo;
1876
                instance.ZIndex = s.ZIndex;
1877
                instance.GroupID = s.GroupID;
1878
                if (s.fontConfig == null || s.fontConfig.ToList().Count == 0)
1879
                {
1880
                    s.fontConfig = new List<string>();
1881

    
1882
                    s.fontConfig.Add("Arial");
1883
                    s.fontConfig.Add("Normal");
1884
                    s.fontConfig.Add("Normal");
1885
                    s.fontConfig.Add("30");
1886
                }
1887
                instance.TextFamily = Markus.Fonts.FontHelper.GetFontFamily(s.fontConfig[0]);
1888
                //인구 추가(2018.04.17)
1889
                instance.TextStyle = StringToFont.ConFontStyle(s.fontConfig[1]);
1890
                instance.TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]);
1891
                instance.TextSize = Convert.ToDouble(s.fontConfig[3]);
1892
                instance.ArcLength = s.ArcLength;
1893
                if (s.fontConfig.Count == 5)
1894
                {
1895
                    instance.UnderLine = TextDecorations.Underline;
1896
                }
1897
            }
1898

    
1899
            return instance;
1900
        }
1901

    
1902
        #region Dispose
1903
        public void Dispose()
1904
        {
1905
            //GC.Collect();
1906
            ////GC.SuppressFinalize(this);
1907
            this.BaseTextbox_Caret = null;
1908
            this.Base_ArrowPath = null;
1909
            this.Base_ArrowSubPath = null;
1910
            this.Base_TextBlock = null;
1911
            this.Base_TextBox = null;
1912
        } 
1913
        #endregion
1914

    
1915
        #region INotifyPropertyChanged
1916
        private void OnPropertyChanged(string name)
1917
        {
1918
            if (PropertyChanged != null)
1919
            {
1920
                PropertyChanged(this, new PropertyChangedEventArgs(name));
1921
            }
1922
        }
1923

    
1924
        public Rect GetCommentRect()
1925
        {
1926
            Rect rect = new Rect();
1927

    
1928
            rect.Location = new Point();
1929
            rect.Size = new Size();
1930

    
1931
            List<Point> points = new List<Point>();
1932

    
1933
            points.AddRange(this.PointSet);
1934

    
1935
            var boxTopleft = new Point(Canvas.GetTop(Base_TextBox), Canvas.GetLeft(Base_TextBox));
1936
            points.Add(boxTopleft);
1937

    
1938
            var boxBottomRight =new Point(boxTopleft.X + Base_TextBox.ActualWidth, boxTopleft.Y + Base_TextBox.ActualHeight);
1939
            points.Add(boxBottomRight);
1940

    
1941
            rect = CommentMath.CalculateBoundingRect(points);
1942

    
1943
            return rect;
1944
        }
1945

    
1946
        public event PropertyChangedEventHandler PropertyChanged; 
1947
        #endregion
1948
    }
1949
}
클립보드 이미지 추가 (최대 크기: 500 MB)