프로젝트

일반

사용자정보

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

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

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

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

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

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

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

    
44

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

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

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

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

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

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

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

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

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

    
152
    public partial class AdornerFinal : UserControl
153
    {
154
        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
            
1250
            //if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1251
            //{
1252
            //    return;
1253
            //}
1254

    
1255
            //if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1256
            //{
1257
            //    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1258
            //    {
1259
            //        if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1260
            //        {
1261
            //            return;
1262
            //        }
1263
            //    }
1264
            //}
1265

    
1266
            var comments = (from drawing in this.Members
1267
                            select drawing.DrawingData as CommentUserInfo).ToList();
1268
            //UndoCommand.Instance.Push(comments, this.AngleValue, 0, lstBeforePointSet);
1269
            UndoCommand.Instance.Push(comments);
1270
        }
1271

    
1272
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1273
        {
1274
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1275
            {
1276
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1277
                    IsTextAngle = true;
1278
                else
1279
                    IsTextAngle = false;
1280
                LastRotateVerticalValue = e.GetPosition(this).X;
1281
            }
1282
            else
1283
            {
1284
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1285
                {
1286
                    RotateFlag = true;
1287
                }
1288
                else
1289
                {
1290
                    RotateFlag = false;
1291
                }
1292
                LastRotateHorizontalValue = e.GetPosition(this).X;
1293
            }
1294
        }
1295

    
1296
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1297
        {
1298
            /// save mouse down and current mouse point
1299
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1300
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1301
            /// up to here
1302

    
1303
            if (ViewerDataModel.Instance.UndoDataList == null)
1304
            {
1305
                return;
1306
            }
1307
            //if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1308
            //{
1309
            //    return;
1310
            //}
1311
            //if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1312
            //{
1313
            //    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1314
            //    {
1315
            //        if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1316
            //        {
1317
            //            return;
1318
            //        }
1319
            //    }
1320
            //}
1321

    
1322
            var comments = (from drawing in this.Members
1323
                            select drawing.DrawingData as CommentUserInfo).ToList();
1324
            //UndoCommand.Instance.Push(comments, this.AngleValue);
1325
            UndoCommand.Instance.Push(comments);
1326
        }
1327

    
1328
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1329
        {
1330
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1331

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

    
1337
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1338
        {
1339
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1340

    
1341
            var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1342
         
1343
            var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1344
            var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1345

    
1346
            try
1347
            {
1348
                DragThumb.Cursor = Cursors.SizeAll;
1349
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1350
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1351

    
1352

    
1353
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1354

    
1355
                //if (ViewerDataModel.Instance.PageAngle == 270 || ViewerDataModel.Instance.PageAngle == 90)
1356
                //{
1357
                //    mainRect = new Rect(0, 0, mainRect.Height, mainRect.Width);
1358
                //}
1359

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

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

    
1364
                var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1365
                
1366
                var moveDirection = mainRect.Movement(rotationRect);
1367

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

    
1371
                //if (Math.Abs(horzChange) > 0)
1372
                //{
1373
                //    if ((horzChange < 0 && !moveDirection.Left) || (horzChange > 0 && !moveDirection.Right))
1374
                //    {
1375
                //        //this.TranslateItems(horzChange * -1, 0);
1376
                //        //e.Handled = true;
1377
                //        horzChange = 0;
1378
                //        newMousePoint.X = this.CurrentMousePoint.X;
1379
                //    }
1380
                //}
1381

    
1382
                //if (Math.Abs(vertChange) > 0)
1383
                //{
1384
                //    if ((vertChange < 0 && !moveDirection.Up) || (vertChange > 0 && !moveDirection.Down))
1385
                //    {
1386
                //        //this.TranslateItems(0, vertChange * -1);
1387
                //        //e.Handled = true;
1388
                //        vertChange = 0;
1389
                //        newMousePoint.Y = this.CurrentMousePoint.Y;
1390
                //    }
1391
                //}
1392

    
1393
                this.TranslateItems(horzChange, vertChange);
1394
            }
1395
            finally
1396
            {
1397
                /// update CurrentMousePoint
1398
                this.CurrentMousePoint = newMousePoint;
1399
            }
1400
        }
1401

    
1402
        /// <summary>
1403
        /// translate all members
1404
        /// </summary>
1405
        /// <param name="e"></param>
1406
        public void TranslateItems(double dx, double dy)
1407
        {
1408
            Dispatcher.BeginInvoke((Action)(() =>
1409
            {
1410
                foreach (var item in this.Members)
1411
                {
1412
                    this.TranslateItem(dx, dy, item);
1413
                }
1414

    
1415
                this.BorderUpdate();
1416
            }));
1417
        }
1418

    
1419
        /// <summary>
1420
        /// translate a item
1421
        /// </summary>
1422
        /// <param name="e"></param>
1423
        /// <param name="item"></param>
1424
        private void TranslateItem(double dx, double dy, AdornerMember item)
1425
        {
1426
            /// rotate point with page rotation
1427
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1428
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1429
            /// up to here
1430
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1431

    
1432
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1433
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null);            
1434

    
1435
            item.UpdateThumb();
1436
        }
1437

    
1438
        private void resize_MouseMove(object sender, MouseEventArgs e)
1439
        {
1440
            //reSizePoint = e.GetPosition(this);
1441
        }
1442

    
1443
        /// <summary>
1444
        /// 회전
1445
        /// </summary>
1446
        /// <param name="sender"></param>
1447
        /// <param name="e"></param>
1448
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1449
        {
1450
            MoveRotate(e);
1451
        }
1452

    
1453
        double LastRotateHorizontalValue = 0;
1454
        double LastRotateVerticalValue = 0;
1455
        bool RotateFlag = false;
1456

    
1457
        /// <summary>
1458
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1459
        /// </summary>
1460
        /// <param name="e"></param>
1461
        public void MoveRotate(DragDeltaEventArgs e)
1462
        {
1463
            Point CenterPoint = this.Centeroid;
1464
            Point pt = Mouse.GetPosition(this);
1465

    
1466
            #region X축 기준으로 회전 각도를 구한다.
1467
            Vector AxisY = new Vector(0, 1);
1468
            Vector vec2 = new Vector(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1469
            vec2.Normalize();
1470
            double angle = Vector.AngleBetween(AxisY, vec2);
1471
            if (angle > 360) angle -= 360;
1472
            if (angle < 0) angle += 360;
1473
            #endregion
1474

    
1475
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1476
            if (ViewerDataModel.Instance.IsAxisLock)
1477
            {
1478
                angle = AlignedAngles.OrderBy(x => Math.Abs(angle - x)).First();
1479
            }
1480
            #endregion
1481

    
1482
            double dDeltaAngle = angle - AngleValue;
1483
            AngleValue = angle;
1484

    
1485
            /// save rotatePoint
1486
            this.rotatePoint = pt;
1487

    
1488
            Dispatcher.BeginInvoke((Action)(() =>
1489
            {
1490
                foreach (var member in this.Members)
1491
                {
1492
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1493
                    #region 보더 업데이트
1494
                    switch (member.Drawingtype)
1495
                    {
1496
                        case ControlType.TextControl:
1497
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1498

    
1499
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1500
                            DragThumb.RenderTransform = new RotateTransform()
1501
                            {
1502
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1503
                            };
1504

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

    
1511
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1512
                            BorderUpdate();
1513
                            break;
1514

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

    
1552
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1553
        {            
1554
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1555
            rotateTop.Cursor = Cursors.SizeAll;
1556

    
1557
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1558
            if ((1 == this.Members.Count) && (this.Members[0]).DrawingData.GetType().Name == "TextControl")
1559
            {
1560
                this.AngleValue = ((this.Members[0]).DrawingData as TextControl).CommentAngle;
1561
            }
1562
            /// up to here
1563

    
1564
            //dBeforeAngle = this.angleValue;
1565

    
1566
            if (ViewerDataModel.Instance.UndoDataList == null)
1567
            {
1568
                return;
1569
            }
1570

    
1571
            //if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1572
            //{
1573
            //    return;
1574
            //}
1575

    
1576
            //if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1577
            //{
1578
            //    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1579
            //    {
1580
            //        if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1581
            //        {
1582
            //            return;
1583
            //        }
1584
            //    }
1585
            //}
1586

    
1587
            var comments = (from drawing in this.Members
1588
                            select drawing.DrawingData as CommentUserInfo).ToList();
1589
            //UndoCommand.Instance.Push(comments, this.AngleValue, this.angleValue);
1590
            UndoCommand.Instance.Push(comments);
1591
        }
1592
        
1593
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1594
        {
1595
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1596

    
1597

    
1598

    
1599
            var comments = (from drawing in this.Members
1600
                            select drawing.DrawingData as CommentUserInfo).ToList();
1601
            //UndoCommand.Instance.Push(comments, this.AngleValue, dBeforeAngle);
1602
        }
1603

    
1604
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1605
        {
1606
            AdornerMember control = this.Members.FirstOrDefault();
1607

    
1608
            if ((control.DrawingData as ArrowTextControl) != null)
1609
            {
1610
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1611
                {
1612
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1613
                }
1614
            }
1615

    
1616
        }
1617

    
1618
        public void TextControlChanger()
1619
        {
1620
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1621
            {
1622
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1623
                AllControl.Base_TextBox.Focus();
1624
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1625
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1626
                AllControl.Base_TextBox.IsHitTestVisible = true;
1627
                AllControl.IsEditingMode = true;
1628
                AllControl.Base_TextBox.Focus();
1629

    
1630
                AllControl.SizeChanged += (sen, ea) =>
1631
                {
1632
                    if (AllControl.Base_TextBox != null)
1633
                    {
1634
                        RectangleGeometry Data = new RectangleGeometry
1635
                        {
1636
                            Rect = new Rect()
1637
                            {
1638
                                X = AllControl.StartPoint.X,
1639
                                Y = AllControl.StartPoint.Y,
1640
                                Width = AllControl.Base_TextBox.Width,
1641
                                Height = AllControl.Base_TextBox.Height,
1642
                            }
1643
                        };
1644

    
1645
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1646
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1647
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1648
                        {
1649
                            Angle = AllControl.CommentAngle,
1650
                            CenterX = middle.X,
1651
                            CenterY = middle.Y,
1652
                        };
1653
                    }
1654
                    BorderUpdate();
1655
                };
1656
            }
1657
        }
1658

    
1659
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1660
        {
1661
            if (e.ClickCount == 2 && this.Members.Count == 1)
1662
            {
1663
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1664
                {
1665
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1666
                    TextControlChanger();                    
1667
                }
1668

    
1669
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1670
                {
1671
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1672
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1673
               
1674
                    //ArrowControl TextBox Thumb없애기
1675
                    tm.Visibility = Visibility.Collapsed;
1676

    
1677
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1678
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1679

    
1680
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1681
                    
1682

    
1683
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1684

    
1685
                    {
1686
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1687
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1688

    
1689
                        List<Point> ps = new List<Point>();
1690
                        
1691
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1692
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1693
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1694
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1695

    
1696

    
1697

    
1698

    
1699
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1700
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1701
                        if (AllControl.isTrans)
1702
                        {
1703
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1704
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1705
                        }
1706
                        else
1707
                        {
1708
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1709
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1710
                        }
1711

    
1712

    
1713
                        BorderUpdate();
1714

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

    
1770
            }
1771
            
1772
        }
1773
        #endregion
1774

    
1775
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1776
        {
1777
            if ((this.Members[0] as AdornerMember).DrawingData.GetType().Name == "TextControl" 
1778
                || (this.Members[0] as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1779
            {
1780
                DragThumb.Visibility = Visibility.Collapsed;
1781
            }
1782
        }
1783
    }
1784
}
클립보드 이미지 추가 (최대 크기: 500 MB)