프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 2a824927

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

1
using KCOM.Common;
2
using KCOM.Events;
3
using MarkupToPDF.Common;
4
using MarkupToPDF.Controls.Cad;
5
using MarkupToPDF.Controls.Common;
6
using MarkupToPDF.Controls.Etc;
7
using MarkupToPDF.Controls.Line;
8
using MarkupToPDF.Controls.Parsing;
9
using MarkupToPDF.Controls.Polygon;
10
using MarkupToPDF.Controls.Shape;
11
using MarkupToPDF.Controls.Text;
12
using System;
13
using System.Collections.Generic;
14
using System.Diagnostics;
15
using System.Linq;
16
using System.Text;
17
using System.Threading.Tasks;
18
using System.Windows;
19
using System.Windows.Controls;
20
using System.Windows.Controls.Primitives;
21
using System.Windows.Input;
22
using System.Windows.Media;
23
using Telerik.Windows.Controls;
24

    
25
namespace KCOM.Controls
26
{
27
    public class MyThumb : Thumb
28
    {
29
        public MyThumb()
30
        {
31
            this.Opacity = 0.6;
32
            this.MouseEnter += MyThumb_MouseEnter;
33
            this.MouseLeave += MyThumb_MouseLeave;
34
        }
35

    
36
        public void Translate(double dx, double dy, double angle)
37
        {
38
            var ratotePoint = MathHelper.RotatePoint(new Point(dx, dy), new Point(), angle);
39

    
40
            Canvas.SetLeft(this, Canvas.GetLeft(this) + ratotePoint.X);
41
            Canvas.SetTop(this, Canvas.GetTop(this) + ratotePoint.Y);
42
        }
43

    
44

    
45
        /// <summary>
46
        /// </summary>
47
        /// <param name="sender"></param>
48
        /// <param name="e"></param>
49
        private void MyThumb_MouseLeave(object sender, MouseEventArgs e)
50
        {
51
            this.Opacity = 0.6;
52
        }
53

    
54
        /// <summary>
55
        /// 
56
        /// </summary>
57
        /// <param name="sender"></param>
58
        /// <param name="e"></param>
59
        private void MyThumb_MouseEnter(object sender, MouseEventArgs e)
60
        {
61
            this.Opacity = 1.0;
62
        }
63
    }
64

    
65
    /// <summary>
66
    /// Interaction logic for AdornerFinal.xaml
67
    /// </summary>
68
    public class AdornerMember
69
    {
70
        public UIElement DrawingData { get; set; }
71
        public ControlType Drawingtype { get; set; }
72
        public double DrawingAngle { get; set; }
73
        public List<MyThumb> ThumbList { get; set; }
74
        public string Symbol_ID { get; set; }
75

    
76
        /// <summary>
77
        /// update thumb
78
        /// </summary>
79
        public void UpdateThumb()
80
        {
81
            var path = this.DrawingData as IPath;
82
            for (int i = 0; i < path.PointSet.Count; ++i)
83
            {
84
                Canvas.SetLeft(this.ThumbList[i], path.PointSet[i].X);
85
                Canvas.SetTop(this.ThumbList[i], path.PointSet[i].Y);
86
            }
87

    
88
            if (this.DrawingData is ArrowTextControl ArrowTextCtrl)
89
            {
90
                if (!ArrowTextCtrl.isTrans) //trans가 True인경우
91
                {
92
                    List<Point> ps = new List<Point>();
93

    
94
                    var temp = this.DrawingData as ArrowTextControl;
95
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
96
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
97
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
98
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
99

    
100
                    if (temp.isFixed)
101
                    {
102
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
103
                        var testP = endP;
104
                        if (ps[0] == endP) //상단
105
                        {
106
                            testP = new Point(endP.X, endP.Y - 50);
107
                        }
108
                        else if (ps[1] == endP) //하단
109
                        {
110
                            testP = new Point(endP.X, endP.Y + 50);
111
                        }
112
                        else if (ps[2] == endP) //좌단
113
                        {
114
                            testP = new Point(endP.X - 50, endP.Y);
115
                        }
116
                        else if (ps[3] == endP) //우단
117
                        {
118
                            testP = new Point(endP.X + 50, endP.Y);
119
                        }
120
                        Canvas.SetLeft(this.ThumbList[1], testP.X);
121
                        Canvas.SetTop(this.ThumbList[1], testP.Y);
122
                    }
123
                    else
124
                    {
125
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
126
                        var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
127
                        Canvas.SetLeft(this.ThumbList[1], tempP.X);
128
                        Canvas.SetTop(this.ThumbList[1], tempP.Y);
129
                    }
130
                }
131
            }
132
        }
133

    
134
        /// <summary>
135
        /// rotate members about given position and angle
136
        /// </summary>
137
        /// <param name="at"></param>
138
        /// <param name="angle">in degree</param>
139
        public void RotateAbout(Point at, double angle)
140
        {
141
            for (int i = 0; i < (this.DrawingData as IPath).PointSet.Count; i++)
142
            {
143
                (this.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(at, (this.DrawingData as IPath).PointSet[i], angle);
144
            }
145
            (this.DrawingData as CommentUserInfo).UpdateControl();
146

    
147
            this.UpdateThumb();
148
        }
149
    }
150

    
151
    public partial class AdornerFinal : UserControl
152
    {
153
        #region 공용 인스턴스
154
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
155
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
156

    
157
        private List<double> AlignedAngles {get;} = new List<double>() { 0, 30, 45, 60, 90, 120, 135, 150, 180, 210, 225, 240, 270, 300, 315, 330, 360 };
158

    
159
        /// <summary>
160
        /// 회전 시작할때의 각도
161
        /// </summary>
162

    
163
        private double angleValue;
164
        public double AngleValue { get => angleValue;
165
            set
166
            {
167
                if(angleValue != value)
168
                {
169
                    angleValue = value;
170
                }
171
            }
172
        }
173

    
174
        /// <summary>
175
        /// Axis Lock을 적용하지 않는 실제 회전 각도
176
        /// </summary>
177
        private double _ActualAngle { get; set; }
178

    
179
        public bool IsTextAngle = false;
180
        public Rect BorderSize { get; set; }
181
        public bool TextCompensation = false;
182
        public bool isDragging { get; set; }
183
        public Thumb DraggerThumb { get; set; }
184
        public RadDropDownButton dropData;
185
        public RadCalendar dropCalendar;
186
        public Thumb mainDragThumb { get; set; }
187

    
188
        private bool disposed;
189

    
190
        public Point reSizePoint { get; set; }
191
        private Point RotatedPoint { get; set; } /// 2018.05.09 added by humkyung
192
        private Point MouseDownPoint = new Point();
193
        private Point CurrentMousePoint = new Point();
194
        #endregion
195
        #region 생성자
196
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
197
        {
198
            dropData = sender as RadDropDownButton;
199
        }
200

    
201
        private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
202
        {
203
            dropCalendar = sender as RadCalendar;
204
            dropCalendar.SelectionChanged += (sen, ea) =>
205
            {
206
                dropData.IsOpen = false;
207
                if ((this.Members[0]).DrawingData.GetType().Name == "DateControl")
208
                {
209
                    DateControl data = (this.Members[0]).DrawingData as DateControl;
210
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
211
                }
212
            };
213
        }
214

    
215
        public AdornerFinal()
216
        {
217
            InitializeComponent();
218
            BorderSize = new Rect();
219
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
220
        }
221

    
222
        public AdornerFinal(CommentUserInfo objectData) : this()
223
        {
224
            InitializeComponent();
225
            objectData.IsHitTestVisible = false;
226

    
227
            if (objectData is ArrowTextControl ArrTextCtrl)
228
            {
229
                ArrTextCtrl.Base_TextBox.Focusable = true;
230
            }
231

    
232
            ///Canvas.SetZIndex(objectData, 84);
233
            try
234
            {
235
                objectData.Index = ViewerDataModel.Instance.MarkupControls_USER.IndexOf(objectData);
236
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
237
                this.ContainerContent.Children.Add(objectData);
238
            }
239
            catch (Exception ex)
240
            {
241
                throw new InvalidOperationException(ex.Message);
242
            }
243

    
244
            SetAdornerMember(objectData);
245
            this.Focus();
246
        }
247

    
248
        public AdornerFinal(List<CommentUserInfo> comments) : this()
249
        {
250
            InitializeComponent();
251
            //comments.ForEach(x => x.Index = ViewerDataModel.Instance.MarkupControls_USER.IndexOf(x));          
252
            RemoveMultipleFromCanvas(comments);
253
            foreach (var item in comments)
254
            {
255
                if (item is ArrowTextControl ArrTextCtrl)
256
                {
257
                    ArrTextCtrl.Base_TextBox.Focusable = true;
258
                }
259
                try
260
                {
261
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);                  
262
                    this.ContainerContent.Children.Add(item);
263
                }
264
                catch (Exception ex)
265
                {
266
                    throw new InvalidOperationException(ex.Message);
267
                }
268
                finally
269
                {
270
                }
271
            }
272

    
273
            this.SetAdornerMember(comments);
274
            this.Focus();
275
        }
276

    
277
        private void RemoveMultipleFromCanvas(IEnumerable<UIElement> elements)
278
        {
279
            if (elements == null)
280
            {
281
                return;
282
            }
283

    
284
            try
285
            {
286
                var elementList = elements.ToList();
287

    
288
                foreach (var element in elementList)
289
                {
290
                    var parent = VisualTreeHelper.GetParent(element);
291
                   if(((System.Windows.FrameworkElement)parent).Parent != null)
292
                    {
293
                        if (parent is Canvas canvas)
294
                        {
295
                            canvas.Children.Remove(element);
296
                        }
297
                    }                   
298
                }
299
            }
300
            catch (InvalidOperationException ex)
301
            {
302
                // 컬렉션 수정 중 예외 처리
303
                Console.WriteLine($"Exception removing elements: {ex.Message}");
304
            }
305
        }
306

    
307
        ~AdornerFinal()
308
        {
309
            this.Dispose(false);
310
        }
311

    
312
        public void Dispose()
313
        {
314
            this.Dispose(true);
315
            GC.SuppressFinalize(this);
316
        }
317

    
318
        protected virtual void Dispose(bool disposing)
319
        {
320
            if (this.disposed) return;
321
            if (disposing)
322
            {
323
                foreach (var member in this.Members)
324
                {
325
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
326
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
327
                }
328
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
329
            }
330
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
331
            this.disposed = true;
332
        }
333

    
334
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
335
        {
336
            mainDragThumb = DragThumb;
337
        }
338

    
339
        public Point Centeroid
340
        {
341
            get
342
            {
343
                List<Point> pts = new List<Point>();
344

    
345
                #region 센터 포인트 구하기 (그룹핑)
346
                foreach (var item in this.Members)
347
                {
348
                    if (item.DrawingData.GetType().Name == "TextControl")
349
                    {
350
                        if (AngleValue == 0)
351
                        {
352
                            AngleValue = (item.DrawingData as TextControl).CommentAngle;
353
                        }
354
                        double X = Canvas.GetLeft((item.DrawingData as TextControl));
355
                        double Y = Canvas.GetTop((item.DrawingData as TextControl));
356
                        pts.Add(new Point(X, Y));
357
                    }
358
                    else
359
                    {
360
                        pts.AddRange((item.DrawingData as IPath).PointSet);
361
                    }
362
                }
363
                #endregion
364

    
365
                return MathSet.FindCentroid(pts);
366
            }
367
        }
368

    
369
        #endregion
370
        #region 메서드
371
        public Rect getAdornerSize()
372
        {
373
            return BorderSize;
374
        }
375

    
376
        private void TextControlLostFocus(object sender,RoutedEventArgs e)
377
        {
378
            TextCompensation = false;
379
            BorderUpdate();
380

    
381
            if (sender is TextBox TextBox)
382
            {
383
                if (TextBox.Text == "") //보류
384
                {
385
                    this.ContainerContent.Children.Remove((sender as TextBox).Parent as MarkupToPDF.Common.CommentUserInfo);
386
                    this.Visibility = Visibility.Collapsed;
387
                }
388
            }
389
        }
390

    
391
        private void TextControlPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
392
        {
393
            if (sender is TextControl)
394
            {
395
                TextCompensation = true;
396
                BorderUpdate();
397
            }
398
        }
399

    
400
        private void TextControlSelectionChanged(object sender, RoutedEventArgs e)
401
        {
402
            BorderUpdate();
403
        }
404

    
405
        
406
        private void ViewBoxRotate(UIElement member)
407
        {
408
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
409
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
410
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
411
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
412
        }
413

    
414
        /// <summary>
415
        /// UIElement를 종류에 맞게 등록시킴
416
        /// </summary>
417
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
418
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
419
        {
420
            switch (member.GetType().Name)
421
            {
422
                #region 컨트롤 조건
423
                case "LineControl":
424
                case "PolygonControl":
425
                case "ArrowControl":
426
                case "ArcControl":
427
                case "ArrowArcControl":
428
                case "ArrowControl_Multi":
429
                case "RectangleControl":
430
                case "TriControl":
431
                case "CircleControl":
432
                case "CloudControl":
433
                case "RectCloudControl":
434
                case "InkControl":
435
                case "InsideWhiteControl":
436
                case "OverlapWhiteControl":
437
                case "ClipWhiteControl":
438
                case "CoordinateControl":
439
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
440
                    _ActualAngle = AngleValue = member.CommentAngle;
441
                    break;
442
                case "ArrowTextControl":
443
                    this.Members.Add(new AdornerMember
444
                    {
445
                        DrawingData = member,
446
                        Drawingtype = ControlType.ArrowTextControl,
447
                        ThumbList = new List<MyThumb>(),
448
                        Symbol_ID = member.SymbolID
449
                    });
450
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
451
                    _ActualAngle = AngleValue = (member as ArrowTextControl).CommentAngle;
452

    
453
                    ((ArrowTextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
454
                    break;
455
                case "ImgControl":
456
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID});
457
                    _ActualAngle = AngleValue = (member as ImgControl).CommentAngle;
458
                    break;
459
                case "DateControl":
460
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
461
                    _ActualAngle = AngleValue = (member as DateControl).CommentAngle;
462
                    break;
463
                case "SignControl":
464
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
465
                    _ActualAngle = AngleValue = (member as SignControl).CommentAngle;
466
                    break;
467
                case "SymControl":
468
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
469
                    _ActualAngle = AngleValue = (member as SymControl).CommentAngle;
470
                    break;
471
                case "SymControlN":
472
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
473
                    _ActualAngle = AngleValue = (member as SymControlN).CommentAngle;
474
                    break;
475
                case "TextControl":
476
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
477
                    RectangleGeometry Data = new RectangleGeometry
478
                    {
479
                        Rect = new Rect()
480
                        {
481
                            X = Canvas.GetLeft((member as TextControl)),
482
                            Y = Canvas.GetTop((member as TextControl)),
483
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
484
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
485
                        }
486
                    };
487
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
488
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
489

    
490

    
491
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
492
                    DragThumb.RenderTransform = new RotateTransform()
493
                    {
494
                        Angle = (member as TextControl).CommentAngle,
495
                    };
496

    
497
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
498
                    AdornerBorder.RenderTransform = new RotateTransform()
499
                    {
500
                        Angle = (member as TextControl).CommentAngle,
501
                    };
502

    
503
                    ((TextControl)member).PropertyChanged += TextControlPropertyChanged;
504
                    ((TextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
505
                    break;
506
                default:
507
                    break;
508
                    #endregion
509
            }
510

    
511
            if (member.GetType().Name == "TextControl")
512
            {
513
                TextControl content = ((TextControl)member);
514
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
515
                content.EndPoint = content.StartPoint;
516
            }
517
            else
518
            {
519
                RegistryPoint(member);
520
            }
521
            BorderUpdate();
522

    
523
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
524
                Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
525
        }
526

    
527

    
528
        public void SetAdornerMember(List<CommentUserInfo> members)
529
        {
530
            foreach (var member in members)
531
            {
532
                switch (member.GetType().Name)
533
                {
534
                    #region 컨트롤 조건
535
                    case "LineControl":
536
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
537
                        break;
538
                    case "ImgControl":
539
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
540
                        break;
541
                    case "ArrowControl":
542
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
543
                        break;
544
                    case "PolygonControl":
545
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
546
                        break;
547
                    case "ArrowTextControl":
548
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
549
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
550
                        break;
551
                    case "ArcControl":
552
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
553
                        break;
554
                    case "ArrowArcControl":
555
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
556
                        break;
557
                    case "DateControl":
558
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
559
                        break;
560
                    case "ArrowControl_Multi":
561
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
562
                        break;
563
                    case "RectangleControl":
564
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
565
                        break;
566
                    case "TriControl":
567
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
568
                        break;
569
                    case "CircleControl":
570
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
571
                        break;
572
                    case "CloudControl":
573
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
574
                        break;
575
                    case "RectCloudControl":
576
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
577
                        break;
578
                    case "SignControl":
579
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
580
                        break;
581
                    case "SymControl":
582
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
583
                        break;
584
                    case "SymControlN":
585
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
586
                        break;
587
                    case "InkControl":
588
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
589
                        break;
590
                    case "TextControl":
591
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
592

    
593
                        (member as TextControl).PropertyChanged += TextControlPropertyChanged;
594
                        (member as TextControl).Base_TextBox.SelectionChanged += TextControlSelectionChanged;
595

    
596
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
597
                        //{
598
                        //    BorderUpdate();
599
                        //});
600
                        //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
601
                        //{
602
                        //    BorderUpdate();
603
                        //    try
604
                        //    {
605
                        //        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
606
                        //    }
607
                        //    catch (Exception)
608
                        //    {
609

    
610
                        //    }
611

    
612
                        //});
613
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
614
                        //{
615
                        //    BorderUpdate();
616
                        //});
617
                        break;
618
                    case "InsideWhiteControl":
619
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
620
                        break;
621
                    case "OverlapWhiteControl":
622
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
623
                        break;
624
                    case "ClipWhiteControl":
625
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
626
                        break;
627
                    case "CoordinateControl":
628
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
629
                        break;
630
                    default:
631
                        break;
632
                        #endregion
633
                }
634
                if (member.GetType().Name == "TextControl")
635
                {
636
                    TextControl content = ((TextControl)member);
637
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
638
                    content.EndPoint = content.StartPoint;
639
                }
640
                else
641
                {
642
                    RegistryPoint(member, members.Count);
643
                }
644

    
645
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
646
                    Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
647
            }
648

    
649
            BorderUpdate();
650
        }
651

    
652

    
653
        /// <summary>
654
        /// Border 를 갱신
655
        /// </summary>
656
        public void BorderUpdate()
657
        {
658
            AdornerBorder.MinWidth = 10;
659
            AdornerBorder.MinHeight = 10;
660

    
661
            double minX = double.MaxValue;
662
            double minY = double.MaxValue;
663
            double maxX = double.MinValue;
664
            double maxY = double.MinValue; 
665
            double lineSize = 0;
666
            double marginSize = 0;
667
            if (this.Members.Count == 1)
668
            {
669
                if (this.Members[0].DrawingData.GetType().Name == "TextControl")
670
                {
671
                    if ((this.Members[0].DrawingData as TextControl).CommentAngle != 0)
672
                    {
673
                        trRotate.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
674
                        trRotateThumb.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
675
                    }
676
                    else
677
                    {
678
                        trRotate.Angle = 0;
679
                        trRotateThumb.Angle = 0;
680
                    }
681
                }
682
            }
683

    
684
            foreach (var item in this.Members)
685
            {
686
                UIElement currentControl = item.DrawingData;
687
                
688
                Point startP = (currentControl as IPath).StartPoint;
689
                Point endP = (currentControl as IPath).EndPoint;
690

    
691
                // ViewerDataModel.Instance.Angle = MathSet.returnAngle(startP, ref endP, ViewerDataModel.Instance.IsPressShift);
692

    
693
                // 컨트롤의 angle변환시 상단 anglecontrol에 출력
694
                ViewerDataModel.Instance.MarkupAngle = (currentControl as CommentUserInfo).CommentAngle;
695

    
696
                if (item.DrawingData.GetType().Name == "TextControl")
697
                {
698
                    double textControlWidth;
699
                    double textControlHeight;
700
                             
701
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
702
                    {
703
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
704
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
705
                    }
706
                    else
707
                    {
708
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
709
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
710
                    }
711
                    
712
                    if ((currentControl as TextControl).EndPoint.X < minX)
713
                    {
714
                        minX = (currentControl as TextControl).EndPoint.X;
715
                    }
716

    
717
                    if ((currentControl as TextControl).EndPoint.Y < minY)
718
                    {
719
                        minY = (currentControl as TextControl).EndPoint.Y;
720
                    }
721

    
722
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
723
                    {
724
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
725
                    }
726

    
727
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
728
                    {
729
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
730
                    }
731
                    if ((currentControl as TextControl).ControlType_No == 2)
732
                        marginSize = (((currentControl as TextControl).Base_TextPath).ActualHeight - ((currentControl as TextControl).Base_Border).ActualHeight) / 2 + (((dynamic)currentControl).LineSize.Left / 2) + (currentControl as TextControl).ArcLength - 30;
733
                    if ((currentControl as TextControl).ControlType_No == 1)
734
                        marginSize = ((dynamic)currentControl).LineSize.Left;
735
                }
736
                else if ((currentControl as IViewBox) != null)
737
                {
738
                    IViewBox instance = currentControl as IViewBox;
739
                    List<Point> am = (currentControl as IPath).PointSet;
740
                    List<double> xSet = am.Select(p => p.X).ToList();
741
                    List<double> ySet = am.Select(p => p.Y).ToList();
742
                    if (xSet.Min() < minX) minX = xSet.Min();
743
                    if (ySet.Min() < minY) minY = ySet.Min();
744
                    if (xSet.Max() > maxX) maxX = xSet.Max();
745
                    if (ySet.Max() > maxY) maxY = ySet.Max();
746
                }
747
                else if ((currentControl as IPath).PathData == null)
748
                {
749
                    Rect rt = new Rect
750
                    {
751
                        X = (currentControl as IPath).StartPoint.X,
752
                        Y = (currentControl as IPath).StartPoint.Y,
753
                        Width = Math.Max((currentControl as IPath).EndPoint.X, (currentControl as IPath).StartPoint.X) - Math.Min((currentControl as IPath).EndPoint.X, (currentControl as IPath).StartPoint.X),
754
                        Height = Math.Max((currentControl as IPath).EndPoint.Y, (currentControl as IPath).StartPoint.Y) - Math.Min((currentControl as IPath).EndPoint.Y, (currentControl as IPath).StartPoint.Y),
755
                    };
756
                    if (rt.Left < minX) minX = rt.Left;
757
                    if (rt.Top < minY) minY = rt.Top;
758
                    if (rt.Right > maxX) maxX = rt.Right;
759
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
760
                }
761
                else if ((currentControl as IPath) == null)
762
                {
763
                    Rect rt = new Rect
764
                    {
765
                        X = (currentControl as IPath).StartPoint.X,
766
                        Y = (currentControl as IPath).StartPoint.Y,
767
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
768
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
769
                    };
770
                    if (rt.Left < minX) minX = rt.Left;
771
                    if (rt.Top < minY) minY = rt.Top;
772
                    if (rt.Right > maxX) maxX = rt.Right;
773
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
774
                }
775
                else if (currentControl is CircleControl CircleCtrl)
776
                {
777
                    List<Point> am = CircleCtrl.PointSet;
778
                    lineSize = CircleCtrl.LineSize;
779

    
780
                    List<double> xSet = am.Select(p => p.X).ToList();
781
                    List<double> ySet = am.Select(p => p.Y).ToList();
782
                    if (xSet.Min() < minX) minX = xSet.Min();
783
                    if (ySet.Min() < minY) minY = ySet.Min();
784
                    if (xSet.Max() > maxX) maxX = xSet.Max();
785
                    if (ySet.Max() > maxY) maxY = ySet.Max();
786
                }
787
                else 
788
                {
789
                    lineSize = ((dynamic)currentControl).LineSize;
790
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
791
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
792
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
793
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
794
                }
795
            }
796

    
797
            Rect ac = new Rect(minX , minY, maxX - minX, maxY - minY);
798
            bool addWidthSize = false;
799
            bool addHeightSize = false;
800
            if (ac.Width <= 10)
801
            {
802
                ac.Width += 10;
803
                addWidthSize = true;
804
            }
805
            if (ac.Height <= 10)
806
            {
807
                ac.Height += 10;
808
                addHeightSize = true;
809
            }
810
            BorderSize = ac;
811
            //lineSize : Thickness 굵기에 따라서 adoner 수정 
812
            ac.Width += lineSize;
813
            ac.Height += lineSize;
814
            AdornerBorder.MinWidth = 10;
815
            AdornerBorder.MinHeight = 10;
816
            AdornerBorder.Width = ac.Width;
817
            AdornerBorder.Height = ac.Height;
818
            minX -= lineSize / 2;
819
            minY -= lineSize / 2;
820
            Canvas.SetLeft(AdornerBorder, minX);
821
            Canvas.SetTop(AdornerBorder, minY);
822

    
823
            DragThumb.Width = ac.Width;
824
            DragThumb.Height = ac.Height;
825
            rotateTop.Margin = new Thickness(rotateTop.Margin.Left, -30 - marginSize, rotateTop.Margin.Right, rotateTop.Margin.Bottom);
826
            DragThumb.MinWidth = 10;
827
            DragThumb.MinHeight = 10;
828
            if (addWidthSize)
829
            {
830
                Canvas.SetLeft(DragThumb, minX - 5);
831
            }
832
            else
833
            {
834
                Canvas.SetLeft(DragThumb, minX);
835
            }
836

    
837
            if (addHeightSize)
838
            {
839
                Canvas.SetTop(DragThumb, minY - 5);
840
            }
841
            else
842
            {
843
                Canvas.SetTop(DragThumb, minY);
844
            }
845
        }
846

    
847
        /// <summary>
848
        /// UIElement 해제
849
        /// </summary>
850
        public void UnRegister()
851
        {
852
            foreach (var item in this.ContainerContent.Children)
853
            {
854
                if (item is MarkupToPDF.Common.CommentUserInfo)
855
                {
856
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
857
                }
858
            }
859
            this.ContainerContent.Children.Clear();
860
        }
861

    
862
        /// <summary>
863
        /// 각 포인트들을 등록합니다.
864
        /// </summary>
865
        /// <param name="pointset">Drawing Point</param>
866
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
867
        {
868
            int count = 0;
869
            List<Point> pts = (member as IPath).PointSet;
870
            if (member.GetType().Name == "InkControl")
871
            {
872
                pts.Clear();
873
                pts.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
874
                pts.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
875
                pts.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
876
                pts.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
877
            }
878
            ControlType markT = this.Members.First(p => p.DrawingData == member).Drawingtype;
879
            double Minx = pts.Min(x => x.X);
880
            double Miny = pts.Min(x => x.Y);
881

    
882
            for (int i = 0; i < pts.Count; i++)
883
            {
884
                MyThumb tm = new MyThumb
885
                {
886
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
887
                };
888

    
889
                this.Members.Last().ThumbList.Add(tm);
890

    
891
                if ((markT == ControlType.ArcLine && pts[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && pts[i] == (member as ArrowArcControl).MiddlePoint))
892
                {
893
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
894
                }
895
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
896
                {
897
                    //if (this.Members.Count()<=1)
898
                    //{
899
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
900
                    List<Point> ps = new List<Point>();
901

    
902
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
903
                    {
904
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
905

    
906
                        switch (Math.Abs(temp.CommentAngle).ToString())
907
                        {
908
                            case "90":
909
                                {
910
                                    ps.Clear();
911
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
912
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
913
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
914

    
915
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간
916
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단
917

    
918
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); //중간 하단
919
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 하단
920

    
921
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
922
                                }
923
                                break;
924
                            case "270":
925
                                {
926
                                    ps.Clear();
927
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
928
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
929
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
930

    
931
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간
932
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단
933

    
934
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); //중간 하단
935
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 하단
936

    
937
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
938
                                }
939
                                break;
940
                            default:
941
                                {
942
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
943
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
944
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
945
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
946
                                }
947
                                break;
948
                        }
949

    
950
                        ArrowTextControl instance = (member as ArrowTextControl);
951
                        if (instance.isTrans)
952
                        {
953
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
954
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
955
                            //list[count] = tempP;
956
                            pts[count] = temp.MidPoint;
957
                        }
958
                        else
959
                        {
960
                            if (temp.isFixed)
961
                            {
962
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
963
                                var testP = endP;
964
                                if (ps[0] == endP) //상단
965
                                {
966
                                    testP = new Point(endP.X, endP.Y - 50);
967
                                }
968
                                else if (ps[1] == endP) //하단
969
                                {
970
                                    testP = new Point(endP.X, endP.Y + 50);
971
                                }
972
                                else if (ps[2] == endP) //좌단
973
                                {
974
                                    testP = new Point(endP.X - 50, endP.Y);
975
                                }
976
                                else if (ps[3] == endP) //우단
977
                                {
978
                                    testP = new Point(endP.X + 50, endP.Y);
979
                                }
980
                                pts[count] = testP;
981
                            }
982
                            else
983
                            {
984
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
985
                                pts[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
986
                            }
987
                        }
988
                    }
989
                }
990

    
991
                /// ArrowTextControl text box 화면 출력
992
                if (member.GetType().Name == "ArrowTextControl" && pts[i] == pts.Last())
993
                {
994
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
995
                    tm.Width = (member as ArrowTextControl).BoxWidth;
996
                    tm.Height = (member as ArrowTextControl).BoxHeight;
997
                    var angle = (member as ArrowTextControl).PageAngle;
998
                    if (Math.Abs(angle).ToString() == "90")
999
                    {
1000
                        tm.RenderTransformOrigin = new Point(0, 0);
1001
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
1002
                    }
1003
                    else if (Math.Abs(angle).ToString() == "270")
1004
                    {
1005
                        tm.RenderTransformOrigin = new Point(0, 0);
1006
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
1007
                    }
1008
                    else
1009
                    {
1010
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
1011
                        tm.RenderTransform = new RotateTransform()
1012
                        {
1013
                            Angle = angle
1014
                        };
1015
                    }
1016
                }
1017
                
1018
                if (member.GetType().Name == "CloudControl")
1019
                {
1020
                    if (i == pts.Count() - 1)
1021
                    {
1022
                        tm.Visibility = System.Windows.Visibility.Collapsed;
1023
                    }
1024
                }
1025
                if (member.GetType().Name == "PolygonControl")
1026
                {
1027
                    if (i == pts.Count() - 1)
1028
                    {
1029
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
1030
                        {
1031

    
1032
                        }
1033
                        else
1034
                        {
1035
                            tm.Visibility = System.Windows.Visibility.Collapsed;
1036
                        }
1037
                    }
1038
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
1039
                    {
1040
                        tm.Visibility = System.Windows.Visibility.Collapsed;
1041
                    }
1042
                }
1043
                
1044
                this.ContainerContent.Children.Add(tm);
1045
                Canvas.SetLeft(tm, pts[count].X);
1046
                Canvas.SetTop(tm, pts[count].Y);
1047
                if (member.GetType().Name == "ArrowTextControl" && pts[i] == (member as ArrowTextControl).MidPoint)
1048
                {
1049
                    Canvas.SetZIndex(tm, 95);
1050
                    //tm.Opacity = 0;
1051
                    tm.DragDelta += MidPoint_DragDelta;
1052
                }
1053
                else
1054
                {
1055
                    tm.DragDelta += ResizeTm_DragDelta;
1056
                    Canvas.SetZIndex(tm, 99);
1057
                }
1058

    
1059
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
1060
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
1061
                
1062
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
1063
                count++;
1064
            }
1065
        }
1066

    
1067
        private void MidPoint_DragDelta(object sender, DragDeltaEventArgs e)
1068
        {
1069
            MyThumb thumb = sender as MyThumb;
1070
            double newHorizontalChange = e.HorizontalChange;
1071
            double newVerticalChange = e.VerticalChange;
1072

    
1073
            var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), 0);// commentInfo.VisualPageAngle);
1074

    
1075
            var direction = VisualHelper.GetPointDirection(newpoint, ViewerDataModel.Instance.PageAngle);
1076

    
1077
            System.Diagnostics.Debug.WriteLine("뱡향 : " + direction.ToString());
1078

    
1079
            AdornerMember control = CurrentAdornerMember(thumb);
1080
            var commentInfo = (control.DrawingData) as CommentUserInfo;
1081

    
1082
            if (commentInfo is ArrowTextControl)
1083
            {
1084
                Point getThumbPoint = GetPosition(thumb);
1085

    
1086
                var arrowText = commentInfo as ArrowTextControl;
1087

    
1088
                //var midPoint = MathSet.getMiddlePoint(arrowText.StartPoint, arrowText.EndPoint);
1089
                //arrowText.MidPoint = newpoint;
1090
                thumb.Translate(newpoint.X, newpoint.Y, this.AngleValue);
1091
          
1092
                commentInfo.OnMoveCtrlPoint(getThumbPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1093

    
1094
                control.UpdateThumb();
1095

    
1096
                System.Diagnostics.Debug.WriteLine($"text {Canvas.GetLeft(arrowText.Base_TextBox)},{Canvas.GetTop(arrowText.Base_TextBox)}");
1097

    
1098
                System.Diagnostics.Debug.WriteLine($"Page Angle : {ViewerDataModel.Instance.PageAngle} GetPoint : {getThumbPoint.X},{getThumbPoint.Y}  Change Value : {newpoint.X},{newpoint.Y}");
1099
            }
1100

    
1101
        }
1102
        
1103

    
1104
        /// <summary>
1105
        /// 제어점을 조정하여 크기를 수정한다.
1106
        /// </summary>
1107
        /// <param name="sender"></param>
1108
        /// <param name="e"></param>
1109
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
1110
        {
1111
            if (sender.GetType() != typeof(MyThumb)) return;
1112

    
1113
            MyThumb thumb = sender as MyThumb;
1114

    
1115
            if (this.Members.Count > 1) return;
1116

    
1117
            System.Diagnostics.Debug.WriteLine($"Value {e.HorizontalChange},{e.VerticalChange}");
1118

    
1119
            double newHorizontalChange = e.HorizontalChange;
1120
            double newVerticalChange = e.VerticalChange;
1121

    
1122
            //if (reSizePoint != new Point(0, 0))
1123
            //{
1124
                //Point setPoint = Mouse.GetPosition(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanCanvas);
1125

    
1126
                Point setPoint = GetPosition(thumb);
1127

    
1128
                //System.Diagnostics.Debug.WriteLine($"1. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}  Change Value : {newHorizontalChange},{newVerticalChange}");
1129

    
1130
                AdornerMember control = CurrentAdornerMember(thumb);
1131
                var commentInfo = (control.DrawingData) as CommentUserInfo;
1132

    
1133
                double ratatePointAngle = 0;
1134

    
1135
                if (commentInfo is ArrowTextControl)
1136
                {
1137
                    var textControl = (commentInfo as ArrowTextControl);
1138

    
1139
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1140

    
1141
                    {
1142
                        textControl.CommentAngle = 0;
1143
                        this.AngleValue = 0;
1144
                        ratatePointAngle = commentInfo.VisualPageAngle;
1145
                    }
1146
                    else
1147
                    {   
1148
                        //textControl.CommentAngle = commentInfo.VisualPageAngle + MathSet.returnAngle(textControl.StartPoint, ref tempPoint, ViewerDataModel.Instance.IsPressShift);
1149
                        textControl.OnCreatingMouseMove(textControl.EndPoint, ViewerDataModel.Instance.IsPressShift);
1150
                        this.AngleValue = textControl.CommentAngle;
1151
                        commentInfo.CommentAngle = this.AngleValue;
1152
                    }
1153
                        //CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1154
                }
1155
                System.Diagnostics.Debug.WriteLine("## Angle : " + this.AngleValue + " ##");
1156
                thumb.Translate(newHorizontalChange, newVerticalChange, this.AngleValue);
1157

    
1158
                // 페이지회전에 따른 화살표텍스트 박스의 이동 수정
1159

    
1160
                var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1161
     
1162
                Point thumbPoint = MathHelper.RotatePoint(setPoint, new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1163

    
1164
                //thumbPoint.X = Math.Abs(thumbPoint.X);
1165
                //thumbPoint.Y = Math.Abs(thumbPoint.Y);
1166

    
1167
                //if ((setPoint.X + newpoint.X) < 0 || (Math.Abs(thumbPoint.X) + newpoint.X) - ViewerDataModel.Instance.ImageViewWidth > 0)
1168
                //{
1169
                //    newpoint.X = 0;
1170
                //}
1171

    
1172
                //if (setPoint.Y + newpoint.Y < 0 || (Math.Abs(thumbPoint.Y) + newpoint.Y) - ViewerDataModel.Instance.ImageViewHeight > 0)
1173
                //{
1174
                //    newpoint.Y = 0;
1175
                //}
1176

    
1177
                commentInfo.OnMoveCtrlPoint(setPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1178

    
1179
                //System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1180
                control.UpdateThumb();
1181

    
1182
                //System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1183
                this.BorderUpdate();
1184

    
1185
               //System.Diagnostics.Debug.WriteLine($"5. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1186
            //}
1187
        }
1188

    
1189
        private AdornerMember CurrentAdornerMember(MyThumb thumb)
1190
        {
1191
            AdornerMember result = null;
1192

    
1193
            try
1194
            {
1195
                result = (from userThumb in this.Members
1196
                            where userThumb.ThumbList.Contains(thumb)
1197
                            select userThumb).FirstOrDefault();
1198
            }
1199
            catch (Exception ex)
1200
            {
1201
                App.FileLogger.Error(ex);
1202
            }
1203

    
1204
            return result;
1205
        }
1206

    
1207
        private Point GetPosition(Thumb thumb)
1208
        {
1209
            return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
1210
        }
1211

    
1212
        #endregion
1213
        #region 이벤트
1214

    
1215
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1216
        {
1217
            this.isDragging = false;
1218
            DraggerThumb = null;
1219

    
1220

    
1221
            var comments = (from drawing in this.Members
1222
                            select drawing.DrawingData as CommentUserInfo).ToList();
1223
            ViewerDataModel.Instance.IsMarkupUpdate = true;
1224
        }
1225

    
1226
        /// <summary>
1227
        /// start drag
1228
        /// </summary>
1229
        /// <param name="sender"></param>
1230
        /// <param name="e"></param>
1231
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1232
        {
1233
            this.DraggerThumb = sender as Thumb;
1234
            this.isDragging = true;
1235

    
1236
            if (ViewerDataModel.Instance.UndoDataList == null)
1237
            {
1238
                return;
1239
            }
1240

    
1241
            var comments = (from drawing in this.Members
1242
                            select drawing.DrawingData as CommentUserInfo).ToList();
1243

    
1244
            UndoCommand.Instance.Push(EventType.Operation, comments);
1245
        }
1246

    
1247
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1248
        {
1249
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1250
            {
1251
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1252
                    IsTextAngle = true;
1253
                else
1254
                    IsTextAngle = false;
1255
                LastRotateVerticalValue = e.GetPosition(this).X;
1256
            }
1257
            else
1258
            {
1259
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1260
                {
1261
                    RotateFlag = true;
1262
                }
1263
                else
1264
                {
1265
                    RotateFlag = false;
1266
                }
1267
                LastRotateHorizontalValue = e.GetPosition(this).X;
1268
            }
1269
        }
1270

    
1271
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1272
        {
1273
            /// save mouse down and current mouse point
1274
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1275
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1276
            /// up to here
1277

    
1278
            if (ViewerDataModel.Instance.UndoDataList == null)
1279
            {
1280
                return;
1281
            }
1282

    
1283
            var comments = (from drawing in this.Members
1284
                            select drawing.DrawingData as CommentUserInfo).ToList();
1285

    
1286
            UndoCommand.Instance.Push(EventType.Operation, comments);
1287
        }
1288

    
1289
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1290
        {
1291
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1292

    
1293
            var comments = (from drawing in this.Members
1294
                            select drawing.DrawingData as CommentUserInfo).ToList();
1295
        }
1296

    
1297
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1298
        {
1299
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1300

    
1301
            var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1302
         
1303
            var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1304
            var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1305

    
1306
            try
1307
            {
1308
                DragThumb.Cursor = Cursors.SizeAll;
1309
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1310
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1311

    
1312

    
1313
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1314

    
1315
                mainRect = MathHelper.RotateRect(ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect(), new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1316

    
1317
                var rect = (this.ContainerContent.FindChildByType<CommentUserInfo>() as CommentUserInfo).ItemRect; //this.AdornerBorder.Bounds(ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel);
1318

    
1319
                var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1320
                
1321
                var moveDirection = mainRect.Movement(rotationRect);
1322

    
1323
                System.Diagnostics.Debug.WriteLine($"horzChange: {horzChange} , vertChange:{vertChange}");
1324

    
1325
                this.TranslateItems(horzChange, vertChange);
1326
            }
1327
            finally
1328
            {
1329
                /// update CurrentMousePoint
1330
                this.CurrentMousePoint = newMousePoint;
1331
            }
1332
        }
1333

    
1334
        /// <summary>
1335
        /// translate all members
1336
        /// </summary>
1337
        /// <param name="e"></param>
1338
        public void TranslateItems(double dx, double dy)
1339
        {
1340
            Dispatcher.BeginInvoke((Action)(() =>
1341
            {
1342
                foreach (var item in this.Members)
1343
                {
1344
                    this.TranslateItem(dx, dy, item);
1345
                }
1346

    
1347
                this.BorderUpdate();
1348
            }));
1349
        }
1350

    
1351
        /// <summary>
1352
        /// translate a item
1353
        /// </summary>
1354
        /// <param name="e"></param>
1355
        /// <param name="item"></param>
1356
        private void TranslateItem(double dx, double dy, AdornerMember item)
1357
        {
1358
            /// rotate point with page rotation
1359
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1360
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1361
            /// up to here
1362
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1363

    
1364
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1365
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), EventType.Operation, null, null);            
1366

    
1367
            item.UpdateThumb();
1368
        }
1369

    
1370
        private void resize_MouseMove(object sender, MouseEventArgs e)
1371
        {
1372
            //reSizePoint = e.GetPosition(this);
1373
        }
1374

    
1375
        /// <summary>
1376
        /// 회전
1377
        /// </summary>
1378
        /// <param name="sender"></param>
1379
        /// <param name="e"></param>
1380
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1381
        {
1382
            MoveRotate(e);
1383
        }
1384

    
1385
        double LastRotateHorizontalValue = 0;
1386
        double LastRotateVerticalValue = 0;
1387
        bool RotateFlag = false;
1388

    
1389
        /// <summary>
1390
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1391
        /// </summary>
1392
        /// <param name="e"></param>
1393
        public void MoveRotate(DragDeltaEventArgs e)
1394
        {
1395
            Point CenterPoint = this.Centeroid;
1396
            Point pt = Mouse.GetPosition(this);
1397

    
1398
            #region X축 기준으로 회전 각도를 구한다.
1399
            Vector AxisX = new Vector(RotatedPoint.X - CenterPoint.X, RotatedPoint.Y - CenterPoint.Y);
1400
            AxisX.Normalize();
1401
            Vector AxisY = new Vector(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1402
            AxisY.Normalize();
1403
            double dDeltaAngle = Vector.AngleBetween(AxisX, AxisY);
1404
            #endregion
1405

    
1406
            _ActualAngle += dDeltaAngle;
1407
            if (_ActualAngle > 360) _ActualAngle -= 360;
1408
            if (_ActualAngle < 0) _ActualAngle += 360;
1409
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1410
            if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
1411
            {
1412
                double tmp = AlignedAngles.OrderBy(x => Math.Abs(_ActualAngle - x)).First();
1413
                dDeltaAngle = tmp - AngleValue;
1414
                AngleValue = tmp;
1415
            }
1416
            else
1417
            {
1418
                AngleValue = _ActualAngle;
1419
            }
1420
            #endregion
1421

    
1422
            /// save rotatePoint
1423
            this.RotatedPoint = pt;
1424

    
1425
            Dispatcher.BeginInvoke((Action)(() =>
1426
            {
1427
                foreach (var member in this.Members)
1428
                {
1429
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1430
                    #region 보더 업데이트
1431
                    switch (member.Drawingtype)
1432
                    {
1433
                        case ControlType.TextControl:
1434
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1435

    
1436
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1437
                            DragThumb.RenderTransform = new RotateTransform()
1438
                            {
1439
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1440
                            };
1441

    
1442
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1443
                            AdornerBorder.RenderTransform = new RotateTransform()
1444
                            {
1445
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1446
                            };
1447

    
1448
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1449
                            BorderUpdate();
1450
                            break;
1451

    
1452
                        case ControlType.ArrowMultiLine:
1453
                        case ControlType.ArcLine:
1454
                        case ControlType.ArcArrow:
1455
                        case ControlType.SingleLine:
1456
                        case ControlType.Triangle:
1457
                        case ControlType.ArrowTextControl:
1458
                        case ControlType.PolygonControl:
1459
                        case ControlType.Ink:
1460
                            BorderUpdate();
1461
                            break;
1462
                        case ControlType.Date:
1463
                        case ControlType.RectCloud:
1464
                        case ControlType.Rectangle:
1465
                        case ControlType.ImgControl:
1466
                        case ControlType.Sign:
1467
                        case ControlType.Symbol:
1468
                        case ControlType.Stamp:
1469
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1470
                            BorderUpdate();
1471
                            break;
1472
                        case ControlType.PolygonCloud:
1473
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1474
                            BorderUpdate();
1475
                            break;
1476
                        case ControlType.Circle:
1477
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1478
                            ((CircleControl)member.DrawingData).SetCenterXY();
1479
                            BorderUpdate();
1480
                            break;
1481
                        default:
1482
                            break;
1483
                    }
1484
                }
1485
                #endregion
1486
            }));
1487
        }
1488

    
1489
        /// <summary>
1490
        /// 객체 회전 시작
1491
        /// </summary>
1492
        /// <param name="sender"></param>
1493
        /// <param name="e"></param>
1494
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1495
        {            
1496
            this.RotatedPoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1497
            rotateTop.Cursor = Cursors.SizeAll;
1498

    
1499
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1500
            if ((1 == this.Members.Count) && (this.Members[0]).DrawingData.GetType().Name == "TextControl")
1501
            {
1502
                this.AngleValue = ((this.Members[0]).DrawingData as TextControl).CommentAngle;
1503
            }
1504
            /// up to here
1505

    
1506
            if (ViewerDataModel.Instance.UndoDataList == null)
1507
            {
1508
                return;
1509
            }
1510

    
1511
            var comments = (from drawing in this.Members
1512
                            select drawing.DrawingData as CommentUserInfo).ToList();
1513
            UndoCommand.Instance.Push(EventType.Operation, comments);
1514
        }
1515
        
1516
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1517
        {
1518
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1519

    
1520
            var comments = (from drawing in this.Members
1521
                            select drawing.DrawingData as CommentUserInfo).ToList();
1522
        }
1523

    
1524
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1525
        {
1526
            AdornerMember control = this.Members.FirstOrDefault();
1527

    
1528
            if ((control.DrawingData as ArrowTextControl) != null)
1529
            {
1530
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1531
                {
1532
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1533
                }
1534
            }
1535

    
1536
        }
1537

    
1538
        public void TextControlChanger()
1539
        {
1540
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1541
            {
1542
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1543
                AllControl.Base_TextBox.Focus();
1544
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1545
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1546
                AllControl.Base_TextBox.IsHitTestVisible = true;
1547
                AllControl.IsEditingMode = true;
1548
                AllControl.Base_TextBox.Focus();
1549

    
1550
                AllControl.SizeChanged += (sen, ea) =>
1551
                {
1552
                    if (AllControl.Base_TextBox != null)
1553
                    {
1554
                        RectangleGeometry Data = new RectangleGeometry
1555
                        {
1556
                            Rect = new Rect()
1557
                            {
1558
                                X = AllControl.StartPoint.X,
1559
                                Y = AllControl.StartPoint.Y,
1560
                                Width = AllControl.Base_TextBox.Width,
1561
                                Height = AllControl.Base_TextBox.Height,
1562
                            }
1563
                        };
1564

    
1565
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1566
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1567
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1568
                        {
1569
                            Angle = AllControl.CommentAngle,
1570
                            CenterX = middle.X,
1571
                            CenterY = middle.Y,
1572
                        };
1573
                    }
1574
                    BorderUpdate();
1575
                };
1576
            }
1577
        }
1578

    
1579
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1580
        {
1581
            if (e.ClickCount == 2 && this.Members.Count == 1)
1582
            {
1583
                if (this.Members[0].DrawingData.GetType().Name == "TextControl")
1584
                {
1585
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1586
                    TextControlChanger();                    
1587
                }
1588

    
1589
                else if (this.Members[0].DrawingData.GetType().Name == "ArrowTextControl")
1590
                {
1591
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1592
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1593
               
1594
                    //ArrowControl TextBox Thumb없애기
1595
                    tm.Visibility = Visibility.Collapsed;
1596

    
1597
                    (this.Members[0].DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1598
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1599

    
1600
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1601
                    
1602

    
1603
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1604

    
1605
                    {
1606
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1607
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1608

    
1609
                        List<Point> ps = new List<Point>();
1610
                        
1611
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1612
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1613
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1614
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1615

    
1616
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1617
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1618
                        if (AllControl.isTrans)
1619
                        {
1620
                            Canvas.SetLeft((this.Members[0]).ThumbList[1], AllControl.MidPoint.X);
1621
                            Canvas.SetTop((this.Members[0]).ThumbList[1], AllControl.MidPoint.Y);
1622
                        }
1623
                        else
1624
                        {
1625
                            Canvas.SetLeft((this.Members[0]).ThumbList[1], tempP.X);
1626
                            Canvas.SetTop((this.Members[0]).ThumbList[1], tempP.Y);
1627
                        }
1628

    
1629

    
1630
                        BorderUpdate();
1631

    
1632
                    };
1633
                }
1634
                else if ((this.Members[0]).DrawingData.GetType().Name == "DateControl")
1635
                {
1636
                    DateControl data = (this.Members[0]).DrawingData as DateControl;
1637
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1638
                    //dropData.IsOpen = true;
1639
                    RadWindow rc = new RadWindow();
1640
                    rc.Width = 300;
1641
                    rc.Height = 300;
1642
                    rc.Header = "Change Date";
1643
                    rc.Content = instanceCal;
1644
                    rc.BorderThickness = new Thickness(3);
1645
                    rc.ResizeMode = ResizeMode.NoResize;
1646
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1647
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1648
                    rc.ModalBackground.Opacity = 0.6;
1649
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1650
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1651
                    {
1652
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1653
                        rc.Close();
1654
                    };
1655
                    rc.ShowDialog();
1656
                    //CalendarControl.xaml
1657
                }
1658
                else if ((this.Members[0]).DrawingData.GetType().Name == "ArcControl")
1659
                {
1660
                    ArcControl instance = ((this.Members[0]).DrawingData as ArcControl);
1661
                    if (instance.isTransOn)
1662
                    {
1663
                        instance.isTransOn = false;
1664
                    }
1665
                    else
1666
                    {
1667
                        instance.isTransOn = true;
1668
                    }
1669
                    ///instance.SetArcPath();
1670
                    BorderUpdate();
1671
                }
1672
                else if ((this.Members[0]).DrawingData.GetType().Name == "ArrowArcControl")
1673
                {
1674
                    ArrowArcControl instance = ((this.Members[0]).DrawingData as ArrowArcControl);
1675
                    if (instance.isTransOn)
1676
                    {
1677
                        instance.isTransOn = false;
1678
                    }
1679
                    else
1680
                    {
1681
                        instance.isTransOn = true;
1682
                    }
1683
                    instance.SetArcPath();
1684
                    BorderUpdate();
1685
                }
1686
            }
1687
        }
1688
        #endregion
1689

    
1690
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1691
        {
1692
            if (this.Members[0].DrawingData.GetType().Name == "TextControl" 
1693
                || this.Members[0].DrawingData.GetType().Name == "ArrowTextControl")
1694
            {
1695
                DragThumb.Visibility = Visibility.Collapsed;
1696
            }
1697
        }
1698
    }
1699
}
클립보드 이미지 추가 (최대 크기: 500 MB)