프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ b2d0f316

이력 | 보기 | 이력해설 | 다운로드 (75.3 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
        public TextBox editTextBox { get; set; }
155
        #region 공용 인스턴스
156
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
157
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
158

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

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

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

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

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

    
190
        private bool disposed;
191

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

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

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

    
224
        ~AdornerFinal()
225
        {
226
            this.Dispose(false);
227
        }
228

    
229
        public void Dispose()
230
        {
231
            this.Dispose(true);
232
            GC.SuppressFinalize(this);
233
        }
234

    
235
        protected virtual void Dispose(bool disposing)
236
        {
237
            if (this.disposed) return;
238
            if (disposing)
239
            {
240
                foreach (var member in this.Members)
241
                {
242
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
243
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
244
                }
245
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
246
            }
247
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
248
            this.disposed = true;
249
        }
250

    
251
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
252
        {
253
            mainDragThumb = DragThumb;
254
        }
255

    
256
        public AdornerFinal(CommentUserInfo objectData) : this()
257
        {
258
            InitializeComponent();
259
            objectData.IsHitTestVisible = false;
260

    
261
            if (objectData is ArrowTextControl ArrTextCtrl)
262
            {
263
                ArrTextCtrl.Base_TextBox.Focusable = true;
264
            }
265

    
266
            ///Canvas.SetZIndex(objectData, 84);
267
            try
268
            {
269
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
270
                this.ContainerContent.Children.Add(objectData);
271
            }
272
            catch (Exception ex)
273
            {
274

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

    
281
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
282
        {
283
            InitializeComponent();
284
            foreach (var item in objectData)
285
            {
286
                //item.IsHitTestVisible = false;
287
                if (item is ArrowTextControl ArrTextCtrl)
288
                {
289
                    ArrTextCtrl.Base_TextBox.Focusable = true;
290
                }
291
                try
292
                {
293
                    ///Canvas.SetZIndex(item, 80);
294

    
295
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
296
                    this.ContainerContent.Children.Add(item);
297
                }
298
                catch //(Exception ex)
299
                {
300
                }
301
                finally
302
                {
303
                    
304
                }
305
            }
306
            this.SetAdornerMember(objectData);
307
            this.Focus();
308
        }
309

    
310
        public Point Centeroid
311
        {
312
            get
313
            {
314
                List<Point> pts = new List<Point>();
315

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

    
336
                return MathSet.FindCentroid(pts);
337
            }
338
        }
339

    
340
        #endregion
341
        #region 메서드
342
        public Rect getAdornerSize()
343
        {
344
            return BorderSize;
345
        }
346

    
347
        private void TextControlLostFocus(object sender,RoutedEventArgs e)
348
        {
349
            TextCompensation = false;
350
            BorderUpdate();
351

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

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

    
371
        private void TextControlSelectionChanged(object sender, RoutedEventArgs e)
372
        {
373
            BorderUpdate();
374
        }
375

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

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

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

    
462

    
463
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
464
                    DragThumb.RenderTransform = new RotateTransform()
465
                    {
466
                        Angle = (member as TextControl).CommentAngle,
467
                    };
468

    
469
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
470
                    AdornerBorder.RenderTransform = new RotateTransform()
471
                    {
472
                        Angle = (member as TextControl).CommentAngle,
473
                    };
474

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

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

    
495
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
496
                Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
497
        }
498

    
499

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

    
565
                        (member as TextControl).PropertyChanged += TextControlPropertyChanged;
566
                        (member as TextControl).Base_TextBox.SelectionChanged += TextControlSelectionChanged;
567

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

    
582
                        //    }
583

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

    
617
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
618
                    Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
619
            }
620

    
621
            BorderUpdate();
622
        }
623

    
624

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

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

    
656
            foreach (var item in this.Members)
657
            {
658
                UIElement currentControl = (item as AdornerMember).DrawingData;
659
                
660
                Point startP = (currentControl as IPath).StartPoint;
661
                Point endP = (currentControl as IPath).EndPoint;
662

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

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

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

    
689
                    if ((currentControl as TextControl).EndPoint.Y < minY)
690
                    {
691
                        minY = (currentControl as TextControl).EndPoint.Y;
692
                    }
693

    
694
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
695
                    {
696
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
697
                    }
698

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

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

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

    
806
            if (addHeightSize)
807
            {
808
                Canvas.SetTop(DragThumb, minY - 5);
809
            }
810
            else
811
            {
812
                Canvas.SetTop(DragThumb, minY);
813
            }
814
        }
815

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

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

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

    
858
                this.Members.Last().ThumbList.Add(tm);
859

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

    
871
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
872
                    {
873
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
874

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1044
            var direction = VisualHelper.GetPointDirection(newpoint, ViewerDataModel.Instance.PageAngle);
1045

    
1046
            System.Diagnostics.Debug.WriteLine("뱡향 : " + direction.ToString());
1047

    
1048
            AdornerMember control = CurrentAdornerMember(thumb);
1049
            var commentInfo = (control.DrawingData) as CommentUserInfo;
1050

    
1051
            if (commentInfo is ArrowTextControl)
1052
            {
1053
                Point getThumbPoint = GetPosition(thumb);
1054

    
1055
                var arrowText = commentInfo as ArrowTextControl;
1056

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

    
1063
                control.UpdateThumb();
1064

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

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

    
1070
        }
1071
        
1072

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

    
1082
            MyThumb thumb = sender as MyThumb;
1083

    
1084
            if (this.Members.Count > 1) return;
1085

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

    
1088
            double newHorizontalChange = e.HorizontalChange;
1089
            double newVerticalChange = e.VerticalChange;
1090

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

    
1095
                Point setPoint = GetPosition(thumb);
1096

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

    
1099
                AdornerMember control = CurrentAdornerMember(thumb);
1100
                var commentInfo = (control.DrawingData) as CommentUserInfo;
1101

    
1102
                double ratatePointAngle = 0;
1103

    
1104
                if (commentInfo is ArrowTextControl)
1105
                {
1106
                    var textControl = (commentInfo as ArrowTextControl);
1107

    
1108
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1109

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

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

    
1129
                var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1130
     
1131
                Point thumbPoint = MathHelper.RotatePoint(setPoint, new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1132

    
1133
                //thumbPoint.X = Math.Abs(thumbPoint.X);
1134
                //thumbPoint.Y = Math.Abs(thumbPoint.Y);
1135

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

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

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

    
1148
                //System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1149
                control.UpdateThumb();
1150

    
1151
                //System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1152
                this.BorderUpdate();
1153

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

    
1158
        private AdornerMember CurrentAdornerMember(MyThumb thumb)
1159
        {
1160
            AdornerMember result = null;
1161

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

    
1173
            return result;
1174
        }
1175

    
1176
        private Point GetPosition(Thumb thumb)
1177
        {
1178
            return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
1179
        }
1180

    
1181
        #endregion
1182
        #region 이벤트
1183

    
1184
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1185
        {
1186
            this.isDragging = false;
1187
            DraggerThumb = null;
1188

    
1189

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

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

    
1205
            if (ViewerDataModel.Instance.UndoDataList == null)
1206
            {
1207
                return;
1208
            }
1209

    
1210
            var comments = (from drawing in this.Members
1211
                            select drawing.DrawingData as CommentUserInfo).ToList();
1212

    
1213
            UndoCommand.Instance.Push(EventType.Operation, comments);
1214
        }
1215

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

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

    
1247
            if (ViewerDataModel.Instance.UndoDataList == null)
1248
            {
1249
                return;
1250
            }
1251

    
1252
            var comments = (from drawing in this.Members
1253
                            select drawing.DrawingData as CommentUserInfo).ToList();
1254

    
1255
            UndoCommand.Instance.Push(EventType.Operation, comments);
1256
        }
1257

    
1258
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1259
        {
1260
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1261

    
1262
            var comments = (from drawing in this.Members
1263
                            select drawing.DrawingData as CommentUserInfo).ToList();
1264
        }
1265

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

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

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

    
1281

    
1282
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1283

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

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

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

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

    
1294
                this.TranslateItems(horzChange, vertChange);
1295
            }
1296
            finally
1297
            {
1298
                /// update CurrentMousePoint
1299
                this.CurrentMousePoint = newMousePoint;
1300
            }
1301
        }
1302

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

    
1316
                this.BorderUpdate();
1317
            }));
1318
        }
1319

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

    
1333
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1334
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), EventType.Operation, null, null);            
1335

    
1336
            item.UpdateThumb();
1337
        }
1338

    
1339
        private void resize_MouseMove(object sender, MouseEventArgs e)
1340
        {
1341
            //reSizePoint = e.GetPosition(this);
1342
        }
1343

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

    
1354
        double LastRotateHorizontalValue = 0;
1355
        double LastRotateVerticalValue = 0;
1356
        bool RotateFlag = false;
1357

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

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

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

    
1391
            /// save rotatePoint
1392
            this.RotatedPoint = pt;
1393

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

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

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

    
1417
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1418
                            BorderUpdate();
1419
                            break;
1420

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

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

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

    
1475
            if (ViewerDataModel.Instance.UndoDataList == null)
1476
            {
1477
                return;
1478
            }
1479

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

    
1489
            var comments = (from drawing in this.Members
1490
                            select drawing.DrawingData as CommentUserInfo).ToList();
1491
        }
1492

    
1493
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1494
        {
1495
            AdornerMember control = this.Members.FirstOrDefault();
1496

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

    
1505
        }
1506

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

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

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

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

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

    
1566
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1567
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1568

    
1569
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1570
                    
1571

    
1572
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1573

    
1574
                    {
1575
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1576
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1577

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

    
1585

    
1586

    
1587

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

    
1601

    
1602
                        BorderUpdate();
1603

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

    
1659
            }
1660
            
1661
        }
1662
        #endregion
1663

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