프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (83.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.Polygon;
9
using MarkupToPDF.Controls.Shape;
10
using MarkupToPDF.Controls.Text;
11
using System;
12
using System.Collections.Generic;
13
using System.Diagnostics;
14
using System.Linq;
15
using System.Reactive.Linq;
16
using System.Text;
17
using System.Windows;
18
using System.Windows.Controls;
19
using System.Windows.Controls.Primitives;
20
using System.Windows.Input;
21
using System.Windows.Media;
22
using Telerik.Windows.Controls;
23

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

    
35
        /// <summary>
36
        /// translate thumb with given delta and angle
37
        /// </summary>
38
        /// <param name="e"></param>
39
        /// <param name="angle"></param>
40
        public void Translate(double dx, double dy, double angle)
41
        {
42
            double radian = angle * Math.PI / 180;
43
            double cos = Math.Cos(radian);
44
            double sin = Math.Sin(radian);
45

    
46
            double _dx = dx * cos - dy * sin;
47
            double _dy = dx * sin + dy * cos;
48
            Canvas.SetLeft(this, Canvas.GetLeft(this) + _dx);
49
            Canvas.SetTop(this, Canvas.GetTop(this) + _dy);
50
        }
51

    
52
        /// <summary>
53
        /// </summary>
54
        /// <param name="sender"></param>
55
        /// <param name="e"></param>
56
        private void MyThumb_MouseLeave(object sender, MouseEventArgs e)
57
        {
58
            this.Opacity = 0.6;
59
        }
60

    
61
        /// <summary>
62
        /// 
63
        /// </summary>
64
        /// <param name="sender"></param>
65
        /// <param name="e"></param>
66
        private void MyThumb_MouseEnter(object sender, MouseEventArgs e)
67
        {
68
            this.Opacity = 1.0;
69
        }
70
    }
71

    
72
    /// <summary>
73
    /// Interaction logic for AdornerFinal.xaml
74
    /// </summary>
75
    public class AdornerMember
76
    {
77
        public UIElement DrawingData { get; set; }
78
        public ControlType Drawingtype { get; set; }
79
        public double DrawingAngle { get; set; }
80
        public List<MyThumb> ThumbList { get; set; }
81
        public string Symbol_ID { get; set; }
82
        public long Group_ID { get; set; }
83

    
84
        /// <summary>
85
        /// update thumb
86
        /// </summary>
87
        public void UpdateThumb()
88
        {
89
            var path = this.DrawingData as IPath;
90
            for (int i = 0; i < path.PointSet.Count; ++i)
91
            {
92
                Canvas.SetLeft(this.ThumbList[i], path.PointSet[i].X);
93
                Canvas.SetTop(this.ThumbList[i], path.PointSet[i].Y);
94
            }
95

    
96
            if (this.DrawingData as ArrowTextControl != null)
97
            {
98
                if (!(this.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
99
                {
100
                    List<Point> ps = new List<Point>();
101

    
102
                    var temp = this.DrawingData as ArrowTextControl;
103
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
104
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
105
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
106
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
107

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

    
142
        /// <summary>
143
        /// rotate members about given position and angle
144
        /// </summary>
145
        /// <param name="at"></param>
146
        /// <param name="angle">in degree</param>
147
        public void RotateAbout(Point at, double angle)
148
        {
149
            for (int i = 0; i < (this.DrawingData as IPath).PointSet.Count; i++)
150
            {
151
                (this.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(at, (this.DrawingData as IPath).PointSet[i], angle);
152
            }
153
            (this.DrawingData as CommentUserInfo).UpdateControl();
154

    
155
            this.UpdateThumb();
156
        }
157
    }
158

    
159
    public partial class AdornerFinal : UserControl
160
    {
161
        public TextBox editTextBox { get; set; }
162
        #region 공용 인스턴스
163
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
164
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
165
        public double AngleValue = 0;
166
        public bool IsTextAngle = false;
167
        public Rect BorderSize { get; set; }
168
        public bool TextCompensation = false;
169
        public bool isDragging { get; set; }
170
        public Thumb DraggerThumb { get; set; }
171
        public RadDropDownButton dropData;
172
        public RadCalendar dropCalendar;
173
        public Thumb mainDragThumb { get; set; }
174

    
175
        private bool disposed;
176

    
177
        public Point reSizePoint { get; set; }
178
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
179
        private Point MouseDownPoint = new Point();
180
        private Point CurrentMousePoint = new Point();
181
        #endregion
182
        #region 생성자
183
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
184
        {
185
            dropData = sender as RadDropDownButton;
186
        }
187

    
188
        private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
189
        {
190
            dropCalendar = sender as RadCalendar;
191
            dropCalendar.SelectionChanged += (sen, ea) =>
192
            {
193
                dropData.IsOpen = false;
194
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
195
                {
196
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
197
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
198
                }
199
            };
200
        }
201

    
202
        public AdornerFinal()
203
        {
204
            InitializeComponent();
205
            BorderSize = new Rect();
206
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
207
        }
208

    
209
        ~AdornerFinal()
210
        {
211
            this.Dispose(false);
212
        }
213

    
214
        public void Dispose()
215
        {
216
            this.Dispose(true);
217
            GC.SuppressFinalize(this);
218
        }
219

    
220
        protected virtual void Dispose(bool disposing)
221
        {
222
            if (this.disposed) return;
223
            if (disposing)
224
            {
225
                foreach (var member in this.Members)
226
                {
227
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
228
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
229
                }
230
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
231
            }
232
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
233
            this.disposed = true;
234
        }
235

    
236
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
237
        {
238
            mainDragThumb = DragThumb;
239
        }
240

    
241
        public AdornerFinal(CommentUserInfo objectData) : this()
242
        {
243
            InitializeComponent();
244
            objectData.IsHitTestVisible = false;
245
            if ((objectData as ArrowTextControl) != null)
246
            {
247
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
248
            }
249
            Canvas.SetZIndex(objectData, 84);
250
            try
251
            {
252
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
253
                this.ContainerContent.Children.Add(objectData);
254
            }
255
            catch (Exception ex)
256
            {
257

    
258
            }
259
           
260
            SetAdornerMember(objectData as CommentUserInfo);
261
            this.Focus();
262
        }
263

    
264
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
265
        {
266
            InitializeComponent();
267
            foreach (var item in objectData)
268
            {
269
                //item.IsHitTestVisible = false;
270
                if ((item as ArrowTextControl) != null)
271
                {
272
                    (item as ArrowTextControl).Base_TextBox.Focusable = true;
273
                }
274
                try
275
                {
276
                    Canvas.SetZIndex(item, 80);
277
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
278
                    this.ContainerContent.Children.Add(item);
279
                }
280
                catch //(Exception ex)
281
                {
282
                }
283
                finally
284
                {
285
                    
286
                }
287
            }
288
            this.SetAdornerMember(objectData);
289
            this.Focus();
290
        }
291

    
292
        #endregion
293
        #region 메서드
294
        public Rect getAdornerSize()
295
        {
296
            return BorderSize;
297
        }
298
        public void addMemberControl(UIElement objectData)
299
        {
300
            this.ContainerContent.Children.Add(objectData);
301
            SetAdornerMember(objectData as CommentUserInfo);
302
            this.Focus();
303
        }
304
        /// <summary>
305
        /// UIElement를 종류에 맞게 등록시킴
306
        /// </summary>
307
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
308
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
309
        {
310
            switch (member.GetType().Name)
311
            {
312
                #region 컨트롤 조건
313
                case "LineControl":
314
                case "PolygonControl":
315
                case "ArrowControl":
316
                case "ArcControl":
317
                case "ArrowArcControl":
318
                case "ArrowControl_Multi":
319
                case "RectangleControl":
320
                case "TriControl":
321
                case "CircleControl":
322
                case "CloudControl":
323
                case "RectCloudControl":
324
                case "InkControl":
325
                case "InsideWhiteControl":
326
                case "OverlapWhiteControl":
327
                case "ClipWhiteControl":
328
                case "CoordinateControl":
329
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
330
                    break;
331
                case "ArrowTextControl":
332
                    this.Members.Add(new AdornerMember
333
                    {
334
                        DrawingData = member,
335
                        Drawingtype = ControlType.ArrowTextControl,
336
                        ThumbList = new List<MyThumb>(),
337
                        Symbol_ID = member.SymbolID,
338
                        Group_ID = member.GroupID,
339
                    });
340
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
341
                    AngleValue = (member as ArrowTextControl).Angle;
342
                    Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
343
                    {
344
                        TextCompensation = false;
345
                        BorderUpdate();
346
                        if ((a.Sender as TextBox).Text == "") //보류
347
                        {
348
                            this.ContainerContent.Children.Remove(member);
349
                            this.Visibility = Visibility.Collapsed;
350
                        }
351
                    });
352
                    break;
353
                case "ImgControl":
354
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
355
                    AngleValue = (member as ImgControl).Angle;
356
                    break;
357
                case "DateControl":
358
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
359
                    AngleValue = (member as DateControl).Angle;
360
                    break;
361
                case "SignControl":
362
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
363
                    AngleValue = (member as SignControl).Angle;
364
                    break;
365
                case "SymControl":
366
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
367
                    AngleValue = (member as SymControl).Angle;
368
                    break;
369
                case "SymControlN":
370
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
371
                    AngleValue = (member as SymControlN).Angle;
372
                    break;
373
                case "TextControl":
374
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
375
                    RectangleGeometry Data = new RectangleGeometry
376
                    {
377
                        Rect = new Rect()
378
                        {
379
                            X = Canvas.GetLeft((member as TextControl)),
380
                            Y = Canvas.GetTop((member as TextControl)),
381
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
382
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
383
                            //Width = (member as TextControl).BoxWidth / 2,
384
                            //Height = (member as TextControl).BoxHeight / 2,
385
                        }
386
                    };
387
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
388
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
389

    
390

    
391
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
392
                    DragThumb.RenderTransform = new RotateTransform()
393
                    {
394
                        Angle = (member as TextControl).Angle,
395
                        //CenterX = middle.X,
396
                        //CenterY = middle.Y,
397
                    };
398

    
399
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
400
                    AdornerBorder.RenderTransform = new RotateTransform()
401
                    {
402
                        Angle = (member as TextControl).Angle,
403
                        //CenterX = middle.X,
404
                        //CenterY = middle.Y,
405
                    };
406
                    Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
407
                    {
408
                        TextCompensation = true;
409
                        BorderUpdate();
410
                        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
411
                    });
412
                    Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
413
                    {
414
                        TextCompensation = false;
415
                        BorderUpdate();
416
                        if ((a.Sender as TextBox).Text == "") //보류
417
                        {
418
                            this.ContainerContent.Children.Remove(member);
419
                            this.Visibility = Visibility.Collapsed;
420
                        }
421

    
422
                        //((TextControl)member).UnEditingMode();
423
                        //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
424
                        //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
425
                        //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
426
                    });
427
                    break;
428
                default:
429
                    break;
430
                    #endregion
431
            }
432

    
433
            if (member.GetType().Name == "TextControl")
434
            {
435
                TextControl content = ((TextControl)member);
436
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
437
                content.EndPoint = content.StartPoint;
438
            }
439
            else
440
            {
441
                RegistryPoint(member);
442
            }
443
            BorderUpdate();
444

    
445
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
446
        }
447

    
448
        private void ViewBoxRotate(UIElement member)
449
        {
450
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
451
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
452
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
453
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
454
        }
455

    
456
        public void SetAdornerMember(List<CommentUserInfo> members)
457
        {
458
            foreach (var member in members)
459
            {
460
                switch (member.GetType().Name)
461
                {
462
                    #region 컨트롤 조건
463
                    case "LineControl":
464
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
465
                        break;
466
                    case "ImgControl":
467
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
468
                        break;
469
                    case "ArrowControl":
470
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
471
                        break;
472
                    case "PolygonControl":
473
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
474
                        break;
475
                    case "ArrowTextControl":
476
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
477
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
478
                        break;
479
                    case "ArcControl":
480
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
481
                        break;
482
                    case "ArrowArcControl":
483
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
484
                        break;
485
                    case "DateControl":
486
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
487
                        break;
488
                    case "ArrowControl_Multi":
489
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
490
                        break;
491
                    case "RectangleControl":
492
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
493
                        break;
494
                    case "TriControl":
495
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
496
                        break;
497
                    case "CircleControl":
498
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
499
                        break;
500
                    case "CloudControl":
501
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
502
                        break;
503
                    case "RectCloudControl":
504
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
505
                        break;
506
                    case "SignControl":
507
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
508
                        break;
509
                    case "SymControl":
510
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
511
                        break;
512
                    case "SymControlN":
513
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
514
                        break;
515
                    case "InkControl":
516
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
517
                        break;
518
                    case "TextControl":
519
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
520
                        Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
521
                        {
522
                            BorderUpdate();
523
                            try
524
                            {
525
                                ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
526
                            }
527
                            catch (Exception)
528
                            {
529

    
530
                            }
531

    
532
                        });
533
                        Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
534
                        {
535
                            BorderUpdate();
536
                        });
537
                        break;
538
                    case "InsideWhiteControl":
539
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
540
                        break;
541
                    case "OverlapWhiteControl":
542
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
543
                        break;
544
                    case "ClipWhiteControl":
545
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
546
                        break;
547
                    case "CoordinateControl":
548
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
549
                        break;
550
                    default:
551
                        break;
552
                        #endregion
553
                }
554
                if (member.GetType().Name == "TextControl")
555
                {
556
                    TextControl content = ((TextControl)member);
557
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
558
                    content.EndPoint = content.StartPoint;
559
                }
560
                else
561
                {
562
                    RegistryPoint(member, members.Count);
563
                }
564

    
565
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))  Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
566
            }
567

    
568
            BorderUpdate();
569
        }
570

    
571
        /// <summary>
572
        /// Border 를 갱신
573
        /// </summary>
574
        public void BorderUpdate()
575
        {
576
            AdornerBorder.MinWidth = 10;
577
            AdornerBorder.MinHeight = 10;
578

    
579
            double minX = double.MaxValue;
580
            double minY = double.MaxValue;
581
            double maxX = double.MinValue;
582
            double maxY = double.MinValue;
583

    
584
            if (this.Members.Count == 1)
585
            {
586
                if (this.Members.First().DrawingData.GetType().Name == "TextControl")
587
                {
588
                    if ((this.Members.First().DrawingData as TextControl).Angle != 0)
589
                    {
590
                        trRotate.Angle = (this.Members.First().DrawingData as TextControl).Angle;
591
                        trRotateThumb.Angle = (this.Members.First().DrawingData as TextControl).Angle;
592
                    }
593
                    else
594
                    {
595
                        trRotate.Angle = 0;
596
                        trRotateThumb.Angle = 0;
597
                    }
598
                }
599
            }
600
            foreach (var item in this.Members)
601
            {
602
                UIElement currentControl = (item as AdornerMember).DrawingData;
603
                if (item.DrawingData.GetType().Name == "TextControl")
604
                {
605
                    double textControlWidth;
606
                    double textControlHeight;
607
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
608
                    {
609
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
610
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
611
                    }
612
                    else
613
                    {
614
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
615
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
616
                    }
617
                    
618
                    if ((currentControl as TextControl).EndPoint.X < minX)
619
                    {
620
                        minX = (currentControl as TextControl).EndPoint.X;
621
                    }
622
                    if ((currentControl as TextControl).EndPoint.Y < minY)
623
                    {
624
                        minY = (currentControl as TextControl).EndPoint.Y;
625
                    }
626
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
627
                    {
628
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
629
                    }
630
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
631
                    {
632
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
633
                    }
634
                }
635
                else if ((currentControl as IViewBox) != null)
636
                {
637
                    IViewBox instance = currentControl as IViewBox;
638
                    List<Point> am = (currentControl as IPath).PointSet;
639
                    List<double> xSet = am.Select(p => p.X).ToList();
640
                    List<double> ySet = am.Select(p => p.Y).ToList();
641
                    if (xSet.Min() < minX) minX = xSet.Min();
642
                    if (ySet.Min() < minY) minY = ySet.Min();
643
                    if (xSet.Max() > maxX) maxX = xSet.Max();
644
                    if (ySet.Max() > maxY) maxY = ySet.Max();
645
                }
646
                else if ((currentControl as IPath).PathData == null)
647
                {
648
                    Rect rt = new Rect
649
                    {
650
                        X = (currentControl as IPath).StartPoint.X,
651
                        Y = (currentControl as IPath).StartPoint.Y,
652
                        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),
653
                        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),
654
                    };
655
                    if (rt.Left < minX) minX = rt.Left;
656
                    if (rt.Top < minY) minY = rt.Top;
657
                    if (rt.Right > maxX) maxX = rt.Right;
658
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
659
                }
660
                else if ((currentControl as IPath) == null)
661
                {
662
                    Rect rt = new Rect
663
                    {
664
                        X = (currentControl as IPath).StartPoint.X,
665
                        Y = (currentControl as IPath).StartPoint.Y,
666
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
667
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
668
                    };
669
                    if (rt.Left < minX) minX = rt.Left;
670
                    if (rt.Top < minY) minY = rt.Top;
671
                    if (rt.Right > maxX) maxX = rt.Right;
672
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
673
                }
674
                else if ((currentControl as CircleControl) != null)
675
                {                    
676
                    List<Point> am = (currentControl as IPath).PointSet;
677
                    List<double> xSet = am.Select(p => p.X).ToList();
678
                    List<double> ySet = am.Select(p => p.Y).ToList();
679
                    if (xSet.Min() < minX) minX = xSet.Min();
680
                    if (ySet.Min() < minY) minY = ySet.Min();
681
                    if (xSet.Max() > maxX) maxX = xSet.Max();
682
                    if (ySet.Max() > maxY) maxY = ySet.Max();
683
                }
684
                else
685
                {
686
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
687
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
688
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
689
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
690
                }
691
            }
692

    
693
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
694
            bool addWidthSize = false;
695
            bool addHeightSize = false;
696
            if (ac.Width <= 10)
697
            {
698
                ac.Width += 10;
699
                addWidthSize = true;
700
            }
701
            if (ac.Height <= 10)
702
            {
703
                ac.Height += 10;
704
                addHeightSize = true;
705
            }
706
            BorderSize = ac;
707
            AdornerBorder.MinWidth = 10;
708
            AdornerBorder.MinHeight = 10;
709
            AdornerBorder.Width = ac.Width;
710
            AdornerBorder.Height = ac.Height;
711
            Canvas.SetLeft(AdornerBorder, minX);
712
            Canvas.SetTop(AdornerBorder, minY);
713

    
714
            DragThumb.Width = ac.Width;
715
            DragThumb.Height = ac.Height;
716

    
717
            DragThumb.MinWidth = 10;
718
            DragThumb.MinHeight = 10;
719
            if (addWidthSize)
720
            {
721
                Canvas.SetLeft(DragThumb, minX - 5);
722
            }
723
            else
724
            {
725
                Canvas.SetLeft(DragThumb, minX);
726
            }
727

    
728
            if (addHeightSize)
729
            {
730
                Canvas.SetTop(DragThumb, minY - 5);
731
            }
732
            else
733
            {
734
                Canvas.SetTop(DragThumb, minY);
735
            }
736
        }
737
        /// <summary>
738
        /// UIElement 해제
739
        /// </summary>
740
        public void unRegister()
741
        {
742
            foreach (var item in this.ContainerContent.Children)
743
            {
744
                if (item is MarkupToPDF.Common.CommentUserInfo)
745
                {
746
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
747
                }
748
            }
749
            this.ContainerContent.Children.Clear();
750
        }
751

    
752
        /// <summary>
753
        /// 각 포인트들을 등록합니다.
754
        /// </summary>
755
        /// <param name="pointset">Drawing Point</param>
756
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
757
        {
758
            int count = 0;
759
            double Minx = 100000000;
760
            double Miny = 100000000;
761
            List<Point> list = (member as IPath).PointSet;
762
            if (member.GetType().Name == "InkControl")
763
            {
764
                list.Clear();
765
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
766
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
767
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
768
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
769
            }
770
            ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype;
771
            foreach (var ax in list)
772
            {
773
                Minx = (ax.X < Minx) ? ax.X : Minx;
774
                Miny = (ax.Y < Miny) ? ax.Y : Miny;
775
            }
776
            for (int i = 0; i < list.Count(); i++)
777
            {
778
                MyThumb tm = new MyThumb
779
                {
780
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
781
                };
782

    
783
                this.Members.Last().ThumbList.Add(tm);
784

    
785
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MidPoint))
786
                {
787
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
788
                }
789
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
790
                {
791
                    //if (this.Members.Count()<=1)
792
                    //{
793
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
794
                    List<Point> ps = new List<Point>();
795

    
796
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
797
                    {
798
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
799

    
800

    
801
                        switch (Math.Abs(temp.Angle).ToString())
802
                        {
803
                            case "90":
804
                                {
805
                                    ps.Clear();
806
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
807
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
808
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
809

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

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

    
816
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
817
                                }
818
                                break;
819
                            case "270":
820
                                {
821
                                    ps.Clear();
822
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
823
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
824
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
825

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

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

    
832
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
833
                                }
834
                                break;
835
                            default:
836
                                {
837
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
838
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
839
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
840
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
841
                                }
842
                                break;
843
                        }
844

    
845
                        ArrowTextControl instance = (member as ArrowTextControl);
846
                        if (instance.isTrans)
847
                        {
848
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
849
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
850
                            //list[count] = tempP;
851
                            list[count] = temp.MidPoint;
852
                        }
853
                        else
854
                        {
855
                            if (temp.isFixed)
856
                            {
857
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
858
                                var testP = endP;
859
                                if (ps[0] == endP) //상단
860
                                {
861
                                    testP = new Point(endP.X, endP.Y - 50);
862
                                }
863
                                else if (ps[1] == endP) //하단
864
                                {
865
                                    testP = new Point(endP.X, endP.Y + 50);
866
                                }
867
                                else if (ps[2] == endP) //좌단
868
                                {
869
                                    testP = new Point(endP.X - 50, endP.Y);
870
                                }
871
                                else if (ps[3] == endP) //우단
872
                                {
873
                                    testP = new Point(endP.X + 50, endP.Y);
874
                                }
875
                                list[count] = testP;
876
                            }
877
                            else
878
                            {
879
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
880
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
881
                            }
882
                        }
883
                    }
884
                }
885
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
886
                {
887
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
888
                    tm.Width = (member as ArrowTextControl).BoxWidth;
889
                    tm.Height = (member as ArrowTextControl).BoxHeight;
890
                    var angle = (member as ArrowTextControl).Angle;
891
                    if (Math.Abs(angle).ToString() == "90")
892
                    {
893
                        tm.RenderTransformOrigin = new Point(0, 0);
894
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
895
                    }
896
                    else if (Math.Abs(angle).ToString() == "270")
897
                    {
898
                        tm.RenderTransformOrigin = new Point(0, 0);
899
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
900
                    }
901
                    else
902
                    {
903
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
904
                        tm.RenderTransform = new RotateTransform()
905
                        {
906
                            Angle = angle,
907
                        };
908
                    }
909
                }
910
                
911
                if (member.GetType().Name == "CloudControl")
912
                {
913
                    if (i == list.Count() - 1)
914
                    {
915
                        tm.Visibility = System.Windows.Visibility.Collapsed;
916
                    }
917
                }
918
                if (member.GetType().Name == "PolygonControl")
919
                {
920
                    if (i == list.Count() - 1)
921
                    {
922
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
923
                        {
924

    
925
                        }
926
                        else
927
                        {
928
                            tm.Visibility = System.Windows.Visibility.Collapsed;
929
                        }
930
                    }
931
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
932
                    {
933
                        tm.Visibility = System.Windows.Visibility.Collapsed;
934
                    }
935
                }
936
                
937
                this.ContainerContent.Children.Add(tm);
938
                Canvas.SetLeft(tm, list[count].X);
939
                Canvas.SetTop(tm, list[count].Y);
940
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
941
                {
942
                    Canvas.SetZIndex(tm, 95);
943
                }
944
                else
945
                {
946
                    Canvas.SetZIndex(tm, 99);
947
                }
948

    
949
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
950
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
951
                tm.DragDelta += ResizeTm_DragDelta;
952
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
953
                count++;
954
            }
955
        }
956

    
957
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
958
        {
959
            if (this.Members.Count > 1) return;
960
            if (reSizePoint != new Point(0, 0))
961
            {
962
                MyThumb thumb = sender as MyThumb;
963
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
964
                thumb.Translate(e.HorizontalChange, e.VerticalChange, this.AngleValue);
965
                
966
                AdornerMember control = (from userThumb in this.Members
967
                                         where userThumb.ThumbList.Contains(thumb)
968
                                         select userThumb).FirstOrDefault();
969

    
970
                IPath AllControl = control.DrawingData as IPath;
971
                ((control.DrawingData) as CommentUserInfo).OnMoveCtrlPoint(setPoint, e.HorizontalChange, e.VerticalChange);
972
                control.UpdateThumb();
973
                this.BorderUpdate();
974
            }
975
        }
976

    
977
        #endregion
978
        #region 이벤트
979

    
980
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
981
        {
982
            this.isDragging = false;
983
            DraggerThumb = null;
984

    
985
            var comments = (from drawing in this.Members
986
                            select drawing.DrawingData as CommentUserInfo).ToList();
987
            UndoCommand.Instance.Push(comments, this.AngleValue);
988
        }
989

    
990
        /// <summary>
991
        /// start drag
992
        /// </summary>
993
        /// <param name="sender"></param>
994
        /// <param name="e"></param>
995
        void tm_DragStarted(object sender, DragStartedEventArgs e)
996
        {
997
            this.DraggerThumb = sender as Thumb;
998
            this.isDragging = true;
999

    
1000
            if (ViewerDataModel.Instance.UndoDataList == null)
1001
            {
1002
                return;
1003
            }
1004

    
1005
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1006
            {
1007
                return;
1008
            }
1009

    
1010
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1011
            {
1012
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1013
                {
1014
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1015
                    {
1016
                        return;
1017
                    }
1018
                }
1019
            }
1020

    
1021
            var comments = (from drawing in this.Members
1022
                            select drawing.DrawingData as CommentUserInfo).ToList();
1023
            UndoCommand.Instance.Push(comments, this.AngleValue);
1024
        }
1025

    
1026
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1027
        {
1028
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1029
            {
1030
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1031
                    IsTextAngle = true;
1032
                else
1033
                    IsTextAngle = false;
1034
                LastRotateVerticalValue = e.GetPosition(this).X;
1035
            }
1036
            else
1037
            {
1038
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1039
                {
1040
                    RotateFlag = true;
1041
                }
1042
                else
1043
                {
1044
                    RotateFlag = false;
1045
                }
1046
                LastRotateHorizontalValue = e.GetPosition(this).X;
1047
            }
1048
        }
1049

    
1050
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1051
        {
1052
            /// save mouse down and current mouse point
1053
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1054
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1055
            /// up to here
1056

    
1057
            if (ViewerDataModel.Instance.UndoDataList == null)
1058
            {
1059
                return;
1060
            }
1061
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1062
            {
1063
                return;
1064
            }
1065
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1066
            {
1067
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1068
                {
1069
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1070
                    {
1071
                        return;
1072
                    }
1073
                }
1074
            }
1075

    
1076
            var comments = (from drawing in this.Members
1077
                            select drawing.DrawingData as CommentUserInfo).ToList();
1078
            UndoCommand.Instance.Push(comments, this.AngleValue);
1079
        }
1080

    
1081
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1082
        {
1083
            DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1084

    
1085
            var comments = (from drawing in this.Members
1086
                            select drawing.DrawingData as CommentUserInfo).ToList();
1087
            UndoCommand.Instance.Push(comments, this.AngleValue);
1088
        }
1089

    
1090
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1091
        {
1092
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1093
            var tmp = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1094
            
1095
            var horzChange = Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1096
            var vertChange = Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1097
            try
1098
            {
1099
                DragThumb.Cursor = Cursors.SizeAll;
1100
                this.TranslateItems(horzChange, vertChange);
1101
            }
1102
            finally
1103
            {
1104
                /// update CurrentMousePoint
1105
                this.CurrentMousePoint = tmp;
1106
            }
1107
        }
1108

    
1109
        /// <summary>
1110
        /// translate all members
1111
        /// </summary>
1112
        /// <param name="e"></param>
1113
        public void TranslateItems(double dx, double dy)
1114
        {
1115
            Dispatcher.BeginInvoke((Action)(() =>
1116
            {
1117
                foreach (var item in this.Members)
1118
                {
1119
                    this.TranslateItem(dx, dy, item);
1120
                }
1121
            }));
1122
            this.BorderUpdate();
1123
        }
1124

    
1125
        /// <summary>
1126
        /// translate a item
1127
        /// </summary>
1128
        /// <param name="e"></param>
1129
        /// <param name="item"></param>
1130
        private void TranslateItem(double dx, double dy, AdornerMember item)
1131
        {
1132
            /// rotate point with page rotation
1133
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1134
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1135
            /// up to here
1136
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1137
            item.UpdateThumb();
1138
        }
1139

    
1140
        public void Set_Rotate()
1141
        {
1142
            double dDeltaAngle = 0;
1143
            List<Point> AllPointSet = new List<Point>();
1144
            Point CenterPoint = new Point();
1145

    
1146
            if (AngleValue >= 360)
1147
            {
1148
                AngleValue -= 360;
1149
            }
1150
            else if (AngleValue <= -360)
1151
            {
1152
                AngleValue += 360;
1153
            }
1154

    
1155
            #region 센터 포인트 구하기 (그룹핑)
1156
            foreach (var item in this.Members)
1157
            {
1158
                if (item.DrawingData.GetType().Name == "TextControl")
1159
                {
1160
                }
1161
                else
1162
                {
1163
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1164
                    {
1165
                        AllPointSet.Add(itemP);
1166
                    }
1167
                }
1168
            }
1169
            #endregion
1170

    
1171
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1172

    
1173
            Dispatcher.BeginInvoke((Action)(() =>
1174
            {
1175
                foreach (var item in this.Members)
1176
                {
1177
                    foreach (var thumb in item.ThumbList)
1178
                    {
1179
                        double x = Canvas.GetLeft(thumb);
1180
                        double y = Canvas.GetTop(thumb);
1181

    
1182
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1183
                        Canvas.SetLeft(thumb, value.X);
1184
                        Canvas.SetTop(thumb, value.Y);
1185

    
1186
                        if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last())
1187
                        {
1188

    
1189
                            Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1190
                            Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1191
                            if (!(item.DrawingData as ArrowTextControl).isTrans)
1192
                            {
1193
                                List<Point> ps = new List<Point>();
1194
                                var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1195
                                switch (Math.Abs(temp.Angle).ToString())
1196
                                {
1197
                                    case "90":
1198
                                        {
1199
                                            ps.Clear();
1200
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1201
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
1202
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
1203

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

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

    
1210
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
1211
                                        }
1212
                                        break;
1213
                                    case "270":
1214
                                        {
1215
                                            ps.Clear();
1216
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1217
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
1218
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
1219

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

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

    
1226
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
1227
                                        }
1228
                                        break;
1229
                                    default:
1230
                                        {
1231
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1232
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1233
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1234
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1235
                                        }
1236
                                        break;
1237
                                }
1238

    
1239
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1240
                                var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1241
                                Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1242
                                Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1243
                            }
1244
                        }
1245
                    }
1246

    
1247
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1248
                    {
1249
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1250
                    }
1251
                }
1252
                #region 컨트롤 업데이트
1253
                foreach (var item in this.Members)
1254
                {
1255
                    switch (item.Drawingtype)
1256
                    {
1257
                        case ControlType.TextControl:
1258
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1259

    
1260
                            RectangleGeometry Data = new RectangleGeometry
1261
                            {
1262
                                Rect = new Rect()
1263
                                {
1264
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1265
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1266
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1267
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1268
                                }
1269
                            };
1270

    
1271
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1272
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);                                                      
1273

    
1274
                            DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
1275
                            DragThumb.RenderTransform = new RotateTransform()
1276
                            {
1277
                                Angle = (item.DrawingData as TextControl).Angle,
1278

    
1279
                            };
1280

    
1281
                            AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
1282
                            AdornerBorder.RenderTransform = new RotateTransform()
1283
                            {
1284
                                Angle = (item.DrawingData as TextControl).Angle,
1285

    
1286
                            };
1287

    
1288
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1289
                            {
1290
                                Angle = (item.DrawingData as TextControl).Angle,
1291
                            };
1292
                            BorderUpdate();
1293
                            break;
1294

    
1295
                        case ControlType.Date:
1296
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1297
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1298
                            BorderUpdate();
1299
                            break;
1300
                        case ControlType.ArrowMultiLine:
1301
                        case ControlType.ArcLine:
1302
                        case ControlType.ArcArrow:
1303
                        case ControlType.SingleLine:
1304
                        case ControlType.Triangle:
1305
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1306
                            BorderUpdate();
1307
                            break;
1308
                        case ControlType.ArrowTextControl:
1309
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1310
                            BorderUpdate();
1311
                            break;
1312
                        case ControlType.RectCloud:
1313
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1314
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1315
                            BorderUpdate();
1316
                            break;
1317
                        case ControlType.Rectangle:
1318
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1319
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1320
                            BorderUpdate();
1321
                            break;
1322
                        case ControlType.ImgControl:
1323
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1324
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1325
                            BorderUpdate();
1326
                            break;
1327
                        case ControlType.Sign:
1328
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1329
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1330
                            BorderUpdate();
1331
                            break;
1332
                        case ControlType.Symbol:
1333
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1334
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1335
                            BorderUpdate();
1336
                            break;
1337
                        case ControlType.Stamp:
1338
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1339
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1340
                            BorderUpdate();
1341
                            break;
1342
                        case ControlType.PolygonControl:
1343
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1344
                            BorderUpdate();
1345
                            break;
1346
                        case ControlType.PolygonCloud:
1347
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1348
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1349
                            BorderUpdate();
1350
                            break;
1351
                        case ControlType.Circle:
1352
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1353
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1354
                            ((CircleControl)item.DrawingData).SetCenterXY();
1355
                            BorderUpdate();
1356
                            break;
1357
                        case ControlType.Ink:
1358
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1359
                            BorderUpdate();
1360
                            break;
1361
                        case ControlType.InsideWhite:
1362
                            ((InsideWhiteControl)item.DrawingData).Angle = AngleValue;
1363
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1364
                            BorderUpdate();
1365
                            break;
1366
                        case ControlType.OverlapWhite:
1367
                            ((OverlapWhiteControl)item.DrawingData).Angle = AngleValue;
1368
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1369
                            BorderUpdate();
1370
                            break;
1371
                        case ControlType.ClipWhite:
1372
                            ((ClipWhiteControl)item.DrawingData).Angle = AngleValue;
1373
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1374
                            BorderUpdate();
1375
                            break;
1376
                        case ControlType.Coordinate:
1377
                            ((CoordinateControl)item.DrawingData).Angle = AngleValue;
1378
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1379
                            BorderUpdate();
1380
                            break;
1381
                        default:
1382
                            break;
1383
                    }
1384
                }
1385
                #endregion
1386
            }));
1387
        }
1388

    
1389
        private void resize_MouseMove(object sender, MouseEventArgs e)
1390
        {
1391
            reSizePoint = e.GetPosition(this);
1392
        }
1393

    
1394
        /// <summary>
1395
        /// 회전
1396
        /// </summary>
1397
        /// <param name="sender"></param>
1398
        /// <param name="e"></param>
1399
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1400
        {
1401
            MoveRotate(e);
1402
        }
1403

    
1404
        double LastRotateHorizontalValue = 0;
1405
        double LastRotateVerticalValue = 0;
1406
        bool RotateFlag = false;
1407

    
1408
        /// <summary>
1409
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1410
        /// </summary>
1411
        /// <param name="e"></param>
1412
        public void MoveRotate(DragDeltaEventArgs e)
1413
        {
1414
            double dDeltaAngle = 0;
1415

    
1416
            List<Point> AllPointSet = new List<Point>();
1417
            Point CenterPoint = new Point();
1418
            
1419
            #region 센터 포인트 구하기 (그룹핑)
1420
            foreach (var item in this.Members)
1421
            {
1422
                if (item.DrawingData.GetType().Name == "TextControl")
1423
                {                    
1424
                    if (AngleValue == 0)
1425
                    {
1426
                        AngleValue = (item.DrawingData as TextControl).Angle;
1427
                    }
1428
                    double X = Canvas.GetLeft((item.DrawingData as TextControl));
1429
                    double Y = Canvas.GetTop((item.DrawingData as TextControl));
1430
                    AllPointSet.Add(new Point(X, Y));
1431
                }
1432
                else
1433
                {
1434
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1435
                    {
1436
                        AllPointSet.Add(itemP);
1437
                    }
1438
                }
1439
            }
1440
            #endregion
1441
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1442
            Point pt = Mouse.GetPosition(this);
1443

    
1444
            Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
1445
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1446
            dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1447

    
1448
            AngleValue += dDeltaAngle;
1449
            if (AngleValue > 360) AngleValue -= 360;
1450
            if (AngleValue < 0) AngleValue += 360;
1451
            this.rotatePoint = pt;  /// save rotatePoint
1452

    
1453
            Dispatcher.BeginInvoke((Action)(() =>
1454
            {
1455
                foreach (var member in this.Members)
1456
                {
1457
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1458
                    #region 보더 업데이트
1459
                    switch (member.Drawingtype)
1460
                    {
1461
                        case ControlType.TextControl:
1462
                            (member.DrawingData as CommentUserInfo).Angle = AngleValue;
1463

    
1464
                            RectangleGeometry Data = new RectangleGeometry
1465
                            {
1466
                                Rect = new Rect()
1467
                                {
1468
                                    X = Canvas.GetLeft((member.DrawingData as TextControl)),
1469
                                    Y = Canvas.GetTop((member.DrawingData as TextControl)),
1470
                                    Width = (member.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1471
                                    Height = (member.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1472
                                }
1473
                            };
1474

    
1475
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1476
                            Point middle = MathSet.getMiddlePoint((member.DrawingData as TextControl).StartPoint, endPointV);
1477

    
1478
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1479
                            DragThumb.RenderTransform = new RotateTransform()
1480
                            {
1481
                                Angle = (member.DrawingData as TextControl).Angle,
1482
                            };
1483

    
1484
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1485
                            AdornerBorder.RenderTransform = new RotateTransform()
1486
                            {
1487
                                Angle = (member.DrawingData as TextControl).Angle,
1488
                            };
1489

    
1490
                            (member.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1491
                            {
1492
                                Angle = (member.DrawingData as TextControl).Angle,
1493
                            };
1494

    
1495
                            BorderUpdate();
1496
                            break;
1497

    
1498
                        case ControlType.ArrowMultiLine:
1499
                        case ControlType.ArcLine:
1500
                        case ControlType.ArcArrow:
1501
                        case ControlType.SingleLine:
1502
                        case ControlType.Triangle:
1503
                        case ControlType.ArrowTextControl:
1504
                        case ControlType.PolygonControl:
1505
                        case ControlType.Ink:
1506
                            BorderUpdate();
1507
                            break;
1508
                        case ControlType.Date:
1509
                        case ControlType.RectCloud:
1510
                        case ControlType.Rectangle:
1511
                        case ControlType.ImgControl:
1512
                        case ControlType.Sign:
1513
                        case ControlType.Symbol:
1514
                        case ControlType.Stamp:
1515
                            (member.DrawingData as CommentUserInfo).Angle = AngleValue;
1516
                            BorderUpdate();
1517
                            break;
1518
                        case ControlType.PolygonCloud:
1519
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1520
                            BorderUpdate();
1521
                            break;
1522
                        case ControlType.Circle:
1523
                            (member.DrawingData as CommentUserInfo).Angle = AngleValue;
1524
                            ((CircleControl)member.DrawingData).SetCenterXY();
1525
                            BorderUpdate();
1526
                            break;
1527
                        default:
1528
                            break;
1529
                    }
1530
                }
1531
                #endregion
1532
            }));
1533
        }
1534

    
1535
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1536
        {            
1537

    
1538
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1539
            rotateTop.Cursor = Cursors.SizeAll;
1540

    
1541
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1542
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1543
            {
1544
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).Angle;
1545
            }
1546
            /// up to here
1547

    
1548

    
1549

    
1550
            if (ViewerDataModel.Instance.UndoDataList == null)
1551
            {
1552
                return;
1553
            }
1554

    
1555
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1556
            {
1557
                return;
1558
            }
1559

    
1560
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1561
            {
1562
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1563
                {
1564
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1565
                    {
1566
                        return;
1567
                    }
1568
                }
1569
            }
1570

    
1571
            var comments = (from drawing in this.Members
1572
                            select drawing.DrawingData as CommentUserInfo).ToList();
1573
            UndoCommand.Instance.Push(comments, this.AngleValue);
1574
        }
1575
        
1576
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1577
        {
1578
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1579

    
1580
            var comments = (from drawing in this.Members
1581
                            select drawing.DrawingData as CommentUserInfo).ToList();
1582
            UndoCommand.Instance.Push(comments, this.AngleValue);
1583
        }
1584

    
1585
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1586
        {
1587
            AdornerMember control = this.Members.FirstOrDefault();
1588

    
1589
            if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null)
1590
            {
1591
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1592
                {
1593
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1594
                }
1595
            }
1596

    
1597
        }
1598

    
1599
        public void TextControlChanger()
1600
        {
1601
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1602
            {
1603
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1604
                AllControl.Base_TextBox.Focus();
1605
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1606
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1607
                AllControl.Base_TextBox.Focus();
1608
                AllControl.SizeChanged += (sen, ea) =>
1609
                {
1610
                    if (AllControl.Base_TextBox != null)
1611
                    {
1612
                        RectangleGeometry Data = new RectangleGeometry
1613
                        {
1614
                            Rect = new Rect()
1615
                            {
1616
                                X = AllControl.StartPoint.X,
1617
                                Y = AllControl.StartPoint.Y,
1618
                                Width = AllControl.Base_TextBox.Width,
1619
                                Height = AllControl.Base_TextBox.Height,
1620
                            }
1621
                        };
1622

    
1623
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1624
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1625
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1626
                        {
1627
                            Angle = AllControl.Angle,
1628
                            CenterX = middle.X,
1629
                            CenterY = middle.Y,
1630
                        };
1631
                    }
1632
                    BorderUpdate();
1633
                };
1634
            }
1635
        }
1636

    
1637
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1638
        {
1639
            if (e.ClickCount == 2 && this.Members.Count == 1)
1640
            {
1641

    
1642
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1643
                {
1644
                    TextControlChanger();                    
1645
                }
1646

    
1647
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1648
                {
1649
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1650
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1651
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1652

    
1653
                    //ArrowControl TextBox Thumb없애기
1654
                    tm.Visibility = Visibility.Collapsed;
1655

    
1656
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1657
                    
1658
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1659

    
1660
                    {
1661
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1662
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1663

    
1664
                        List<Point> ps = new List<Point>();
1665
                        
1666
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1667
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1668
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1669
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1670

    
1671

    
1672

    
1673

    
1674
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1675
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1676
                        if (AllControl.isTrans)
1677
                        {
1678
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1679
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1680
                        }
1681
                        else
1682
                        {
1683
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1684
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1685
                        }
1686

    
1687

    
1688
                        BorderUpdate();
1689

    
1690
                    };
1691
                }
1692
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1693
                {
1694
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1695
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1696
                    //dropData.IsOpen = true;
1697
                    RadWindow rc = new RadWindow();
1698
                    rc.Width = 300;
1699
                    rc.Height = 300;
1700
                    rc.Header = "Change Date";
1701
                    rc.Content = instanceCal;
1702
                    rc.BorderThickness = new Thickness(3);
1703
                    rc.ResizeMode = ResizeMode.NoResize;
1704
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1705
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1706
                    rc.ModalBackground.Opacity = 0.6;
1707
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1708
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1709
                    {
1710
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1711
                        rc.Close();
1712
                    };
1713
                    rc.ShowDialog();
1714
                    //CalendarControl.xaml
1715
                }
1716
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1717
                {
1718
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1719
                    if (instance.isTransOn)
1720
                    {
1721
                        instance.isTransOn = false;
1722
                    }
1723
                    else
1724
                    {
1725
                        instance.isTransOn = true;
1726
                    }
1727
                    ///instance.SetArcPath();
1728
                    BorderUpdate();
1729
                }
1730
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1731
                {
1732
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1733
                    if (instance.isTransOn)
1734
                    {
1735
                        instance.isTransOn = false;
1736
                    }
1737
                    else
1738
                    {
1739
                        instance.isTransOn = true;
1740
                    }
1741
                    instance.SetArcPath();
1742
                    BorderUpdate();
1743
                }
1744

    
1745
            }
1746
            
1747
        }
1748
        #endregion
1749

    
1750
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1751
        {
1752
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1753
            {
1754
                DragThumb.Visibility = Visibility.Collapsed;
1755
            }
1756
        }
1757
    }
1758
}
클립보드 이미지 추가 (최대 크기: 500 MB)