프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 0d97ab05

이력 | 보기 | 이력해설 | 다운로드 (75.6 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
        public long Group_ID { get; set; }
76

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

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

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

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

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

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

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

    
158
        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 };
159

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

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

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

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

    
189
        private bool disposed;
190

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

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

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

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

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

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

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

    
249
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
250
        {
251
            InitializeComponent();
252
            foreach (var item in objectData)
253
            {
254
                //item.IsHitTestVisible = false;
255
                if (item is ArrowTextControl ArrTextCtrl)
256
                {
257
                    ArrTextCtrl.Base_TextBox.Focusable = true;
258
                }
259
                try
260
                {
261
                    ///Canvas.SetZIndex(item, 80);
262

    
263
                    item.Index = ViewerDataModel.Instance.MarkupControls_USER.IndexOf(item);
264
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
265
                    this.ContainerContent.Children.Add(item);
266
                }
267
                catch (Exception ex)
268
                {
269
                    throw new InvalidOperationException(ex.Message);
270
                }
271
                finally
272
                {
273

    
274
                }
275
            }
276

    
277
            this.SetAdornerMember(objectData);
278
            this.Focus();
279
        }
280

    
281
        ~AdornerFinal()
282
        {
283
            this.Dispose(false);
284
        }
285

    
286
        public void Dispose()
287
        {
288
            this.Dispose(true);
289
            GC.SuppressFinalize(this);
290
        }
291

    
292
        protected virtual void Dispose(bool disposing)
293
        {
294
            if (this.disposed) return;
295
            if (disposing)
296
            {
297
                foreach (var member in this.Members)
298
                {
299
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
300
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
301
                }
302
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
303
            }
304
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
305
            this.disposed = true;
306
        }
307

    
308
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
309
        {
310
            mainDragThumb = DragThumb;
311
        }
312

    
313
        public Point Centeroid
314
        {
315
            get
316
            {
317
                List<Point> pts = new List<Point>();
318

    
319
                #region 센터 포인트 구하기 (그룹핑)
320
                foreach (var item in this.Members)
321
                {
322
                    if (item.DrawingData.GetType().Name == "TextControl")
323
                    {
324
                        if (AngleValue == 0)
325
                        {
326
                            AngleValue = (item.DrawingData as TextControl).CommentAngle;
327
                        }
328
                        double X = Canvas.GetLeft((item.DrawingData as TextControl));
329
                        double Y = Canvas.GetTop((item.DrawingData as TextControl));
330
                        pts.Add(new Point(X, Y));
331
                    }
332
                    else
333
                    {
334
                        pts.AddRange((item.DrawingData as IPath).PointSet);
335
                    }
336
                }
337
                #endregion
338

    
339
                return MathSet.FindCentroid(pts);
340
            }
341
        }
342

    
343
        #endregion
344
        #region 메서드
345
        public Rect getAdornerSize()
346
        {
347
            return BorderSize;
348
        }
349

    
350
        private void TextControlLostFocus(object sender,RoutedEventArgs e)
351
        {
352
            TextCompensation = false;
353
            BorderUpdate();
354

    
355
            if (sender is TextBox TextBox)
356
            {
357
                if (TextBox.Text == "") //보류
358
                {
359
                    this.ContainerContent.Children.Remove((sender as TextBox).Parent as MarkupToPDF.Common.CommentUserInfo);
360
                    this.Visibility = Visibility.Collapsed;
361
                }
362
            }
363
        }
364

    
365
        private void TextControlPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
366
        {
367
            if (sender is TextControl)
368
            {
369
                TextCompensation = true;
370
                BorderUpdate();
371
            }
372
        }
373

    
374
        private void TextControlSelectionChanged(object sender, RoutedEventArgs e)
375
        {
376
            BorderUpdate();
377
        }
378

    
379
        
380
        private void ViewBoxRotate(UIElement member)
381
        {
382
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
383
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
384
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
385
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
386
        }
387

    
388
        /// <summary>
389
        /// UIElement를 종류에 맞게 등록시킴
390
        /// </summary>
391
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
392
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
393
        {
394
            switch (member.GetType().Name)
395
            {
396
                #region 컨트롤 조건
397
                case "LineControl":
398
                case "PolygonControl":
399
                case "ArrowControl":
400
                case "ArcControl":
401
                case "ArrowArcControl":
402
                case "ArrowControl_Multi":
403
                case "RectangleControl":
404
                case "TriControl":
405
                case "CircleControl":
406
                case "CloudControl":
407
                case "RectCloudControl":
408
                case "InkControl":
409
                case "InsideWhiteControl":
410
                case "OverlapWhiteControl":
411
                case "ClipWhiteControl":
412
                case "CoordinateControl":
413
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
414
                    _ActualAngle = AngleValue = member.CommentAngle;
415
                    break;
416
                case "ArrowTextControl":
417
                    this.Members.Add(new AdornerMember
418
                    {
419
                        DrawingData = member,
420
                        Drawingtype = ControlType.ArrowTextControl,
421
                        ThumbList = new List<MyThumb>(),
422
                        Symbol_ID = member.SymbolID,
423
                        Group_ID = member.GroupID,
424
                    });
425
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
426
                    _ActualAngle = AngleValue = (member as ArrowTextControl).CommentAngle;
427

    
428
                    ((ArrowTextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
429
                    break;
430
                case "ImgControl":
431
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
432
                    _ActualAngle = AngleValue = (member as ImgControl).CommentAngle;
433
                    break;
434
                case "DateControl":
435
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
436
                    _ActualAngle = AngleValue = (member as DateControl).CommentAngle;
437
                    break;
438
                case "SignControl":
439
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
440
                    _ActualAngle = AngleValue = (member as SignControl).CommentAngle;
441
                    break;
442
                case "SymControl":
443
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
444
                    _ActualAngle = AngleValue = (member as SymControl).CommentAngle;
445
                    break;
446
                case "SymControlN":
447
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
448
                    _ActualAngle = AngleValue = (member as SymControlN).CommentAngle;
449
                    break;
450
                case "TextControl":
451
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
452
                    RectangleGeometry Data = new RectangleGeometry
453
                    {
454
                        Rect = new Rect()
455
                        {
456
                            X = Canvas.GetLeft((member as TextControl)),
457
                            Y = Canvas.GetTop((member as TextControl)),
458
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
459
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
460
                        }
461
                    };
462
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
463
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
464

    
465

    
466
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
467
                    DragThumb.RenderTransform = new RotateTransform()
468
                    {
469
                        Angle = (member as TextControl).CommentAngle,
470
                    };
471

    
472
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
473
                    AdornerBorder.RenderTransform = new RotateTransform()
474
                    {
475
                        Angle = (member as TextControl).CommentAngle,
476
                    };
477

    
478
                    ((TextControl)member).PropertyChanged += TextControlPropertyChanged;
479
                    ((TextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
480
                    break;
481
                default:
482
                    break;
483
                    #endregion
484
            }
485

    
486
            if (member.GetType().Name == "TextControl")
487
            {
488
                TextControl content = ((TextControl)member);
489
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
490
                content.EndPoint = content.StartPoint;
491
            }
492
            else
493
            {
494
                RegistryPoint(member);
495
            }
496
            BorderUpdate();
497

    
498
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
499
                Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
500
        }
501

    
502

    
503
        public void SetAdornerMember(List<CommentUserInfo> members)
504
        {
505
            foreach (var member in members)
506
            {
507
                switch (member.GetType().Name)
508
                {
509
                    #region 컨트롤 조건
510
                    case "LineControl":
511
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
512
                        break;
513
                    case "ImgControl":
514
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
515
                        break;
516
                    case "ArrowControl":
517
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
518
                        break;
519
                    case "PolygonControl":
520
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
521
                        break;
522
                    case "ArrowTextControl":
523
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
524
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
525
                        break;
526
                    case "ArcControl":
527
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
528
                        break;
529
                    case "ArrowArcControl":
530
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
531
                        break;
532
                    case "DateControl":
533
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
534
                        break;
535
                    case "ArrowControl_Multi":
536
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
537
                        break;
538
                    case "RectangleControl":
539
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
540
                        break;
541
                    case "TriControl":
542
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
543
                        break;
544
                    case "CircleControl":
545
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
546
                        break;
547
                    case "CloudControl":
548
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
549
                        break;
550
                    case "RectCloudControl":
551
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
552
                        break;
553
                    case "SignControl":
554
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
555
                        break;
556
                    case "SymControl":
557
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
558
                        break;
559
                    case "SymControlN":
560
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
561
                        break;
562
                    case "InkControl":
563
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
564
                        break;
565
                    case "TextControl":
566
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
567

    
568
                        (member as TextControl).PropertyChanged += TextControlPropertyChanged;
569
                        (member as TextControl).Base_TextBox.SelectionChanged += TextControlSelectionChanged;
570

    
571
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
572
                        //{
573
                        //    BorderUpdate();
574
                        //});
575
                        //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
576
                        //{
577
                        //    BorderUpdate();
578
                        //    try
579
                        //    {
580
                        //        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
581
                        //    }
582
                        //    catch (Exception)
583
                        //    {
584

    
585
                        //    }
586

    
587
                        //});
588
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
589
                        //{
590
                        //    BorderUpdate();
591
                        //});
592
                        break;
593
                    case "InsideWhiteControl":
594
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
595
                        break;
596
                    case "OverlapWhiteControl":
597
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
598
                        break;
599
                    case "ClipWhiteControl":
600
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
601
                        break;
602
                    case "CoordinateControl":
603
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
604
                        break;
605
                    default:
606
                        break;
607
                        #endregion
608
                }
609
                if (member.GetType().Name == "TextControl")
610
                {
611
                    TextControl content = ((TextControl)member);
612
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
613
                    content.EndPoint = content.StartPoint;
614
                }
615
                else
616
                {
617
                    RegistryPoint(member, members.Count);
618
                }
619

    
620
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
621
                    Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
622
            }
623

    
624
            BorderUpdate();
625
        }
626

    
627

    
628
        /// <summary>
629
        /// Border 를 갱신
630
        /// </summary>
631
        public void BorderUpdate()
632
        {
633
            AdornerBorder.MinWidth = 10;
634
            AdornerBorder.MinHeight = 10;
635

    
636
            double minX = double.MaxValue;
637
            double minY = double.MaxValue;
638
            double maxX = double.MinValue;
639
            double maxY = double.MinValue; 
640
            double lineSize = 0;
641
            double marginSize = 0;
642
            if (this.Members.Count == 1)
643
            {
644
                if (this.Members[0].DrawingData.GetType().Name == "TextControl")
645
                {
646
                    if ((this.Members[0].DrawingData as TextControl).CommentAngle != 0)
647
                    {
648
                        trRotate.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
649
                        trRotateThumb.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
650
                    }
651
                    else
652
                    {
653
                        trRotate.Angle = 0;
654
                        trRotateThumb.Angle = 0;
655
                    }
656
                }
657
            }
658

    
659
            foreach (var item in this.Members)
660
            {
661
                UIElement currentControl = item.DrawingData;
662
                
663
                Point startP = (currentControl as IPath).StartPoint;
664
                Point endP = (currentControl as IPath).EndPoint;
665

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

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

    
671
                if (item.DrawingData.GetType().Name == "TextControl")
672
                {
673
                    double textControlWidth;
674
                    double textControlHeight;
675
                             
676
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
677
                    {
678
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
679
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
680
                    }
681
                    else
682
                    {
683
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
684
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
685
                    }
686
                    
687
                    if ((currentControl as TextControl).EndPoint.X < minX)
688
                    {
689
                        minX = (currentControl as TextControl).EndPoint.X;
690
                    }
691

    
692
                    if ((currentControl as TextControl).EndPoint.Y < minY)
693
                    {
694
                        minY = (currentControl as TextControl).EndPoint.Y;
695
                    }
696

    
697
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
698
                    {
699
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
700
                    }
701

    
702
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
703
                    {
704
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
705
                    }
706
                    if ((currentControl as TextControl).ControlType_No == 2)
707
                        marginSize = (((currentControl as TextControl).Base_TextPath).ActualHeight - ((currentControl as TextControl).Base_Border).ActualHeight) / 2 + (((dynamic)currentControl).LineSize.Left / 2) + (currentControl as TextControl).ArcLength - 30;
708
                    if ((currentControl as TextControl).ControlType_No == 1)
709
                        marginSize = ((dynamic)currentControl).LineSize.Left;
710
                }
711
                else if ((currentControl as IViewBox) != null)
712
                {
713
                    IViewBox instance = currentControl as IViewBox;
714
                    List<Point> am = (currentControl as IPath).PointSet;
715
                    List<double> xSet = am.Select(p => p.X).ToList();
716
                    List<double> ySet = am.Select(p => p.Y).ToList();
717
                    if (xSet.Min() < minX) minX = xSet.Min();
718
                    if (ySet.Min() < minY) minY = ySet.Min();
719
                    if (xSet.Max() > maxX) maxX = xSet.Max();
720
                    if (ySet.Max() > maxY) maxY = ySet.Max();
721
                }
722
                else if ((currentControl as IPath).PathData == null)
723
                {
724
                    Rect rt = new Rect
725
                    {
726
                        X = (currentControl as IPath).StartPoint.X,
727
                        Y = (currentControl as IPath).StartPoint.Y,
728
                        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),
729
                        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),
730
                    };
731
                    if (rt.Left < minX) minX = rt.Left;
732
                    if (rt.Top < minY) minY = rt.Top;
733
                    if (rt.Right > maxX) maxX = rt.Right;
734
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
735
                }
736
                else if ((currentControl as IPath) == null)
737
                {
738
                    Rect rt = new Rect
739
                    {
740
                        X = (currentControl as IPath).StartPoint.X,
741
                        Y = (currentControl as IPath).StartPoint.Y,
742
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
743
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
744
                    };
745
                    if (rt.Left < minX) minX = rt.Left;
746
                    if (rt.Top < minY) minY = rt.Top;
747
                    if (rt.Right > maxX) maxX = rt.Right;
748
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
749
                }
750
                else if (currentControl is CircleControl CircleCtrl)
751
                {
752
                    List<Point> am = CircleCtrl.PointSet;
753
                    lineSize = CircleCtrl.LineSize;
754
                    minX = am.Min(x => x.X);
755
                    minY = am.Min(x => x.Y);
756
                    maxX = am.Max(x => x.X);
757
                    maxY = am.Max(x => x.Y);
758
                }
759
                else 
760
                {
761
                    lineSize = ((dynamic)currentControl).LineSize;
762
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
763
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
764
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
765
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
766
                }
767
            }
768

    
769
            Rect ac = new Rect(minX , minY, maxX - minX, maxY - minY);
770
            bool addWidthSize = false;
771
            bool addHeightSize = false;
772
            if (ac.Width <= 10)
773
            {
774
                ac.Width += 10;
775
                addWidthSize = true;
776
            }
777
            if (ac.Height <= 10)
778
            {
779
                ac.Height += 10;
780
                addHeightSize = true;
781
            }
782
            BorderSize = ac;
783
            //lineSize : Thickness 굵기에 따라서 adoner 수정 
784
            ac.Width += lineSize;
785
            ac.Height += lineSize;
786
            AdornerBorder.MinWidth = 10;
787
            AdornerBorder.MinHeight = 10;
788
            AdornerBorder.Width = ac.Width;
789
            AdornerBorder.Height = ac.Height;
790
            minX -= lineSize / 2;
791
            minY -= lineSize / 2;
792
            Canvas.SetLeft(AdornerBorder, minX);
793
            Canvas.SetTop(AdornerBorder, minY);
794

    
795
            DragThumb.Width = ac.Width;
796
            DragThumb.Height = ac.Height;
797
            rotateTop.Margin = new Thickness(rotateTop.Margin.Left, -30 - marginSize, rotateTop.Margin.Right, rotateTop.Margin.Bottom);
798
            DragThumb.MinWidth = 10;
799
            DragThumb.MinHeight = 10;
800
            if (addWidthSize)
801
            {
802
                Canvas.SetLeft(DragThumb, minX - 5);
803
            }
804
            else
805
            {
806
                Canvas.SetLeft(DragThumb, minX);
807
            }
808

    
809
            if (addHeightSize)
810
            {
811
                Canvas.SetTop(DragThumb, minY - 5);
812
            }
813
            else
814
            {
815
                Canvas.SetTop(DragThumb, minY);
816
            }
817
        }
818

    
819
        /// <summary>
820
        /// UIElement 해제
821
        /// </summary>
822
        public void UnRegister()
823
        {
824
            foreach (var item in this.ContainerContent.Children)
825
            {
826
                if (item is MarkupToPDF.Common.CommentUserInfo)
827
                {
828
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
829
                }
830
            }
831
            this.ContainerContent.Children.Clear();
832
        }
833

    
834
        /// <summary>
835
        /// 각 포인트들을 등록합니다.
836
        /// </summary>
837
        /// <param name="pointset">Drawing Point</param>
838
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
839
        {
840
            int count = 0;
841
            List<Point> pts = (member as IPath).PointSet;
842
            if (member.GetType().Name == "InkControl")
843
            {
844
                pts.Clear();
845
                pts.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
846
                pts.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
847
                pts.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
848
                pts.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
849
            }
850
            ControlType markT = this.Members.First(p => p.DrawingData == member).Drawingtype;
851
            double Minx = pts.Min(x => x.X);
852
            double Miny = pts.Min(x => x.Y);
853

    
854
            for (int i = 0; i < pts.Count; i++)
855
            {
856
                MyThumb tm = new MyThumb
857
                {
858
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
859
                };
860

    
861
                this.Members.Last().ThumbList.Add(tm);
862

    
863
                if ((markT == ControlType.ArcLine && pts[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && pts[i] == (member as ArrowArcControl).MiddlePoint))
864
                {
865
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
866
                }
867
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
868
                {
869
                    //if (this.Members.Count()<=1)
870
                    //{
871
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
872
                    List<Point> ps = new List<Point>();
873

    
874
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
875
                    {
876
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
877

    
878
                        switch (Math.Abs(temp.CommentAngle).ToString())
879
                        {
880
                            case "90":
881
                                {
882
                                    ps.Clear();
883
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
884
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
885
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
886

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

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

    
893
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
894
                                }
895
                                break;
896
                            case "270":
897
                                {
898
                                    ps.Clear();
899
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
900
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
901
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
902

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

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

    
909
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
910
                                }
911
                                break;
912
                            default:
913
                                {
914
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
915
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
916
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
917
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
918
                                }
919
                                break;
920
                        }
921

    
922
                        ArrowTextControl instance = (member as ArrowTextControl);
923
                        if (instance.isTrans)
924
                        {
925
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
926
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
927
                            //list[count] = tempP;
928
                            pts[count] = temp.MidPoint;
929
                        }
930
                        else
931
                        {
932
                            if (temp.isFixed)
933
                            {
934
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
935
                                var testP = endP;
936
                                if (ps[0] == endP) //상단
937
                                {
938
                                    testP = new Point(endP.X, endP.Y - 50);
939
                                }
940
                                else if (ps[1] == endP) //하단
941
                                {
942
                                    testP = new Point(endP.X, endP.Y + 50);
943
                                }
944
                                else if (ps[2] == endP) //좌단
945
                                {
946
                                    testP = new Point(endP.X - 50, endP.Y);
947
                                }
948
                                else if (ps[3] == endP) //우단
949
                                {
950
                                    testP = new Point(endP.X + 50, endP.Y);
951
                                }
952
                                pts[count] = testP;
953
                            }
954
                            else
955
                            {
956
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
957
                                pts[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
958
                            }
959
                        }
960
                    }
961
                }
962

    
963
                /// ArrowTextControl text box 화면 출력
964
                if (member.GetType().Name == "ArrowTextControl" && pts[i] == pts.Last())
965
                {
966
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
967
                    tm.Width = (member as ArrowTextControl).BoxWidth;
968
                    tm.Height = (member as ArrowTextControl).BoxHeight;
969
                    var angle = (member as ArrowTextControl).PageAngle;
970
                    if (Math.Abs(angle).ToString() == "90")
971
                    {
972
                        tm.RenderTransformOrigin = new Point(0, 0);
973
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
974
                    }
975
                    else if (Math.Abs(angle).ToString() == "270")
976
                    {
977
                        tm.RenderTransformOrigin = new Point(0, 0);
978
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
979
                    }
980
                    else
981
                    {
982
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
983
                        tm.RenderTransform = new RotateTransform()
984
                        {
985
                            Angle = angle
986
                        };
987
                    }
988
                }
989
                
990
                if (member.GetType().Name == "CloudControl")
991
                {
992
                    if (i == pts.Count() - 1)
993
                    {
994
                        tm.Visibility = System.Windows.Visibility.Collapsed;
995
                    }
996
                }
997
                if (member.GetType().Name == "PolygonControl")
998
                {
999
                    if (i == pts.Count() - 1)
1000
                    {
1001
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
1002
                        {
1003

    
1004
                        }
1005
                        else
1006
                        {
1007
                            tm.Visibility = System.Windows.Visibility.Collapsed;
1008
                        }
1009
                    }
1010
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
1011
                    {
1012
                        tm.Visibility = System.Windows.Visibility.Collapsed;
1013
                    }
1014
                }
1015
                
1016
                this.ContainerContent.Children.Add(tm);
1017
                Canvas.SetLeft(tm, pts[count].X);
1018
                Canvas.SetTop(tm, pts[count].Y);
1019
                if (member.GetType().Name == "ArrowTextControl" && pts[i] == (member as ArrowTextControl).MidPoint)
1020
                {
1021
                    Canvas.SetZIndex(tm, 95);
1022
                    //tm.Opacity = 0;
1023
                    tm.DragDelta += MidPoint_DragDelta;
1024
                }
1025
                else
1026
                {
1027
                    tm.DragDelta += ResizeTm_DragDelta;
1028
                    Canvas.SetZIndex(tm, 99);
1029
                }
1030

    
1031
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
1032
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
1033
                
1034
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
1035
                count++;
1036
            }
1037
        }
1038

    
1039
        private void MidPoint_DragDelta(object sender, DragDeltaEventArgs e)
1040
        {
1041
            MyThumb thumb = sender as MyThumb;
1042
            double newHorizontalChange = e.HorizontalChange;
1043
            double newVerticalChange = e.VerticalChange;
1044

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

    
1047
            var direction = VisualHelper.GetPointDirection(newpoint, ViewerDataModel.Instance.PageAngle);
1048

    
1049
            System.Diagnostics.Debug.WriteLine("뱡향 : " + direction.ToString());
1050

    
1051
            AdornerMember control = CurrentAdornerMember(thumb);
1052
            var commentInfo = (control.DrawingData) as CommentUserInfo;
1053

    
1054
            if (commentInfo is ArrowTextControl)
1055
            {
1056
                Point getThumbPoint = GetPosition(thumb);
1057

    
1058
                var arrowText = commentInfo as ArrowTextControl;
1059

    
1060
                //var midPoint = MathSet.getMiddlePoint(arrowText.StartPoint, arrowText.EndPoint);
1061
                //arrowText.MidPoint = newpoint;
1062
                thumb.Translate(newpoint.X, newpoint.Y, this.AngleValue);
1063
          
1064
                commentInfo.OnMoveCtrlPoint(getThumbPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1065

    
1066
                control.UpdateThumb();
1067

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

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

    
1073
        }
1074
        
1075

    
1076
        /// <summary>
1077
        /// 제어점을 조정하여 크기를 수정한다.
1078
        /// </summary>
1079
        /// <param name="sender"></param>
1080
        /// <param name="e"></param>
1081
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
1082
        {
1083
            if (sender.GetType() != typeof(MyThumb)) return;
1084

    
1085
            MyThumb thumb = sender as MyThumb;
1086

    
1087
            if (this.Members.Count > 1) return;
1088

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

    
1091
            double newHorizontalChange = e.HorizontalChange;
1092
            double newVerticalChange = e.VerticalChange;
1093

    
1094
            //if (reSizePoint != new Point(0, 0))
1095
            //{
1096
                //Point setPoint = Mouse.GetPosition(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanCanvas);
1097

    
1098
                Point setPoint = GetPosition(thumb);
1099

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

    
1102
                AdornerMember control = CurrentAdornerMember(thumb);
1103
                var commentInfo = (control.DrawingData) as CommentUserInfo;
1104

    
1105
                double ratatePointAngle = 0;
1106

    
1107
                if (commentInfo is ArrowTextControl)
1108
                {
1109
                    var textControl = (commentInfo as ArrowTextControl);
1110

    
1111
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1112

    
1113
                    {
1114
                        textControl.CommentAngle = 0;
1115
                        this.AngleValue = 0;
1116
                        ratatePointAngle = commentInfo.VisualPageAngle;
1117
                    }
1118
                    else
1119
                    {   
1120
                        //textControl.CommentAngle = commentInfo.VisualPageAngle + MathSet.returnAngle(textControl.StartPoint, ref tempPoint, ViewerDataModel.Instance.IsPressShift);
1121
                        textControl.OnCreatingMouseMove(textControl.EndPoint, ViewerDataModel.Instance.IsPressShift);
1122
                        this.AngleValue = textControl.CommentAngle;
1123
                        commentInfo.CommentAngle = this.AngleValue;
1124
                    }
1125
                        //CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1126
                }
1127
                System.Diagnostics.Debug.WriteLine("## Angle : " + this.AngleValue + " ##");
1128
                thumb.Translate(newHorizontalChange, newVerticalChange, this.AngleValue);
1129

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

    
1132
                var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1133
     
1134
                Point thumbPoint = MathHelper.RotatePoint(setPoint, new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1135

    
1136
                //thumbPoint.X = Math.Abs(thumbPoint.X);
1137
                //thumbPoint.Y = Math.Abs(thumbPoint.Y);
1138

    
1139
                //if ((setPoint.X + newpoint.X) < 0 || (Math.Abs(thumbPoint.X) + newpoint.X) - ViewerDataModel.Instance.ImageViewWidth > 0)
1140
                //{
1141
                //    newpoint.X = 0;
1142
                //}
1143

    
1144
                //if (setPoint.Y + newpoint.Y < 0 || (Math.Abs(thumbPoint.Y) + newpoint.Y) - ViewerDataModel.Instance.ImageViewHeight > 0)
1145
                //{
1146
                //    newpoint.Y = 0;
1147
                //}
1148

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

    
1151
                //System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1152
                control.UpdateThumb();
1153

    
1154
                //System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1155
                this.BorderUpdate();
1156

    
1157
               //System.Diagnostics.Debug.WriteLine($"5. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1158
            //}
1159
        }
1160

    
1161
        private AdornerMember CurrentAdornerMember(MyThumb thumb)
1162
        {
1163
            AdornerMember result = null;
1164

    
1165
            try
1166
            {
1167
                result = (from userThumb in this.Members
1168
                            where userThumb.ThumbList.Contains(thumb)
1169
                            select userThumb).FirstOrDefault();
1170
            }
1171
            catch (Exception ex)
1172
            {
1173
                App.FileLogger.Error(ex);
1174
            }
1175

    
1176
            return result;
1177
        }
1178

    
1179
        private Point GetPosition(Thumb thumb)
1180
        {
1181
            return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
1182
        }
1183

    
1184
        #endregion
1185
        #region 이벤트
1186

    
1187
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1188
        {
1189
            this.isDragging = false;
1190
            DraggerThumb = null;
1191

    
1192

    
1193
            var comments = (from drawing in this.Members
1194
                            select drawing.DrawingData as CommentUserInfo).ToList();
1195
            ViewerDataModel.Instance.IsMarkupUpdate = true;
1196
        }
1197

    
1198
        /// <summary>
1199
        /// start drag
1200
        /// </summary>
1201
        /// <param name="sender"></param>
1202
        /// <param name="e"></param>
1203
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1204
        {
1205
            this.DraggerThumb = sender as Thumb;
1206
            this.isDragging = true;
1207

    
1208
            if (ViewerDataModel.Instance.UndoDataList == null)
1209
            {
1210
                return;
1211
            }
1212

    
1213
            var comments = (from drawing in this.Members
1214
                            select drawing.DrawingData as CommentUserInfo).ToList();
1215

    
1216
            UndoCommand.Instance.Push(EventType.Operation, comments);
1217
        }
1218

    
1219
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1220
        {
1221
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1222
            {
1223
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1224
                    IsTextAngle = true;
1225
                else
1226
                    IsTextAngle = false;
1227
                LastRotateVerticalValue = e.GetPosition(this).X;
1228
            }
1229
            else
1230
            {
1231
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1232
                {
1233
                    RotateFlag = true;
1234
                }
1235
                else
1236
                {
1237
                    RotateFlag = false;
1238
                }
1239
                LastRotateHorizontalValue = e.GetPosition(this).X;
1240
            }
1241
        }
1242

    
1243
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1244
        {
1245
            /// save mouse down and current mouse point
1246
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1247
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1248
            /// up to here
1249

    
1250
            if (ViewerDataModel.Instance.UndoDataList == null)
1251
            {
1252
                return;
1253
            }
1254

    
1255
            var comments = (from drawing in this.Members
1256
                            select drawing.DrawingData as CommentUserInfo).ToList();
1257

    
1258
            UndoCommand.Instance.Push(EventType.Operation, comments);
1259
        }
1260

    
1261
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1262
        {
1263
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1264

    
1265
            var comments = (from drawing in this.Members
1266
                            select drawing.DrawingData as CommentUserInfo).ToList();
1267
        }
1268

    
1269
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1270
        {
1271
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1272

    
1273
            var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1274
         
1275
            var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1276
            var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1277

    
1278
            try
1279
            {
1280
                DragThumb.Cursor = Cursors.SizeAll;
1281
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1282
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1283

    
1284

    
1285
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1286

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

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

    
1291
                var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1292
                
1293
                var moveDirection = mainRect.Movement(rotationRect);
1294

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

    
1297
                this.TranslateItems(horzChange, vertChange);
1298
            }
1299
            finally
1300
            {
1301
                /// update CurrentMousePoint
1302
                this.CurrentMousePoint = newMousePoint;
1303
            }
1304
        }
1305

    
1306
        /// <summary>
1307
        /// translate all members
1308
        /// </summary>
1309
        /// <param name="e"></param>
1310
        public void TranslateItems(double dx, double dy)
1311
        {
1312
            Dispatcher.BeginInvoke((Action)(() =>
1313
            {
1314
                foreach (var item in this.Members)
1315
                {
1316
                    this.TranslateItem(dx, dy, item);
1317
                }
1318

    
1319
                this.BorderUpdate();
1320
            }));
1321
        }
1322

    
1323
        /// <summary>
1324
        /// translate a item
1325
        /// </summary>
1326
        /// <param name="e"></param>
1327
        /// <param name="item"></param>
1328
        private void TranslateItem(double dx, double dy, AdornerMember item)
1329
        {
1330
            /// rotate point with page rotation
1331
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1332
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1333
            /// up to here
1334
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1335

    
1336
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1337
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), EventType.Operation, null, null);            
1338

    
1339
            item.UpdateThumb();
1340
        }
1341

    
1342
        private void resize_MouseMove(object sender, MouseEventArgs e)
1343
        {
1344
            //reSizePoint = e.GetPosition(this);
1345
        }
1346

    
1347
        /// <summary>
1348
        /// 회전
1349
        /// </summary>
1350
        /// <param name="sender"></param>
1351
        /// <param name="e"></param>
1352
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1353
        {
1354
            MoveRotate(e);
1355
        }
1356

    
1357
        double LastRotateHorizontalValue = 0;
1358
        double LastRotateVerticalValue = 0;
1359
        bool RotateFlag = false;
1360

    
1361
        /// <summary>
1362
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1363
        /// </summary>
1364
        /// <param name="e"></param>
1365
        public void MoveRotate(DragDeltaEventArgs e)
1366
        {
1367
            Point CenterPoint = this.Centeroid;
1368
            Point pt = Mouse.GetPosition(this);
1369

    
1370
            #region X축 기준으로 회전 각도를 구한다.
1371
            Vector AxisX = new Vector(RotatedPoint.X - CenterPoint.X, RotatedPoint.Y - CenterPoint.Y);
1372
            AxisX.Normalize();
1373
            Vector AxisY = new Vector(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1374
            AxisY.Normalize();
1375
            double dDeltaAngle = Vector.AngleBetween(AxisX, AxisY);
1376
            #endregion
1377

    
1378
            _ActualAngle += dDeltaAngle;
1379
            if (_ActualAngle > 360) _ActualAngle -= 360;
1380
            if (_ActualAngle < 0) _ActualAngle += 360;
1381
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1382
            if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
1383
            {
1384
                double tmp = AlignedAngles.OrderBy(x => Math.Abs(_ActualAngle - x)).First();
1385
                dDeltaAngle = tmp - AngleValue;
1386
                AngleValue = tmp;
1387
            }
1388
            else
1389
            {
1390
                AngleValue = _ActualAngle;
1391
            }
1392
            #endregion
1393

    
1394
            /// save rotatePoint
1395
            this.RotatedPoint = pt;
1396

    
1397
            Dispatcher.BeginInvoke((Action)(() =>
1398
            {
1399
                foreach (var member in this.Members)
1400
                {
1401
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1402
                    #region 보더 업데이트
1403
                    switch (member.Drawingtype)
1404
                    {
1405
                        case ControlType.TextControl:
1406
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1407

    
1408
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1409
                            DragThumb.RenderTransform = new RotateTransform()
1410
                            {
1411
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1412
                            };
1413

    
1414
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1415
                            AdornerBorder.RenderTransform = new RotateTransform()
1416
                            {
1417
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1418
                            };
1419

    
1420
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1421
                            BorderUpdate();
1422
                            break;
1423

    
1424
                        case ControlType.ArrowMultiLine:
1425
                        case ControlType.ArcLine:
1426
                        case ControlType.ArcArrow:
1427
                        case ControlType.SingleLine:
1428
                        case ControlType.Triangle:
1429
                        case ControlType.ArrowTextControl:
1430
                        case ControlType.PolygonControl:
1431
                        case ControlType.Ink:
1432
                            BorderUpdate();
1433
                            break;
1434
                        case ControlType.Date:
1435
                        case ControlType.RectCloud:
1436
                        case ControlType.Rectangle:
1437
                        case ControlType.ImgControl:
1438
                        case ControlType.Sign:
1439
                        case ControlType.Symbol:
1440
                        case ControlType.Stamp:
1441
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1442
                            BorderUpdate();
1443
                            break;
1444
                        case ControlType.PolygonCloud:
1445
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1446
                            BorderUpdate();
1447
                            break;
1448
                        case ControlType.Circle:
1449
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1450
                            ((CircleControl)member.DrawingData).SetCenterXY();
1451
                            BorderUpdate();
1452
                            break;
1453
                        default:
1454
                            break;
1455
                    }
1456
                }
1457
                #endregion
1458
            }));
1459
        }
1460

    
1461
        /// <summary>
1462
        /// 객체 회전 시작
1463
        /// </summary>
1464
        /// <param name="sender"></param>
1465
        /// <param name="e"></param>
1466
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1467
        {            
1468
            this.RotatedPoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1469
            rotateTop.Cursor = Cursors.SizeAll;
1470

    
1471
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1472
            if ((1 == this.Members.Count) && (this.Members[0]).DrawingData.GetType().Name == "TextControl")
1473
            {
1474
                this.AngleValue = ((this.Members[0]).DrawingData as TextControl).CommentAngle;
1475
            }
1476
            /// up to here
1477

    
1478
            if (ViewerDataModel.Instance.UndoDataList == null)
1479
            {
1480
                return;
1481
            }
1482

    
1483
            var comments = (from drawing in this.Members
1484
                            select drawing.DrawingData as CommentUserInfo).ToList();
1485
            UndoCommand.Instance.Push(EventType.Operation, comments);
1486
        }
1487
        
1488
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1489
        {
1490
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1491

    
1492
            var comments = (from drawing in this.Members
1493
                            select drawing.DrawingData as CommentUserInfo).ToList();
1494
        }
1495

    
1496
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1497
        {
1498
            AdornerMember control = this.Members.FirstOrDefault();
1499

    
1500
            if ((control.DrawingData as ArrowTextControl) != null)
1501
            {
1502
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1503
                {
1504
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1505
                }
1506
            }
1507

    
1508
        }
1509

    
1510
        public void TextControlChanger()
1511
        {
1512
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1513
            {
1514
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1515
                AllControl.Base_TextBox.Focus();
1516
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1517
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1518
                AllControl.Base_TextBox.IsHitTestVisible = true;
1519
                AllControl.IsEditingMode = true;
1520
                AllControl.Base_TextBox.Focus();
1521

    
1522
                AllControl.SizeChanged += (sen, ea) =>
1523
                {
1524
                    if (AllControl.Base_TextBox != null)
1525
                    {
1526
                        RectangleGeometry Data = new RectangleGeometry
1527
                        {
1528
                            Rect = new Rect()
1529
                            {
1530
                                X = AllControl.StartPoint.X,
1531
                                Y = AllControl.StartPoint.Y,
1532
                                Width = AllControl.Base_TextBox.Width,
1533
                                Height = AllControl.Base_TextBox.Height,
1534
                            }
1535
                        };
1536

    
1537
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1538
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1539
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1540
                        {
1541
                            Angle = AllControl.CommentAngle,
1542
                            CenterX = middle.X,
1543
                            CenterY = middle.Y,
1544
                        };
1545
                    }
1546
                    BorderUpdate();
1547
                };
1548
            }
1549
        }
1550

    
1551
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1552
        {
1553
            if (e.ClickCount == 2 && this.Members.Count == 1)
1554
            {
1555
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1556
                {
1557
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1558
                    TextControlChanger();                    
1559
                }
1560

    
1561
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1562
                {
1563
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1564
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1565
               
1566
                    //ArrowControl TextBox Thumb없애기
1567
                    tm.Visibility = Visibility.Collapsed;
1568

    
1569
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1570
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1571

    
1572
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1573
                    
1574

    
1575
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1576

    
1577
                    {
1578
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1579
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1580

    
1581
                        List<Point> ps = new List<Point>();
1582
                        
1583
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1584
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1585
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1586
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1587

    
1588

    
1589

    
1590

    
1591
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1592
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1593
                        if (AllControl.isTrans)
1594
                        {
1595
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1596
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1597
                        }
1598
                        else
1599
                        {
1600
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1601
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1602
                        }
1603

    
1604

    
1605
                        BorderUpdate();
1606

    
1607
                    };
1608
                }
1609
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1610
                {
1611
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1612
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1613
                    //dropData.IsOpen = true;
1614
                    RadWindow rc = new RadWindow();
1615
                    rc.Width = 300;
1616
                    rc.Height = 300;
1617
                    rc.Header = "Change Date";
1618
                    rc.Content = instanceCal;
1619
                    rc.BorderThickness = new Thickness(3);
1620
                    rc.ResizeMode = ResizeMode.NoResize;
1621
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1622
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1623
                    rc.ModalBackground.Opacity = 0.6;
1624
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1625
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1626
                    {
1627
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1628
                        rc.Close();
1629
                    };
1630
                    rc.ShowDialog();
1631
                    //CalendarControl.xaml
1632
                }
1633
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1634
                {
1635
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1636
                    if (instance.isTransOn)
1637
                    {
1638
                        instance.isTransOn = false;
1639
                    }
1640
                    else
1641
                    {
1642
                        instance.isTransOn = true;
1643
                    }
1644
                    ///instance.SetArcPath();
1645
                    BorderUpdate();
1646
                }
1647
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1648
                {
1649
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1650
                    if (instance.isTransOn)
1651
                    {
1652
                        instance.isTransOn = false;
1653
                    }
1654
                    else
1655
                    {
1656
                        instance.isTransOn = true;
1657
                    }
1658
                    instance.SetArcPath();
1659
                    BorderUpdate();
1660
                }
1661

    
1662
            }
1663
            
1664
        }
1665
        #endregion
1666

    
1667
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1668
        {
1669
            if (this.Members[0].DrawingData.GetType().Name == "TextControl" 
1670
                || this.Members[0].DrawingData.GetType().Name == "ArrowTextControl")
1671
            {
1672
                DragThumb.Visibility = Visibility.Collapsed;
1673
            }
1674
        }
1675
    }
1676
}
클립보드 이미지 추가 (최대 크기: 500 MB)