프로젝트

일반

사용자정보

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

markus / MarkupToPDF_Old / Controls / Text / ArrowTextControl.cs @ b3fb7321

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

1
using MarkupToPDF.Controls.Common;
2
using System;
3
using System.Collections.Generic;
4
using System.ComponentModel;
5
using System.Linq;
6
using System.Text;
7
using System.Threading.Tasks;
8
using System.Windows;
9
using System.Windows.Controls;
10
using System.Windows.Media;
11
using System.Windows.Shapes;
12

    
13
namespace MarkupToPDF.Controls.Text
14
{
15
    public class ArrowTextControl : Control, IDisposable, INotifyPropertyChanged, IPath, ITextControl, IMarkupControlData
16
    {
17
        private const string PART_ArrowPath = "PART_ArrowPath";
18
        private const string PART_TextBox = "PART_ArrowTextBox";
19
        private const string PART_ArrowSubPath = "PART_ArrowSubPath";
20
        private const string PART_Border = "PART_Border";
21
        
22
        public Path Base_ArrowPath = null;
23
        public Path Base_ArrowSubPath = null;
24
        public TextBox Base_TextBox = null;
25

    
26
        #region Object & Variable
27
        GeometryGroup instanceGroup = new GeometryGroup();
28
        
29
        Path Cemy = new Path();
30
        LineGeometry connectorSMGeometry = new LineGeometry();
31
        LineGeometry connectorMEGeometry = new LineGeometry();
32

    
33
        //안쓰고 있음
34
        //LineGeometry connectorMCEGeometry = new LineGeometry();
35

    
36
        public enum ArrowTextStyleSet { Normal, Cloud, Rect };
37

    
38
        #endregion
39

    
40
        static ArrowTextControl()
41
        {
42
            DefaultStyleKeyProperty.OverrideMetadata(typeof(ArrowTextControl), new FrameworkPropertyMetadata(typeof(ArrowTextControl)));
43
            ResourceDictionary dictionary = new ResourceDictionary();
44
            dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
45
            Application.Current.Resources.MergedDictionaries.Add(dictionary);
46
        }
47

    
48
        public ArrowTextControl()
49
        {
50
            this.DefaultStyleKey = typeof(ArrowTextControl);
51
        }
52

    
53
        public override void OnApplyTemplate()
54
        {
55
            base.OnApplyTemplate();
56
            Base_ArrowPath = GetTemplateChild(PART_ArrowPath) as Path;
57
            Base_ArrowSubPath = GetTemplateChild(PART_ArrowSubPath) as Path;
58
            Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox;
59

    
60
            //TextBoxBackground = Brushes.Red;
61
            //Base_TextBox.Opacity = 0.5;
62

    
63
            Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged);
64
            Base_TextBox.GotFocus += new RoutedEventHandler(Base_TextBox_GotFocus);
65
            Base_TextBox.LostFocus += new RoutedEventHandler(Base_TextBox_LostFocus);
66

    
67
            Base_TextBox.Focus();
68
        }
69

    
70
        void Base_TextBox_LostFocus(object sender, RoutedEventArgs e)
71
        {
72
            this.ArrowText = Base_TextBox.Text;
73

    
74
            this.IsEditingMode = false;
75

    
76
            ApplyOverViewData();
77
        }
78

    
79
        void Base_TextBox_GotFocus(object sender, RoutedEventArgs e)
80
        {
81
          
82
            this.IsEditingMode = true;
83
        }
84

    
85
        void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e)
86
        {
87
            if (Base_TextBox.Text.Length > 0)
88
            {
89
                this.ArrowText = Base_TextBox.Text;
90
                BoxWidth = e.NewSize.Width;
91
                BoxHeight = e.NewSize.Height;
92
                SetArrowTextPath();
93

    
94
                //this.OverViewPathData = PathData;
95
                //this.OverViewArrowText = ArrowText;
96
            }
97
        }
98

    
99
        #region Properties
100
        private bool _IsEditingMode;
101
        public bool IsEditingMode
102
        {
103
            get
104
            {
105
                return _IsEditingMode;
106
            }
107
            set
108
            {
109
                _IsEditingMode = value;
110
                OnPropertyChanged("IsEditingMode");
111
            }
112
        }
113
        #endregion
114

    
115
        #region dp Properties
116
        public SolidColorBrush StrokeColor
117
        {
118
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
119
            set
120
            {
121
                if (this.StrokeColor != value)
122
                {
123
                    SetValue(StrokeColorProperty, value);
124
                }
125
            }
126
        }
127

    
128
        public PathGeometry SubPathData
129
        {
130
            get { return (PathGeometry)GetValue(SubPathDataProperty); }
131
            set
132
            {
133
                if (this.SubPathData != value)
134
                {
135
                    SetValue(SubPathDataProperty, value);
136
                }
137
            }
138
        }
139

    
140
        public string UserID
141
        {
142
            get { return (string)GetValue(UserIDProperty); }
143
            set
144
            {
145
                if (this.UserID != value)
146
                {
147
                    SetValue(UserIDProperty, value);
148
                    OnPropertyChanged("UserID");
149
                }
150
            }
151
        }
152

    
153
        public List<Point> PointSet
154
        {
155
            get { return (List<Point>)GetValue(PointSetProperty); }
156
            set { SetValue(PointSetProperty, value); }
157
        }
158

    
159
        public bool IsSelected
160
        {
161
            get
162
            {
163
                return (bool)GetValue(IsSelectedProperty);
164
            }
165
            set
166
            {
167
                SetValue(IsSelectedProperty, value);
168
                OnPropertyChanged("IsSelected");
169
            }
170
        }
171

    
172
        public ControlType ControlType
173
        {
174
            set
175
            {
176
                SetValue(ControlTypeProperty, value);
177
                OnPropertyChanged("ControlType");
178
            }
179
            get
180
            {
181
                return (ControlType)GetValue(ControlTypeProperty);
182
            }
183
        }
184

    
185
        public Point StartPoint
186
        {
187
            get { return (Point)GetValue(StartPointProperty); }
188
            set { SetValue(StartPointProperty, value); }
189
        }
190

    
191
        public Point EndPoint
192
        {
193
            get { return (Point)GetValue(EndPointProperty); }
194
            set { SetValue(EndPointProperty, value); }
195
        }
196

    
197
        public Point OverViewStartPoint
198
        {
199
            get { return (Point)GetValue(OverViewStartPointProperty); }
200
            set { SetValue(OverViewStartPointProperty, value); }
201
        }
202

    
203
        public Point OverViewEndPoint
204
        {
205
            get { return (Point)GetValue(OverViewEndPointProperty); }
206
            set { SetValue(OverViewEndPointProperty, value); }
207
        }
208

    
209

    
210
        public double Angle
211
        {
212
            get { return (double)GetValue(AngleProperty); }
213
            set { SetValue(AngleProperty, value); }
214
        }
215

    
216
        public Thickness BorderSize
217
        {
218
            get { return (Thickness)GetValue(BorderSizeProperty); }
219
            set
220
            {
221
                if (this.BorderSize != value)
222
                {
223
                    SetValue(BorderSizeProperty, value);
224
                }
225
            }
226
        }
227

    
228

    
229
        public Point MidPoint
230
        {
231
            get { return (Point)GetValue(MidPointProperty); }
232
            set { SetValue(MidPointProperty, value); }
233
        }
234

    
235
        public bool isFixed
236
        {
237
            get { return (bool)GetValue(IsFixedProperty); }
238
            set { SetValue(IsFixedProperty, value); }
239
        }
240

    
241
        public bool isTrans
242
        {
243
            get { return (bool)GetValue(TransformerProperty); }
244
            set { SetValue(TransformerProperty, value); }
245
        }
246

    
247
        public bool isHighLight
248
        {
249
            get { return (bool)GetValue(isHighlightProperty); }
250
            set
251
            {
252
                if (this.isHighLight != value)
253
                {
254
                    SetValue(isHighlightProperty, value);
255
                    OnPropertyChanged("isHighLight");
256
                }
257
            }
258
        }
259

    
260
        public FontWeight TextWeight
261
        {
262
            get { return (FontWeight)GetValue(TextWeightProperty); }
263
            set
264
            {
265
                if (this.TextWeight != value)
266
                {
267
                    SetValue(TextWeightProperty, value);
268
                    OnPropertyChanged("TextWeight");
269
                }
270
            }
271
        }
272

    
273
        public Double LineSize
274
        {
275
            get { return (Double)GetValue(LineSizeProperty); }
276
            set
277
            {
278
                if (this.LineSize != value)
279
                {
280
                    SetValue(LineSizeProperty, value);
281
                }
282
            }
283
        }
284

    
285
        public Double BoxWidth
286
        {
287
            get { return (Double)GetValue(BoxWidthProperty); }
288
            set
289
            {
290
                if (this.BoxWidth != value)
291
                {
292
                    SetValue(BoxWidthProperty, value);
293
                }
294
            }
295
        }
296

    
297
        public Double BoxHeight
298
        {
299
            get { return (Double)GetValue(BoxHeightProperty); }
300
            set
301
            {
302
                if (this.BoxHeight != value)
303
                {
304
                    SetValue(BoxHeightProperty, value);
305
                }
306
            }
307
        }
308

    
309
        public ArrowTextStyleSet ArrowTextStyle
310
        {
311
            get { return (ArrowTextStyleSet)GetValue(ArrowTextStyleProperty); }
312
            set
313
            {
314
                if (this.ArrowTextStyle != value)
315
                {
316
                    SetValue(ArrowTextStyleProperty, value);
317
                }
318
            }
319
        }
320

    
321
        public Geometry PathData
322
        {
323
            get { return (Geometry)GetValue(PathDataProperty); }
324
            set { SetValue(PathDataProperty, value);
325

    
326
                OnPropertyChanged("PathData");
327
            }
328
        }
329

    
330
        public Geometry OverViewPathData
331
        {
332
            get { return (Geometry)GetValue(OverViewPathDataProperty); }
333
            set { SetValue(OverViewPathDataProperty, value);
334

    
335
                OnPropertyChanged("OverViewPathData");
336

    
337
            }
338
        }
339

    
340
        public FontFamily TextFamily
341
        {
342
            get { return (FontFamily)GetValue(TextFamilyProperty); }
343
            set
344
            {
345
                if (this.TextFamily != value)
346
                {
347
                    SetValue(TextFamilyProperty, value);
348
                    OnPropertyChanged("TextFamily");
349
                }
350
            }
351
        }
352

    
353
        public string ArrowText
354
        {
355
            get { return (string)GetValue(ArrowTextProperty); }
356
            set
357
            {
358
                if (this.ArrowText != value)
359
                {
360
                    SetValue(ArrowTextProperty, value);
361
                    OnPropertyChanged("ArrowText");
362
                }
363
            }
364
        }
365

    
366
        public string OverViewArrowText
367
        {
368

    
369
            get { return (string)GetValue(OverViewArrowTextProperty);
370
            }
371
            set
372
            {
373
                if (this.OverViewArrowText != value)
374
                {
375
                    SetValue(OverViewArrowTextProperty, value);
376
                    OnPropertyChanged("OverViewArrowText");
377
                }
378
            }
379
        }
380

    
381
        public Double TextSize
382
        {
383
            get { return (Double)GetValue(TextSizeProperty); }
384
            set
385
            {
386
                if (this.TextSize != value)
387
                {
388
                    SetValue(TextSizeProperty, value);
389
                    OnPropertyChanged("TextSize");
390
                }
391
            }
392
        }
393

    
394
        public FontStyle TextStyle
395
        {
396
            get { return (FontStyle)GetValue(TextStyleProperty); }
397
            set
398
            {
399
                if (this.TextStyle != value)
400
                {
401
                    SetValue(TextStyleProperty, value);
402
                    OnPropertyChanged("TextStyle");
403
                }
404
            }
405
        }
406

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

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

    
433
        public double CenterX
434
        {
435
            get { return (double)GetValue(CenterXProperty); }
436
            set { SetValue(CenterXProperty, value);
437
            OnPropertyChanged("CenterX");
438
            
439
            }
440
        }
441

    
442
        public double CenterY
443
        {
444
            get { return (double)GetValue(CenterYProperty); }
445
            set { SetValue(CenterYProperty, value);
446
            OnPropertyChanged("CenterY");
447
            }
448
        }
449

    
450
        public Brush SubPathFill
451
        {
452
            get { return (Brush)GetValue(SubPathFillProperty); }
453
            set
454
            {
455
                SetValue(SubPathFillProperty, value);
456
                OnPropertyChanged("SubPathFill");
457
            }
458
        }
459

    
460
        public Brush TextBoxBackground
461
        {
462
            get { return (Brush)GetValue(TextBoxBackgroundProperty); }
463
            set
464
            {
465
                SetValue(TextBoxBackgroundProperty, value);
466
                OnPropertyChanged("TextBoxBackground");
467
            }
468
        }
469

    
470
        #endregion
471

    
472
        #region Dependency Properties
473

    
474
        public static readonly DependencyProperty BoxWidthProperty = DependencyProperty.Register(
475
                "BoxWidth", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
476

    
477
        public static readonly DependencyProperty BoxHeightProperty = DependencyProperty.Register(
478
                "BoxHeight", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20));
479

    
480
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
481
                "UserID", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
482

    
483
        public static readonly DependencyProperty ArrowTextStyleProperty = DependencyProperty.Register(
484
               "ArrowTextStyle", typeof(ArrowTextStyleSet), typeof(ArrowTextControl), new PropertyMetadata(ArrowTextStyleSet.Normal));
485

    
486
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register(
487
                "CenterX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
488

    
489
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register(
490
                "CenterY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
491

    
492
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register(
493
                "Angle", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(PointValueChanged)));
494
        
495
        public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
496
                "CanvasX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
497

    
498
        public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
499
                "CanvasY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
500

    
501
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
502
                "PointSet", typeof(List<Point>), typeof(ArrowTextControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
503

    
504
        public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register(
505
                "TextFamily", typeof(FontFamily), typeof(ArrowTextControl), new PropertyMetadata(new FontFamily("Arial"), TextChanged));
506

    
507
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
508
                "PathData", typeof(Geometry), typeof(ArrowTextControl), null);
509
      
510
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
511
               "LineSize", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)3));
512

    
513
        public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register(
514
                "TextStyle", typeof(FontStyle), typeof(ArrowTextControl), new PropertyMetadata(FontStyles.Normal));
515

    
516
        public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register(
517
                "TextSize", typeof(Double), typeof(ArrowTextControl), new PropertyMetadata((Double)30, PointValueChanged));
518

    
519
        public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register(
520
                "TextWeight", typeof(FontWeight), typeof(ArrowTextControl), new PropertyMetadata(FontWeights.Normal));
521

    
522
        public static readonly DependencyProperty IsFixedProperty = DependencyProperty.Register(
523
                "isFixed", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
524

    
525
        public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
526
                "IsSelected", typeof(bool), typeof(ArrowTextControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
527

    
528
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
529
                "StrokeColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
530

    
531
        public static readonly DependencyProperty ControlTypeProperty = DependencyProperty.Register(
532
                "ControlType", typeof(ControlType), typeof(ArrowTextControl), new FrameworkPropertyMetadata(ControlType.ArrowTextControl));
533

    
534
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
535
                "StartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
536

    
537
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
538
                "EndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
539

    
540
        public static readonly DependencyProperty isHighlightProperty = DependencyProperty.Register(
541
                "isHighlight", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false));
542

    
543
        public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register(
544
                "MidPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
545

    
546
        public static readonly DependencyProperty TransformerProperty = DependencyProperty.Register(
547
                "isTrans", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged));
548

    
549
        public static readonly DependencyProperty BorderSizeProperty = DependencyProperty.Register(
550
                "BorderSize", typeof(Thickness), typeof(ArrowTextControl), new PropertyMetadata(null));
551
    
552
        public static readonly DependencyProperty ArrowTextProperty = DependencyProperty.Register(
553
              "ArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null));
554

    
555
        //, new PropertyChangedCallback(TextChanged)
556

    
557

    
558
        #region 추가 사항
559
        public static readonly DependencyProperty SubPathDataProperty = DependencyProperty.Register(
560
                "SubPathData", typeof(Geometry), typeof(ArrowTextControl), null);
561

    
562

    
563
        public static readonly DependencyProperty SubPathFillProperty = DependencyProperty.Register(
564
                "SubPathFill", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(null));
565

    
566
        public static readonly DependencyProperty TextBoxBackgroundProperty = DependencyProperty.Register(
567
                "TextBoxBackground", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(Brushes.White));
568

    
569
        public static readonly DependencyProperty OverViewArrowTextProperty = DependencyProperty.Register(
570
                "OverViewArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null, new PropertyChangedCallback(TextChanged)));
571

    
572
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
573
                "OverViewPathData", typeof(Geometry), typeof(ArrowTextControl), null);
574

    
575
        public static readonly DependencyProperty OverViewStartPointProperty = DependencyProperty.Register(
576
                "OverViewStartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
577

    
578
        public static readonly DependencyProperty OverViewEndPointProperty = DependencyProperty.Register(
579
                "OverViewEndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null));
580
        #endregion
581

    
582
        #endregion
583

    
584
        #region CallBack Method
585
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
586
        {
587
            var instance = (ArrowTextControl)sender;
588

    
589
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
590
            {
591
                instance.SetArrowTextPath();
592
            }
593
        }
594

    
595
        public static void TextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
596
        {
597
            var instance = (ArrowTextControl)sender;
598
            
599
            if (e.OldValue != e.NewValue)
600
            {
601
                instance.SetValue(e.Property, e.NewValue);
602
                //instance.BoxWidth = instance.Base_TextBox.ActualWidth;
603
                //instance.BoxHeight = instance.Base_TextBox.ActualHeight;
604
            }
605
        }
606

    
607
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
608
        {
609
            var instance = (ArrowTextControl)sender;
610
            if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null)
611
            {
612
                instance.SetValue(e.Property, e.NewValue);
613
                instance.SetArrowTextPath();
614
            }
615
        }
616

    
617
        public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
618
        {
619
            var instance = (ArrowTextControl)sender;
620

    
621
            if (e.OldValue != e.NewValue && instance != null)
622
            {
623
                instance.SetValue(e.Property, e.NewValue);
624
                //Canvas.SetLeft(instance, instance.CanvasX);
625
                //Canvas.SetTop(instance, instance.CanvasY);
626
            }
627
        }
628

    
629
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
630
        {
631
            var instance = (ArrowTextControl)sender;
632

    
633
            if (e.OldValue != e.NewValue && instance.Base_TextBox != null)
634
            {
635
                instance.SetValue(e.Property, e.NewValue);
636

    
637
                if (instance.IsSelected)
638
                {
639
                    instance.BorderSize = new Thickness(1);
640

    
641
                    instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Blue);
642
                    //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Blue);
643
                }
644
                else
645
                {
646
                    instance.BorderSize = new Thickness(0);
647
                    instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Transparent);
648
                    //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Transparent);
649
                }
650
            }
651
        }
652
        #endregion
653

    
654
        #region Internal Method
655

    
656
        #region 주석
657

    
658
        //        public void SetArrowTextPath()
659
        //        {
660
        //            instanceGroup.Children.Clear();
661

    
662
        //            instanceSubGroup = new PathGeometry();
663
        //            connectorSMGeometry.StartPoint = this.StartPoint;
664
        //            connectorSMGeometry.EndPoint = this.MidPoint;
665
        //            connectorMEGeometry.StartPoint = this.MidPoint; //핵심
666

    
667
        //            //Canvas.SetLeft(Base_TextBox, this.EndPoint.X - BoxWidth / 2);
668
        //            //Canvas.SetTop(Base_TextBox, this.EndPoint.Y - BoxHeight / 2);
669

    
670
        //            Canvas.SetLeft(Base_TextBox, this.EndPoint.X);
671
        //            Canvas.SetTop(Base_TextBox, this.EndPoint.Y);
672

    
673

    
674

    
675
        //            List<Point> ps = new List<Point>();
676
        //            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox))); //상단
677

    
678
        //            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox) + this.BoxHeight)); // 하단
679

    
680
        //            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2)); //좌단
681

    
682
        //            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2));  //우단
683

    
684
        //            //ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox)));
685
        //            //ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)));
686
        //            //ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight));
687
        //            //ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight));
688

    
689
        //            if (isTrans)
690
        //            {
691
        //                switch (Math.Abs(this.Angle).ToString())
692
        //                {
693
        //                    case "90":
694
        //                        {
695
        //                            ps.Clear();
696
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
697
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
698
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
699

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

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

    
706
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간
707
        //                        }
708
        //                        break;
709
        //                    case "270":
710
        //                        {
711
        //                            ps.Clear();
712
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
713
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
714
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
715

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

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

    
722
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간
723
        //                        }
724
        //                        break;
725
        //                    default:
726
        //                        break;
727
        //                }
728
        //                var endP = MathSet.getNearPoint(ps, this.MidPoint);
729

    
730
        //                connectorMEGeometry.EndPoint = endP;
731
        //                instanceGroup.Children.Add(SingleAllow(this.MidPoint, this.StartPoint, this.LineSize));
732
        //            }
733
        //            else
734
        //            {
735
        //                switch (Math.Abs(this.Angle).ToString())
736
        //                {
737
        //                    case "90":
738
        //                        {
739
        //                            ps.Clear();
740
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
741
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
742
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
743

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

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

    
750
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간
751
        //                        }
752
        //                        break;
753
        //                    case "270":
754
        //                        {
755
        //                            ps.Clear();
756
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
757
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
758
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
759

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

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

    
766
        //                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간
767
        //                        }
768
        //                        break;
769
        //                    default:
770
        //                        break;
771
        //                }
772

    
773
        //                var endP = MathSet.getNearPoint(ps, this.MidPoint);
774
        //                connectorMEGeometry.EndPoint = endP; //최상단
775

    
776
        //                #region 보정치
777

    
778

    
779
        //                //enP는 그 점
780

    
781
        //                //Point testP = new Point(endP.X-100,endP.Y);
782
        //                Point testP = endP;
783

    
784
        //                if (isFixed)
785
        //                {
786
        //                    if (ps[0] == endP) //상단
787
        //                    {
788
        //                        testP = new Point(endP.X, endP.Y - 50);
789
        //                        System.Diagnostics.Debug.WriteLine("상단");
790
        //                    }
791
        //                    else if (ps[1] == endP) //하단
792
        //                    {
793
        //                        testP = new Point(endP.X, endP.Y + 50);
794
        //                        System.Diagnostics.Debug.WriteLine("하단");
795
        //                    }
796
        //                    else if (ps[2] == endP) //좌단
797
        //                    {
798
        //                        testP = new Point(endP.X - 50, endP.Y);
799
        //                        System.Diagnostics.Debug.WriteLine("좌단");
800
        //                    }
801
        //                    else if (ps[3] == endP) //우단
802
        //                    {
803
        //                        testP = new Point(endP.X + 50, endP.Y);
804
        //                        System.Diagnostics.Debug.WriteLine("우단");
805
        //                    }
806
        //                }
807
        //                connectorSMGeometry.EndPoint = testP;
808
        //                connectorMEGeometry.StartPoint = testP;
809

    
810
        //                //connectorSMGeometry.EndPoint = endP;
811
        //                //connectorMEGeometry.StartPoint = endP;
812
        //                instanceGroup.Children.Add(SingleAllow(testP, this.StartPoint, this.LineSize));
813
        //                #endregion
814
        //            }
815

    
816
        //            switch (this.ArrowTextStyle)
817
        //            {
818
        //                case ArrowTextStyleSet.Normal:
819
        //                    this.BorderSize = new Thickness(0);
820
        //                    break;
821
        //                case ArrowTextStyleSet.Cloud:
822
        //                    this.BorderSize = new Thickness(0);
823
        //                    DrawingCloud();
824
        //                    break;
825
        //                default:
826
        //                    this.BorderSize = new Thickness(3);
827
        //                    break;
828
        //            }
829

    
830
        //            if (isHighLight)
831
        //            {
832
        //                Base_TextBox.Background = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
833
        //                Base_ArrowSubPath.Fill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
834

    
835
        //            }
836
        //            else
837
        //            {
838
        //                //Base_ArrowSubPath.Fill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
839
        //                //Base_TextBox.Background = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
840
        //            }
841

    
842
        //            instanceGroup.Children.Add(connectorSMGeometry);
843
        //            instanceGroup.Children.Add(connectorMEGeometry);
844

    
845
        //            this.Base_ArrowPath.Stroke = this.StrokeColor;
846
        //            this.PathData = instanceGroup;
847

    
848
        //            Base_ArrowSubPath.Data = instanceSubGroup;
849

    
850
        //            var tempAngle = Math.Abs(this.Angle);
851

    
852
        //            if (tempAngle == Convert.ToDouble(90) || tempAngle == Convert.ToDouble(270))
853
        //            {
854
        //                this.RenderTransformOrigin = new Point(0.5, 0.5);
855
        //                this.Base_ArrowPath.RenderTransformOrigin = new Point(0, 0);
856
        //                this.Base_ArrowSubPath.RenderTransformOrigin = new Point(0, 0);
857

    
858
        //                Base_TextBox.RenderTransformOrigin = new Point(0, 0);
859
        //            }
860

    
861
        //            Base_ArrowSubPath.RenderTransform = new RotateTransform
862
        //            {
863
        //                Angle = this.Angle,
864
        //                CenterX = this.EndPoint.X,
865
        //                CenterY = this.EndPoint.Y,
866
        //            };
867
        //        }
868

    
869
        //        public void updateControl()
870
        //        {
871
        //            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
872
        //            this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
873
        //            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
874
        //            //isTrans = true;
875
        //        }
876

    
877
        //        private void DrawingCloud()
878
        //        {
879
        //            List<Point> pCloud = new List<Point>()
880
        //            {
881
        //#if SILVERLIGHT
882
        //                new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
883
        //                new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
884
        //                new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
885
        //                new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
886
        //                new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
887
        //#else
888
        //                new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
889
        //                new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
890
        //                new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
891
        //                new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
892
        //                new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
893

    
894
        //                //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
895
        //                //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
896
        //                //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
897
        //                //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
898
        //                //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
899
        //#endif
900
        //            };
901
        //            //instanceGroup.Children.Add(Generate(pCloud));
902
        //            instanceSubGroup = (Generate(pCloud));
903

    
904
        //        } 
905

    
906
        #endregion
907

    
908
        public void SetArrowTextPath()
909
        {
910
            instanceGroup.Children.Clear();
911

    
912
            connectorSMGeometry.StartPoint = this.StartPoint;
913
            connectorSMGeometry.EndPoint = this.MidPoint;
914
            connectorMEGeometry.StartPoint = this.MidPoint; //핵심
915
            //Canvas.SetLeft(Base_TextBox, this.EndPoint.X - BoxWidth / 2);
916
            //Canvas.SetTop(Base_TextBox, this.EndPoint.Y - BoxHeight / 2);
917
            Canvas.SetLeft(Base_TextBox, this.EndPoint.X);
918
            Canvas.SetTop(Base_TextBox, this.EndPoint.Y);
919

    
920
            List<Point> ps = new List<Point>();
921
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox))); //상단
922
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox) + this.BoxHeight)); // 하단
923
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2)); //좌단
924
            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2));  //우단
925
            //ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox)));
926
            //ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)));
927
            //ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight));
928
            //ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight));
929

    
930
            if (isTrans)
931
            {
932
                switch (Math.Abs(this.Angle).ToString())
933
                {
934
                    case "90":
935
                        {
936
                            ps.Clear();
937
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
938
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
939
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
940

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

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

    
947
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간
948
                        }
949
                        break;
950
                    case "270":
951
                        {
952
                            ps.Clear();
953
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
954
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
955
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
956

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

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

    
963
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간
964
                        }
965
                        break;
966
                    default:
967
                        break;
968
                }
969
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
970

    
971
                connectorMEGeometry.EndPoint = endP;
972
                instanceGroup.Children.Add(SingleAllow(this.MidPoint, this.StartPoint, this.LineSize));
973
            }
974
            else
975
            {
976
                switch (Math.Abs(this.Angle).ToString())
977
                {
978
                    case "90":
979
                        {
980
                            ps.Clear();
981
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
982
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간
983
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽
984

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

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

    
991
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간
992
                        }
993
                        break;
994
                    case "270":
995
                        {
996
                            ps.Clear();
997
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽
998
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간
999
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽
1000

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

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

    
1007
                            ps.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간
1008
                        }
1009
                        break;
1010
                    default:
1011
                        break;
1012
                }
1013

    
1014

    
1015
                var endP = MathSet.getNearPoint(ps, this.MidPoint);
1016
                //connectorMEGeometry.EndPoint = endP;
1017
                //connectorMEGeometry.EndPoint = endP;
1018
                connectorMEGeometry.EndPoint = endP; //최상단
1019
                //connectorMEGeometry.EndPoint = this.EndPoint; //핵심
1020
                //this.MidPoint= MathSet.getMiddlePoint(this.StartPoint, endP);
1021
                #region 보정치
1022
                //enP는 그 점
1023
                //Point testP = new Point(endP.X-100,endP.Y);
1024
                Point testP = endP;
1025

    
1026

    
1027

    
1028
                if (isFixed)
1029
                {
1030
                    if (ps[0] == endP) //상단
1031
                    {
1032
                        testP = new Point(endP.X, endP.Y - 50);
1033
                        //System.Diagnostics.Debug.WriteLine("상단");
1034
                    }
1035
                    else if (ps[1] == endP) //하단
1036
                    {
1037
                        testP = new Point(endP.X, endP.Y + 50);
1038
                        //System.Diagnostics.Debug.WriteLine("하단");
1039
                    }
1040
                    else if (ps[2] == endP) //좌단
1041
                    {
1042
                        testP = new Point(endP.X - 50, endP.Y);
1043
                        //System.Diagnostics.Debug.WriteLine("좌단");
1044
                    }
1045
                    else if (ps[3] == endP) //우단
1046
                    {
1047
                        testP = new Point(endP.X + 50, endP.Y);
1048
                        //System.Diagnostics.Debug.WriteLine("우단");
1049
                    }
1050
                }
1051
                connectorSMGeometry.EndPoint = testP;
1052
                connectorMEGeometry.StartPoint = testP;
1053
                //connectorSMGeometry.EndPoint = endP;
1054
                //connectorMEGeometry.StartPoint = endP;
1055
                instanceGroup.Children.Add(SingleAllow(testP, this.StartPoint, this.LineSize));
1056
                #endregion
1057
            }
1058

    
1059
            switch (this.ArrowTextStyle)
1060
            {
1061
                case ArrowTextStyleSet.Normal:
1062
                    this.BorderSize = new Thickness(0);
1063
                    break;
1064
                case ArrowTextStyleSet.Cloud:
1065
                    this.BorderSize = new Thickness(0);
1066
                    DrawingCloud();
1067
                    break;
1068
                default:
1069
                    this.BorderSize = new Thickness(3);
1070
                    break;
1071
            }
1072

    
1073
            if (isHighLight)
1074
            {
1075
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B)); ;
1076
                //Base_ArrowSubPath.Fill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1077

    
1078
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1079
                //Base_TextBox.Background = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
1080
            }
1081
            else
1082
            {
1083
                SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1084
                TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1085

    
1086
                //Base_ArrowSubPath.Fill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1087
                //Base_TextBox.Background = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B));
1088
            }
1089

    
1090
            instanceGroup.Children.Add(connectorSMGeometry);
1091
            instanceGroup.Children.Add(connectorMEGeometry);
1092

    
1093
            //이미 바인딩 되어있음
1094
            //this.Base_ArrowPath.Stroke = this.StrokeColor;
1095

    
1096
            this.PathData = instanceGroup;
1097
            OverViewPathData = PathData;
1098
            OverViewArrowText = ArrowText;
1099
            OverViewEndPoint = connectorMEGeometry.EndPoint;
1100
            OverViewStartPoint = connectorSMGeometry.StartPoint;
1101
            //OverViewText = Text;
1102

    
1103
            //Base_ArrowSubPath.Data = instanceSubGroup;
1104
            //Angle = Math.Abs(this.Angle);
1105
            var tempAngle = Math.Abs(this.Angle);
1106

    
1107
            if (tempAngle == Convert.ToDouble(90) || tempAngle == Convert.ToDouble(270))
1108
            {
1109
                ////this.Angle = 90;
1110

    
1111
                this.RenderTransformOrigin = new Point(0.5, 0.5);
1112
                this.Base_ArrowPath.RenderTransformOrigin = new Point(0, 0);
1113
                this.Base_ArrowSubPath.RenderTransformOrigin = new Point(0, 0);
1114

    
1115
                Base_TextBox.RenderTransformOrigin = new Point(0, 0);
1116

    
1117

    
1118
                //ScaleTransform myScaleTransform = new ScaleTransform();
1119
                //myScaleTransform.ScaleY = 1;
1120
                //myScaleTransform.ScaleX = -1;
1121
                //RotateTransform myRotateTransform = new RotateTransform();
1122
                //myRotateTransform.Angle = tempAngle - 90;
1123

    
1124

    
1125
                //TransformGroup myTransformGroup = new TransformGroup();
1126
                //myTransformGroup.Children.Add(myScaleTransform);
1127
                //myTransformGroup.Children.Add(myRotateTransform);
1128
                //this.RenderTransform = myTransformGroup;
1129

    
1130

    
1131

    
1132
                //ScaleTransform myScaleTransform2 = new ScaleTransform();
1133
                //myScaleTransform2.ScaleY = -0;
1134
                //myScaleTransform2.ScaleX = +1;
1135
                //RotateTransform myRotateTransform2 = new RotateTransform();
1136
                //myRotateTransform2.Angle = tempAngle-90;
1137

    
1138

    
1139
                //TransformGroup myTransformGroup2 = new TransformGroup();
1140
                ////myTransformGroup2.Children.Add(myScaleTransform2);
1141
                //myTransformGroup2.Children.Add(myRotateTransform2);
1142
                //this.Base_TextBox.RenderTransform = myTransformGroup2;
1143

    
1144

    
1145

    
1146
                //this.Base_ArrowPath.RenderTransform = new RotateTransform
1147
                //{
1148
                //    Angle = tempAngle - 90
1149
                //};
1150

    
1151
                ////TransformGroup myTransformGroup3 = new TransformGroup();
1152
                ////myTransformGroup.Children.Add(myScaleTransform);
1153
                ////this.Base_ArrowPath.RenderTransform = myTransformGroup3;
1154

    
1155
                //this.Base_ArrowPath.RenderTransform = myTransformGroup;
1156

    
1157

    
1158
                ////ScaleTransform myScaleTransform2 = new ScaleTransform();
1159
                ////myScaleTransform2.ScaleY = -1;
1160
                ////myScaleTransform2.ScaleX = 1;
1161
                ////RotateTransform myRotateTransform2 = new RotateTransform();
1162
                //////myRotateTransform2.Angle = tempAngle - 90;
1163
                ////myRotateTransform2.Angle = tempAngle - 90;
1164

    
1165
                ////TransformGroup myTransformGroup2 = new TransformGroup();
1166
                ////myTransformGroup2.Children.Add(myScaleTransform2);
1167
                ////myTransformGroup2.Children.Add(myRotateTransform2);
1168
                ////this.Base_TextBox.RenderTransform = myTransformGroup2;
1169

    
1170
            }
1171

    
1172
            Base_ArrowSubPath.RenderTransform = new RotateTransform
1173
            {
1174
                Angle = this.Angle,
1175
                CenterX = this.EndPoint.X,
1176
                CenterY = this.EndPoint.Y,
1177
            };
1178
        }
1179

    
1180
        private void DrawingCloud()
1181
        {
1182
            List<Point> pCloud = new List<Point>()
1183
            {
1184
#if SILVERLIGHT
1185
		        new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1186
                new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1187
                new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1188
                new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1189
                new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1190

    
1191
#else
1192
                new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1193
                new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래
1194
                new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight),
1195
                new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)),
1196
                new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위  
1197

    
1198
                //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1199
                //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래
1200
                //new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4),
1201
                //new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)),
1202
                //new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위
1203
#endif
1204
            };
1205
            //instanceGroup.Children.Add(Generate(pCloud));
1206
            SubPathData = (Generate(pCloud));
1207
        }
1208

    
1209
        public void updateControl()
1210
        {
1211
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
1212
            this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
1213
            this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y);
1214
            //isTrans = true;
1215
        }
1216

    
1217
        public void ApplyOverViewData()
1218
        {
1219
            this.OverViewPathData = this.PathData;
1220
            this.OverViewArrowText = this.ArrowText;
1221
            this.OverViewStartPoint = this.StartPoint;
1222
            this.OverViewEndPoint = this.EndPoint;
1223
        }
1224

    
1225
        #endregion
1226

    
1227
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
1228
        {
1229
            PathFigure pathFigure = new PathFigure();
1230
            pathFigure.StartPoint = p1;
1231

    
1232
            double arcLength = arcLength_;
1233
            /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung 
1234
            double dx = p2.X - p1.X;
1235
            double dy = p2.Y - p1.Y;
1236
            double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2
1237
            double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
1238
            Point lastPt = new Point(p1.X, p1.Y);
1239
            double count = l / arcLength;
1240
            /// normalize
1241
            dx /= l;
1242
            dy /= l;
1243
            Double j = 1;
1244
            for (j = 1; j < (count - 1); j++)
1245
            {
1246
                ArcSegment arcSeg = new ArcSegment();
1247
                arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8);						/// x size and y size of arc
1248
                arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);	/// end point of arc
1249
                lastPt = arcSeg.Point;  /// save last point
1250
                arcSeg.RotationAngle = theta + 90;
1251
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1252
                pathFigure.Segments.Add(arcSeg);
1253
            }
1254

    
1255
            /// draw arc between last point and end point
1256
            if ((count > j) || (count > 0))
1257
            {
1258
                arcLength = MathSet.DistanceTo(lastPt, p2);
1259
                ArcSegment arcSeg = new ArcSegment();
1260
                arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8);	/// x size and y size of arc
1261
                arcSeg.Point = new Point(p2.X, p2.Y);						/// end point of arc
1262
                arcSeg.RotationAngle = theta;
1263
                if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
1264
                pathFigure.Segments.Add(arcSeg);
1265
            }
1266
            /// up to here
1267

    
1268
            return pathFigure;
1269
        }
1270

    
1271
        public static PathGeometry Generate(List<Point> pData)
1272
        {
1273
            var _pathGeometry = new PathGeometry();
1274
            double area = MathSet.AreaOf(pData);
1275
            bool reverse = (area > 0);
1276
            int count = pData.Count;
1277
            for (int i = 0; i < (count - 1); i++)
1278
            {
1279
                PathFigure pathFigure = GenerateLineWithCloud(pData[i], pData[i + 1], 20, reverse);
1280
                pathFigure.IsClosed = false;
1281
                pathFigure.IsFilled = true;
1282
                _pathGeometry.Figures.Add(pathFigure);
1283
            }
1284
            return _pathGeometry;
1285
        }
1286

    
1287
        public static PathGeometry SingleAllow(Point p2, Point p1, double lineSize)
1288
        {
1289
            double theta = Math.Atan2((p2.Y - p1.Y), (p2.X - p1.X)) * 180 / Math.PI;
1290
            PathGeometry pathGeometry = new PathGeometry();
1291
            PathFigure pathFigure = new PathFigure();
1292
            pathFigure.StartPoint = p1;
1293

    
1294
            Point lpoint = new Point(p1.X + lineSize * 2, p1.Y + lineSize * 4);
1295
            Point rpoint = new Point(p1.X - lineSize * 2, p1.Y + lineSize * 4);
1296

    
1297
            LineSegment seg1 = new LineSegment();
1298
            seg1.Point = lpoint;
1299
            pathFigure.Segments.Add(seg1);
1300

    
1301
            LineSegment seg2 = new LineSegment();
1302
            seg2.Point = rpoint;
1303
            pathFigure.Segments.Add(seg2);
1304

    
1305
            LineSegment seg3 = new LineSegment();
1306
            seg3.Point = p1;
1307
            pathFigure.Segments.Add(seg3);
1308

    
1309
            pathFigure.IsClosed = true;
1310
            pathFigure.IsFilled = true;
1311

    
1312
            pathGeometry.Figures.Add(pathFigure);
1313
            pathGeometry.FillRule = FillRule.Nonzero;
1314
            RotateTransform transform = new RotateTransform();
1315
            transform.Angle = theta - 90;
1316
            transform.CenterX = p1.X;
1317
            transform.CenterY = p1.Y;
1318
            pathGeometry.Transform = transform;
1319
            return pathGeometry;
1320
        }
1321

    
1322
        #region Dispose
1323
        public void Dispose()
1324
        {
1325
            GC.Collect();
1326
            GC.SuppressFinalize(this);
1327
        } 
1328
        #endregion
1329

    
1330
        #region INotifyPropertyChanged
1331
        private void OnPropertyChanged(string name)
1332
        {
1333
            if (PropertyChanged != null)
1334
            {
1335
                PropertyChanged(this, new PropertyChangedEventArgs(name));
1336
            }
1337
        }
1338

    
1339
        public event PropertyChangedEventHandler PropertyChanged; 
1340
        #endregion
1341
    }
1342
}
클립보드 이미지 추가 (최대 크기: 500 MB)