프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Text / ArrowTextControl.cs @ 284ed1c7

이력 | 보기 | 이력해설 | 다운로드 (78.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, 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
        /// <summary>
1016
        /// 연결점 리스트를 리턴한다.
1017
        /// </summary>
1018
        /// <returns></returns>
1019
        private List<Point> GetConnectionPointList()
1020
        {
1021
            List<Point> res = new List<Point>();
1022
            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox))); //상단
1023
            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox) + this.BoxHeight)); // 하단
1024
            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2)); //좌단
1025
            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2));  //우단
1026

    
1027
            if (isTrans)
1028
            {
1029
                switch (Math.Abs(this.PageAngle).ToString())
1030
                {
1031
                    case "90":
1032
                        {
1033
                            res.Clear();
1034

    
1035
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1036
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1037
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1038

    
1039
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1040
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1041

    
1042
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); //중간 하단
1043
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 하단
1044

    
1045
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간
1046
                        }
1047
                        break;
1048
                    case "270":
1049
                        {
1050
                            res.Clear();
1051

    
1052
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1053
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1054
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1055

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

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

    
1062
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간
1063
                        }
1064
                        break;
1065
                    default:
1066
                        break;
1067
                }
1068
            }
1069
            else
1070
            {
1071
                switch (Math.Abs(this.PageAngle).ToString())
1072
                {
1073
                    case "90":
1074
                        {
1075
                            res.Clear();
1076

    
1077
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1078
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1079
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1080

    
1081
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1082
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1083

    
1084
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); //중간 하단
1085
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 하단
1086
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간 
1087
                        }
1088
                        break;
1089
                    case "270":
1090
                        {
1091
                            res.Clear();
1092

    
1093
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1094
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1095
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1096

    
1097
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1098
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1099

    
1100
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); //중간 하단
1101
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 하단
1102

    
1103
                            res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1104
                        }
1105
                        break;
1106
                    default:
1107
                        break;
1108
                }
1109
            }
1110

    
1111
            return res;
1112
        }
1113

    
1114
        /// <summary>
1115
        /// connection을 이용하여 꺽인점의 위치를 구한다.
1116
        /// </summary>
1117
        /// <returns></returns>
1118
        private Point? GetBendingPoint(List<Point> ConnectionPointList, Point connection)
1119
        {
1120
            Point? BendingPoint = null;
1121

    
1122
            if (isTrans)
1123
            {
1124
                //20180910 LJY 각도에 따라.
1125
                switch (Math.Abs(this.PageAngle).ToString())
1126
                {
1127
                    case "90":
1128
                        if (isFixed)
1129
                        {
1130
                            if (ConnectionPointList[0] == connection) //상단
1131
                            {
1132
                                BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength);
1133
                            }
1134
                            else if (ConnectionPointList[1] == connection) //하단
1135
                            {
1136
                                BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength);
1137
                            }
1138
                            else if (ConnectionPointList[2] == connection) //좌단
1139
                            {
1140
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1141
                            }
1142
                            else if (ConnectionPointList[3] == connection) //우단
1143
                            {
1144
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1145
                            }
1146
                        }
1147
                        break;
1148
                    case "270":
1149
                        if (isFixed)
1150
                        {
1151
                            if (ConnectionPointList[0] == connection) //상단
1152
                            {
1153
                                BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength);
1154
                            }
1155
                            else if (ConnectionPointList[1] == connection) //하단
1156
                            {
1157
                                BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength);
1158
                            }
1159
                            else if (ConnectionPointList[2] == connection) //좌단
1160
                            {
1161
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1162
                            }
1163
                            else if (ConnectionPointList[3] == connection) //우단
1164
                            {
1165
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1166
                            }
1167
                        }
1168
                        break;
1169
                    default:
1170
                        if (isFixed)
1171
                        {
1172
                            if (ConnectionPointList[0] == connection) //상단
1173
                            {
1174
                                BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength);
1175
                            }
1176
                            else if (ConnectionPointList[1] == connection) //하단
1177
                            {
1178
                                BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength);
1179
                            }
1180
                            else if (ConnectionPointList[2] == connection) //좌단
1181
                            {
1182
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1183
                            }
1184
                            else if (ConnectionPointList[3] == connection) //우단
1185
                            {
1186
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1187
                            }
1188
                        }
1189
                        break;
1190
                }
1191
            }
1192
            else
1193
            {
1194
                //20180910 LJY 각도에 따라.
1195
                switch (Math.Abs(this.PageAngle).ToString())
1196
                {
1197
                    case "90":
1198
                        if (isFixed)
1199
                        {
1200
                            if (ConnectionPointList[0] == connection) //상단
1201
                            {
1202
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1203
                            }
1204
                            else if (ConnectionPointList[1] == connection) //하단
1205
                            {
1206
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1207
                            }
1208
                            else if (ConnectionPointList[2] == connection) //좌단
1209
                            {
1210
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1211
                            }
1212
                            else if (ConnectionPointList[3] == connection) //우단
1213
                            {
1214
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1215
                            }
1216
                        }
1217
                        break;
1218
                    case "270":
1219
                        if (isFixed)
1220
                        {
1221
                            if (ConnectionPointList[0] == connection) //상단
1222
                            {
1223
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1224
                            }
1225
                            else if (ConnectionPointList[1] == connection) //하단
1226
                            {
1227
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1228
                            }
1229
                            else if (ConnectionPointList[2] == connection) //좌단
1230
                            {
1231
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1232
                            }
1233
                            else if (ConnectionPointList[3] == connection) //우단
1234
                            {
1235
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1236
                            }
1237
                        }
1238
                        break;
1239
                    default:
1240
                        if (isFixed)
1241
                        {
1242
                            if (ConnectionPointList[0] == connection) //상단
1243
                            {
1244
                                BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength);
1245
                            }
1246
                            else if (ConnectionPointList[1] == connection) //하단
1247
                            {
1248
                                BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength);
1249
                            }
1250
                            else if (ConnectionPointList[2] == connection) //좌단
1251
                            {
1252
                                BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y);
1253
                            }
1254
                            else if (ConnectionPointList[3] == connection) //우단
1255
                            {
1256
                                BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y);
1257
                            }
1258
                        }
1259
                        break;
1260
                }
1261
            }
1262

    
1263

    
1264
            return BendingPoint;
1265
        }
1266

    
1267
        private void SetArrowTextPath(bool IsInit = false)
1268
        {
1269
            instanceGroup.Children.Clear();
1270

    
1271
            if (Math.Abs(PageAngle).ToString() == "90")
1272
            {
1273
                VisualPageAngle = 270;
1274
            }
1275
            else if (Math.Abs(PageAngle).ToString() == "270")
1276
            {
1277
                VisualPageAngle = 90;
1278
            }
1279
            else
1280
            {
1281
                VisualPageAngle = PageAngle;
1282
            }
1283

    
1284
            connectorSMGeometry.StartPoint = this.StartPoint;
1285
            connectorSMGeometry.EndPoint = this.MidPoint;
1286
            connectorMEGeometry.StartPoint = this.MidPoint; //핵심
1287

    
1288
            /// 텍스트박스의 좌표 설정
1289
            Canvas.SetLeft(Base_TextBox, this.EndPoint.X);
1290
            Canvas.SetTop(Base_TextBox, this.EndPoint.Y);
1291

    
1292
            List<Point> ps = GetConnectionPointList();
1293
            if (isTrans)
1294
            {
1295
                var ConnectionPoint = MathSet.getNearPoint(ps, this.MidPoint);
1296
                Point? BendingPoint = GetBendingPoint(ps, ConnectionPoint);
1297
                if (BendingPoint.HasValue)
1298
                {
1299
                    connectorSMGeometry.EndPoint = BendingPoint.Value;
1300
                    connectorMEGeometry.StartPoint = BendingPoint.Value;
1301
                    connectorMEGeometry.EndPoint = ConnectionPoint;
1302

    
1303
                    //20180910 LJY 각도에 따라.
1304
                    this.MidPoint = BendingPoint.Value;
1305
                    instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint.Value, this.StartPoint, this.LineSize));
1306
                    instanceGroup.FillRule = FillRule.Nonzero;
1307
                    this.Base_ArrowPath.Fill = this.StrokeColor;
1308
                    this.Base_ArrowSubPath.Fill = this.StrokeColor;
1309
                }
1310
            }
1311
            else
1312
            {
1313
                var ConnectionPoint = MathSet.getNearPoint(ps, this.MidPoint);
1314
                #region 보정치
1315
                Point? BendingPoint = GetBendingPoint(ps, ConnectionPoint);
1316
                if (BendingPoint.HasValue)
1317
                {
1318
                    connectorSMGeometry.EndPoint = BendingPoint.Value;
1319
                    connectorMEGeometry.StartPoint = BendingPoint.Value;
1320
                    connectorMEGeometry.EndPoint = ConnectionPoint;
1321
                    instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint.Value, this.StartPoint, this.LineSize));
1322
                    instanceGroup.FillRule = FillRule.Nonzero;
1323
                    this.Base_ArrowPath.Fill = this.StrokeColor;
1324
                    this.Base_ArrowSubPath.Fill = this.StrokeColor;
1325
                }
1326
                #endregion
1327
            }
1328

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

    
1345
                    break;
1346
            }
1347

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

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

    
1362
            instanceGroup.Children.Add(connectorSMGeometry);
1363
            instanceGroup.Children.Add(connectorMEGeometry);
1364

    
1365
            this.PathData = instanceGroup;
1366
            OverViewPathData = PathData;
1367
            OverViewArrowText = ArrowText;
1368
            OverViewEndPoint = connectorMEGeometry.EndPoint;
1369
            OverViewStartPoint = connectorSMGeometry.StartPoint;
1370

    
1371
            var tempAngle = Math.Abs(this.VisualPageAngle);
1372

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

    
1379
                Base_TextBox.RenderTransformOrigin = new Point(0, 0);
1380
                BaseTextbox_Caret.RenderTransformOrigin = new Point(0, 0);
1381
            }
1382

    
1383
            Base_TextBox.RenderTransform = new RotateTransform
1384
            {
1385
                Angle = this.VisualPageAngle,
1386
                CenterX = this.CenterX,
1387
                CenterY = this.CenterY,
1388
            };
1389

    
1390
            Base_ArrowSubPath.RenderTransform = new RotateTransform
1391
            {
1392
                Angle = this.VisualPageAngle,
1393
                CenterX = this.EndPoint.X,
1394
                CenterY = this.EndPoint.Y,
1395
            };
1396

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

    
1406
                MoveCustomCaret();
1407
            }
1408
        }
1409

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

    
1436
                List<Point> pCloud = new List<Point>()
1437
                {
1438
    #if SILVERLIGHT
1439
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1440
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1441
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1442
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1443
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1444

    
1445
    #else
1446
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize ), Canvas.GetTop(Base_TextBox) -(this.LineSize)), //위
1447
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize ), Canvas.GetTop(Base_TextBox)+ BoxHeight+(this.LineSize)), //왼쪽 아래
1448
                    new Point(Canvas.GetLeft(Base_TextBox)+ boxWidth+(this.LineSize ), Canvas.GetTop(Base_TextBox) + BoxHeight+(this.LineSize)),
1449
                    new Point(Canvas.GetLeft(Base_TextBox) + boxWidth+(this.LineSize ), Canvas.GetTop(Base_TextBox)-(this.LineSize)),
1450
                    new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize), Canvas.GetTop(Base_TextBox)-(this.LineSize)), //위  
1451

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

    
1465
        }
1466

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

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

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

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

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

    
1550
        #endregion
1551

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

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

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

    
1593
            return pathFigure;
1594
        }
1595

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

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

    
1622
            PathFigure pathFigur2 = new PathFigure();
1623
            pathFigur2.StartPoint = pData[0];
1624

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

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

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

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

    
1641

    
1642
            pathFigur2.IsClosed = true;
1643
            pathFigur2.IsFilled = true;
1644
            _pathGeometry.Figures.Add(pathFigur2);           
1645

    
1646
            return _pathGeometry;
1647
        }
1648

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

    
1657
            PathFigure pathFigur2 = new PathFigure();
1658
            pathFigur2.StartPoint = pData[0];
1659

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

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

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

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

    
1693
            pathFigur2.IsClosed = true;
1694
            pathFigur2.IsFilled = true;
1695
            _pathGeometry.Figures.Add(pathFigur2);
1696

    
1697
            return _pathGeometry;
1698
        }
1699

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

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

    
1713
            if (bAxisLocked)
1714
            {
1715
                this.EndPoint = tempPoint;
1716
            }
1717

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

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

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

    
1742
            Point selected = MathSet.getNearPoint(path.PointSet, pt);
1743
            selected.X += dx;
1744
            selected.Y += dy;
1745

    
1746
            int i = 0;
1747
            for (i = 0; i < (this as IPath).PointSet.Count; i++)
1748
            {
1749
                if (pt.Equals((this as IPath).PointSet[i])) break;
1750
            }
1751

    
1752
            List<Point> pts = path.PointSet;
1753
            #region 끝점을 이동할때
1754
            if (i == 0)
1755
            {
1756
                var connections = GetConnectionPointList();
1757
                var near = MathSet.getNearPoint(connections, selected);
1758
                var bending = GetBendingPoint(connections, near);
1759
                if(bending.HasValue) path.PointSet[1] = bending.Value;
1760
            }
1761
            #endregion
1762
            #region 중간점을 이동할때
1763
            else if (i == 1)
1764
            {
1765
                path.PointSet[1] = selected;
1766
            }
1767
            #endregion
1768

    
1769
            if (path.PointSet.Count > i) {
1770
                path.PointSet[i] = selected;
1771
            }
1772

    
1773
            this.UpdateControl();
1774
        }
1775

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

    
1790
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
1791
            }
1792
        }
1793

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

    
1831
                if (this.UnderLine != null)
1832
                {
1833
                    ctrl.fontConfig.Add("true");
1834
                }
1835

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

    
1844
                return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize()));
1845
            };
1846
        }
1847

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

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

    
1902
            return instance;
1903
        }
1904

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

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

    
1927
        public Rect GetCommentRect()
1928
        {
1929
            Rect rect = new Rect();
1930

    
1931
            rect.Location = new Point();
1932
            rect.Size = new Size();
1933

    
1934
            List<Point> points = new List<Point>();
1935

    
1936
            points.AddRange(this.PointSet);
1937

    
1938
            var boxTopleft = new Point(Canvas.GetTop(Base_TextBox), Canvas.GetLeft(Base_TextBox));
1939
            points.Add(boxTopleft);
1940

    
1941
            var boxBottomRight =new Point(boxTopleft.X + Base_TextBox.ActualWidth, boxTopleft.Y + Base_TextBox.ActualHeight);
1942
            points.Add(boxBottomRight);
1943

    
1944
            rect = CommentMath.CalculateBoundingRect(points);
1945

    
1946
            return rect;
1947
        }
1948

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