프로젝트

일반

사용자정보

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

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

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

1 787a4489 KangIngu
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 036650a0 humkyung
using MarkupToPDF.Serialize.Core;
15
using MarkupToPDF.Serialize.S_Control;
16 24c5e56c taeseongkim
using Markus.Fonts;
17 787a4489 KangIngu
18
namespace MarkupToPDF.Controls.Text
19
{
20 3b938959 taeseongkim
    public class ArrowTextControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IPath, ITextControl, IMarkupControlData,ICommentRect
21 787a4489 KangIngu
    {
22
        private const string PART_ArrowPath = "PART_ArrowPath";
23
        private const string PART_TextBox = "PART_ArrowTextBox";
24
        //private const string PART_TextBlock = "PART_ArrowTextBlock";
25
        private const string PART_ArrowSubPath = "PART_ArrowSubPath";
26
        private const string PART_Border = "PART_Border";
27 3074202c 송근호
        private const string PART_BaseTextbox_Caret = "Caret";
28
29 787a4489 KangIngu
        public Path Base_ArrowPath = null;
30
        public Path Base_ArrowSubPath = null;
31
        public TextBox Base_TextBox = null;
32
        public TextBlock Base_TextBlock = null;
33 3074202c 송근호
        public Border BaseTextbox_Caret = null;
34 1b2cf911 taeseongkim
        public event EventHandler<EventArgs> EditEnded;
35
36 787a4489 KangIngu
37 53393bae KangIngu
        private const double _CloudArcDepth = 0.8;  /// 2018.05.14 added by humkyung
38
39 787a4489 KangIngu
        #region Object & Variable
40
        GeometryGroup instanceGroup = new GeometryGroup();
41
        
42
        Path Cemy = new Path();
43
        LineGeometry connectorSMGeometry = new LineGeometry();
44
        LineGeometry connectorMEGeometry = new LineGeometry();
45
46
        public enum ArrowTextStyleSet { Normal, Cloud, Rect };
47
48
        #endregion
49
50
        static ArrowTextControl()
51
        {
52
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ArrowTextControl), new FrameworkPropertyMetadata(typeof(ArrowTextControl)));
53 a6f7f9b6 djkim
            //ResourceDictionary dictionary = new ResourceDictionary();
54
            //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
55
            //if(!Application.Current.Resources.MergedDictionaries.Any(x=>x.Source == dictionary.Source))
56
            //    Application.Current.Resources.MergedDictionaries.Add(dictionary);
57 787a4489 KangIngu
        }
58
59 907a99b3 taeseongkim
        public ArrowTextControl() :base()
60 787a4489 KangIngu
        {
61 a6f7f9b6 djkim
            //this.DefaultStyleKey = typeof(ArrowTextControl);
62 787a4489 KangIngu
        }
63
64
        public override void OnApplyTemplate()
65
        {
66
            base.OnApplyTemplate();
67
            Base_ArrowPath = GetTemplateChild(PART_ArrowPath) as Path;
68
            Base_ArrowSubPath = GetTemplateChild(PART_ArrowSubPath) as Path;
69
            Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox;
70 3074202c 송근호
            BaseTextbox_Caret = GetTemplateChild(PART_BaseTextbox_Caret) as Border;
71 4fcb686a taeseongkim
            Base_TextBox.FontFamily = this.TextFamily;
72 907a99b3 taeseongkim
            if (Base_TextBox != null)
73
            {
74
                this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length;
75
                this.Base_TextBox.CaretBrush = new SolidColorBrush(Colors.Transparent);
76 4fcb686a taeseongkim
                
77
                if (this.ArrowTextStyle == ArrowTextStyleSet.Cloud)
78
                {
79
                    
80
                }
81
82 907a99b3 taeseongkim
                this.Base_TextBox.ApplyTemplate();
83
                this.Base_TextBox.Text = this.ArrowText;
84
85
                MoveCustomCaret();
86
87
                Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged);
88
                Base_TextBox.GotFocus += new RoutedEventHandler(Base_TextBox_GotFocus);
89
                Base_TextBox.LostFocus += new RoutedEventHandler(Base_TextBox_LostFocus);
90
                Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret();
91
                this.KeyDown += ArrowTextControl_KeyDown;
92
93
                SetArrowTextPath(true);
94
95
                Base_TextBox.IsTabStop = true;
96
            }
97 787a4489 KangIngu
        }
98
99 fa48eb85 taeseongkim
        private void ArrowTextControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
100
        {
101
           if(e.Key == System.Windows.Input.Key.Escape)
102
            {
103
                if(string.IsNullOrEmpty(Base_TextBox.Text))
104
                {
105
                    this.Visibility = Visibility.Collapsed;
106
                }
107
108
                EditEnd();
109
            }
110
        }
111
112 55d4f382 송근호
        public void SetFontFamily(FontFamily fontFamily)
113
        {
114 4fcb686a taeseongkim
            if (this.Base_TextBlock != null)
115
            {
116
                this.Base_TextBlock.FontFamily = fontFamily;
117
            }
118
119
            if (this.Base_TextBox != null)
120
            {
121
                this.Base_TextBox.FontFamily = fontFamily;
122
            }
123 55d4f382 송근호
            this.FontFamily = fontFamily;
124
            this.TextFamily = fontFamily;
125
        }
126
127 3074202c 송근호
        /// <summary>
128
        /// Moves the custom caret on the canvas.
129
        /// </summary>
130
        public void MoveCustomCaret()
131
        {
132 f011637d 송근호
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
133
134 fa48eb85 taeseongkim
            var angle = Math.Abs(this.PageAngle);
135
            //angle = 0;
136
            System.Diagnostics.Debug.WriteLine("Page Angle : " +  this.PageAngle);
137
138 f011637d 송근호
            if (!double.IsInfinity(caretLocation.X))
139
            {
140 fa48eb85 taeseongkim
                if (angle == 90)
141 f011637d 송근호
                {
142
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.Y);
143
                }
144 fa48eb85 taeseongkim
                else if (angle == 180)
145 f011637d 송근호
                {
146
                    
147
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X+ this.Base_TextBox.ActualWidth) - caretLocation.X) ;
148 fa48eb85 taeseongkim
                    System.Diagnostics.Debug.WriteLine("Caret X : " + ((this.EndPoint.X + this.Base_TextBox.ActualWidth) - caretLocation.X));
149
                } 
150
                else if (angle == 270)
151 f011637d 송근호
                {
152
                    Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X) - caretLocation.Y);
153
                }
154
                else
155
                {
156 fa48eb85 taeseongkim
                    System.Diagnostics.Debug.WriteLine("Caret X : " + (this.EndPoint.X - caretLocation.X));
157 f011637d 송근호
                    Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.X);
158 fa48eb85 taeseongkim
                } 
159 f011637d 송근호
            }
160
161
            if (!double.IsInfinity(caretLocation.Y))
162
            {
163 fa48eb85 taeseongkim
                if (angle == 90)
164 f011637d 송근호
                {
165
                    Canvas.SetTop(this.BaseTextbox_Caret, this.EndPoint.Y - caretLocation.X);
166
                }
167 fa48eb85 taeseongkim
                else if (angle == 180)
168 f011637d 송근호
                {//보정치40
169
                    Canvas.SetTop(this.BaseTextbox_Caret, ((this.EndPoint.Y -40) + this.Base_TextBox.ActualHeight)- caretLocation.Y );
170 fa48eb85 taeseongkim
                    System.Diagnostics.Debug.WriteLine("Caret Y : " + (((this.EndPoint.Y - 40) + this.Base_TextBox.ActualHeight) - caretLocation.Y));
171 f011637d 송근호
                }
172 fa48eb85 taeseongkim
                else if (angle == 270)
173 f011637d 송근호
                {
174
                    Canvas.SetTop(this.BaseTextbox_Caret, (this.EndPoint.Y) + caretLocation.X);
175
                }
176
                else
177
                {
178 fa48eb85 taeseongkim
                    Canvas.SetTop(this.BaseTextbox_Caret, this.EndPoint.Y  + caretLocation.Y);
179
                    System.Diagnostics.Debug.WriteLine("Caret Y : " + (this.EndPoint.Y + caretLocation.Y - BaseTextbox_Caret.ActualHeight));
180 f011637d 송근호
                }
181
            }
182
        }
183
184
        public void MoveCustomCaret(Point point)
185
        {
186 3074202c 송근호
187
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
188
189
            if (!double.IsInfinity(caretLocation.X))
190
            {
191 fa48eb85 taeseongkim
                if (Math.Abs(this.PageAngle) == 90)
192 f011637d 송근호
                {
193
                    Canvas.SetLeft(this.BaseTextbox_Caret, point.X + caretLocation.Y);
194
                }
195 fa48eb85 taeseongkim
                else if (Math.Abs(this.PageAngle) == 180)
196 f011637d 송근호
                {
197
198
                    Canvas.SetLeft(this.BaseTextbox_Caret, (point.X + this.Base_TextBox.ActualWidth) - caretLocation.X);
199
                }
200 fa48eb85 taeseongkim
                else if (Math.Abs(this.PageAngle) == 270)
201 f011637d 송근호
                {
202
                    Canvas.SetLeft(this.BaseTextbox_Caret, (point.X) - caretLocation.Y);
203
                }
204
                else
205
                {
206
                    Canvas.SetLeft(this.BaseTextbox_Caret, point.X + caretLocation.X);
207
                }
208 3074202c 송근호
            }
209
210
            if (!double.IsInfinity(caretLocation.Y))
211
            {
212 fa48eb85 taeseongkim
                if (Math.Abs(this.PageAngle) == 90)
213 f011637d 송근호
                {
214
                    Canvas.SetTop(this.BaseTextbox_Caret, point.Y - caretLocation.X);
215
                }
216 fa48eb85 taeseongkim
                else if (Math.Abs(this.PageAngle) == 180)
217 f011637d 송근호
                {
218
                    Canvas.SetTop(this.BaseTextbox_Caret, (point.Y + this.Base_TextBox.ActualHeight) - caretLocation.Y);
219
                }
220 fa48eb85 taeseongkim
                else if (Math.Abs(this.CommentAngle) == 270)
221 f011637d 송근호
                {
222
                    Canvas.SetTop(this.BaseTextbox_Caret, (point.Y) + caretLocation.X);
223
                }
224
                else
225
                {
226
                    Canvas.SetTop(this.BaseTextbox_Caret, point.Y + caretLocation.Y);
227
                }
228 3074202c 송근호
            }
229
        }
230
231
232 787a4489 KangIngu
        void Base_TextBox_LostFocus(object sender, RoutedEventArgs e)
233
        {
234 fa48eb85 taeseongkim
            EditEnd();
235
        }
236
237
        private void EditEnd()
238
        { 
239 787a4489 KangIngu
            this.ArrowText = Base_TextBox.Text;
240 fa48eb85 taeseongkim
            Base_TextBox.Focusable = false;
241 3074202c 송근호
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
242 787a4489 KangIngu
            this.IsEditingMode = false;
243
            ApplyOverViewData();
244 1b2cf911 taeseongkim
245
            if(EditEnded != null)
246
            {
247
                EditEnded(this, new EventArgs());
248
            }
249
250 787a4489 KangIngu
        }
251
252
        void Base_TextBox_GotFocus(object sender, RoutedEventArgs e)
253
        {
254 3074202c 송근호
            this.BaseTextbox_Caret.Visibility = Visibility.Visible;
255 fa48eb85 taeseongkim
            MoveCustomCaret();
256 1305c420 taeseongkim
            Base_TextBox.Focus();
257 787a4489 KangIngu
            this.IsEditingMode = true;
258
        }
259
260
        void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e)
261
        {
262 3c71b3a5 taeseongkim
            if(this.IsEditingMode)
263 b0fb3ad7 ljiyeon
            {
264 3c71b3a5 taeseongkim
                if (Base_TextBox.Text.Contains("|OR||DZ|"))
265
                {
266
                    Base_TextBox.Text = this.ArrowText;
267
                }
268
269
                this.ArrowText = Base_TextBox.Text;
270 8898253f djkim
                
271
            }
272
            BoxWidth = e.NewSize.Width;
273
            BoxHeight = e.NewSize.Height;
274
            SetArrowTextPath();
275 787a4489 KangIngu
        }
276
277
        #region Properties
278
        private bool _IsEditingMode;
279
        public bool IsEditingMode
280
        {
281
            get
282
            {
283
                return _IsEditingMode;
284
            }
285
            set
286
            {
287
                _IsEditingMode = value;
288
                OnPropertyChanged("IsEditingMode");
289
            }
290
        }
291
292
293
        #endregion
294
295
        #region dp Properties
296
        //강인구 주석 풀기
297
        public Visibility TextBoxVisibility
298
        {
299
            get { return (Visibility)GetValue(TextBoxVisibilityProperty); }
300
            set
301
            {
302
                if (this.TextBoxVisibility != value)
303
                {
304
                    SetValue(TextBoxVisibilityProperty, value);
305
                    OnPropertyChanged("TextBoxVisibility");
306
                }
307
            }
308
        }
309
310
        //강인구 주석 풀기
311
        public Visibility TextBlockVisibility
312
        {
313
            get { return (Visibility)GetValue(TextBlockVisibilityProperty); }
314
            set
315
            {
316
                if (this.TextBlockVisibility != value)
317
                {
318
                    SetValue(TextBlockVisibilityProperty, value);
319
                    OnPropertyChanged("TextBlockVisibility");
320
                }
321
            }
322
        }
323
324
325 4913851c humkyung
        public override SolidColorBrush StrokeColor
326 787a4489 KangIngu
        {
327
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
328
            set
329
            {
330
                if (this.StrokeColor != value)
331
                {
332
                    SetValue(StrokeColorProperty, value);
333
                }
334
            }
335
        }
336
337
        public PathGeometry SubPathData
338
        {
339
            get { return (PathGeometry)GetValue(SubPathDataProperty); }
340
            set
341
            {
342
                if (this.SubPathData != value)
343
                {
344
                    SetValue(SubPathDataProperty, value);
345
                }
346
            }
347
        }
348
349
        public string UserID
350
        {
351
            get { return (string)GetValue(UserIDProperty); }
352
            set
353
            {
354
                if (this.UserID != value)
355
                {
356
                    SetValue(UserIDProperty, value);
357
                    OnPropertyChanged("UserID");
358
                }
359
            }
360
        }
361
362
        public List<Point> PointSet
363
        {
364
            get { return (List<Point>)GetValue(PointSetProperty); }
365
            set { SetValue(PointSetProperty, value); }
366
        }
367
368 959b3ef2 humkyung
        public override bool IsSelected
369 787a4489 KangIngu
        {
370
            get
371
            {
372
                return (bool)GetValue(IsSelectedProperty);
373
            }
374
            set
375
            {
376
                SetValue(IsSelectedProperty, value);
377
                OnPropertyChanged("IsSelected");
378
            }
379
        }
380
381 5529d2a2 humkyung
        public override ControlType ControlType
382 787a4489 KangIngu
        {
383
            set
384
            {
385
                SetValue(ControlTypeProperty, value);
386
                OnPropertyChanged("ControlType");
387
            }
388
            get
389
            {
390
                return (ControlType)GetValue(ControlTypeProperty);
391
            }
392
        }
393
394
        public Point StartPoint
395
        {
396
            get { return (Point)GetValue(StartPointProperty); }
397
            set { SetValue(StartPointProperty, value); }
398
        }
399
400
        public Point EndPoint
401
        {
402
            get { return (Point)GetValue(EndPointProperty); }
403
            set { SetValue(EndPointProperty, value); }
404
        }
405
406
        public Point OverViewStartPoint
407
        {
408
            get { return (Point)GetValue(OverViewStartPointProperty); }
409
            set { SetValue(OverViewStartPointProperty, value); }
410
        }
411
412
        public Point OverViewEndPoint
413
        {
414
            get { return (Point)GetValue(OverViewEndPointProperty); }
415
            set { SetValue(OverViewEndPointProperty, value); }
416
        }
417
418
419 168f8027 taeseongkim
        //public double Angle
420
        //{
421
        //    get { return (double)GetValue(AngleProperty); }
422
        //    set { SetValue(AngleProperty, value); }
423
        //}
424 787a4489 KangIngu
425
        public Thickness BorderSize
426
        {
427
            get { return (Thickness)GetValue(BorderSizeProperty); }
428
            set
429
            {
430
                if (this.BorderSize != value)
431
                {
432
                    SetValue(BorderSizeProperty, value);
433
                }
434
            }
435
        }
436
437
438
        public Point MidPoint
439
        {
440
            get { return (Point)GetValue(MidPointProperty); }
441
            set { SetValue(MidPointProperty, value); }
442
        }
443
444
        public bool isFixed
445
        {
446
            get { return (bool)GetValue(IsFixedProperty); }
447
            set { SetValue(IsFixedProperty, value); }
448
        }
449
450
        public bool isTrans
451
        {
452
            get { return (bool)GetValue(TransformerProperty); }
453
            set { SetValue(TransformerProperty, value); }
454
        }
455
456
        public bool isHighLight
457
        {
458
            get { return (bool)GetValue(isHighlightProperty); }
459
            set
460
            {
461
                if (this.isHighLight != value)
462
                {
463
                    SetValue(isHighlightProperty, value);
464
                    OnPropertyChanged("isHighLight");
465
                }
466
            }
467
        }
468
469
        public FontWeight TextWeight
470
        {
471
            get { return (FontWeight)GetValue(TextWeightProperty); }
472
            set
473
            {
474
                if (this.TextWeight != value)
475
                {
476
                    SetValue(TextWeightProperty, value);
477
                    OnPropertyChanged("TextWeight");
478
                }
479
            }
480
        }
481
482
        public Double LineSize
483
        {
484
            get { return (Double)GetValue(LineSizeProperty); }
485
            set
486
            {
487
                if (this.LineSize != value)
488
                {
489
                    SetValue(LineSizeProperty, value);
490
                }
491
            }
492
        }
493
494
        public Double BoxWidth
495
        {
496
            get { return (Double)GetValue(BoxWidthProperty); }
497
            set
498
            {
499
                if (this.BoxWidth != value)
500
                {
501
                    SetValue(BoxWidthProperty, value);
502
                }
503
            }
504
        }
505
506
        public Double BoxHeight
507
        {
508
            get { return (Double)GetValue(BoxHeightProperty); }
509
            set
510
            {
511
                if (this.BoxHeight != value)
512
                {
513
                    SetValue(BoxHeightProperty, value);
514
                }
515
            }
516
        }
517
518
        public ArrowTextStyleSet ArrowTextStyle
519
        {
520
            get { return (ArrowTextStyleSet)GetValue(ArrowTextStyleProperty); }
521
            set
522
            {
523
                if (this.ArrowTextStyle != value)
524
                {
525
                    SetValue(ArrowTextStyleProperty, value);
526
                }
527
            }
528
        }
529
530
        public Geometry PathData
531
        {
532
            get { return (Geometry)GetValue(PathDataProperty); }
533
            set { SetValue(PathDataProperty, value);
534
535
                OnPropertyChanged("PathData");
536
            }
537
        }
538
539
        public SolidColorBrush BackInnerColor
540
        {
541
            get { return (SolidColorBrush)GetValue(BackInnerColorProperty); }
542
            set
543
            {
544
                if (this.BackInnerColor != value)
545
                {
546
                    SetValue(BackInnerColorProperty, value);
547
                    OnPropertyChanged("BackInnerColor");
548
                }
549
            }
550
        }
551
552
        public Geometry PathDataInner
553
        {
554
            get { return (Geometry)GetValue(PathDataInnerProperty); }
555
            set
556
            {
557
                SetValue(PathDataInnerProperty, value);
558
                OnPropertyChanged("PathDataInner");
559
            }
560
        }
561
562
        public Geometry OverViewPathData
563
        {
564
            get { return (Geometry)GetValue(OverViewPathDataProperty); }
565
            set { SetValue(OverViewPathDataProperty, value);
566
567
                OnPropertyChanged("OverViewPathData");
568
569
            }
570
        }
571
572
        public FontFamily TextFamily
573
        {
574
            get { return (FontFamily)GetValue(TextFamilyProperty); }
575
            set
576
            {
577
                if (this.TextFamily != value)
578
                {
579
                    SetValue(TextFamilyProperty, value);
580
                    OnPropertyChanged("TextFamily");
581
                }
582
            }
583
        }
584
585
        public string ArrowText
586
        {
587
            get { return (string)GetValue(ArrowTextProperty); }
588
            set
589
            {
590
                if (this.ArrowText != value)
591
                {
592
                    SetValue(ArrowTextProperty, value);
593
                    OnPropertyChanged("ArrowText");
594
                }
595
            }
596
        }
597
598
        public string OverViewArrowText
599
        {
600
601
            get { return (string)GetValue(OverViewArrowTextProperty);
602
            }
603
            set
604
            {
605
                if (this.OverViewArrowText != value)
606
                {
607
                    SetValue(OverViewArrowTextProperty, value);
608
                    OnPropertyChanged("OverViewArrowText");
609
                }
610
            }
611
        }
612
613
        public Double TextSize
614
        {
615
            get { return (Double)GetValue(TextSizeProperty); }
616
            set
617
            {
618
                if (this.TextSize != value)
619
                {
620
                    SetValue(TextSizeProperty, value);
621
                    OnPropertyChanged("TextSize");
622
                }
623
            }
624
        }
625
626
        public FontStyle TextStyle
627
        {
628
            get { return (FontStyle)GetValue(TextStyleProperty); }
629
            set
630
            {
631
                if (this.TextStyle != value)
632
                {
633
                    SetValue(TextStyleProperty, value);
634
                    OnPropertyChanged("TextStyle");
635
                }
636
            }
637
        }
638
639
        //강인구 추가
640
        public TextDecorationCollection UnderLine
641
        {
642
            get
643
            {
644
                return (TextDecorationCollection)GetValue(UnderLineProperty);
645
            }
646
            set
647
            {
648
                if (this.UnderLine != value)
649
                {
650
                    SetValue(UnderLineProperty, value);
651
                    OnPropertyChanged("UnderLine");
652
                }
653
            }
654
        }
655
656
        public double CanvasX
657
        {
658
            get { return (double)GetValue(CanvasXProperty); }
659
            set
660
            {
661
                if (this.CanvasX != value)
662
                {
663
                    SetValue(CanvasXProperty, value);
664
                    OnPropertyChanged("CanvasX");
665
                }
666
            }
667
        }
668
669
        public double CanvasY
670
        {
671
            get { return (double)GetValue(CanvasYProperty); }
672
            set
673
            {
674
                if (this.CanvasY != value)
675
                {
676
                    SetValue(CanvasYProperty, value);
677
                    OnPropertyChanged("CanvasY");
678
                }
679
            }
680
        } 
681
682
        public double CenterX
683
        {
684
            get { return (double)GetValue(CenterXProperty); }
685
            set { SetValue(CenterXProperty, value);
686
            OnPropertyChanged("CenterX");
687
            
688
            }
689
        }
690
691
        public double CenterY
692
        {
693
            get { return (double)GetValue(CenterYProperty); }
694
            set { SetValue(CenterYProperty, value);
695
            OnPropertyChanged("CenterY");
696
            }
697
        }
698
699
        public Brush SubPathFill
700
        {
701
            get { return (Brush)GetValue(SubPathFillProperty); }
702
            set
703
            {
704
                SetValue(SubPathFillProperty, value);
705
                OnPropertyChanged("SubPathFill");
706
            }
707
        }
708
709
        public Brush TextBoxBackground
710
        {
711
            get { return (Brush)GetValue(TextBoxBackgroundProperty); }
712
            set
713
            {
714
                SetValue(TextBoxBackgroundProperty, value);
715
                OnPropertyChanged("TextBoxBackground");
716
            }
717
        }
718
719
720
        //강인구 추가 주석풀기
721 71d7e0bf 송근호
       
722 787a4489 KangIngu
723
        public bool EnableEditing
724
        {
725
            get { return (bool)GetValue(EnableEditingProperty); }
726
            set
727
            {
728
                if (this.EnableEditing != value)
729
                {
730
                    SetValue(EnableEditingProperty, value);
731
                    OnPropertyChanged("EnableEditing");
732
                }
733
            }
734
        }
735
736
        #endregion
737
738
        #region Dependency Properties
739
740
        public static readonly DependencyProperty BoxWidthProperty = DependencyProperty.Register(
741
                "BoxWidth", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
742
743
        public static readonly DependencyProperty BoxHeightProperty = DependencyProperty.Register(
744
                "BoxHeight", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
745
746
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
747
                "UserID", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
748
749
        public static readonly DependencyProperty ArrowTextStyleProperty = DependencyProperty.Register(
750
               "ArrowTextStyle", typeof(ArrowTextStyleSet), typeof(ArrowTextControl), new PropertyMetadata(ArrowTextStyleSet.Normal));
751
752
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register(
753
                "CenterX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
754
755
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register(
756
                "CenterY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
757
758
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register(
759
                "Angle", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(PointValueChanged)));
760
        
761
        public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
762
                "CanvasX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
763
764
        public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
765
                "CanvasY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
766
767
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
768
                "PointSet", typeof(List<Point>), typeof(ArrowTextControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
769
770
        public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register(
771
                "TextFamily", typeof(FontFamily), typeof(ArrowTextControl), new PropertyMetadata(new FontFamily("Arial"), TextChanged));
772
773
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
774
                "PathData", typeof(Geometry), typeof(ArrowTextControl), null);
775
776
        //강인구 추가
777
        public static readonly DependencyProperty UnderLineProperty = DependencyProperty.Register(
778
    "UnderLine", typeof(TextDecorationCollection), typeof(ArrowTextControl), new PropertyMetadata(null, PointValueChanged));
779
780
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
781
               "LineSize", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)3, PointValueChanged));
782
783
        public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register(
784
                "TextStyle", typeof(FontStyle), typeof(ArrowTextControl), new PropertyMetadata(FontStyles.Normal));
785
786
        public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register(
787
                "TextSize", typeof(Double), typeof(ArrowTextControl), new PropertyMetadata((Double)30, PointValueChanged));
788
789
        public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register(
790
                "TextWeight", typeof(FontWeight), typeof(ArrowTextControl), new PropertyMetadata(FontWeights.Normal));
791
792
        public static readonly DependencyProperty IsFixedProperty = DependencyProperty.Register(
793
                "isFixed", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
794
795
        public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
796
                "IsSelected", typeof(bool), typeof(ArrowTextControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
797
798
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
799
                "StrokeColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
800
801
        public static readonly DependencyProperty ControlTypeProperty = DependencyProperty.Register(
802
                "ControlType", typeof(ControlType), typeof(ArrowTextControl), new FrameworkPropertyMetadata(ControlType.ArrowTextControl));
803
804
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
805
                "StartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
806
807
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
808
                "EndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
809
810
        public static readonly DependencyProperty BackInnerColorProperty = DependencyProperty.Register(
811
            "BackInnerColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.White)));
812
813
        public static readonly DependencyProperty PathDataInnerProperty = DependencyProperty.Register(
814
    "PathDataInner", typeof(Geometry), typeof(ArrowTextControl), null);
815
816
        public static readonly DependencyProperty isHighlightProperty = DependencyProperty.Register(
817
                "isHighlight", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
818
819
        public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register(
820
                "MidPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
821
822
        public static readonly DependencyProperty TransformerProperty = DependencyProperty.Register(
823
                "isTrans", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
824
825
        public static readonly DependencyProperty BorderSizeProperty = DependencyProperty.Register(
826 f8769f8a ljiyeon
                "BorderSize", typeof(Thickness), typeof(ArrowTextControl), new PropertyMetadata(new Thickness(0), PointValueChanged));
827 787a4489 KangIngu
    
828
        public static readonly DependencyProperty ArrowTextProperty = DependencyProperty.Register(
829
              "ArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
830
831
832
833
        //, new PropertyChangedCallback(TextChanged)
834
835
836
        #region 추가 사항
837
        public static readonly DependencyProperty SubPathDataProperty = DependencyProperty.Register(
838
                "SubPathData", typeof(Geometry), typeof(ArrowTextControl), null);
839
840
841
        public static readonly DependencyProperty SubPathFillProperty = DependencyProperty.Register(
842
                "SubPathFill", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(null));
843
844
        public static readonly DependencyProperty TextBoxBackgroundProperty = DependencyProperty.Register(
845
                "TextBoxBackground", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(Brushes.White));
846
847
        public static readonly DependencyProperty OverViewArrowTextProperty = DependencyProperty.Register(
848
                "OverViewArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null, new PropertyChangedCallback(TextChanged)));
849
850
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
851
                "OverViewPathData", typeof(Geometry), typeof(ArrowTextControl), null);
852
853
        public static readonly DependencyProperty OverViewStartPointProperty = DependencyProperty.Register(
854
                "OverViewStartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
855
856
        public static readonly DependencyProperty OverViewEndPointProperty = DependencyProperty.Register(
857
                "OverViewEndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
858
859
        public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register(
860
            "TextBoxVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged));
861
862
        //강인구 추가(주석풀기)
863
        public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register(
864
            "TextBlockVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged));
865
866
        public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register(
867 71d7e0bf 송근호
           "EnableEditing", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata((true), new PropertyChangedCallback(OnIsEditingChanged)));
868 787a4489 KangIngu
869
        #endregion
870
871
        #endregion
872
873
        #region CallBack Method
874
875
        //강인구 추가(주석풀기)
876
        public static void OnIsEditingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
877
        {
878
            var instance = (ArrowTextControl)sender;
879
880
            if (e.OldValue != e.NewValue && instance.Base_TextBlock != null)
881
            {
882
                instance.SetValue(e.Property, e.NewValue);
883
884
                if (instance.EnableEditing)
885
                {
886 71d7e0bf 송근호
                    instance.EditingMode();
887 787a4489 KangIngu
                }
888
                else
889
                {
890
                    instance.UnEditingMode();
891
                }
892
            }
893
        }
894
895
        public static void OnTextBoxVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
896
        {
897
            var instance = (ArrowTextControl)sender;
898
899
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
900
            {
901
                instance.SetValue(e.Property, e.NewValue);
902
            }
903
        }
904
905
        public static void OnTextBlockVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
906
        {
907
            var instance = (ArrowTextControl)sender;
908
909
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
910
            {
911
                instance.SetValue(e.Property, e.NewValue);
912
            }
913
        }
914
915
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
916
        {
917
            var instance = (ArrowTextControl)sender;
918
919
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
920
            {
921
                instance.SetArrowTextPath();
922
            }
923
        }
924
925
926
927
        public static void TextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
928
        {
929
            var instance = (ArrowTextControl)sender;
930
            
931
            if (e.OldValue != e.NewValue)
932
            {
933
                instance.SetValue(e.Property, e.NewValue);
934
                //instance.BoxWidth = instance.Base_TextBox.ActualWidth;
935
                //instance.BoxHeight = instance.Base_TextBox.ActualHeight;
936
            }
937
        }
938
939
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
940
        {
941
            var instance = (ArrowTextControl)sender;
942
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
943
            {
944
                instance.SetValue(e.Property, e.NewValue);
945
                instance.SetArrowTextPath();
946
            }
947
        }
948
949
        public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
950
        {
951
            var instance = (ArrowTextControl)sender;
952
953
            if (e.OldValue != e.NewValue && instance != null)
954
            {
955
                instance.SetValue(e.Property, e.NewValue);
956
                //Canvas.SetLeft(instance, instance.CanvasX);
957
                //Canvas.SetTop(instance, instance.CanvasY);
958
            }
959
        }
960
961
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
962
        {
963
            //var instance = (ArrowTextControl)sender;
964
965
            //if (e.OldValue != e.NewValue)
966
            //{
967
            //    instance.SetValue(e.Property, e.NewValue);
968
969
            //    if (instance.IsSelected && instance.Base_TextBox != null)
970
            //    {
971
            //        instance.BorderSize = new Thickness(1);
972
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Blue);
973
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Blue);
974
            //    }
975
            //    else
976
            //    {
977
            //        instance.BorderSize = new Thickness(0);
978
            //        //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Transparent);
979
            //        //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Transparent);
980
            //    }
981
            //}
982
        }
983
        #endregion
984
985
        #region Internal Method
986
987
        //강인구 주석 풀기
988
        public void EditingMode()
989
        {
990
            TextBoxVisibility = Visibility.Visible;
991
            TextBlockVisibility = Visibility.Collapsed;
992
993
994
            //강인구 언더라인 추가
995
            if (UnderLine != null)
996
                Base_TextBlock.TextDecorations = UnderLine;
997
        }
998
        //강인구 주석 풀기
999
        public void UnEditingMode()
1000
        {
1001
            TextBoxVisibility = Visibility.Collapsed;
1002
            TextBlockVisibility = Visibility.Visible;
1003
1004 38d69491 taeseongkim
            if (Base_TextBlock != null)
1005
            {
1006
                if (UnderLine != null)
1007
                    Base_TextBlock.TextDecorations = UnderLine;
1008 787a4489 KangIngu
1009 38d69491 taeseongkim
                Base_TextBlock.Margin =
1010
                     new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4,
1011
                         Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4);
1012
            }
1013
1014
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
1015 787a4489 KangIngu
        }
1016
1017 4f017ed3 taeseongkim
        private void SetArrowTextPath(bool IsInit = false)
1018 787a4489 KangIngu
        {
1019
            instanceGroup.Children.Clear();
1020
1021 fa48eb85 taeseongkim
            //VisualPageAngle = 0;
1022
1023
            if (Math.Abs(PageAngle).ToString() == "90")
1024
            {
1025
                VisualPageAngle = 270;
1026
            }
1027
            else if (Math.Abs(PageAngle).ToString() == "270")
1028
            {
1029
                VisualPageAngle = 90;
1030
            }
1031
            else
1032
            {
1033
                VisualPageAngle = PageAngle;
1034
            }
1035
1036 787a4489 KangIngu
            connectorSMGeometry.StartPoint = this.StartPoint;
1037
            connectorSMGeometry.EndPoint = this.MidPoint;
1038
            connectorMEGeometry.StartPoint = this.MidPoint; //핵심
1039 ca40e004 ljiyeon
1040 fa48eb85 taeseongkim
            /// 텍스트박스의 좌표 설정
1041 787a4489 KangIngu
            Canvas.SetLeft(Base_TextBox, this.EndPoint.X);
1042
            Canvas.SetTop(Base_TextBox, this.EndPoint.Y);
1043 15bbef90 taeseongkim
            //System.Diagnostics.Debug.WriteLine($"TextBox Set {this.EndPoint.X},{this.EndPoint.Y}");
1044 fa48eb85 taeseongkim
            
1045
1046 787a4489 KangIngu
            List<Point> ps = new List<Point>();
1047
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox))); //상단
1048
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox) + this.BoxHeight)); // 하단
1049
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2)); //좌단
1050
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2));  //우단
1051
1052
            if (isTrans)
1053
            {
1054 fa48eb85 taeseongkim
                switch (Math.Abs(this.PageAngle).ToString())
1055 787a4489 KangIngu
                {
1056
                    case "90":
1057
                        {
1058
                            ps.Clear();
1059
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1060
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1061
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1062
1063
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1064
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1065
1066
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); //중간 하단
1067
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 하단
1068
1069
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간
1070
                        }
1071
                        break;
1072
                    case "270":
1073
                        {
1074
                            ps.Clear();
1075
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1076
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1077
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1078
1079
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1080
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1081
1082
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); //중간 하단
1083
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 하단
1084
1085
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간
1086
                        }
1087
                        break;
1088
                    default:
1089
                        break;
1090
                }
1091 ca40e004 ljiyeon
                
1092 787a4489 KangIngu
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1093
1094 ca40e004 ljiyeon
                //20180911 LJY 꺾이는 부분 수정
1095 6c122a60 ljiyeon
                Point testP = endP;                
1096 fa48eb85 taeseongkim
                switch (Math.Abs(this.PageAngle).ToString())
1097 ca40e004 ljiyeon
                {
1098 6c122a60 ljiyeon
                    case "90":
1099
                        testP = new Point(endP.X + 50, endP.Y);
1100
                        break;
1101
                    case "270":
1102
                        testP = new Point(endP.X - 50, endP.Y);
1103
                        break;
1104
                }                
1105 ca40e004 ljiyeon
1106
                //20180910 LJY 각도에 따라.
1107 fa48eb85 taeseongkim
                switch (Math.Abs(this.PageAngle).ToString())
1108 ca40e004 ljiyeon
                {
1109
                    case "90":
1110
                        if (isFixed)
1111
                        {
1112
                            if (ps[0] == endP) //상단
1113
                            {
1114
                                testP = new Point(endP.X , endP.Y + 50);
1115
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1116
                            }
1117
                            else if (ps[1] == endP) //하단
1118
                            {
1119
                                testP = new Point(endP.X , endP.Y - 50);
1120
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1121
                            }
1122
                            else if (ps[2] == endP) //좌단
1123
                            {
1124
                                testP = new Point(endP.X - 50, endP.Y);
1125
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1126
                            }
1127
                            else if (ps[3] == endP) //우단
1128
                            {
1129
                                testP = new Point(endP.X + 50, endP.Y);
1130
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1131
                            }
1132
                        }
1133
                        break;
1134
                    case "270":
1135
                        if (isFixed)
1136
                        {
1137
                            if (ps[0] == endP) //상단
1138
                            {
1139
                                testP = new Point(endP.X , endP.Y - 50);
1140
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1141
                            }
1142
                            else if (ps[1] == endP) //하단
1143
                            {
1144
                                testP = new Point(endP.X, endP.Y + 50);
1145
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1146
                            }
1147
                            else if (ps[2] == endP) //좌단
1148
                            {
1149
                                testP = new Point(endP.X + 50, endP.Y);
1150
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1151
                            }
1152
                            else if (ps[3] == endP) //우단
1153
                            {
1154
                                testP = new Point(endP.X - 50, endP.Y);
1155
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1156
                            }
1157
                        }
1158
                        break;
1159
                    default:
1160
                        if (isFixed)
1161
                        {
1162
                            if (ps[0] == endP) //상단
1163
                            {
1164
                                testP = new Point(endP.X, endP.Y - 50);
1165
                                //System.Diagnostics.Debug.WriteLine("상단");
1166
                            }
1167
                            else if (ps[1] == endP) //하단
1168
                            {
1169
                                testP = new Point(endP.X, endP.Y + 50);
1170
                                //System.Diagnostics.Debug.WriteLine("하단");
1171
                            }
1172
                            else if (ps[2] == endP) //좌단
1173
                            {
1174
                                testP = new Point(endP.X - 50, endP.Y);
1175
                                //System.Diagnostics.Debug.WriteLine("좌단");
1176
                            }
1177
                            else if (ps[3] == endP) //우단
1178
                            {
1179
                                testP = new Point(endP.X + 50, endP.Y);
1180
                                //System.Diagnostics.Debug.WriteLine("우단");
1181
                            }
1182
                        }
1183
                        break;
1184
                }
1185 f9d42594 djkim
                connectorMEGeometry.EndPoint = endP;
1186 ca40e004 ljiyeon
                connectorSMGeometry.EndPoint = testP;
1187
                connectorMEGeometry.StartPoint = testP;
1188 f9d42594 djkim
                
1189 ca40e004 ljiyeon
                //20180910 LJY 각도에 따라.
1190 f9d42594 djkim
                this.MidPoint = testP;
1191 d251456f humkyung
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1192 2b69c140 humkyung
                instanceGroup.FillRule = FillRule.Nonzero;
1193
                this.Base_ArrowPath.Fill = this.StrokeColor;
1194
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1195 787a4489 KangIngu
            }
1196
            else
1197
            {
1198 fa48eb85 taeseongkim
                switch (Math.Abs(this.PageAngle).ToString())
1199 787a4489 KangIngu
                {
1200
                    case "90":
1201
                        {
1202
                            ps.Clear();
1203 ca40e004 ljiyeon
1204 787a4489 KangIngu
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1205
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
1206
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
1207
1208
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1209
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1210
1211
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); //중간 하단
1212
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 하단
1213 ca40e004 ljiyeon
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간 
1214 787a4489 KangIngu
                        }
1215
                        break;
1216
                    case "270":
1217
                        {
1218
                            ps.Clear();
1219 ca40e004 ljiyeon
                            
1220 787a4489 KangIngu
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1221
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1222
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1223
1224
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1225
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1226
1227
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); //중간 하단
1228
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 하단
1229
1230 ca40e004 ljiyeon
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1231 787a4489 KangIngu
                        }
1232
                        break;
1233 fa48eb85 taeseongkim
                    //case "180":
1234
                    //    {
1235
                    //        ps.Clear();
1236
1237
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
1238
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
1239
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1240
1241
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간
1242
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단
1243
1244
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); //중간 하단
1245
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 하단
1246
1247
                    //        ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 
1248
                    //    }
1249
                    //    break;
1250 787a4489 KangIngu
                    default:
1251
                        break;
1252
                }
1253
1254
1255
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1256
                connectorMEGeometry.EndPoint = endP; //최상단
1257 ca40e004 ljiyeon
                                                     //connectorMEGeometry.EndPoint = this.EndPoint; //핵심
1258
                                                     //this.MidPoint= MathSet.getMiddlePoint(this.StartPoint, endP);
1259 787a4489 KangIngu
                #region 보정치
1260 ca40e004 ljiyeon
                Point testP = endP;
1261
1262
                //20180910 LJY 각도에 따라.
1263 fa48eb85 taeseongkim
                switch (Math.Abs(this.PageAngle).ToString())
1264 ca40e004 ljiyeon
                {
1265
                    case "90":
1266
                        if (isFixed)
1267
                        {
1268
                            if (ps[0] == endP) //상단
1269
                            {
1270
                                testP = new Point(endP.X - 50, endP.Y);
1271
                                //System.Diagnostics.Debug.WriteLine("상단"+ testP);
1272
                            }
1273
                            else if (ps[1] == endP) //하단
1274
                            {
1275
                                testP = new Point(endP.X + 50, endP.Y);
1276
                                //System.Diagnostics.Debug.WriteLine("하단"+ testP);
1277
                            }
1278
                            else if (ps[2] == endP) //좌단
1279
                            {
1280
                                testP = new Point(endP.X - 50, endP.Y);
1281
                                //System.Diagnostics.Debug.WriteLine("좌단"+ testP);
1282
                            }
1283
                            else if (ps[3] == endP) //우단
1284
                            {
1285
                                testP = new Point(endP.X + 50 , endP.Y);
1286
                                //System.Diagnostics.Debug.WriteLine("우단"+ testP);
1287
                            }
1288
                        }
1289
                        break;
1290
                    case "270":
1291
                        if (isFixed)
1292
                        {
1293
                            if (ps[0] == endP) //상단
1294
                            {
1295
                                testP = new Point(endP.X + 50, endP.Y);
1296
                                //System.Diagnostics.Debug.WriteLine("상단" + testP);
1297
                            }
1298
                            else if (ps[1] == endP) //하단
1299
                            {
1300
                                testP = new Point(endP.X - 50, endP.Y);
1301
                                //System.Diagnostics.Debug.WriteLine("하단" + testP);
1302
                            }
1303
                            else if (ps[2] == endP) //좌단
1304
                            {
1305
                                testP = new Point(endP.X + 50, endP.Y);
1306
                                //System.Diagnostics.Debug.WriteLine("좌단" + testP);
1307
                            }
1308
                            else if (ps[3] == endP) //우단
1309
                            {
1310
                                testP = new Point(endP.X + 50, endP.Y );
1311
                                //System.Diagnostics.Debug.WriteLine("우단" + testP);
1312
                            }
1313
                        }
1314
                        break;
1315
                    default:
1316
                        if (isFixed)
1317
                        {
1318
                            if (ps[0] == endP) //상단
1319
                            {
1320
                                testP = new Point(endP.X, endP.Y - 50);
1321
                                //System.Diagnostics.Debug.WriteLine("상단");
1322
                            }
1323
                            else if (ps[1] == endP) //하단
1324
                            {
1325
                                testP = new Point(endP.X, endP.Y + 50);
1326
                                //System.Diagnostics.Debug.WriteLine("하단");
1327
                            }
1328
                            else if (ps[2] == endP) //좌단
1329
                            {
1330
                                testP = new Point(endP.X - 50, endP.Y);
1331
                                //System.Diagnostics.Debug.WriteLine("좌단");
1332
                            }
1333
                            else if (ps[3] == endP) //우단
1334
                            {
1335
                                testP = new Point(endP.X + 50, endP.Y);
1336
                                //System.Diagnostics.Debug.WriteLine("우단");
1337
                            }
1338
                        }
1339
                        break;
1340
                }
1341
                  
1342
1343 787a4489 KangIngu
                connectorSMGeometry.EndPoint = testP;
1344
                connectorMEGeometry.StartPoint = testP;
1345 d251456f humkyung
                instanceGroup.Children.Add(DrawSet.DrawArrow(testP, this.StartPoint, this.LineSize));
1346 2b69c140 humkyung
                instanceGroup.FillRule = FillRule.Nonzero;
1347
                this.Base_ArrowPath.Fill = this.StrokeColor;
1348
                this.Base_ArrowSubPath.Fill = this.StrokeColor;
1349 787a4489 KangIngu
                #endregion
1350
            }
1351
1352
            switch (this.ArrowTextStyle)
1353
            {
1354
                case ArrowTextStyleSet.Normal:
1355
                    this.BorderSize = new Thickness(0);
1356 05009a0e ljiyeon
                    DrawingRect();
1357 787a4489 KangIngu
                    break;
1358
                case ArrowTextStyleSet.Cloud:
1359
                    this.BorderSize = new Thickness(0);
1360
                    DrawingCloud();
1361
                    break;
1362
                default:
1363
                    {
1364 4fcb686a taeseongkim
                        this.BorderSize = new Thickness(LineSize);
1365 787a4489 KangIngu
                        DrawingRect();
1366
                    }
1367
1368
                    break;
1369
            }
1370
1371
            if (isHighLight)
1372
            {
1373
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1374
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1375
1376
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1377
            }
1378
            else
1379
            {
1380
                BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1381
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1382
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1), Colors.White.R, Colors.White.G, Colors.White.B));
1383
            }
1384
1385
            instanceGroup.Children.Add(connectorSMGeometry);
1386
            instanceGroup.Children.Add(connectorMEGeometry);
1387
1388
            this.PathData = instanceGroup;
1389
            OverViewPathData = PathData;
1390
            OverViewArrowText = ArrowText;
1391
            OverViewEndPoint = connectorMEGeometry.EndPoint;
1392
            OverViewStartPoint = connectorSMGeometry.StartPoint;
1393
1394 4f017ed3 taeseongkim
            var tempAngle = Math.Abs(this.VisualPageAngle);
1395 787a4489 KangIngu
1396
            if (tempAngle == Convert.ToDouble(90) || tempAngle == Convert.ToDouble(270))
1397
            {
1398
                this.RenderTransformOrigin = new Point(0.5, 0.5);
1399
                this.Base_ArrowPath.RenderTransformOrigin = new Point(0, 0);
1400
                this.Base_ArrowSubPath.RenderTransformOrigin = new Point(0, 0);
1401
1402
                Base_TextBox.RenderTransformOrigin = new Point(0, 0);
1403 f011637d 송근호
                BaseTextbox_Caret.RenderTransformOrigin = new Point(0, 0);
1404 787a4489 KangIngu
            }
1405
1406 fa48eb85 taeseongkim
            Base_TextBox.RenderTransform = new RotateTransform
1407
            {
1408
                Angle = this.VisualPageAngle,
1409
                CenterX = this.CenterX,
1410
                CenterY = this.CenterY,
1411
            };
1412
1413 787a4489 KangIngu
            Base_ArrowSubPath.RenderTransform = new RotateTransform
1414
            {
1415 fa48eb85 taeseongkim
                Angle = this.VisualPageAngle,
1416 787a4489 KangIngu
                CenterX = this.EndPoint.X,
1417
                CenterY = this.EndPoint.Y,
1418
            };
1419 fa48eb85 taeseongkim
1420
            if (BaseTextbox_Caret.Visibility == Visibility.Visible)
1421
            {
1422
                BaseTextbox_Caret.RenderTransform = new RotateTransform
1423
                {
1424
                    Angle = this.VisualPageAngle,
1425
                    CenterX = this.CenterX,
1426
                    CenterY = this.CenterY,
1427
                };
1428
1429
                MoveCustomCaret();
1430
            }
1431 787a4489 KangIngu
        }
1432
1433
        private void DrawingCloud()
1434
        {
1435 ca40e004 ljiyeon
            //20180906 LJY Textbox guide
1436 fa48eb85 taeseongkim
            string angle = Math.Abs(this.PageAngle).ToString();
1437 ca40e004 ljiyeon
            if (angle == "180")
1438 787a4489 KangIngu
            {
1439 ca40e004 ljiyeon
                List<Point> pCloud = new List<Point>()
1440
                {
1441
                     new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1442
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxHeight), //왼쪽 아래
1443
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox) - BoxHeight),
1444
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox)),
1445
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1446
                };
1447
                SubPathData = (Generate(pCloud));
1448
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1449
            
1450
            }//20180906 LJY Textbox guide
1451
            else
1452 4fcb686a taeseongkim
            {
1453
                var boxWidth = BoxWidth;
1454
                System.Diagnostics.Debug.WriteLine("disp Width : " + BoxWidth);
1455
                //boxWidth = boxWidth + Base_TextBox.Margin.Left + Base_TextBox.Margin.Right + Base_TextBox.Padding.Left + Base_TextBox.Padding.Right;
1456
1457 ca40e004 ljiyeon
                List<Point> pCloud = new List<Point>()
1458
                {
1459
    #if SILVERLIGHT
1460
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1461
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1462
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1463
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1464
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1465
1466
    #else
1467
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1468
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1469 4fcb686a taeseongkim
                    new Point(Canvas.GetLeft(Base_TextBox)+ boxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1470
                    new Point(Canvas.GetLeft(Base_TextBox) + boxWidth, Canvas.GetTop(Base_TextBox)),
1471 ca40e004 ljiyeon
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1472
1473
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1474
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1475
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1476
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1477
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1478
    #endif
1479
                };
1480
                //instanceGroup.Children.Add(Generate(pCloud));
1481
                SubPathData = (Generate(pCloud));
1482
                PathDataInner = (GenerateInnerCloud(pCloud, angle));
1483
                //   }
1484
            }
1485
1486 787a4489 KangIngu
        }
1487
1488
        private void DrawingRect()
1489
        {
1490 ca40e004 ljiyeon
            //20180906 LJY Textbox guide
1491 05009a0e ljiyeon
            if(this.ArrowTextStyle == ArrowTextStyleSet.Normal)
1492
            {
1493
                this.Base_TextBox.BorderBrush = Brushes.Transparent;
1494
            }
1495 43e1d368 taeseongkim
            
1496 fa48eb85 taeseongkim
            if (Math.Abs(this.PageAngle).ToString() == "90")
1497 787a4489 KangIngu
            {
1498 ca40e004 ljiyeon
                List<Point> pCloud = new List<Point>()
1499
                {
1500
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1501
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxWidth), //왼쪽 아래
1502
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox) - BoxWidth),
1503
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox)),
1504
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1505
                };
1506
                PathDataInner = (GenerateInner(pCloud));
1507
            }
1508 fa48eb85 taeseongkim
            else if(Math.Abs(this.PageAngle).ToString() == "270")
1509 ca40e004 ljiyeon
            {
1510
                List<Point> pCloud = new List<Point>()
1511
                {
1512
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1513
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + BoxWidth), //왼쪽 아래
1514
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox) + BoxWidth),
1515
                    new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox)),
1516
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1517
                };
1518
                PathDataInner = (GenerateInner(pCloud));
1519
            }//20180906 LJY Textbox guide
1520
            else
1521
            { 
1522
                List<Point> pCloud = new List<Point>()
1523
                {
1524
    #if SILVERLIGHT
1525
		            new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1526
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1527
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1528
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1529
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1530
1531
    #else
1532
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1533
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1534
                    new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1535
                    new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1536
                    new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1537
1538
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1539
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1540
                    //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1541
                    //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1542
                    //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1543
    #endif
1544
                };
1545
                //instanceGroup.Children.Add(Generate(pCloud));
1546
                PathDataInner = (GenerateInner(pCloud));
1547
            }
1548 787a4489 KangIngu
        }
1549
1550 0d00f9c8 humkyung
        public override void UpdateControl()
1551 787a4489 KangIngu
        {
1552
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
1553
            this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
1554
            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
1555
        }
1556
1557 f513c215 humkyung
        public override void ApplyOverViewData()
1558 787a4489 KangIngu
        {
1559
            this.OverViewPathData = this.PathData;
1560
            if (ArrowText == "")
1561 1b2cf911 taeseongkim
            {
1562
                this.OverViewArrowText = "";
1563 787a4489 KangIngu
                this.ArrowText = this.OverViewArrowText;
1564 1b2cf911 taeseongkim
            }
1565 787a4489 KangIngu
            else
1566
                this.OverViewArrowText = this.ArrowText;
1567
            this.OverViewStartPoint = this.StartPoint;
1568
            this.OverViewEndPoint = this.EndPoint;
1569
        }
1570
1571
        #endregion
1572
1573
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
1574
        {
1575
            PathFigure pathFigure = new PathFigure();
1576
            pathFigure.StartPoint = p1;
1577
1578
            double arcLength = arcLength_;
1579
            /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung 
1580
            double dx = p2.X - p1.X;
1581
            double dy = p2.Y - p1.Y;
1582
            double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2
1583
            double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
1584
            Point lastPt = new Point(p1.X, p1.Y);
1585
            double count = l / arcLength;
1586
            /// normalize
1587
            dx /= l;
1588
            dy /= l;
1589
            Double j = 1;
1590 ca40e004 ljiyeon
            for (j = 1; j < (count - 1); j++) 
1591 787a4489 KangIngu
            {
1592
                ArcSegment arcSeg = new ArcSegment();
1593 53393bae KangIngu
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);						/// x size and y size of arc
1594 787a4489 KangIngu
                arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);	/// end point of arc
1595
                lastPt = arcSeg.Point;  /// save last point
1596
                arcSeg.RotationAngle = theta + 90;
1597
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1598
                pathFigure.Segments.Add(arcSeg);
1599
            }
1600
1601
            /// draw arc between last point and end point
1602
            if ((count > j) || (count > 0))
1603
            {
1604
                arcLength = MathSet.DistanceTo(lastPt, p2);
1605
                ArcSegment arcSeg = new ArcSegment();
1606 53393bae KangIngu
                arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth);	/// x size and y size of arc
1607 787a4489 KangIngu
                arcSeg.Point = new Point(p2.X, p2.Y);						/// end point of arc
1608
                arcSeg.RotationAngle = theta;
1609
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1610
                pathFigure.Segments.Add(arcSeg);
1611
            }
1612
            /// up to here
1613
1614
            return pathFigure;
1615
        }
1616
1617
        public static PathGeometry Generate(List<Point> pData)
1618
        {
1619
            var _pathGeometry = new PathGeometry();
1620 ca40e004 ljiyeon
            
1621 787a4489 KangIngu
            double area = MathSet.AreaOf(pData);
1622
            bool reverse = (area > 0);
1623
            int count = pData.Count;
1624
            for (int i = 0; i < (count - 1); i++)
1625
            {
1626 43e1d368 taeseongkim
                PathFigure pathFigure = Polygon.CloudControl.GenerateLineWithCloud(pData[i], pData[i + 1], 20, reverse);
1627 787a4489 KangIngu
                pathFigure.IsClosed = false;
1628 43e1d368 taeseongkim
                pathFigure.IsFilled = false;
1629 787a4489 KangIngu
                _pathGeometry.Figures.Add(pathFigure);
1630
            }
1631 ca40e004 ljiyeon
            
1632 787a4489 KangIngu
            return _pathGeometry;
1633
        }
1634 ca40e004 ljiyeon
1635
        
1636 787a4489 KangIngu
        public static PathGeometry GenerateInner(List<Point> pData)
1637
        {
1638
            var _pathGeometry = new PathGeometry();
1639
            double area = MathSet.AreaOf(pData);
1640
            bool reverse = (area > 0);
1641
            int count = pData.Count;
1642
1643
            PathFigure pathFigur2 = new PathFigure();
1644
            pathFigur2.StartPoint = pData[0];
1645
1646
            LineSegment lineSegment0 = new LineSegment();
1647
            lineSegment0.Point = pData[0];
1648
            pathFigur2.Segments.Add(lineSegment0);
1649
1650
            LineSegment lineSegment1 = new LineSegment();
1651
            lineSegment1.Point = pData[1];
1652
            pathFigur2.Segments.Add(lineSegment1);
1653
1654
            LineSegment lineSegment2 = new LineSegment();
1655
            lineSegment2.Point = pData[2];
1656
            pathFigur2.Segments.Add(lineSegment2);
1657
1658
            LineSegment lineSegment3 = new LineSegment();
1659
            lineSegment3.Point = pData[3];
1660
            pathFigur2.Segments.Add(lineSegment3);
1661
1662
1663
            pathFigur2.IsClosed = true;
1664
            pathFigur2.IsFilled = true;
1665 ca40e004 ljiyeon
            _pathGeometry.Figures.Add(pathFigur2);           
1666 787a4489 KangIngu
1667
            return _pathGeometry;
1668
        }
1669
1670 ca40e004 ljiyeon
        //20180910 LJY Cloud rotation 추가
1671
        public static PathGeometry GenerateInnerCloud(List<Point> pData, string angle)
1672
        {
1673
            var _pathGeometry = new PathGeometry();
1674
            double area = MathSet.AreaOf(pData);
1675
            bool reverse = (area > 0);
1676
            int count = pData.Count;
1677
1678
            PathFigure pathFigur2 = new PathFigure();
1679
            pathFigur2.StartPoint = pData[0];
1680
1681
            LineSegment lineSegment0 = new LineSegment();
1682
            lineSegment0.Point = pData[0];
1683
            pathFigur2.Segments.Add(lineSegment0);
1684
1685
            LineSegment lineSegment1 = new LineSegment();
1686
            lineSegment1.Point = pData[1];
1687
            pathFigur2.Segments.Add(lineSegment1);
1688
1689
            LineSegment lineSegment2 = new LineSegment();
1690
            lineSegment2.Point = pData[2];
1691
            pathFigur2.Segments.Add(lineSegment2);
1692
1693
            LineSegment lineSegment3 = new LineSegment();
1694
            lineSegment3.Point = pData[3];
1695
            pathFigur2.Segments.Add(lineSegment3);
1696
            
1697
            RotateTransform transform = new RotateTransform();
1698
            switch (angle)
1699
            {
1700
                case "90":
1701
                    transform.Angle = -90;
1702
                    break;
1703
                case "180":
1704
                    transform.Angle = -180;
1705
                    break;
1706
                case "270":
1707
                    transform.Angle = -270;
1708
                    break;
1709
            }
1710
            transform.CenterX = pData[0].X;
1711
            transform.CenterY = pData[0].Y;
1712
            _pathGeometry.Transform = transform;
1713
1714
            pathFigur2.IsClosed = true;
1715
            pathFigur2.IsFilled = true;
1716
            _pathGeometry.Figures.Add(pathFigur2);
1717
1718
            return _pathGeometry;
1719 91efe37a humkyung
        }
1720
1721
        /// <summary>
1722 a6272c57 humkyung
        /// call when mouse is moving while drawing control
1723
        /// </summary>
1724
        /// <author>humkyung</author>
1725
        /// <param name="pt"></param>
1726
        /// <param name="bAxisLocked"></param>
1727 233ef333 taeseongkim
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
1728 a6272c57 humkyung
        {
1729
            this.EndPoint = pt;
1730
1731 168f8027 taeseongkim
            Point tempPoint = this.EndPoint;
1732 233ef333 taeseongkim
            CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1733 168f8027 taeseongkim
1734 233ef333 taeseongkim
            if (bAxisLocked)
1735 a6272c57 humkyung
            {
1736
                this.EndPoint = tempPoint;
1737
            }
1738
1739
            this.MidPoint = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint);
1740
            this.isFixed = (this.ControlType == ControlType.ArrowTransTextControl) || 
1741
                (this.ControlType == ControlType.ArrowTransTextBorderControl) || (this.ControlType == ControlType.ArrowTransTextCloudControl);
1742
1743
            this.PointSet = new List<Point>
1744
            {
1745
                this.StartPoint,
1746
                this.MidPoint,
1747
                this.EndPoint,
1748
            };
1749
        }
1750
1751
        /// <summary>
1752 d2114d3b humkyung
        /// move control point has same location of given pt along given delta
1753
        /// </summary>
1754
        /// <author>humkyung</author>
1755
        /// <date>2019.06.20</date>
1756
        /// <param name="pt"></param>
1757
        /// <param name="dx"></param>
1758
        /// <param name="dy"></param>
1759 233ef333 taeseongkim
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
1760 d2114d3b humkyung
        {
1761
            IPath path = (this as IPath);
1762
1763
            Point selected = MathSet.getNearPoint(path.PointSet, pt);
1764 7575b5e5 송근호
1765 50e6a733 송근호
            //StartPoint에 표시된 Thumb는 dx,dy가 +로 더해줘야한다.
1766
            if (path.PointSet.IndexOf(selected) != 0)
1767 7575b5e5 송근호
            {
1768 fa48eb85 taeseongkim
                double radian = this.CommentAngle * Math.PI / 180;
1769 fb1e3af2 djkim
                double cos = Math.Cos(radian);
1770
                double sin = Math.Sin(radian);
1771 ac8521e2 송근호
1772 fb1e3af2 djkim
                double _dx = dx * cos - dy * sin;
1773
                double _dy = dx * sin + dy * cos;
1774
1775 39f208de taeseongkim
                //var transform = new RotateTransform() { Angle = CommentAngle, CenterX = dx, CenterY = dy };
1776
                //var transformedPoint = transform.Transform(pt);
1777
                //selected = transformedPoint;
1778
1779 fb1e3af2 djkim
                selected.X += _dx;
1780
                selected.Y += _dy;
1781 7575b5e5 송근호
            }
1782
            else
1783
            {
1784
                selected.X += dx;
1785
                selected.Y += dy;
1786
            }
1787
1788 39f208de taeseongkim
    int i = 0;
1789 d2114d3b humkyung
            for (i = 0; i < (this as IPath).PointSet.Count; i++)
1790
            {
1791
                if (pt.Equals((this as IPath).PointSet[i])) break;
1792
            }
1793
1794
            List<Point> pts = path.PointSet;
1795
            if ((pts[0].X > pts[1].X && dx > 0) || (pts[0].X < pts[1].X && dx < 0))
1796
            {
1797
                pts[1] = new Point(pts[1].X + dx, pts[1].Y);
1798
            }
1799
            if ((pts[0].Y > pts[1].Y && dy > 0) || (pts[0].Y < pts[1].Y && dy < 0))
1800
            {
1801
                pts[1] = new Point(pts[1].X, pts[1].Y + dy);
1802
            }
1803 50e6a733 송근호
1804 d2114d3b humkyung
            path.PointSet[1] = pts[1];
1805 7575b5e5 송근호
1806
            if (path.PointSet.Count > i) {
1807
                path.PointSet[i] = selected;
1808
            }
1809 15bbef90 taeseongkim
            //System.Diagnostics.Debug.WriteLine($"OnMoveCtrlPoint end : {path.PointSet[1].X},{path.PointSet[1].Y}");
1810 0d00f9c8 humkyung
            this.UpdateControl();
1811 d2114d3b humkyung
        }
1812
1813
        /// <summary>
1814 91efe37a humkyung
        /// return ArrowTextControl's area
1815
        /// </summary>
1816
        /// <author>humkyung</author>
1817
        /// <date>2019.06.13</date>
1818
        public override Rect ItemRect
1819
        {
1820
            get
1821
            {
1822
                double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X);
1823
                double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y);
1824
                double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X);
1825
                double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y);
1826
1827
                return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY));
1828
            }
1829 ca40e004 ljiyeon
        }
1830 787a4489 KangIngu
1831 036650a0 humkyung
        /// <summary>
1832
        /// Serialize this
1833
        /// </summary>
1834
        /// <param name="sUserId"></param>
1835
        /// <returns></returns>
1836
        public override string Serialize()
1837
        {
1838
            using (S_ArrowTextControl STemp = new S_ArrowTextControl())
1839
            {
1840
                STemp.TransformPoint = "0|0";
1841
                STemp.PointSet = this.PointSet;
1842
                STemp.SizeSet = String.Format("{0}", this.LineSize);
1843
                STemp.StrokeColor = this.StrokeColor.Color.ToString();
1844
                STemp.StartPoint = this.StartPoint;
1845
                STemp.ArrowStyle = this.ArrowTextStyle;
1846
                //STemp.StrokeColor = "#FF00FF00";
1847
                STemp.UserID = this.UserID;
1848
                STemp.ArrowText = this.Base_TextBox.Text;
1849
                STemp.BorderSize = this.BorderSize;
1850
                STemp.isHighLight = this.isHighLight;
1851
                STemp.BoxHeight = this.BoxHeight;
1852
                STemp.BoxWidth = this.BoxWidth;
1853
                STemp.Opac = this.Opacity;
1854
                STemp.EndPoint = this.EndPoint;
1855
                STemp.isFixed = this.isFixed;
1856
                //STemp.DashSize = this.DashSize;
1857
                STemp.Name = this.GetType().Name.ToString();
1858
                STemp.isTrans = this.isTrans;
1859
                STemp.MidPoint = this.MidPoint;
1860 15bbef90 taeseongkim
                STemp.Angle = this.PageAngle;
1861 036650a0 humkyung
                STemp.fontConfig = new List<string>()
1862
                            {
1863 24c5e56c taeseongkim
                                this.TextFamily.FontName(),
1864 036650a0 humkyung
                                this.TextStyle.ToString(),
1865
                                this.TextWeight.ToString(),
1866
                                this.TextSize.ToString(),
1867
                            };
1868
1869
                if (this.UnderLine != null)
1870
                {
1871
                    STemp.fontConfig.Add("true");
1872
                }
1873
1874
                ///강인구 추가(2017.11.02)
1875
                ///Memo 추가
1876
                STemp.Memo = this.Memo;
1877
                STemp.BorderSize = this.BorderSize;
1878
                return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize()));
1879
            };
1880
        }
1881
1882 661b7416 humkyung
        /// <summary>
1883
        /// create a arrowtextcontrol from given string
1884
        /// </summary>
1885
        /// <param name="str"></param>
1886
        /// <returns></returns>
1887 4f017ed3 taeseongkim
        public static ArrowTextControl FromString(string str, SolidColorBrush brush, string sProjectNo,double PageAngle)
1888 661b7416 humkyung
        {
1889
            ArrowTextControl instance = null;
1890
            using (S_ArrowTextControl s = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(str))
1891
            {
1892
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1893
                instance = new ArrowTextControl();
1894 4f017ed3 taeseongkim
                instance.PageAngle = s.Angle;
1895 661b7416 humkyung
                instance.LineSize = Convert.ToDouble(data2.First());
1896
                instance.PointSet = s.PointSet;
1897
                instance.StartPoint = s.StartPoint;
1898
                instance.EndPoint = s.EndPoint;
1899
                instance.StrokeColor = brush;
1900 4fcb686a taeseongkim
                //instance.DashSize = s.DashSize; 
1901 661b7416 humkyung
                instance.ArrowTextStyle = s.ArrowStyle;
1902
                instance.isHighLight = s.isHighLight;
1903
                instance.ArrowText = s.ArrowText;
1904
                instance.Opacity = s.Opac;
1905
                instance.BorderSize = s.BorderSize;
1906
                instance.BoxWidth = s.BoxWidth;
1907
                instance.BoxHeight = s.BoxHeight;
1908
                instance.isFixed = s.isFixed;
1909 4f017ed3 taeseongkim
                //instance.VisualPageAngle = s.Angle;
1910 661b7416 humkyung
                instance.UserID = s.UserID;
1911
                instance.isTrans = s.isTrans;
1912
                instance.MidPoint = s.MidPoint;
1913
                instance.Memo = s.Memo;
1914
                if (s.fontConfig == null || s.fontConfig.ToList().Count == 0)
1915
                {
1916
                    s.fontConfig = new List<string>();
1917
1918
                    s.fontConfig.Add("Arial");
1919
                    s.fontConfig.Add("Normal");
1920
                    s.fontConfig.Add("Normal");
1921
                    s.fontConfig.Add("30");
1922
                }
1923 24c5e56c taeseongkim
                instance.TextFamily = Markus.Fonts.FontHelper.GetFontFamily(s.fontConfig[0]);
1924 661b7416 humkyung
                //인구 추가(2018.04.17)
1925
                instance.TextStyle = StringToFont.ConFontStyle(s.fontConfig[1]);
1926
                instance.TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]);
1927
                instance.TextSize = Convert.ToDouble(s.fontConfig[3]);
1928
1929
                if (s.fontConfig.Count() == 5)
1930
                {
1931
                    instance.UnderLine = TextDecorations.Underline;
1932
                }
1933
            }
1934
1935
            return instance;
1936
        }
1937
1938 787a4489 KangIngu
        #region Dispose
1939
        public void Dispose()
1940
        {
1941 a6f7f9b6 djkim
            //GC.Collect();
1942 24c5e56c taeseongkim
            ////GC.SuppressFinalize(this);
1943 a6f7f9b6 djkim
            this.BaseTextbox_Caret = null;
1944
            this.Base_ArrowPath = null;
1945
            this.Base_ArrowSubPath = null;
1946
            this.Base_TextBlock = null;
1947
            this.Base_TextBox = null;
1948 787a4489 KangIngu
        } 
1949
        #endregion
1950
1951
        #region INotifyPropertyChanged
1952
        private void OnPropertyChanged(string name)
1953
        {
1954
            if (PropertyChanged != null)
1955
            {
1956
                PropertyChanged(this, new PropertyChangedEventArgs(name));
1957
            }
1958
        }
1959
1960 3b938959 taeseongkim
        public Rect GetCommentRect()
1961
        {
1962
            Rect rect = new Rect();
1963
1964
            rect.Location = new Point();
1965
            rect.Size = new Size();
1966
1967
            List<Point> points = new List<Point>();
1968
1969
            points.AddRange(this.PointSet);
1970
1971
            var boxTopleft = new Point(Canvas.GetTop(Base_TextBox), Canvas.GetLeft(Base_TextBox));
1972
            points.Add(boxTopleft);
1973
1974
            var boxBottomRight =new Point(boxTopleft.X + Base_TextBox.ActualWidth, boxTopleft.Y + Base_TextBox.ActualHeight);
1975
            points.Add(boxBottomRight);
1976
1977
            rect = CommentMath.CalculateBoundingRect(points);
1978
1979
            return rect;
1980
        }
1981
1982 787a4489 KangIngu
        public event PropertyChangedEventHandler PropertyChanged; 
1983
        #endregion
1984
    }
1985
}
클립보드 이미지 추가 (최대 크기: 500 MB)