프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Text / ArrowTextControl.cs @ da7ab6ad

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

    
17
namespace MarkupToPDF.Controls.Text
18
{
19
    public class ArrowTextControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IPath, ITextControl, IMarkupControlData
20
    {
21
        private const string PART_ArrowPath = "PART_ArrowPath";
22
        private const string PART_TextBox = "PART_ArrowTextBox";
23
        //private const string PART_TextBlock = "PART_ArrowTextBlock";
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

    
34
        private const double _CloudArcDepth = 0.8;  /// 2018.05.14 added by humkyung
35

    
36
        #region Object & Variable
37
        GeometryGroup instanceGroup = new GeometryGroup();
38
        
39
        Path Cemy = new Path();
40
        LineGeometry connectorSMGeometry = new LineGeometry();
41
        LineGeometry connectorMEGeometry = 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
            //ResourceDictionary dictionary = new ResourceDictionary();
51
            //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
52
            //if(!Application.Current.Resources.MergedDictionaries.Any(x=>x.Source == dictionary.Source))
53
            //    Application.Current.Resources.MergedDictionaries.Add(dictionary);
54
        }
55

    
56
        public ArrowTextControl()
57
        {
58
            //this.DefaultStyleKey = typeof(ArrowTextControl);
59
        }
60

    
61
        public override void OnApplyTemplate()
62
        {
63
            base.OnApplyTemplate();
64
            Base_ArrowPath = GetTemplateChild(PART_ArrowPath) as Path;
65
            Base_ArrowSubPath = GetTemplateChild(PART_ArrowSubPath) as Path;
66
            Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox;
67
            BaseTextbox_Caret = GetTemplateChild(PART_BaseTextbox_Caret) as Border;
68
            Base_TextBox.Text = this.ArrowText;
69
           
70
            this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length;
71
            this.Base_TextBox.CaretBrush = new SolidColorBrush(Colors.Transparent);
72
            this.Base_TextBox.ApplyTemplate();
73
            MoveCustomCaret();
74

    
75
            Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged);
76
            Base_TextBox.GotFocus += new RoutedEventHandler(Base_TextBox_GotFocus);
77
            Base_TextBox.LostFocus += new RoutedEventHandler(Base_TextBox_LostFocus);
78
            Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret();
79

    
80
            SetArrowTextPath();
81
            Base_TextBox.IsTabStop = true;
82
        }
83

    
84
        public void SetFontFamily(FontFamily fontFamily)
85
        {
86
            this.FontFamily = fontFamily;
87
            this.TextFamily = fontFamily;
88
        }
89

    
90
        /// <summary>
91
        /// Moves the custom caret on the canvas.
92
        /// </summary>
93
        public void MoveCustomCaret()
94
        {
95
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
96

    
97
            var angle = Math.Abs(this.PageAngle);
98
            //angle = 0;
99
            System.Diagnostics.Debug.WriteLine("Page Angle : " +  this.PageAngle);
100

    
101
            if (!double.IsInfinity(caretLocation.X))
102
            {
103
                if (angle == 90)
104
                {
105
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.Y);
106
                }
107
                else if (angle == 180)
108
                {
109
                    
110
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X+ this.Base_TextBox.ActualWidth) - caretLocation.X) ;
111
                    System.Diagnostics.Debug.WriteLine("Caret X : " + ((this.EndPoint.X + this.Base_TextBox.ActualWidth) - caretLocation.X));
112
                } 
113
                else if (angle == 270)
114
                {
115
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X) - caretLocation.Y);
116
                }
117
                else
118
                {
119
                    System.Diagnostics.Debug.WriteLine("Caret X : " + (this.EndPoint.X - caretLocation.X));
120
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.X);
121
                } 
122
            }
123

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

    
147
        public void MoveCustomCaret(Point point)
148
        {
149

    
150
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
151

    
152
            if (!double.IsInfinity(caretLocation.X))
153
            {
154
                if (Math.Abs(this.PageAngle) == 90)
155
                {
156
                    Canvas.SetLeft(this.BaseTextbox_Caret, point.X + caretLocation.Y);
157
                }
158
                else if (Math.Abs(this.PageAngle) == 180)
159
                {
160

    
161
                    Canvas.SetLeft(this.BaseTextbox_Caret, (point.X + this.Base_TextBox.ActualWidth) - caretLocation.X);
162
                }
163
                else if (Math.Abs(this.PageAngle) == 270)
164
                {
165
                    Canvas.SetLeft(this.BaseTextbox_Caret, (point.X) - caretLocation.Y);
166
                }
167
                else
168
                {
169
                    Canvas.SetLeft(this.BaseTextbox_Caret, point.X + caretLocation.X);
170
                }
171
            }
172

    
173
            if (!double.IsInfinity(caretLocation.Y))
174
            {
175
                if (Math.Abs(this.PageAngle) == 90)
176
                {
177
                    Canvas.SetTop(this.BaseTextbox_Caret, point.Y - caretLocation.X);
178
                }
179
                else if (Math.Abs(this.PageAngle) == 180)
180
                {
181
                    Canvas.SetTop(this.BaseTextbox_Caret, (point.Y + this.Base_TextBox.ActualHeight) - caretLocation.Y);
182
                }
183
                else if (Math.Abs(this.CommentAngle) == 270)
184
                {
185
                    Canvas.SetTop(this.BaseTextbox_Caret, (point.Y) + caretLocation.X);
186
                }
187
                else
188
                {
189
                    Canvas.SetTop(this.BaseTextbox_Caret, point.Y + caretLocation.Y);
190
                }
191
            }
192
        }
193

    
194

    
195
        void Base_TextBox_LostFocus(object sender, RoutedEventArgs e)
196
        {
197
            
198
            this.ArrowText = Base_TextBox.Text;
199
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
200
            this.IsEditingMode = false;
201
            ApplyOverViewData();
202
        }
203

    
204
        void Base_TextBox_GotFocus(object sender, RoutedEventArgs e)
205
        {
206
            this.BaseTextbox_Caret.Visibility = Visibility.Visible;
207
            MoveCustomCaret();
208
            this.IsEditingMode = true;
209
        }
210

    
211
        void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e)
212
        {
213
            if(this.IsEditingMode)
214
            {
215
                if (Base_TextBox.Text.Contains("|OR||DZ|"))
216
                {
217
                    Base_TextBox.Text = this.ArrowText;
218
                }
219

    
220
                this.ArrowText = Base_TextBox.Text;
221
                
222
            }
223
            BoxWidth = e.NewSize.Width;
224
            BoxHeight = e.NewSize.Height;
225
            SetArrowTextPath();
226
        }
227

    
228
        #region Properties
229
        private bool _IsEditingMode;
230
        public bool IsEditingMode
231
        {
232
            get
233
            {
234
                return _IsEditingMode;
235
            }
236
            set
237
            {
238
                _IsEditingMode = value;
239
                OnPropertyChanged("IsEditingMode");
240
            }
241
        }
242

    
243

    
244
        #endregion
245

    
246
        #region dp Properties
247
        //강인구 주석 풀기
248
        public Visibility TextBoxVisibility
249
        {
250
            get { return (Visibility)GetValue(TextBoxVisibilityProperty); }
251
            set
252
            {
253
                if (this.TextBoxVisibility != value)
254
                {
255
                    SetValue(TextBoxVisibilityProperty, value);
256
                    OnPropertyChanged("TextBoxVisibility");
257
                }
258
            }
259
        }
260

    
261
        //강인구 주석 풀기
262
        public Visibility TextBlockVisibility
263
        {
264
            get { return (Visibility)GetValue(TextBlockVisibilityProperty); }
265
            set
266
            {
267
                if (this.TextBlockVisibility != value)
268
                {
269
                    SetValue(TextBlockVisibilityProperty, value);
270
                    OnPropertyChanged("TextBlockVisibility");
271
                }
272
            }
273
        }
274

    
275

    
276
        public override SolidColorBrush StrokeColor
277
        {
278
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
279
            set
280
            {
281
                if (this.StrokeColor != value)
282
                {
283
                    SetValue(StrokeColorProperty, value);
284
                }
285
            }
286
        }
287

    
288
        public PathGeometry SubPathData
289
        {
290
            get { return (PathGeometry)GetValue(SubPathDataProperty); }
291
            set
292
            {
293
                if (this.SubPathData != value)
294
                {
295
                    SetValue(SubPathDataProperty, value);
296
                }
297
            }
298
        }
299

    
300
        public string UserID
301
        {
302
            get { return (string)GetValue(UserIDProperty); }
303
            set
304
            {
305
                if (this.UserID != value)
306
                {
307
                    SetValue(UserIDProperty, value);
308
                    OnPropertyChanged("UserID");
309
                }
310
            }
311
        }
312

    
313
        public List<Point> PointSet
314
        {
315
            get { return (List<Point>)GetValue(PointSetProperty); }
316
            set { SetValue(PointSetProperty, value); }
317
        }
318

    
319
        public override bool IsSelected
320
        {
321
            get
322
            {
323
                return (bool)GetValue(IsSelectedProperty);
324
            }
325
            set
326
            {
327
                SetValue(IsSelectedProperty, value);
328
                OnPropertyChanged("IsSelected");
329
            }
330
        }
331

    
332
        public override ControlType ControlType
333
        {
334
            set
335
            {
336
                SetValue(ControlTypeProperty, value);
337
                OnPropertyChanged("ControlType");
338
            }
339
            get
340
            {
341
                return (ControlType)GetValue(ControlTypeProperty);
342
            }
343
        }
344

    
345
        public Point StartPoint
346
        {
347
            get { return (Point)GetValue(StartPointProperty); }
348
            set { SetValue(StartPointProperty, value); }
349
        }
350

    
351
        public Point EndPoint
352
        {
353
            get { return (Point)GetValue(EndPointProperty); }
354
            set { SetValue(EndPointProperty, value); }
355
        }
356

    
357
        public Point OverViewStartPoint
358
        {
359
            get { return (Point)GetValue(OverViewStartPointProperty); }
360
            set { SetValue(OverViewStartPointProperty, value); }
361
        }
362

    
363
        public Point OverViewEndPoint
364
        {
365
            get { return (Point)GetValue(OverViewEndPointProperty); }
366
            set { SetValue(OverViewEndPointProperty, value); }
367
        }
368

    
369

    
370
        //public double Angle
371
        //{
372
        //    get { return (double)GetValue(AngleProperty); }
373
        //    set { SetValue(AngleProperty, value); }
374
        //}
375

    
376
        public Thickness BorderSize
377
        {
378
            get { return (Thickness)GetValue(BorderSizeProperty); }
379
            set
380
            {
381
                if (this.BorderSize != value)
382
                {
383
                    SetValue(BorderSizeProperty, value);
384
                }
385
            }
386
        }
387

    
388

    
389
        public Point MidPoint
390
        {
391
            get { return (Point)GetValue(MidPointProperty); }
392
            set { SetValue(MidPointProperty, value); }
393
        }
394

    
395
        public bool isFixed
396
        {
397
            get { return (bool)GetValue(IsFixedProperty); }
398
            set { SetValue(IsFixedProperty, value); }
399
        }
400

    
401
        public bool isTrans
402
        {
403
            get { return (bool)GetValue(TransformerProperty); }
404
            set { SetValue(TransformerProperty, value); }
405
        }
406

    
407
        public bool isHighLight
408
        {
409
            get { return (bool)GetValue(isHighlightProperty); }
410
            set
411
            {
412
                if (this.isHighLight != value)
413
                {
414
                    SetValue(isHighlightProperty, value);
415
                    OnPropertyChanged("isHighLight");
416
                }
417
            }
418
        }
419

    
420
        public FontWeight TextWeight
421
        {
422
            get { return (FontWeight)GetValue(TextWeightProperty); }
423
            set
424
            {
425
                if (this.TextWeight != value)
426
                {
427
                    SetValue(TextWeightProperty, value);
428
                    OnPropertyChanged("TextWeight");
429
                }
430
            }
431
        }
432

    
433
        public Double LineSize
434
        {
435
            get { return (Double)GetValue(LineSizeProperty); }
436
            set
437
            {
438
                if (this.LineSize != value)
439
                {
440
                    SetValue(LineSizeProperty, value);
441
                }
442
            }
443
        }
444

    
445
        public Double BoxWidth
446
        {
447
            get { return (Double)GetValue(BoxWidthProperty); }
448
            set
449
            {
450
                if (this.BoxWidth != value)
451
                {
452
                    SetValue(BoxWidthProperty, value);
453
                }
454
            }
455
        }
456

    
457
        public Double BoxHeight
458
        {
459
            get { return (Double)GetValue(BoxHeightProperty); }
460
            set
461
            {
462
                if (this.BoxHeight != value)
463
                {
464
                    SetValue(BoxHeightProperty, value);
465
                }
466
            }
467
        }
468

    
469
        public ArrowTextStyleSet ArrowTextStyle
470
        {
471
            get { return (ArrowTextStyleSet)GetValue(ArrowTextStyleProperty); }
472
            set
473
            {
474
                if (this.ArrowTextStyle != value)
475
                {
476
                    SetValue(ArrowTextStyleProperty, value);
477
                }
478
            }
479
        }
480

    
481
        public Geometry PathData
482
        {
483
            get { return (Geometry)GetValue(PathDataProperty); }
484
            set { SetValue(PathDataProperty, value);
485

    
486
                OnPropertyChanged("PathData");
487
            }
488
        }
489

    
490
        public SolidColorBrush BackInnerColor
491
        {
492
            get { return (SolidColorBrush)GetValue(BackInnerColorProperty); }
493
            set
494
            {
495
                if (this.BackInnerColor != value)
496
                {
497
                    SetValue(BackInnerColorProperty, value);
498
                    OnPropertyChanged("BackInnerColor");
499
                }
500
            }
501
        }
502

    
503
        public Geometry PathDataInner
504
        {
505
            get { return (Geometry)GetValue(PathDataInnerProperty); }
506
            set
507
            {
508
                SetValue(PathDataInnerProperty, value);
509
                OnPropertyChanged("PathDataInner");
510
            }
511
        }
512

    
513
        public Geometry OverViewPathData
514
        {
515
            get { return (Geometry)GetValue(OverViewPathDataProperty); }
516
            set { SetValue(OverViewPathDataProperty, value);
517

    
518
                OnPropertyChanged("OverViewPathData");
519

    
520
            }
521
        }
522

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

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

    
549
        public string OverViewArrowText
550
        {
551

    
552
            get { return (string)GetValue(OverViewArrowTextProperty);
553
            }
554
            set
555
            {
556
                if (this.OverViewArrowText != value)
557
                {
558
                    SetValue(OverViewArrowTextProperty, value);
559
                    OnPropertyChanged("OverViewArrowText");
560
                }
561
            }
562
        }
563

    
564
        public Double TextSize
565
        {
566
            get { return (Double)GetValue(TextSizeProperty); }
567
            set
568
            {
569
                if (this.TextSize != value)
570
                {
571
                    SetValue(TextSizeProperty, value);
572
                    OnPropertyChanged("TextSize");
573
                }
574
            }
575
        }
576

    
577
        public FontStyle TextStyle
578
        {
579
            get { return (FontStyle)GetValue(TextStyleProperty); }
580
            set
581
            {
582
                if (this.TextStyle != value)
583
                {
584
                    SetValue(TextStyleProperty, value);
585
                    OnPropertyChanged("TextStyle");
586
                }
587
            }
588
        }
589

    
590
        //강인구 추가
591
        public TextDecorationCollection UnderLine
592
        {
593
            get
594
            {
595
                return (TextDecorationCollection)GetValue(UnderLineProperty);
596
            }
597
            set
598
            {
599
                if (this.UnderLine != value)
600
                {
601
                    SetValue(UnderLineProperty, value);
602
                    OnPropertyChanged("UnderLine");
603
                }
604
            }
605
        }
606

    
607
        public double CanvasX
608
        {
609
            get { return (double)GetValue(CanvasXProperty); }
610
            set
611
            {
612
                if (this.CanvasX != value)
613
                {
614
                    SetValue(CanvasXProperty, value);
615
                    OnPropertyChanged("CanvasX");
616
                }
617
            }
618
        }
619

    
620
        public double CanvasY
621
        {
622
            get { return (double)GetValue(CanvasYProperty); }
623
            set
624
            {
625
                if (this.CanvasY != value)
626
                {
627
                    SetValue(CanvasYProperty, value);
628
                    OnPropertyChanged("CanvasY");
629
                }
630
            }
631
        } 
632

    
633
        public double CenterX
634
        {
635
            get { return (double)GetValue(CenterXProperty); }
636
            set { SetValue(CenterXProperty, value);
637
            OnPropertyChanged("CenterX");
638
            
639
            }
640
        }
641

    
642
        public double CenterY
643
        {
644
            get { return (double)GetValue(CenterYProperty); }
645
            set { SetValue(CenterYProperty, value);
646
            OnPropertyChanged("CenterY");
647
            }
648
        }
649

    
650
        public Brush SubPathFill
651
        {
652
            get { return (Brush)GetValue(SubPathFillProperty); }
653
            set
654
            {
655
                SetValue(SubPathFillProperty, value);
656
                OnPropertyChanged("SubPathFill");
657
            }
658
        }
659

    
660
        public Brush TextBoxBackground
661
        {
662
            get { return (Brush)GetValue(TextBoxBackgroundProperty); }
663
            set
664
            {
665
                SetValue(TextBoxBackgroundProperty, value);
666
                OnPropertyChanged("TextBoxBackground");
667
            }
668
        }
669

    
670

    
671
        //강인구 추가 주석풀기
672
       
673

    
674
        public bool EnableEditing
675
        {
676
            get { return (bool)GetValue(EnableEditingProperty); }
677
            set
678
            {
679
                if (this.EnableEditing != value)
680
                {
681
                    SetValue(EnableEditingProperty, value);
682
                    OnPropertyChanged("EnableEditing");
683
                }
684
            }
685
        }
686

    
687
        #endregion
688

    
689
        #region Dependency Properties
690

    
691
        public static readonly DependencyProperty BoxWidthProperty = DependencyProperty.Register(
692
                "BoxWidth", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
693

    
694
        public static readonly DependencyProperty BoxHeightProperty = DependencyProperty.Register(
695
                "BoxHeight", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
696

    
697
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
698
                "UserID", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
699

    
700
        public static readonly DependencyProperty ArrowTextStyleProperty = DependencyProperty.Register(
701
               "ArrowTextStyle", typeof(ArrowTextStyleSet), typeof(ArrowTextControl), new PropertyMetadata(ArrowTextStyleSet.Normal));
702

    
703
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register(
704
                "CenterX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
705

    
706
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register(
707
                "CenterY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
708

    
709
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register(
710
                "Angle", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(PointValueChanged)));
711
        
712
        public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
713
                "CanvasX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
714

    
715
        public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
716
                "CanvasY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
717

    
718
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
719
                "PointSet", typeof(List<Point>), typeof(ArrowTextControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
720

    
721
        public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register(
722
                "TextFamily", typeof(FontFamily), typeof(ArrowTextControl), new PropertyMetadata(new FontFamily("Arial"), TextChanged));
723

    
724
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
725
                "PathData", typeof(Geometry), typeof(ArrowTextControl), null);
726

    
727
        //강인구 추가
728
        public static readonly DependencyProperty UnderLineProperty = DependencyProperty.Register(
729
    "UnderLine", typeof(TextDecorationCollection), typeof(ArrowTextControl), new PropertyMetadata(null, PointValueChanged));
730

    
731
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
732
               "LineSize", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)3, PointValueChanged));
733

    
734
        public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register(
735
                "TextStyle", typeof(FontStyle), typeof(ArrowTextControl), new PropertyMetadata(FontStyles.Normal));
736

    
737
        public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register(
738
                "TextSize", typeof(Double), typeof(ArrowTextControl), new PropertyMetadata((Double)30, PointValueChanged));
739

    
740
        public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register(
741
                "TextWeight", typeof(FontWeight), typeof(ArrowTextControl), new PropertyMetadata(FontWeights.Normal));
742

    
743
        public static readonly DependencyProperty IsFixedProperty = DependencyProperty.Register(
744
                "isFixed", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
745

    
746
        public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
747
                "IsSelected", typeof(bool), typeof(ArrowTextControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
748

    
749
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
750
                "StrokeColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
751

    
752
        public static readonly DependencyProperty ControlTypeProperty = DependencyProperty.Register(
753
                "ControlType", typeof(ControlType), typeof(ArrowTextControl), new FrameworkPropertyMetadata(ControlType.ArrowTextControl));
754

    
755
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
756
                "StartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
757

    
758
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
759
                "EndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
760

    
761
        public static readonly DependencyProperty BackInnerColorProperty = DependencyProperty.Register(
762
            "BackInnerColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.White)));
763

    
764
        public static readonly DependencyProperty PathDataInnerProperty = DependencyProperty.Register(
765
    "PathDataInner", typeof(Geometry), typeof(ArrowTextControl), null);
766

    
767
        public static readonly DependencyProperty isHighlightProperty = DependencyProperty.Register(
768
                "isHighlight", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
769

    
770
        public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register(
771
                "MidPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
772

    
773
        public static readonly DependencyProperty TransformerProperty = DependencyProperty.Register(
774
                "isTrans", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
775

    
776
        public static readonly DependencyProperty BorderSizeProperty = DependencyProperty.Register(
777
                "BorderSize", typeof(Thickness), typeof(ArrowTextControl), new PropertyMetadata(new Thickness(0), PointValueChanged));
778
    
779
        public static readonly DependencyProperty ArrowTextProperty = DependencyProperty.Register(
780
              "ArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
781

    
782

    
783

    
784
        //, new PropertyChangedCallback(TextChanged)
785

    
786

    
787
        #region 추가 사항
788
        public static readonly DependencyProperty SubPathDataProperty = DependencyProperty.Register(
789
                "SubPathData", typeof(Geometry), typeof(ArrowTextControl), null);
790

    
791

    
792
        public static readonly DependencyProperty SubPathFillProperty = DependencyProperty.Register(
793
                "SubPathFill", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(null));
794

    
795
        public static readonly DependencyProperty TextBoxBackgroundProperty = DependencyProperty.Register(
796
                "TextBoxBackground", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(Brushes.White));
797

    
798
        public static readonly DependencyProperty OverViewArrowTextProperty = DependencyProperty.Register(
799
                "OverViewArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null, new PropertyChangedCallback(TextChanged)));
800

    
801
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
802
                "OverViewPathData", typeof(Geometry), typeof(ArrowTextControl), null);
803

    
804
        public static readonly DependencyProperty OverViewStartPointProperty = DependencyProperty.Register(
805
                "OverViewStartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
806

    
807
        public static readonly DependencyProperty OverViewEndPointProperty = DependencyProperty.Register(
808
                "OverViewEndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
809

    
810
        public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register(
811
            "TextBoxVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged));
812

    
813
        //강인구 추가(주석풀기)
814
        public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register(
815
            "TextBlockVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged));
816

    
817
        public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register(
818
           "EnableEditing", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata((true), new PropertyChangedCallback(OnIsEditingChanged)));
819

    
820
        #endregion
821

    
822
        #endregion
823

    
824
        #region CallBack Method
825

    
826
        //강인구 추가(주석풀기)
827
        public static void OnIsEditingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
828
        {
829
            var instance = (ArrowTextControl)sender;
830

    
831
            if (e.OldValue != e.NewValue && instance.Base_TextBlock != null)
832
            {
833
                instance.SetValue(e.Property, e.NewValue);
834

    
835
                if (instance.EnableEditing)
836
                {
837
                    instance.EditingMode();
838
                }
839
                else
840
                {
841
                    instance.UnEditingMode();
842
                }
843
            }
844
        }
845

    
846
        public static void OnTextBoxVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
847
        {
848
            var instance = (ArrowTextControl)sender;
849

    
850
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
851
            {
852
                instance.SetValue(e.Property, e.NewValue);
853
            }
854
        }
855

    
856
        public static void OnTextBlockVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
857
        {
858
            var instance = (ArrowTextControl)sender;
859

    
860
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
861
            {
862
                instance.SetValue(e.Property, e.NewValue);
863
            }
864
        }
865

    
866
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
867
        {
868
            var instance = (ArrowTextControl)sender;
869

    
870
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
871
            {
872
                instance.SetArrowTextPath();
873
            }
874
        }
875

    
876

    
877

    
878
        public static void TextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
879
        {
880
            var instance = (ArrowTextControl)sender;
881
            
882
            if (e.OldValue != e.NewValue)
883
            {
884
                instance.SetValue(e.Property, e.NewValue);
885
                //instance.BoxWidth = instance.Base_TextBox.ActualWidth;
886
                //instance.BoxHeight = instance.Base_TextBox.ActualHeight;
887
            }
888
        }
889

    
890
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
891
        {
892
            var instance = (ArrowTextControl)sender;
893
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
894
            {
895
                instance.SetValue(e.Property, e.NewValue);
896
                instance.SetArrowTextPath();
897
            }
898
        }
899

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

    
904
            if (e.OldValue != e.NewValue && instance != null)
905
            {
906
                instance.SetValue(e.Property, e.NewValue);
907
                //Canvas.SetLeft(instance, instance.CanvasX);
908
                //Canvas.SetTop(instance, instance.CanvasY);
909
            }
910
        }
911

    
912
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
913
        {
914
            //var instance = (ArrowTextControl)sender;
915

    
916
            //if (e.OldValue != e.NewValue)
917
            //{
918
            //    instance.SetValue(e.Property, e.NewValue);
919

    
920
            //    if (instance.IsSelected && instance.Base_TextBox != null)
921
            //    {
922
            //        instance.BorderSize = new Thickness(1);
923
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Blue);
924
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Blue);
925
            //    }
926
            //    else
927
            //    {
928
            //        instance.BorderSize = new Thickness(0);
929
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Transparent);
930
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Transparent);
931
            //    }
932
            //}
933
        }
934
        #endregion
935

    
936
        #region Internal Method
937

    
938
        //강인구 주석 풀기
939
        public void EditingMode()
940
        {
941
            TextBoxVisibility = Visibility.Visible;
942
            TextBlockVisibility = Visibility.Collapsed;
943

    
944

    
945
            //강인구 언더라인 추가
946
            if (UnderLine != null)
947
                Base_TextBlock.TextDecorations = UnderLine;
948
        }
949
        //강인구 주석 풀기
950
        public void UnEditingMode()
951
        {
952

    
953
            TextBoxVisibility = Visibility.Collapsed;
954
            TextBlockVisibility = Visibility.Visible;
955

    
956
            if (UnderLine != null)
957
                Base_TextBlock.TextDecorations = UnderLine;
958

    
959
            Base_TextBlock.Margin =
960
                 new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4,
961
                     Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4);
962
        }
963

    
964
        private void SetArrowTextPath()
965
        {
966
            instanceGroup.Children.Clear();
967

    
968
            //VisualPageAngle = 0;
969

    
970
            if (Math.Abs(PageAngle).ToString() == "90")
971
            {
972
                VisualPageAngle = 270;
973
            }
974
            else if (Math.Abs(PageAngle).ToString() == "270")
975
            {
976
                VisualPageAngle = 90;
977
            }
978
            else
979
            {
980
                VisualPageAngle = PageAngle;
981
            }
982

    
983
            connectorSMGeometry.StartPoint = this.StartPoint;
984
            connectorSMGeometry.EndPoint = this.MidPoint;
985
            connectorMEGeometry.StartPoint = this.MidPoint; //핵심
986

    
987
            /// 텍스트박스의 좌표 설정
988
            Canvas.SetLeft(Base_TextBox, this.EndPoint.X);
989
            Canvas.SetTop(Base_TextBox, this.EndPoint.Y);
990
            System.Diagnostics.Debug.WriteLine($"TextBox Set {this.EndPoint.X},{this.EndPoint.Y}");
991
            
992

    
993
            List<Point> ps = new List<Point>();
994
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox))); //상단
995
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox) + this.BoxHeight)); // 하단
996
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2)); //좌단
997
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2));  //우단
998

    
999
            if (isTrans)
1000
            {
1001
                switch (Math.Abs(this.PageAngle).ToString())
1002
                {
1003
                    case "90":
1004
                        {
1005
                            ps.Clear();
1006
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1007
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1008
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1009

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

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

    
1016
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간
1017
                        }
1018
                        break;
1019
                    case "270":
1020
                        {
1021
                            ps.Clear();
1022
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1023
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1024
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1025

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

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

    
1032
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간
1033
                        }
1034
                        break;
1035
                    default:
1036
                        break;
1037
                }
1038
                
1039
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1040

    
1041
                //20180911 LJY 꺾이는 부분 수정
1042
                Point testP = endP;                
1043
                switch (Math.Abs(this.PageAngle).ToString())
1044
                {
1045
                    case "90":
1046
                        testP = new Point(endP.X + 50, endP.Y);
1047
                        break;
1048
                    case "270":
1049
                        testP = new Point(endP.X - 50, endP.Y);
1050
                        break;
1051
                }                
1052

    
1053
                //20180910 LJY 각도에 따라.
1054
                switch (Math.Abs(this.PageAngle).ToString())
1055
                {
1056
                    case "90":
1057
                        if (isFixed)
1058
                        {
1059
                            if (ps[0] == endP) //상단
1060
                            {
1061
                                testP = new Point(endP.X , endP.Y + 50);
1062
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1063
                            }
1064
                            else if (ps[1] == endP) //하단
1065
                            {
1066
                                testP = new Point(endP.X , endP.Y - 50);
1067
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1068
                            }
1069
                            else if (ps[2] == endP) //좌단
1070
                            {
1071
                                testP = new Point(endP.X - 50, endP.Y);
1072
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1073
                            }
1074
                            else if (ps[3] == endP) //우단
1075
                            {
1076
                                testP = new Point(endP.X + 50, endP.Y);
1077
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1078
                            }
1079
                        }
1080
                        break;
1081
                    case "270":
1082
                        if (isFixed)
1083
                        {
1084
                            if (ps[0] == endP) //상단
1085
                            {
1086
                                testP = new Point(endP.X , endP.Y - 50);
1087
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1088
                            }
1089
                            else if (ps[1] == endP) //하단
1090
                            {
1091
                                testP = new Point(endP.X, endP.Y + 50);
1092
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1093
                            }
1094
                            else if (ps[2] == endP) //좌단
1095
                            {
1096
                                testP = new Point(endP.X + 50, endP.Y);
1097
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1098
                            }
1099
                            else if (ps[3] == endP) //우단
1100
                            {
1101
                                testP = new Point(endP.X - 50, endP.Y);
1102
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1103
                            }
1104
                        }
1105
                        break;
1106
                    default:
1107
                        if (isFixed)
1108
                        {
1109
                            if (ps[0] == endP) //상단
1110
                            {
1111
                                testP = new Point(endP.X, endP.Y - 50);
1112
                                //System.Diagnostics.Debug.WriteLine("상단");
1113
                            }
1114
                            else if (ps[1] == endP) //하단
1115
                            {
1116
                                testP = new Point(endP.X, endP.Y + 50);
1117
                                //System.Diagnostics.Debug.WriteLine("하단");
1118
                            }
1119
                            else if (ps[2] == endP) //좌단
1120
                            {
1121
                                testP = new Point(endP.X - 50, endP.Y);
1122
                                //System.Diagnostics.Debug.WriteLine("좌단");
1123
                            }
1124
                            else if (ps[3] == endP) //우단
1125
                            {
1126
                                testP = new Point(endP.X + 50, endP.Y);
1127
                                //System.Diagnostics.Debug.WriteLine("우단");
1128
                            }
1129
                        }
1130
                        break;
1131
                }
1132
                connectorMEGeometry.EndPoint = endP;
1133
                connectorSMGeometry.EndPoint = testP;
1134
                connectorMEGeometry.StartPoint = testP;
1135
                
1136
                //20180910 LJY 각도에 따라.
1137
                this.MidPoint = testP;
1138
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1139
                instanceGroup.FillRule = FillRule.Nonzero;
1140
                this.Base_ArrowPath.Fill = this.StrokeColor;
1141
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1142
            }
1143
            else
1144
            {
1145
                switch (Math.Abs(this.PageAngle).ToString())
1146
                {
1147
                    case "90":
1148
                        {
1149
                            ps.Clear();
1150

    
1151
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1152
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1153
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1154

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

    
1158
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); //중간 하단
1159
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 하단
1160
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간 
1161
                        }
1162
                        break;
1163
                    case "270":
1164
                        {
1165
                            ps.Clear();
1166
                            
1167
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1168
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1169
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1170

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

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

    
1177
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1178
                        }
1179
                        break;
1180
                    //case "180":
1181
                    //    {
1182
                    //        ps.Clear();
1183

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

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

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

    
1194
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1195
                    //    }
1196
                    //    break;
1197
                    default:
1198
                        break;
1199
                }
1200

    
1201

    
1202
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1203
                connectorMEGeometry.EndPoint = endP; //최상단
1204
                                                     //connectorMEGeometry.EndPoint = this.EndPoint; //핵심
1205
                                                     //this.MidPoint= MathSet.getMiddlePoint(this.StartPoint, endP);
1206
                #region 보정치
1207
                Point testP = endP;
1208

    
1209
                //20180910 LJY 각도에 따라.
1210
                switch (Math.Abs(this.PageAngle).ToString())
1211
                {
1212
                    case "90":
1213
                        if (isFixed)
1214
                        {
1215
                            if (ps[0] == endP) //상단
1216
                            {
1217
                                testP = new Point(endP.X - 50, endP.Y);
1218
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1219
                            }
1220
                            else if (ps[1] == endP) //하단
1221
                            {
1222
                                testP = new Point(endP.X + 50, endP.Y);
1223
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1224
                            }
1225
                            else if (ps[2] == endP) //좌단
1226
                            {
1227
                                testP = new Point(endP.X - 50, endP.Y);
1228
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1229
                            }
1230
                            else if (ps[3] == endP) //우단
1231
                            {
1232
                                testP = new Point(endP.X + 50 , endP.Y);
1233
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1234
                            }
1235
                        }
1236
                        break;
1237
                    case "270":
1238
                        if (isFixed)
1239
                        {
1240
                            if (ps[0] == endP) //상단
1241
                            {
1242
                                testP = new Point(endP.X + 50, endP.Y);
1243
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1244
                            }
1245
                            else if (ps[1] == endP) //하단
1246
                            {
1247
                                testP = new Point(endP.X - 50, endP.Y);
1248
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1249
                            }
1250
                            else if (ps[2] == endP) //좌단
1251
                            {
1252
                                testP = new Point(endP.X + 50, endP.Y);
1253
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1254
                            }
1255
                            else if (ps[3] == endP) //우단
1256
                            {
1257
                                testP = new Point(endP.X + 50, endP.Y );
1258
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1259
                            }
1260
                        }
1261
                        break;
1262
                    default:
1263
                        if (isFixed)
1264
                        {
1265
                            if (ps[0] == endP) //상단
1266
                            {
1267
                                testP = new Point(endP.X, endP.Y - 50);
1268
                                //System.Diagnostics.Debug.WriteLine("상단");
1269
                            }
1270
                            else if (ps[1] == endP) //하단
1271
                            {
1272
                                testP = new Point(endP.X, endP.Y + 50);
1273
                                //System.Diagnostics.Debug.WriteLine("하단");
1274
                            }
1275
                            else if (ps[2] == endP) //좌단
1276
                            {
1277
                                testP = new Point(endP.X - 50, endP.Y);
1278
                                //System.Diagnostics.Debug.WriteLine("좌단");
1279
                            }
1280
                            else if (ps[3] == endP) //우단
1281
                            {
1282
                                testP = new Point(endP.X + 50, endP.Y);
1283
                                //System.Diagnostics.Debug.WriteLine("우단");
1284
                            }
1285
                        }
1286
                        break;
1287
                }
1288
                  
1289

    
1290
                connectorSMGeometry.EndPoint = testP;
1291
                connectorMEGeometry.StartPoint = testP;
1292
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1293
                instanceGroup.FillRule = FillRule.Nonzero;
1294
                this.Base_ArrowPath.Fill = this.StrokeColor;
1295
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1296
                #endregion
1297
            }
1298

    
1299
            switch (this.ArrowTextStyle)
1300
            {
1301
                case ArrowTextStyleSet.Normal:
1302
                    this.BorderSize = new Thickness(0);
1303
                    DrawingRect();
1304
                    break;
1305
                case ArrowTextStyleSet.Cloud:
1306
                    this.BorderSize = new Thickness(0);
1307
                    DrawingCloud();
1308
                    break;
1309
                default:
1310
                    {
1311
                        this.BorderSize = new Thickness(LineSize); //올라
1312
                        DrawingRect();
1313
                    }
1314

    
1315
                    break;
1316
            }
1317

    
1318
            if (isHighLight)
1319
            {
1320
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1321
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1322

    
1323
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1324
            }
1325
            else
1326
            {
1327
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1328
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1329
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1), Colors.White.R, Colors.White.G, Colors.White.B));
1330
            }
1331

    
1332
            instanceGroup.Children.Add(connectorSMGeometry);
1333
            instanceGroup.Children.Add(connectorMEGeometry);
1334

    
1335
            this.PathData = instanceGroup;
1336
            OverViewPathData = PathData;
1337
            OverViewArrowText = ArrowText;
1338
            OverViewEndPoint = connectorMEGeometry.EndPoint;
1339
            OverViewStartPoint = connectorSMGeometry.StartPoint;
1340

    
1341
            var tempAngle = Math.Abs(this.PageAngle);
1342

    
1343
            if (tempAngle == Convert.ToDouble(90) || tempAngle == Convert.ToDouble(270))
1344
            {
1345
                this.RenderTransformOrigin = new Point(0.5, 0.5);
1346
                this.Base_ArrowPath.RenderTransformOrigin = new Point(0, 0);
1347
                this.Base_ArrowSubPath.RenderTransformOrigin = new Point(0, 0);
1348

    
1349
                Base_TextBox.RenderTransformOrigin = new Point(0, 0);
1350
                BaseTextbox_Caret.RenderTransformOrigin = new Point(0, 0);
1351
            }
1352

    
1353
            Base_TextBox.RenderTransform = new RotateTransform
1354
            {
1355
                Angle = this.VisualPageAngle,
1356
                CenterX = this.CenterX,
1357
                CenterY = this.CenterY,
1358
            };
1359

    
1360
            System.Diagnostics.Debug.WriteLine($"base TextBox center X : {this.CenterX} Y : {this.CenterY} ");
1361

    
1362
            
1363

    
1364
            Base_ArrowSubPath.RenderTransform = new RotateTransform
1365
            {
1366
                Angle = this.VisualPageAngle,
1367
                CenterX = this.EndPoint.X,
1368
                CenterY = this.EndPoint.Y,
1369
            };
1370

    
1371
            if (BaseTextbox_Caret.Visibility == Visibility.Visible)
1372
            {
1373
                BaseTextbox_Caret.RenderTransform = new RotateTransform
1374
                {
1375
                    Angle = this.VisualPageAngle,
1376
                    CenterX = this.CenterX,
1377
                    CenterY = this.CenterY,
1378
                };
1379

    
1380
                MoveCustomCaret();
1381
            }
1382
        }
1383

    
1384
        private void DrawingCloud()
1385
        {
1386
            //20180906 LJY Textbox guide
1387
            string angle = Math.Abs(this.PageAngle).ToString();
1388
            if (angle == "180")
1389
            {
1390
                List<Point> pCloud = new List<Point>()
1391
                {
1392
                     new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1393
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxHeight), //왼쪽 아래
1394
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox) - BoxHeight),
1395
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox)),
1396
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1397
                };
1398
                SubPathData = (Generate(pCloud));
1399
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1400
            
1401
            }//20180906 LJY Textbox guide
1402
            else
1403
            {            
1404
                List<Point> pCloud = new List<Point>()
1405
                {
1406
    #if SILVERLIGHT
1407
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1408
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1409
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1410
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1411
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1412

    
1413
    #else
1414
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1415
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1416
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1417
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1418
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1419

    
1420
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1421
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1422
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1423
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1424
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1425
    #endif
1426
                };
1427
                //instanceGroup.Children.Add(Generate(pCloud));
1428
                SubPathData = (Generate(pCloud));
1429
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1430
                //   }
1431
            }
1432

    
1433
        }
1434

    
1435
        private void DrawingRect()
1436
        {
1437
            //20180906 LJY Textbox guide
1438
            if(this.ArrowTextStyle == ArrowTextStyleSet.Normal)
1439
            {
1440
                this.Base_TextBox.BorderBrush = Brushes.Transparent;
1441
            }
1442

    
1443
            if (Math.Abs(this.PageAngle).ToString() == "90")
1444
            {
1445
                List<Point> pCloud = new List<Point>()
1446
                {
1447
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1448
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxWidth), //왼쪽 아래
1449
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox) - BoxWidth),
1450
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox)),
1451
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1452
                };
1453
                PathDataInner = (GenerateInner(pCloud));
1454
            }
1455
            else if(Math.Abs(this.PageAngle).ToString() == "270")
1456
            {
1457
                List<Point> pCloud = new List<Point>()
1458
                {
1459
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1460
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + BoxWidth), //왼쪽 아래
1461
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox) + BoxWidth),
1462
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox)),
1463
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1464
                };
1465
                PathDataInner = (GenerateInner(pCloud));
1466
            }//20180906 LJY Textbox guide
1467
            else
1468
            { 
1469
                List<Point> pCloud = new List<Point>()
1470
                {
1471
    #if SILVERLIGHT
1472
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1473
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1474
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1475
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1476
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1477

    
1478
    #else
1479
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1480
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1481
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1482
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1483
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1484

    
1485
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1486
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1487
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1488
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1489
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1490
    #endif
1491
                };
1492
                //instanceGroup.Children.Add(Generate(pCloud));
1493
                PathDataInner = (GenerateInner(pCloud));
1494
            }
1495
        }
1496

    
1497
        public override void UpdateControl()
1498
        {
1499
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
1500
            this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
1501
            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
1502
        }
1503

    
1504
        public override void ApplyOverViewData()
1505
        {
1506
            this.OverViewPathData = this.PathData;
1507
            if (ArrowText == "")
1508
                this.ArrowText = this.OverViewArrowText;
1509
            else
1510
                this.OverViewArrowText = this.ArrowText;
1511
            this.OverViewStartPoint = this.StartPoint;
1512
            this.OverViewEndPoint = this.EndPoint;
1513
        }
1514

    
1515
        #endregion
1516

    
1517
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
1518
        {
1519
            PathFigure pathFigure = new PathFigure();
1520
            pathFigure.StartPoint = p1;
1521

    
1522
            double arcLength = arcLength_;
1523
            /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung 
1524
            double dx = p2.X - p1.X;
1525
            double dy = p2.Y - p1.Y;
1526
            double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2
1527
            double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
1528
            Point lastPt = new Point(p1.X, p1.Y);
1529
            double count = l / arcLength;
1530
            /// normalize
1531
            dx /= l;
1532
            dy /= l;
1533
            Double j = 1;
1534
            for (j = 1; j < (count - 1); j++) 
1535
            {
1536
                ArcSegment arcSeg = new ArcSegment();
1537
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);						/// x size and y size of arc
1538
                arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);	/// end point of arc
1539
                lastPt = arcSeg.Point;  /// save last point
1540
                arcSeg.RotationAngle = theta + 90;
1541
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1542
                pathFigure.Segments.Add(arcSeg);
1543
            }
1544

    
1545
            /// draw arc between last point and end point
1546
            if ((count > j) || (count > 0))
1547
            {
1548
                arcLength = MathSet.DistanceTo(lastPt, p2);
1549
                ArcSegment arcSeg = new ArcSegment();
1550
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);	/// x size and y size of arc
1551
                arcSeg.Point = new Point(p2.X, p2.Y);						/// end point of arc
1552
                arcSeg.RotationAngle = theta;
1553
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1554
                pathFigure.Segments.Add(arcSeg);
1555
            }
1556
            /// up to here
1557

    
1558
            return pathFigure;
1559
        }
1560

    
1561
        public static PathGeometry Generate(List<Point> pData)
1562
        {
1563
            var _pathGeometry = new PathGeometry();
1564
            
1565
            double area = MathSet.AreaOf(pData);
1566
            bool reverse = (area > 0);
1567
            int count = pData.Count;
1568
            for (int i = 0; i < (count - 1); i++)
1569
            {
1570
                PathFigure pathFigure = GenerateLineWithCloud(pData[i], pData[i + 1], 20, reverse);
1571
                pathFigure.IsClosed = false;
1572
                pathFigure.IsFilled = true;
1573
                _pathGeometry.Figures.Add(pathFigure);
1574
            }
1575
            
1576
            return _pathGeometry;
1577
        }
1578

    
1579
        
1580
        public static PathGeometry GenerateInner(List<Point> pData)
1581
        {
1582
            var _pathGeometry = new PathGeometry();
1583
            double area = MathSet.AreaOf(pData);
1584
            bool reverse = (area > 0);
1585
            int count = pData.Count;
1586

    
1587
            PathFigure pathFigur2 = new PathFigure();
1588
            pathFigur2.StartPoint = pData[0];
1589

    
1590
            LineSegment lineSegment0 = new LineSegment();
1591
            lineSegment0.Point = pData[0];
1592
            pathFigur2.Segments.Add(lineSegment0);
1593

    
1594
            LineSegment lineSegment1 = new LineSegment();
1595
            lineSegment1.Point = pData[1];
1596
            pathFigur2.Segments.Add(lineSegment1);
1597

    
1598
            LineSegment lineSegment2 = new LineSegment();
1599
            lineSegment2.Point = pData[2];
1600
            pathFigur2.Segments.Add(lineSegment2);
1601

    
1602
            LineSegment lineSegment3 = new LineSegment();
1603
            lineSegment3.Point = pData[3];
1604
            pathFigur2.Segments.Add(lineSegment3);
1605

    
1606

    
1607
            pathFigur2.IsClosed = true;
1608
            pathFigur2.IsFilled = true;
1609
            _pathGeometry.Figures.Add(pathFigur2);           
1610

    
1611
            return _pathGeometry;
1612
        }
1613

    
1614
        //20180910 LJY Cloud rotation 추가
1615
        public static PathGeometry GenerateInnerCloud(List<Point> pData, string angle)
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
            RotateTransform transform = new RotateTransform();
1642
            switch (angle)
1643
            {
1644
                case "90":
1645
                    transform.Angle = -90;
1646
                    break;
1647
                case "180":
1648
                    transform.Angle = -180;
1649
                    break;
1650
                case "270":
1651
                    transform.Angle = -270;
1652
                    break;
1653
            }
1654
            transform.CenterX = pData[0].X;
1655
            transform.CenterY = pData[0].Y;
1656
            _pathGeometry.Transform = transform;
1657

    
1658
            pathFigur2.IsClosed = true;
1659
            pathFigur2.IsFilled = true;
1660
            _pathGeometry.Figures.Add(pathFigur2);
1661

    
1662
            return _pathGeometry;
1663
        }
1664

    
1665
        /// <summary>
1666
        /// call when mouse is moving while drawing control
1667
        /// </summary>
1668
        /// <author>humkyung</author>
1669
        /// <param name="pt"></param>
1670
        /// <param name="bAxisLocked"></param>
1671
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed)
1672
        {
1673
            this.EndPoint = pt;
1674

    
1675
            Point tempPoint = this.EndPoint;
1676
            CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bShiftKeyPressed);
1677

    
1678
            if (bAxisLocked || bShiftKeyPressed)
1679
            {
1680
                this.EndPoint = tempPoint;
1681
            }
1682

    
1683
            this.MidPoint = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint);
1684
            this.isFixed = (this.ControlType == ControlType.ArrowTransTextControl) || 
1685
                (this.ControlType == ControlType.ArrowTransTextBorderControl) || (this.ControlType == ControlType.ArrowTransTextCloudControl);
1686

    
1687
            this.PointSet = new List<Point>
1688
            {
1689
                this.StartPoint,
1690
                this.MidPoint,
1691
                this.EndPoint,
1692
            };
1693
        }
1694

    
1695
        /// <summary>
1696
        /// move control point has same location of given pt along given delta
1697
        /// </summary>
1698
        /// <author>humkyung</author>
1699
        /// <date>2019.06.20</date>
1700
        /// <param name="pt"></param>
1701
        /// <param name="dx"></param>
1702
        /// <param name="dy"></param>
1703
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy)
1704
        {
1705
            IPath path = (this as IPath);
1706

    
1707
            Point selected = MathSet.getNearPoint(path.PointSet, pt);
1708

    
1709
            //StartPoint에 표시된 Thumb는 dx,dy가 +로 더해줘야한다.
1710
            if (path.PointSet.IndexOf(selected) != 0)
1711
            {
1712
                double radian = this.CommentAngle * Math.PI / 180;
1713
                double cos = Math.Cos(radian);
1714
                double sin = Math.Sin(radian);
1715

    
1716
                double _dx = dx * cos - dy * sin;
1717
                double _dy = dx * sin + dy * cos;
1718

    
1719
                selected.X += _dx;
1720
                selected.Y += _dy;
1721
            }
1722
            else
1723
            {
1724
                selected.X += dx;
1725
                selected.Y += dy;
1726
            }
1727

    
1728
            int i = 0;
1729
            for (i = 0; i < (this as IPath).PointSet.Count; i++)
1730
            {
1731
                if (pt.Equals((this as IPath).PointSet[i])) break;
1732
            }
1733

    
1734
            List<Point> pts = path.PointSet;
1735
            if ((pts[0].X > pts[1].X && dx > 0) || (pts[0].X < pts[1].X && dx < 0))
1736
            {
1737
                pts[1] = new Point(pts[1].X + dx, pts[1].Y);
1738
            }
1739
            if ((pts[0].Y > pts[1].Y && dy > 0) || (pts[0].Y < pts[1].Y && dy < 0))
1740
            {
1741
                pts[1] = new Point(pts[1].X, pts[1].Y + dy);
1742
            }
1743

    
1744
            path.PointSet[1] = pts[1];
1745

    
1746
            if (path.PointSet.Count > i) {
1747
                path.PointSet[i] = selected;
1748
            }
1749

    
1750
            this.UpdateControl();
1751
        }
1752

    
1753
        /// <summary>
1754
        /// return ArrowTextControl's area
1755
        /// </summary>
1756
        /// <author>humkyung</author>
1757
        /// <date>2019.06.13</date>
1758
        public override Rect ItemRect
1759
        {
1760
            get
1761
            {
1762
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
1763
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
1764
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
1765
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
1766

    
1767
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
1768
            }
1769
        }
1770

    
1771
        /// <summary>
1772
        /// Serialize this
1773
        /// </summary>
1774
        /// <param name="sUserId"></param>
1775
        /// <returns></returns>
1776
        public override string Serialize()
1777
        {
1778
            using (S_ArrowTextControl STemp = new S_ArrowTextControl())
1779
            {
1780
                STemp.TransformPoint = "0|0";
1781
                STemp.PointSet = this.PointSet;
1782
                STemp.SizeSet = String.Format("{0}", this.LineSize);
1783
                STemp.StrokeColor = this.StrokeColor.Color.ToString();
1784
                STemp.StartPoint = this.StartPoint;
1785
                STemp.ArrowStyle = this.ArrowTextStyle;
1786
                //STemp.StrokeColor = "#FF00FF00";
1787
                STemp.UserID = this.UserID;
1788
                STemp.ArrowText = this.Base_TextBox.Text;
1789
                STemp.BorderSize = this.BorderSize;
1790
                STemp.isHighLight = this.isHighLight;
1791
                STemp.BoxHeight = this.BoxHeight;
1792
                STemp.BoxWidth = this.BoxWidth;
1793
                STemp.Opac = this.Opacity;
1794
                STemp.EndPoint = this.EndPoint;
1795
                STemp.isFixed = this.isFixed;
1796
                //STemp.DashSize = this.DashSize;
1797
                STemp.Name = this.GetType().Name.ToString();
1798
                STemp.isTrans = this.isTrans;
1799
                STemp.MidPoint = this.MidPoint;
1800
                STemp.Angle = this.CommentAngle;
1801
                STemp.fontConfig = new List<string>()
1802
                            {
1803
                                this.TextFamily.ToString(),
1804
                                this.TextStyle.ToString(),
1805
                                this.TextWeight.ToString(),
1806
                                this.TextSize.ToString(),
1807
                            };
1808

    
1809
                if (this.UnderLine != null)
1810
                {
1811
                    STemp.fontConfig.Add("true");
1812
                }
1813

    
1814
                ///강인구 추가(2017.11.02)
1815
                ///Memo 추가
1816
                STemp.Memo = this.Memo;
1817
                STemp.BorderSize = this.BorderSize;
1818
                return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize()));
1819
            };
1820
        }
1821

    
1822
        /// <summary>
1823
        /// create a arrowtextcontrol from given string
1824
        /// </summary>
1825
        /// <param name="str"></param>
1826
        /// <returns></returns>
1827
        public static ArrowTextControl FromString(string str, SolidColorBrush brush, string sProjectNo)
1828
        {
1829
            ArrowTextControl instance = null;
1830
            using (S_ArrowTextControl s = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(str))
1831
            {
1832
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1833
                instance = new ArrowTextControl();
1834
                instance.LineSize = Convert.ToDouble(data2.First());
1835
                instance.PointSet = s.PointSet;
1836
                instance.StartPoint = s.StartPoint;
1837
                instance.EndPoint = s.EndPoint;
1838
                instance.StrokeColor = brush;
1839
                //instance.DashSize = s.DashSize;
1840
                instance.ArrowTextStyle = s.ArrowStyle;
1841
                instance.isHighLight = s.isHighLight;
1842
                instance.ArrowText = s.ArrowText;
1843
                instance.Opacity = s.Opac;
1844
                instance.BorderSize = s.BorderSize;
1845
                instance.BoxWidth = s.BoxWidth;
1846
                instance.BoxHeight = s.BoxHeight;
1847
                instance.isFixed = s.isFixed;
1848
                instance.CommentAngle = s.Angle;
1849
                instance.UserID = s.UserID;
1850
                instance.isTrans = s.isTrans;
1851
                instance.MidPoint = s.MidPoint;
1852
                instance.Memo = s.Memo;
1853
                if (s.fontConfig == null || s.fontConfig.ToList().Count == 0)
1854
                {
1855
                    s.fontConfig = new List<string>();
1856

    
1857
                    s.fontConfig.Add("Arial");
1858
                    s.fontConfig.Add("Normal");
1859
                    s.fontConfig.Add("Normal");
1860
                    s.fontConfig.Add("30");
1861
                }
1862
                instance.TextFamily = new FontFamily(s.fontConfig[0]);
1863
                //인구 추가(2018.04.17)
1864
                instance.TextStyle = StringToFont.ConFontStyle(s.fontConfig[1]);
1865
                instance.TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]);
1866
                instance.TextSize = Convert.ToDouble(s.fontConfig[3]);
1867

    
1868
                if (s.fontConfig.Count() == 5)
1869
                {
1870
                    instance.UnderLine = TextDecorations.Underline;
1871
                }
1872
            }
1873

    
1874
            return instance;
1875
        }
1876

    
1877
        #region Dispose
1878
        public void Dispose()
1879
        {
1880
            //GC.Collect();
1881
            //GC.SuppressFinalize(this);
1882
            this.BaseTextbox_Caret = null;
1883
            this.Base_ArrowPath = null;
1884
            this.Base_ArrowSubPath = null;
1885
            this.Base_TextBlock = null;
1886
            this.Base_TextBox = null;
1887
        } 
1888
        #endregion
1889

    
1890
        #region INotifyPropertyChanged
1891
        private void OnPropertyChanged(string name)
1892
        {
1893
            if (PropertyChanged != null)
1894
            {
1895
                PropertyChanged(this, new PropertyChangedEventArgs(name));
1896
            }
1897
        }
1898

    
1899
        public event PropertyChangedEventHandler PropertyChanged; 
1900
        #endregion
1901
    }
1902
}
클립보드 이미지 추가 (최대 크기: 500 MB)