프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (80.7 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
        private double angleValue;
162
        public double dBeforeAngle { get; set; }
163

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

    
174
        public List<Point> lstBeforePointSet { get; set; }
175

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

    
185
        private bool disposed;
186

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

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

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

    
219
        ~AdornerFinal()
220
        {
221
            this.Dispose(false);
222
        }
223

    
224
        public void Dispose()
225
        {
226
            this.Dispose(true);
227
            GC.SuppressFinalize(this);
228
        }
229

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

    
246
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
247
        {
248
            mainDragThumb = DragThumb;
249
        }
250

    
251
        public AdornerFinal(CommentUserInfo objectData) : this()
252
        {
253
            InitializeComponent();
254
            objectData.IsHitTestVisible = false;
255

    
256
            if ((objectData as ArrowTextControl) != null)
257
            {
258
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
259
            }
260

    
261
            Canvas.SetZIndex(objectData, 84);
262
            try
263
            {
264
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
265
                this.ContainerContent.Children.Add(objectData);
266
            }
267
            catch (Exception ex)
268
            {
269

    
270
            }
271
           
272
            SetAdornerMember(objectData as CommentUserInfo);
273
            this.Focus();
274
        }
275

    
276
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
277
        {
278
            InitializeComponent();
279
            foreach (var item in objectData)
280
            {
281
                //item.IsHitTestVisible = false;
282
                if ((item as ArrowTextControl) != null)
283
                {
284
                    (item as ArrowTextControl).Base_TextBox.Focusable = true;
285
                }
286
                try
287
                {
288
                    Canvas.SetZIndex(item, 80);
289
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
290
                    this.ContainerContent.Children.Add(item);
291
                }
292
                catch //(Exception ex)
293
                {
294
                }
295
                finally
296
                {
297
                    
298
                }
299
            }
300
            this.SetAdornerMember(objectData);
301
            this.Focus();
302
        }
303

    
304
        public Point Centeroid
305
        {
306
            get
307
            {
308
                List<Point> pts = new List<Point>();
309

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

    
330
                return MathSet.FindCentroid(pts);
331
            }
332
        }
333

    
334
        #endregion
335
        #region 메서드
336
        public Rect getAdornerSize()
337
        {
338
            return BorderSize;
339
        }
340
        public void addMemberControl(UIElement objectData)
341
        {
342
            this.ContainerContent.Children.Add(objectData);
343
            SetAdornerMember(objectData as CommentUserInfo);
344
            this.Focus();
345
        }
346

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

    
352
            if (sender is TextBox)
353
            {
354
                if ((sender as 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
                    break;
412
                case "ArrowTextControl":
413
                    this.Members.Add(new AdornerMember
414
                    {
415
                        DrawingData = member,
416
                        Drawingtype = ControlType.ArrowTextControl,
417
                        ThumbList = new List<MyThumb>(),
418
                        Symbol_ID = member.SymbolID,
419
                        Group_ID = member.GroupID,
420
                    });
421
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
422
                    AngleValue = (member as ArrowTextControl).CommentAngle;
423

    
424
                    ((ArrowTextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
425

    
426
                    //Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
427
                    //{
428
                    //    TextCompensation = false;
429
                    //    BorderUpdate();
430
                    //    if ((a.Sender as TextBox).Text == "") //보류
431
                    //    {
432
                    //        this.ContainerContent.Children.Remove(member);
433
                    //        this.Visibility = Visibility.Collapsed;
434
                    //    }
435
                    //});
436
                    break;
437
                case "ImgControl":
438
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
439
                    AngleValue = (member as ImgControl).CommentAngle;
440
                    break;
441
                case "DateControl":
442
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
443
                    AngleValue = (member as DateControl).CommentAngle;
444
                    break;
445
                case "SignControl":
446
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
447
                    AngleValue = (member as SignControl).CommentAngle;
448
                    break;
449
                case "SymControl":
450
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
451
                    AngleValue = (member as SymControl).CommentAngle;
452
                    break;
453
                case "SymControlN":
454
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
455
                    AngleValue = (member as SymControlN).CommentAngle;
456
                    break;
457
                case "TextControl":
458
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
459
                    RectangleGeometry Data = new RectangleGeometry
460
                    {
461
                        Rect = new Rect()
462
                        {
463
                            X = Canvas.GetLeft((member as TextControl)),
464
                            Y = Canvas.GetTop((member as TextControl)),
465
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
466
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
467
                            //Width = (member as TextControl).BoxWidth / 2,
468
                            //Height = (member as TextControl).BoxHeight / 2,
469
                        }
470
                    };
471
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
472
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
473

    
474

    
475
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
476
                    DragThumb.RenderTransform = new RotateTransform()
477
                    {
478
                        Angle = (member as TextControl).CommentAngle,
479
                        //CenterX = middle.X,
480
                        //CenterY = middle.Y,
481
                    };
482

    
483
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
484
                    AdornerBorder.RenderTransform = new RotateTransform()
485
                    {
486
                        Angle = (member as TextControl).CommentAngle,
487
                        //CenterX = middle.X,
488
                        //CenterY = middle.Y,
489
                    };
490
                    //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
491
                    //{
492
                    //    TextCompensation = true;
493
                    //    BorderUpdate();
494
                    //    ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
495
                    //});
496

    
497
                    //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
498
                    //{
499
                    //    TextCompensation = true;
500
                    //    BorderUpdate();
501
                    //    ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
502
                    //});
503

    
504
                    ((TextControl)member).PropertyChanged += TextControlPropertyChanged;
505
                    ((TextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
506

    
507
                    //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
508
                    //{
509
                    //    TextCompensation = false;
510
                    //    BorderUpdate();
511
                    //    if ((a.Sender as TextBox).Text == "") //보류
512
                    //    {
513
                    //        this.ContainerContent.Children.Remove(member);
514
                    //        this.Visibility = Visibility.Collapsed;
515
                    //    }
516

    
517
                    //    //((TextControl)member).UnEditingMode();
518
                    //    //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
519
                    //    //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
520
                    //    //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
521
                    //});
522
                    break;
523
                default:
524
                    break;
525
                    #endregion
526
            }
527

    
528
            if (member.GetType().Name == "TextControl")
529
            {
530
                TextControl content = ((TextControl)member);
531
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
532
                content.EndPoint = content.StartPoint;
533
            }
534
            else
535
            {
536
                RegistryPoint(member);
537
            }
538
            BorderUpdate();
539

    
540
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
541
                Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
542
        }
543

    
544

    
545
        public void SetAdornerMember(List<CommentUserInfo> members)
546
        {
547
            foreach (var member in members)
548
            {
549
                switch (member.GetType().Name)
550
                {
551
                    #region 컨트롤 조건
552
                    case "LineControl":
553
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
554
                        break;
555
                    case "ImgControl":
556
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
557
                        break;
558
                    case "ArrowControl":
559
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
560
                        break;
561
                    case "PolygonControl":
562
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
563
                        break;
564
                    case "ArrowTextControl":
565
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
566
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
567
                        break;
568
                    case "ArcControl":
569
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
570
                        break;
571
                    case "ArrowArcControl":
572
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
573
                        break;
574
                    case "DateControl":
575
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
576
                        break;
577
                    case "ArrowControl_Multi":
578
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
579
                        break;
580
                    case "RectangleControl":
581
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
582
                        break;
583
                    case "TriControl":
584
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
585
                        break;
586
                    case "CircleControl":
587
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
588
                        break;
589
                    case "CloudControl":
590
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
591
                        break;
592
                    case "RectCloudControl":
593
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
594
                        break;
595
                    case "SignControl":
596
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
597
                        break;
598
                    case "SymControl":
599
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
600
                        break;
601
                    case "SymControlN":
602
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
603
                        break;
604
                    case "InkControl":
605
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
606
                        break;
607
                    case "TextControl":
608
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
609

    
610
                        (member as TextControl).PropertyChanged += TextControlPropertyChanged;
611
                        (member as TextControl).Base_TextBox.SelectionChanged += TextControlSelectionChanged;
612

    
613
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
614
                        //{
615
                        //    BorderUpdate();
616
                        //});
617
                        //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
618
                        //{
619
                        //    BorderUpdate();
620
                        //    try
621
                        //    {
622
                        //        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
623
                        //    }
624
                        //    catch (Exception)
625
                        //    {
626

    
627
                        //    }
628

    
629
                        //});
630
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
631
                        //{
632
                        //    BorderUpdate();
633
                        //});
634
                        break;
635
                    case "InsideWhiteControl":
636
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
637
                        break;
638
                    case "OverlapWhiteControl":
639
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
640
                        break;
641
                    case "ClipWhiteControl":
642
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
643
                        break;
644
                    case "CoordinateControl":
645
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
646
                        break;
647
                    default:
648
                        break;
649
                        #endregion
650
                }
651
                if (member.GetType().Name == "TextControl")
652
                {
653
                    TextControl content = ((TextControl)member);
654
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
655
                    content.EndPoint = content.StartPoint;
656
                }
657
                else
658
                {
659
                    RegistryPoint(member, members.Count);
660
                }
661

    
662
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
663
                    Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
664
            }
665

    
666
            BorderUpdate();
667
        }
668

    
669

    
670
        /// <summary>
671
        /// Border 를 갱신
672
        /// </summary>
673
        public void BorderUpdate()
674
        {
675
            AdornerBorder.MinWidth = 10;
676
            AdornerBorder.MinHeight = 10;
677

    
678
            double minX = double.MaxValue;
679
            double minY = double.MaxValue;
680
            double maxX = double.MinValue;
681
            double maxY = double.MinValue;
682

    
683
            if (this.Members.Count == 1)
684
            {
685
                if (this.Members[0].DrawingData.GetType().Name == "TextControl")
686
                {
687
                    if ((this.Members[0].DrawingData as TextControl).CommentAngle != 0)
688
                    {
689
                        trRotate.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
690
                        trRotateThumb.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
691
                    }
692
                    else
693
                    {
694
                        trRotate.Angle = 0;
695
                        trRotateThumb.Angle = 0;
696
                    }
697
                }
698
            }
699

    
700
            foreach (var item in this.Members)
701
            {
702
                UIElement currentControl = (item as AdornerMember).DrawingData;
703

    
704
                Point startP = (currentControl as IPath).StartPoint;
705
                Point endP = (currentControl as IPath).EndPoint;
706

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

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

    
712
                if (item.DrawingData.GetType().Name == "TextControl")
713
                {
714
                    double textControlWidth;
715
                    double textControlHeight;
716

    
717
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
718
                    {
719
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
720
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
721
                    }
722
                    else
723
                    {
724
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
725
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
726
                    }
727
                    
728
                    if ((currentControl as TextControl).EndPoint.X < minX)
729
                    {
730
                        minX = (currentControl as TextControl).EndPoint.X;
731
                    }
732

    
733
                    if ((currentControl as TextControl).EndPoint.Y < minY)
734
                    {
735
                        minY = (currentControl as TextControl).EndPoint.Y;
736
                    }
737

    
738
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
739
                    {
740
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
741
                    }
742

    
743
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
744
                    {
745
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
746
                    }
747
                }
748
                else if ((currentControl as IViewBox) != null)
749
                {
750
                    IViewBox instance = currentControl as IViewBox;
751
                    List<Point> am = (currentControl as IPath).PointSet;
752
                    List<double> xSet = am.Select(p => p.X).ToList();
753
                    List<double> ySet = am.Select(p => p.Y).ToList();
754
                    if (xSet.Min() < minX) minX = xSet.Min();
755
                    if (ySet.Min() < minY) minY = ySet.Min();
756
                    if (xSet.Max() > maxX) maxX = xSet.Max();
757
                    if (ySet.Max() > maxY) maxY = ySet.Max();
758
                }
759
                else if ((currentControl as IPath).PathData == null)
760
                {
761
                    Rect rt = new Rect
762
                    {
763
                        X = (currentControl as IPath).StartPoint.X,
764
                        Y = (currentControl as IPath).StartPoint.Y,
765
                        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),
766
                        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),
767
                    };
768
                    if (rt.Left < minX) minX = rt.Left;
769
                    if (rt.Top < minY) minY = rt.Top;
770
                    if (rt.Right > maxX) maxX = rt.Right;
771
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
772
                }
773
                else if ((currentControl as IPath) == null)
774
                {
775
                    Rect rt = new Rect
776
                    {
777
                        X = (currentControl as IPath).StartPoint.X,
778
                        Y = (currentControl as IPath).StartPoint.Y,
779
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
780
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
781
                    };
782
                    if (rt.Left < minX) minX = rt.Left;
783
                    if (rt.Top < minY) minY = rt.Top;
784
                    if (rt.Right > maxX) maxX = rt.Right;
785
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
786
                }
787
                else if (currentControl is CircleControl CircleCtrl)
788
                {
789
                    List<Point> am = CircleCtrl.PointSet;
790
                    minX = am.Min(x => x.X);
791
                    minY = am.Min(x => x.Y);
792
                    maxX = am.Max(x => x.X);
793
                    maxY = am.Max(x => x.Y);
794
                }
795
                else
796
                {
797
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
798
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
799
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
800
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
801
                }
802
            }
803

    
804
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
805
            bool addWidthSize = false;
806
            bool addHeightSize = false;
807
            if (ac.Width <= 10)
808
            {
809
                ac.Width += 10;
810
                addWidthSize = true;
811
            }
812
            if (ac.Height <= 10)
813
            {
814
                ac.Height += 10;
815
                addHeightSize = true;
816
            }
817
            BorderSize = ac;
818
            AdornerBorder.MinWidth = 10;
819
            AdornerBorder.MinHeight = 10;
820
            AdornerBorder.Width = ac.Width;
821
            AdornerBorder.Height = ac.Height;
822
            Canvas.SetLeft(AdornerBorder, minX);
823
            Canvas.SetTop(AdornerBorder, minY);
824

    
825
            DragThumb.Width = ac.Width;
826
            DragThumb.Height = ac.Height;
827

    
828
            DragThumb.MinWidth = 10;
829
            DragThumb.MinHeight = 10;
830
            if (addWidthSize)
831
            {
832
                Canvas.SetLeft(DragThumb, minX - 5);
833
            }
834
            else
835
            {
836
                Canvas.SetLeft(DragThumb, minX);
837
            }
838

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

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

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

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

    
891
                this.Members.Last().ThumbList.Add(tm);
892

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1077
            var direction = VisualHelper.GetPointDirection(newpoint, ViewerDataModel.Instance.PageAngle);
1078

    
1079
            System.Diagnostics.Debug.WriteLine("뱡향 : " + direction.ToString());
1080

    
1081
            AdornerMember control = CurrentAdornerMember(thumb);
1082
            var commentInfo = (control.DrawingData) as CommentUserInfo;
1083

    
1084
            if (commentInfo is ArrowTextControl)
1085
            {
1086
                Point getThumbPoint = GetPosition(thumb);
1087

    
1088
                var arrowText = commentInfo as ArrowTextControl;
1089

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

    
1096
                control.UpdateThumb();
1097

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

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

    
1103
        }
1104
        
1105

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

    
1115
            MyThumb thumb = sender as MyThumb;
1116

    
1117
            if (this.Members.Count > 1) return;
1118

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

    
1121
            double newHorizontalChange = e.HorizontalChange;
1122
            double newVerticalChange = e.VerticalChange;
1123

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

    
1128
                Point setPoint = GetPosition(thumb);
1129

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

    
1132
                AdornerMember control = CurrentAdornerMember(thumb);
1133
                var commentInfo = (control.DrawingData) as CommentUserInfo;
1134

    
1135
                double ratatePointAngle = 0;
1136

    
1137
                if (commentInfo is ArrowTextControl)
1138
                {
1139
                    var textControl = (commentInfo as ArrowTextControl);
1140

    
1141
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1142

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

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

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

    
1166
                //thumbPoint.X = Math.Abs(thumbPoint.X);
1167
                //thumbPoint.Y = Math.Abs(thumbPoint.Y);
1168

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

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

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

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

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

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

    
1191
        private AdornerMember CurrentAdornerMember(MyThumb thumb)
1192
        {
1193
            AdornerMember result = null;
1194

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

    
1206
            return result;
1207
        }
1208

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

    
1214
        #endregion
1215
        #region 이벤트
1216

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

    
1222
            List<Point> lstPointTemp = new List<Point>();
1223
            foreach(var vPoint in this.lstBeforePointSet)
1224
            {
1225
                lstPointTemp.Add(vPoint);
1226
            }
1227

    
1228
            var comments = (from drawing in this.Members
1229
                            select drawing.DrawingData as CommentUserInfo).ToList();
1230
            UndoCommand.Instance.Push(comments, this.AngleValue, 0, lstPointTemp);
1231
            ViewerDataModel.Instance.IsMarkupUpdate = true;
1232
        }
1233

    
1234
        /// <summary>
1235
        /// start drag
1236
        /// </summary>
1237
        /// <param name="sender"></param>
1238
        /// <param name="e"></param>
1239
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1240
        {
1241
            this.DraggerThumb = sender as Thumb;
1242
            this.isDragging = true;
1243

    
1244
            if (ViewerDataModel.Instance.UndoDataList == null)
1245
            {
1246
                return;
1247
            }
1248

    
1249
            if (lstBeforePointSet == null)
1250
                lstBeforePointSet = new List<Point>();
1251

    
1252
            lstBeforePointSet.Clear();
1253
            foreach(var vPoint in ((dynamic)this.Members.FirstOrDefault().DrawingData).PointSet)
1254
            {
1255
                lstBeforePointSet.Add(vPoint);
1256
            }
1257

    
1258
            //lstBeforePointSet = ((dynamic)this.Members.FirstOrDefault().DrawingData).PointSet;
1259

    
1260
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1261
            {
1262
                return;
1263
            }
1264

    
1265
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1266
            {
1267
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1268
                {
1269
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1270
                    {
1271
                        return;
1272
                    }
1273
                }
1274
            }
1275

    
1276
            var comments = (from drawing in this.Members
1277
                            select drawing.DrawingData as CommentUserInfo).ToList();
1278
            UndoCommand.Instance.Push(comments, this.AngleValue, 0, lstBeforePointSet);
1279
        }
1280

    
1281
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1282
        {
1283
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1284
            {
1285
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1286
                    IsTextAngle = true;
1287
                else
1288
                    IsTextAngle = false;
1289
                LastRotateVerticalValue = e.GetPosition(this).X;
1290
            }
1291
            else
1292
            {
1293
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1294
                {
1295
                    RotateFlag = true;
1296
                }
1297
                else
1298
                {
1299
                    RotateFlag = false;
1300
                }
1301
                LastRotateHorizontalValue = e.GetPosition(this).X;
1302
            }
1303
        }
1304

    
1305
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1306
        {
1307
            /// save mouse down and current mouse point
1308
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1309
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1310
            /// up to here
1311

    
1312
            if (ViewerDataModel.Instance.UndoDataList == null)
1313
            {
1314
                return;
1315
            }
1316
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1317
            {
1318
                return;
1319
            }
1320
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1321
            {
1322
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1323
                {
1324
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1325
                    {
1326
                        return;
1327
                    }
1328
                }
1329
            }
1330

    
1331
            var comments = (from drawing in this.Members
1332
                            select drawing.DrawingData as CommentUserInfo).ToList();
1333
            UndoCommand.Instance.Push(comments, this.AngleValue);
1334
        }
1335

    
1336
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1337
        {
1338
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1339

    
1340
            var comments = (from drawing in this.Members
1341
                            select drawing.DrawingData as CommentUserInfo).ToList();
1342
            UndoCommand.Instance.Push(comments, this.AngleValue);
1343
        }
1344

    
1345
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1346
        {
1347
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1348

    
1349
            var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1350
         
1351
            var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1352
            var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1353

    
1354
            try
1355
            {
1356
                DragThumb.Cursor = Cursors.SizeAll;
1357
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1358
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1359

    
1360

    
1361
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1362

    
1363
                //if (ViewerDataModel.Instance.PageAngle == 270 || ViewerDataModel.Instance.PageAngle == 90)
1364
                //{
1365
                //    mainRect = new Rect(0, 0, mainRect.Height, mainRect.Width);
1366
                //}
1367

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

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

    
1372
                var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1373
                
1374
                var moveDirection = mainRect.Movement(rotationRect);
1375

    
1376
                System.Diagnostics.Debug.WriteLine($"horzChange: {horzChange} , vertChange:{vertChange}");
1377
                //System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : Top:{rect.Top}, Left:{rect.Left}, Right:{rect.Right}, Bottom:{rect.Bottom} ,BottomLeft : {rect.BottomLeft} BottomRight : {rect.BottomRight}");
1378

    
1379
                //if (Math.Abs(horzChange) > 0)
1380
                //{
1381
                //    if ((horzChange < 0 && !moveDirection.Left) || (horzChange > 0 && !moveDirection.Right))
1382
                //    {
1383
                //        //this.TranslateItems(horzChange * -1, 0);
1384
                //        //e.Handled = true;
1385
                //        horzChange = 0;
1386
                //        newMousePoint.X = this.CurrentMousePoint.X;
1387
                //    }
1388
                //}
1389

    
1390
                //if (Math.Abs(vertChange) > 0)
1391
                //{
1392
                //    if ((vertChange < 0 && !moveDirection.Up) || (vertChange > 0 && !moveDirection.Down))
1393
                //    {
1394
                //        //this.TranslateItems(0, vertChange * -1);
1395
                //        //e.Handled = true;
1396
                //        vertChange = 0;
1397
                //        newMousePoint.Y = this.CurrentMousePoint.Y;
1398
                //    }
1399
                //}
1400

    
1401
                this.TranslateItems(horzChange, vertChange);
1402
            }
1403
            finally
1404
            {
1405
                /// update CurrentMousePoint
1406
                this.CurrentMousePoint = newMousePoint;
1407
            }
1408
        }
1409

    
1410
        /// <summary>
1411
        /// translate all members
1412
        /// </summary>
1413
        /// <param name="e"></param>
1414
        public void TranslateItems(double dx, double dy)
1415
        {
1416
            Dispatcher.BeginInvoke((Action)(() =>
1417
            {
1418
                foreach (var item in this.Members)
1419
                {
1420
                    this.TranslateItem(dx, dy, item);
1421
                }
1422

    
1423
                this.BorderUpdate();
1424
            }));
1425
        }
1426

    
1427
        /// <summary>
1428
        /// translate a item
1429
        /// </summary>
1430
        /// <param name="e"></param>
1431
        /// <param name="item"></param>
1432
        private void TranslateItem(double dx, double dy, AdornerMember item)
1433
        {
1434
            /// rotate point with page rotation
1435
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1436
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1437
            /// up to here
1438
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1439

    
1440
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1441
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null);            
1442

    
1443
            item.UpdateThumb();
1444
        }
1445

    
1446
        private void resize_MouseMove(object sender, MouseEventArgs e)
1447
        {
1448
            //reSizePoint = e.GetPosition(this);
1449
        }
1450

    
1451
        /// <summary>
1452
        /// 회전
1453
        /// </summary>
1454
        /// <param name="sender"></param>
1455
        /// <param name="e"></param>
1456
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1457
        {
1458
            MoveRotate(e);
1459
        }
1460

    
1461
        double LastRotateHorizontalValue = 0;
1462
        double LastRotateVerticalValue = 0;
1463
        bool RotateFlag = false;
1464

    
1465
        /// <summary>
1466
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1467
        /// </summary>
1468
        /// <param name="e"></param>
1469
        public void MoveRotate(DragDeltaEventArgs e)
1470
        {
1471
            Point CenterPoint = this.Centeroid;
1472
            Point pt = Mouse.GetPosition(this);
1473

    
1474
            #region X축 기준으로 회전 각도를 구한다.
1475
            Vector AxisY = new Vector(0, 1);
1476
            Vector vec2 = new Vector(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1477
            vec2.Normalize();
1478
            double angle = Vector.AngleBetween(AxisY, vec2);
1479
            if (angle > 360) angle -= 360;
1480
            if (angle < 0) angle += 360;
1481
            #endregion
1482

    
1483
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1484
            if (ViewerDataModel.Instance.IsAxisLock)
1485
            {
1486
                angle = AlignedAngles.OrderBy(x => Math.Abs(angle - x)).First();
1487
            }
1488
            #endregion
1489

    
1490
            double dDeltaAngle = angle - AngleValue;
1491
            AngleValue = angle;
1492

    
1493
            /// save rotatePoint
1494
            this.rotatePoint = pt;
1495

    
1496
            Dispatcher.BeginInvoke((Action)(() =>
1497
            {
1498
                foreach (var member in this.Members)
1499
                {
1500
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1501
                    #region 보더 업데이트
1502
                    switch (member.Drawingtype)
1503
                    {
1504
                        case ControlType.TextControl:
1505
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1506

    
1507
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1508
                            DragThumb.RenderTransform = new RotateTransform()
1509
                            {
1510
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1511
                            };
1512

    
1513
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1514
                            AdornerBorder.RenderTransform = new RotateTransform()
1515
                            {
1516
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1517
                            };
1518

    
1519
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1520
                            BorderUpdate();
1521
                            break;
1522

    
1523
                        case ControlType.ArrowMultiLine:
1524
                        case ControlType.ArcLine:
1525
                        case ControlType.ArcArrow:
1526
                        case ControlType.SingleLine:
1527
                        case ControlType.Triangle:
1528
                        case ControlType.ArrowTextControl:
1529
                        case ControlType.PolygonControl:
1530
                        case ControlType.Ink:
1531
                            BorderUpdate();
1532
                            break;
1533
                        case ControlType.Date:
1534
                        case ControlType.RectCloud:
1535
                        case ControlType.Rectangle:
1536
                        case ControlType.ImgControl:
1537
                        case ControlType.Sign:
1538
                        case ControlType.Symbol:
1539
                        case ControlType.Stamp:
1540
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1541
                            BorderUpdate();
1542
                            break;
1543
                        case ControlType.PolygonCloud:
1544
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1545
                            BorderUpdate();
1546
                            break;
1547
                        case ControlType.Circle:
1548
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1549
                            ((CircleControl)member.DrawingData).SetCenterXY();
1550
                            BorderUpdate();
1551
                            break;
1552
                        default:
1553
                            break;
1554
                    }
1555
                }
1556
                #endregion
1557
            }));
1558
        }
1559

    
1560
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1561
        {            
1562
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1563
            rotateTop.Cursor = Cursors.SizeAll;
1564

    
1565
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1566
            if ((1 == this.Members.Count) && (this.Members[0]).DrawingData.GetType().Name == "TextControl")
1567
            {
1568
                this.AngleValue = ((this.Members[0]).DrawingData as TextControl).CommentAngle;
1569
            }
1570
            /// up to here
1571

    
1572
            dBeforeAngle = this.angleValue;
1573

    
1574
            if (ViewerDataModel.Instance.UndoDataList == null)
1575
            {
1576
                return;
1577
            }
1578

    
1579
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1580
            {
1581
                return;
1582
            }
1583

    
1584
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1585
            {
1586
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1587
                {
1588
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1589
                    {
1590
                        return;
1591
                    }
1592
                }
1593
            }
1594

    
1595
            var comments = (from drawing in this.Members
1596
                            select drawing.DrawingData as CommentUserInfo).ToList();
1597
            UndoCommand.Instance.Push(comments, this.AngleValue, this.angleValue);
1598
        }
1599
        
1600
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1601
        {
1602
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1603

    
1604

    
1605

    
1606
            var comments = (from drawing in this.Members
1607
                            select drawing.DrawingData as CommentUserInfo).ToList();
1608
            UndoCommand.Instance.Push(comments, this.AngleValue, dBeforeAngle);
1609
        }
1610

    
1611
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1612
        {
1613
            AdornerMember control = this.Members.FirstOrDefault();
1614

    
1615
            if ((control.DrawingData as ArrowTextControl) != null)
1616
            {
1617
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1618
                {
1619
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1620
                }
1621
            }
1622

    
1623
        }
1624

    
1625
        public void TextControlChanger()
1626
        {
1627
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1628
            {
1629
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1630
                AllControl.Base_TextBox.Focus();
1631
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1632
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1633
                AllControl.Base_TextBox.IsHitTestVisible = true;
1634
                AllControl.IsEditingMode = true;
1635
                AllControl.Base_TextBox.Focus();
1636

    
1637
                AllControl.SizeChanged += (sen, ea) =>
1638
                {
1639
                    if (AllControl.Base_TextBox != null)
1640
                    {
1641
                        RectangleGeometry Data = new RectangleGeometry
1642
                        {
1643
                            Rect = new Rect()
1644
                            {
1645
                                X = AllControl.StartPoint.X,
1646
                                Y = AllControl.StartPoint.Y,
1647
                                Width = AllControl.Base_TextBox.Width,
1648
                                Height = AllControl.Base_TextBox.Height,
1649
                            }
1650
                        };
1651

    
1652
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1653
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1654
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1655
                        {
1656
                            Angle = AllControl.CommentAngle,
1657
                            CenterX = middle.X,
1658
                            CenterY = middle.Y,
1659
                        };
1660
                    }
1661
                    BorderUpdate();
1662
                };
1663
            }
1664
        }
1665

    
1666
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1667
        {
1668
            if (e.ClickCount == 2 && this.Members.Count == 1)
1669
            {
1670
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1671
                {
1672
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1673
                    TextControlChanger();                    
1674
                }
1675

    
1676
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1677
                {
1678
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1679
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1680
               
1681
                    //ArrowControl TextBox Thumb없애기
1682
                    tm.Visibility = Visibility.Collapsed;
1683

    
1684
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1685
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1686

    
1687
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1688
                    
1689

    
1690
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1691

    
1692
                    {
1693
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1694
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1695

    
1696
                        List<Point> ps = new List<Point>();
1697
                        
1698
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1699
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1700
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1701
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1702

    
1703

    
1704

    
1705

    
1706
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1707
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1708
                        if (AllControl.isTrans)
1709
                        {
1710
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1711
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1712
                        }
1713
                        else
1714
                        {
1715
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1716
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1717
                        }
1718

    
1719

    
1720
                        BorderUpdate();
1721

    
1722
                    };
1723
                }
1724
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1725
                {
1726
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1727
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1728
                    //dropData.IsOpen = true;
1729
                    RadWindow rc = new RadWindow();
1730
                    rc.Width = 300;
1731
                    rc.Height = 300;
1732
                    rc.Header = "Change Date";
1733
                    rc.Content = instanceCal;
1734
                    rc.BorderThickness = new Thickness(3);
1735
                    rc.ResizeMode = ResizeMode.NoResize;
1736
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1737
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1738
                    rc.ModalBackground.Opacity = 0.6;
1739
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1740
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1741
                    {
1742
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1743
                        rc.Close();
1744
                    };
1745
                    rc.ShowDialog();
1746
                    //CalendarControl.xaml
1747
                }
1748
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1749
                {
1750
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1751
                    if (instance.isTransOn)
1752
                    {
1753
                        instance.isTransOn = false;
1754
                    }
1755
                    else
1756
                    {
1757
                        instance.isTransOn = true;
1758
                    }
1759
                    ///instance.SetArcPath();
1760
                    BorderUpdate();
1761
                }
1762
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1763
                {
1764
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1765
                    if (instance.isTransOn)
1766
                    {
1767
                        instance.isTransOn = false;
1768
                    }
1769
                    else
1770
                    {
1771
                        instance.isTransOn = true;
1772
                    }
1773
                    instance.SetArcPath();
1774
                    BorderUpdate();
1775
                }
1776

    
1777
            }
1778
            
1779
        }
1780
        #endregion
1781

    
1782
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1783
        {
1784
            if ((this.Members[0] as AdornerMember).DrawingData.GetType().Name == "TextControl" 
1785
                || (this.Members[0] as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1786
            {
1787
                DragThumb.Visibility = Visibility.Collapsed;
1788
            }
1789
        }
1790
    }
1791
}
클립보드 이미지 추가 (최대 크기: 500 MB)