프로젝트

일반

사용자정보

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

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

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

1
using KCOM.Common;
2
using KCOM.Events;
3
using MarkupToPDF.Common;
4
using MarkupToPDF.Controls.Cad;
5
using MarkupToPDF.Controls.Common;
6
using MarkupToPDF.Controls.Etc;
7
using MarkupToPDF.Controls.Line;
8
using MarkupToPDF.Controls.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

    
85
    public partial class AdornerFinal : UserControl
86
    {
87
        public TextBox editTextBox { get; set; }
88
        #region 공용 인스턴스
89
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
90
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
91
        public double AngleValue = 0;
92
        public bool IsTextAngle = false;
93
        public Rect BorderSize { get; set; }
94
        public bool TextCompensation = false;
95
        public bool isDragging { get; set; }
96
        public Thumb DraggerThumb { get; set; }
97
        public RadDropDownButton dropData;
98
        public RadCalendar dropCalendar;
99
        public Thumb mainDragThumb { get; set; }
100

    
101
        private bool disposed;
102

    
103
        public Point reSizePoint { get; set; }
104
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
105
        private Point MouseDownPoint = new Point();
106
        private Point CurrentMousePoint = new Point();
107
        #endregion
108
        #region 생성자
109
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
110
        {
111
            dropData = sender as RadDropDownButton;
112
        }
113

    
114
        private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
115
        {
116
            dropCalendar = sender as RadCalendar;
117
            dropCalendar.SelectionChanged += (sen, ea) =>
118
            {
119
                dropData.IsOpen = false;
120
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
121
                {
122
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
123
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
124
                }
125
            };
126
        }
127

    
128
        public AdornerFinal()
129
        {
130
            InitializeComponent();
131
            BorderSize = new Rect();
132
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
133
        }
134

    
135
        ~AdornerFinal()
136
        {
137
            this.Dispose(false);
138
        }
139

    
140
        public void Dispose()
141
        {
142
            this.Dispose(true);
143
            GC.SuppressFinalize(this);
144
        }
145

    
146
        protected virtual void Dispose(bool disposing)
147
        {
148
            if (this.disposed) return;
149
            if (disposing)
150
            {
151
                foreach (var member in this.Members)
152
                {
153
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
154
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
155
                }
156
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
157
            }
158
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
159
            this.disposed = true;
160
        }
161

    
162
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
163
        {
164
            mainDragThumb = DragThumb;
165
        }
166

    
167
        public AdornerFinal(CommentUserInfo objectData) : this()
168
        {
169
            InitializeComponent();
170
            objectData.IsHitTestVisible = false;
171
            if ((objectData as ArrowTextControl) != null)
172
            {
173
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
174
            }
175
            Canvas.SetZIndex(objectData, 84);
176
            try
177
            {
178
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
179
                this.ContainerContent.Children.Add(objectData);
180
            }
181
            catch (Exception ex)
182
            {
183

    
184
            }
185
           
186
            SetAdornerMember(objectData as CommentUserInfo);
187
            this.Focus();
188
        }
189

    
190
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
191
        {
192
            InitializeComponent();
193
            foreach (var item in objectData)
194
            {
195
                //item.IsHitTestVisible = false;
196
                if ((item as ArrowTextControl) != null)
197
                {
198
                    (item as ArrowTextControl).Base_TextBox.Focusable = true;
199
                }
200
                try
201
                {
202
                    Canvas.SetZIndex(item, 80);
203
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
204
                    this.ContainerContent.Children.Add(item);
205
                }
206
                catch //(Exception ex)
207
                {
208
                }
209
                finally
210
                {
211
                    
212
                }
213
            }
214
            this.SetAdornerMember(objectData);
215
            this.Focus();
216
        }
217

    
218
        #endregion
219
        #region 메서드
220
        public Rect getAdornerSize()
221
        {
222
            return BorderSize;
223
        }
224
        public void addMemberControl(UIElement objectData)
225
        {
226
            this.ContainerContent.Children.Add(objectData);
227
            SetAdornerMember(objectData as CommentUserInfo);
228
            this.Focus();
229
        }
230
        /// <summary>
231
        /// UIElement를 종류에 맞게 등록시킴
232
        /// </summary>
233
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
234
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
235
        {
236

    
237
            switch (member.GetType().Name)
238
            {
239
                #region 컨트롤 조건
240
                case "LineControl": //Angle추가 안했음
241
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
242
                    break;
243
                case "ImgControl": //Angle추가 안했음
244
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
245
                    //AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);            
246
                    //DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
247
                    AngleValue = (member as ImgControl).Angle;
248
                    break;
249
                //case "SymControl": //Angle추가 안했음
250
                //    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<MyThumb>() });
251
                //    AngleValue = (member as SymControl).Angle;
252
                //    //ViewBoxRotate(member);
253
                //    break;
254
                //case "SymControlN": //Angle추가 안했음
255
                //    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<MyThumb>() });
256
                //    AngleValue = (member as SymControlN).Angle;
257
                //    //ViewBoxRotate(member);
258
                //    break;
259
                case "PolygonControl": //Angle추가 안했음
260
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
261
                    break;
262
                case "ArrowControl":
263
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
264
                    break;
265
                case "ArrowTextControl":
266
                    this.Members.Add(new AdornerMember
267
                    {
268
                        DrawingData = member,
269
                        Drawingtype = ControlType.ArrowTextControl,
270
                        ThumbList = new List<MyThumb>(),
271
                        Symbol_ID = member.SymbolID,
272
                        Group_ID = member.GroupID,
273
                    });
274
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
275
                    AngleValue = (member as ArrowTextControl).Angle;
276
                    Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
277
                    {
278
                        TextCompensation = false;
279
                        BorderUpdate();
280
                        if ((a.Sender as TextBox).Text == "") //보류
281
                        {
282
                            this.ContainerContent.Children.Remove(member);
283
                            this.Visibility = Visibility.Collapsed;
284
                        }
285
                    });
286
                    break;
287
                case "ArcControl":
288
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
289
                    break;
290
                case "ArrowArcControl":
291
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
292
                    break;
293
                case "ArrowControl_Multi":
294
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
295
                    break;
296
                case "RectangleControl":
297
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
298
                    break;
299
                case "DateControl":
300
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
301
                    AngleValue = (member as DateControl).Angle;
302
                    break;
303
                case "TriControl":
304
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
305
                    break;
306
                case "CircleControl":
307
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
308
                    break;
309
                case "CloudControl":
310
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
311
                    break;
312
                case "RectCloudControl":
313
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
314
                    break;
315
                case "SignControl":
316
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
317
                    AngleValue = (member as SignControl).Angle;
318
                    break;
319

    
320
                case "SymControl":
321
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
322
                    AngleValue = (member as SymControl).Angle;
323
                    break;
324
                case "SymControlN":
325
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
326
                    AngleValue = (member as SymControlN).Angle;
327
                    break;
328
                case "InkControl": //Angle추가 안했음
329
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
330
                    break;
331
                case "TextControl":
332
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
333
                    RectangleGeometry Data = new RectangleGeometry
334
                    {
335
                        Rect = new Rect()
336
                        {
337
                            X = Canvas.GetLeft((member as TextControl)),
338
                            Y = Canvas.GetTop((member as TextControl)),
339
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
340
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
341
                            //Width = (member as TextControl).BoxWidth / 2,
342
                            //Height = (member as TextControl).BoxHeight / 2,
343
                        }
344
                    };
345
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
346
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
347

    
348

    
349
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
350
                    DragThumb.RenderTransform = new RotateTransform()
351
                    {
352
                        Angle = (member as TextControl).Angle,
353
                        //CenterX = middle.X,
354
                        //CenterY = middle.Y,
355
                    };
356

    
357
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
358
                    AdornerBorder.RenderTransform = new RotateTransform()
359
                    {
360
                        Angle = (member as TextControl).Angle,
361
                        //CenterX = middle.X,
362
                        //CenterY = middle.Y,
363
                    };
364
                    Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
365
                    {
366
                        TextCompensation = true;
367
                        BorderUpdate();
368
                        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
369
                    });
370
                    Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
371
                    {
372
                        TextCompensation = false;
373
                        BorderUpdate();
374
                        if ((a.Sender as TextBox).Text == "") //보류
375
                        {
376
                            this.ContainerContent.Children.Remove(member);
377
                            this.Visibility = Visibility.Collapsed;
378
                        }
379

    
380
                        //((TextControl)member).UnEditingMode();
381
                        //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
382
                        //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
383
                        //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
384
                    });
385
                    break;
386
                case "InsideWhiteControl":
387
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
388
                    break;
389
                case "OverlapWhiteControl":
390
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
391
                    break;
392
                case "ClipWhiteControl":
393
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
394
                    break;
395
                case "CoordinateControl":
396
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
397
                    break;
398
                default:
399
                    break;
400
                    #endregion
401
            }
402
            if (member.GetType().Name == "TextControl")
403
            {
404
                TextControl content = ((TextControl)member);
405
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
406
                content.EndPoint = content.StartPoint;
407

    
408
            }
409
            else
410
            {
411
                RegistryPoint(member);
412
            }
413
            BorderUpdate();
414

    
415
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
416
        }
417

    
418
        private void ViewBoxRotate(UIElement member)
419
        {
420
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
421
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
422
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
423
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
424
        }
425

    
426
        public void SetAdornerMember(List<CommentUserInfo> members)
427
        {
428
            foreach (var member in members)
429
            {
430
                switch (member.GetType().Name)
431
                {
432
                    #region 컨트롤 조건
433
                    case "LineControl":
434
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
435
                        break;
436
                    case "ImgControl":
437
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
438
                        break;
439
                    case "ArrowControl":
440
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
441
                        break;
442
                    case "PolygonControl":
443
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
444
                        break;
445
                    case "ArrowTextControl":
446
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
447
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
448
                        break;
449
                    case "ArcControl":
450
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
451
                        break;
452
                    case "ArrowArcControl":
453
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
454
                        break;
455
                    case "DateControl":
456
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
457
                        break;
458
                    case "ArrowControl_Multi":
459
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
460
                        break;
461
                    case "RectangleControl":
462
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
463
                        break;
464
                    case "TriControl":
465
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
466
                        break;
467
                    case "CircleControl":
468
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
469
                        break;
470
                    case "CloudControl":
471
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
472
                        break;
473
                    case "RectCloudControl":
474
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
475
                        break;
476
                    case "SignControl":
477
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
478
                        break;
479
                    case "SymControl":
480
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
481
                        break;
482
                    case "SymControlN":
483
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
484
                        break;
485
                    case "InkControl":
486
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
487
                        break;
488
                    case "TextControl":
489
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
490
                        Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
491
                        {
492
                            BorderUpdate();
493
                            try
494
                            {
495
                                ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
496
                            }
497
                            catch (Exception)
498
                            {
499

    
500
                            }
501

    
502
                        });
503
                        Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
504
                        {
505
                            BorderUpdate();
506
                        });
507
                        break;
508
                    case "InsideWhiteControl":
509
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
510
                        break;
511
                    case "OverlapWhiteControl":
512
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
513
                        break;
514
                    case "ClipWhiteControl":
515
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
516
                        break;
517
                    case "CoordinateControl":
518
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
519
                        break;
520
                    default:
521
                        break;
522
                        #endregion
523
                }
524
                if (member.GetType().Name == "TextControl")
525
                {
526
                    TextControl content = ((TextControl)member);
527
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
528
                    content.EndPoint = content.StartPoint;
529
                }
530
                else
531
                {
532
                    RegistryPoint(member, members.Count);
533
                }
534

    
535
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))  Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
536
            }
537

    
538
            BorderUpdate();
539
        }
540

    
541
        /// <summary>
542
        /// Border 를 갱신
543
        /// </summary>
544
        public void BorderUpdate()
545
        {
546
            AdornerBorder.MinWidth = 10;
547
            AdornerBorder.MinHeight = 10;
548

    
549
            double minX = double.MaxValue;
550
            double minY = double.MaxValue;
551
            double maxX = double.MinValue;
552
            double maxY = double.MinValue;
553

    
554
            if (this.Members.Count == 1)
555
            {
556
                if (this.Members.First().DrawingData.GetType().Name == "TextControl")
557
                {
558
                    if ((this.Members.First().DrawingData as TextControl).Angle != 0)
559
                    {
560
                        trRotate.Angle = (this.Members.First().DrawingData as TextControl).Angle;
561
                        trRotateThumb.Angle = (this.Members.First().DrawingData as TextControl).Angle;
562
                    }
563
                    else
564
                    {
565
                        trRotate.Angle = 0;
566
                        trRotateThumb.Angle = 0;
567
                    }
568
                }
569
            }
570
            foreach (var item in this.Members)
571
            {
572
                UIElement currentControl = (item as AdornerMember).DrawingData;
573
                if (item.DrawingData.GetType().Name == "TextControl")
574
                {
575
                    double textControlWidth;
576
                    double textControlHeight;
577
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
578
                    {
579
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
580
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
581
                    }
582
                    else
583
                    {
584
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
585
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
586
                    }
587
                    
588
                    if ((currentControl as TextControl).EndPoint.X < minX)
589
                    {
590
                        minX = (currentControl as TextControl).EndPoint.X;
591
                    }
592
                    if ((currentControl as TextControl).EndPoint.Y < minY)
593
                    {
594
                        minY = (currentControl as TextControl).EndPoint.Y;
595
                    }
596
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
597
                    {
598
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
599
                    }
600
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
601
                    {
602
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
603
                    }
604
                }
605
                else if ((currentControl as IViewBox) != null)
606
                {
607
                    IViewBox instance = currentControl as IViewBox;
608
                    List<Point> am = (currentControl as IPath).PointSet;
609
                    List<double> xSet = am.Select(p => p.X).ToList();
610
                    List<double> ySet = am.Select(p => p.Y).ToList();
611
                    if (xSet.Min() < minX) minX = xSet.Min();
612
                    if (ySet.Min() < minY) minY = ySet.Min();
613
                    if (xSet.Max() > maxX) maxX = xSet.Max();
614
                    if (ySet.Max() > maxY) maxY = ySet.Max();
615
                }
616
                else if ((currentControl as IPath).PathData == null)
617
                {
618
                    Rect rt = new Rect
619
                    {
620
                        X = (currentControl as IPath).StartPoint.X,
621
                        Y = (currentControl as IPath).StartPoint.Y,
622
                        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),
623
                        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),
624
                    };
625
                    if (rt.Left < minX) minX = rt.Left;
626
                    if (rt.Top < minY) minY = rt.Top;
627
                    if (rt.Right > maxX) maxX = rt.Right;
628
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
629
                }
630
                else if ((currentControl as IPath) == null)
631
                {
632
                    Rect rt = new Rect
633
                    {
634
                        X = (currentControl as IPath).StartPoint.X,
635
                        Y = (currentControl as IPath).StartPoint.Y,
636
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
637
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
638
                    };
639
                    if (rt.Left < minX) minX = rt.Left;
640
                    if (rt.Top < minY) minY = rt.Top;
641
                    if (rt.Right > maxX) maxX = rt.Right;
642
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
643
                }
644
                else if ((currentControl as CircleControl) != null)
645
                {                    
646
                    List<Point> am = (currentControl as IPath).PointSet;
647
                    List<double> xSet = am.Select(p => p.X).ToList();
648
                    List<double> ySet = am.Select(p => p.Y).ToList();
649
                    if (xSet.Min() < minX) minX = xSet.Min();
650
                    if (ySet.Min() < minY) minY = ySet.Min();
651
                    if (xSet.Max() > maxX) maxX = xSet.Max();
652
                    if (ySet.Max() > maxY) maxY = ySet.Max();
653
                }
654
                else
655
                {
656
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
657
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
658
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
659
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
660
                }
661
            }
662

    
663
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
664
            bool addWidthSize = false;
665
            bool addHeightSize = false;
666
            if (ac.Width <= 10)
667
            {
668
                ac.Width += 10;
669
                addWidthSize = true;
670
            }
671
            if (ac.Height <= 10)
672
            {
673
                ac.Height += 10;
674
                addHeightSize = true;
675
            }
676
            BorderSize = ac;
677
            AdornerBorder.MinWidth = 10;
678
            AdornerBorder.MinHeight = 10;
679
            AdornerBorder.Width = ac.Width;
680
            AdornerBorder.Height = ac.Height;
681
            Canvas.SetLeft(AdornerBorder, minX);
682
            Canvas.SetTop(AdornerBorder, minY);
683

    
684
            DragThumb.Width = ac.Width;
685
            DragThumb.Height = ac.Height;
686

    
687
            DragThumb.MinWidth = 10;
688
            DragThumb.MinHeight = 10;
689
            if (addWidthSize)
690
            {
691
                Canvas.SetLeft(DragThumb, minX - 5);
692
            }
693
            else
694
            {
695
                Canvas.SetLeft(DragThumb, minX);
696
            }
697

    
698
            if (addHeightSize)
699
            {
700
                Canvas.SetTop(DragThumb, minY - 5);
701
            }
702
            else
703
            {
704
                Canvas.SetTop(DragThumb, minY);
705
            }
706
        }
707
        /// <summary>
708
        /// UIElement 해제
709
        /// </summary>
710
        public void unRegister()
711
        {
712
            foreach (var item in this.ContainerContent.Children)
713
            {
714
                if (item is MarkupToPDF.Common.CommentUserInfo)
715
                {
716
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
717
                }
718
            }
719
            this.ContainerContent.Children.Clear();
720
        }
721

    
722
        /// <summary>
723
        /// 각 포인트들을 등록합니다.
724
        /// </summary>
725
        /// <param name="pointset">Drawing Point</param>
726
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
727
        {
728
            int count = 0;
729
            double Minx = 100000000;
730
            double Miny = 100000000;
731
            List<Point> list = (member as IPath).PointSet;
732
            if (member.GetType().Name == "InkControl")
733
            {
734
                list.Clear();
735
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
736
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
737
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
738
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
739
            }
740
            ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype;
741
            foreach (var ax in list)
742
            {
743
                Minx = (ax.X < Minx) ? ax.X : Minx;
744
                Miny = (ax.Y < Miny) ? ax.Y : Miny;
745
            }
746
            for (int i = 0; i < list.Count(); i++)
747
            {
748
                MyThumb tm = new MyThumb
749
                {
750
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
751
                };
752

    
753
                this.Members.Last().ThumbList.Add(tm);
754

    
755
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MidPoint))
756
                {
757
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
758
                }
759
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
760
                {
761
                    //if (this.Members.Count()<=1)
762
                    //{
763
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
764
                    List<Point> ps = new List<Point>();
765

    
766
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
767
                    {
768
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
769

    
770

    
771
                        switch (Math.Abs(temp.Angle).ToString())
772
                        {
773
                            case "90":
774
                                {
775
                                    ps.Clear();
776
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
777
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
778
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
779

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

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

    
786
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
787
                                }
788
                                break;
789
                            case "270":
790
                                {
791
                                    ps.Clear();
792
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
793
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
794
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
795

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

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

    
802
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
803
                                }
804
                                break;
805
                            default:
806
                                {
807
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
808
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
809
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
810
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
811
                                }
812
                                break;
813
                        }
814

    
815
                        ArrowTextControl instance = (member as ArrowTextControl);
816
                        if (instance.isTrans)
817
                        {
818
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
819
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
820
                            //list[count] = tempP;
821
                            list[count] = temp.MidPoint;
822
                        }
823
                        else
824
                        {
825
                            if (temp.isFixed)
826
                            {
827
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
828
                                var testP = endP;
829
                                if (ps[0] == endP) //상단
830
                                {
831
                                    testP = new Point(endP.X, endP.Y - 50);
832
                                }
833
                                else if (ps[1] == endP) //하단
834
                                {
835
                                    testP = new Point(endP.X, endP.Y + 50);
836
                                }
837
                                else if (ps[2] == endP) //좌단
838
                                {
839
                                    testP = new Point(endP.X - 50, endP.Y);
840
                                }
841
                                else if (ps[3] == endP) //우단
842
                                {
843
                                    testP = new Point(endP.X + 50, endP.Y);
844
                                }
845
                                list[count] = testP;
846
                            }
847
                            else
848
                            {
849
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
850
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
851
                            }
852
                        }
853
                    }
854
                }
855
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
856
                {
857
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
858
                    tm.Width = (member as ArrowTextControl).BoxWidth;
859
                    tm.Height = (member as ArrowTextControl).BoxHeight;
860
                    var angle = (member as ArrowTextControl).Angle;
861
                    if (Math.Abs(angle).ToString() == "90")
862
                    {
863
                        tm.RenderTransformOrigin = new Point(0, 0);
864
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
865
                    }
866
                    else if (Math.Abs(angle).ToString() == "270")
867
                    {
868
                        tm.RenderTransformOrigin = new Point(0, 0);
869
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
870
                    }
871
                    else
872
                    {
873
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
874
                        tm.RenderTransform = new RotateTransform()
875
                        {
876
                            Angle = angle,
877
                        };
878
                    }
879
                }
880
                
881
                if (member.GetType().Name == "CloudControl")
882
                {
883
                    if (i == list.Count() - 1)
884
                    {
885
                        tm.Visibility = System.Windows.Visibility.Collapsed;
886
                    }
887
                }
888
                if (member.GetType().Name == "PolygonControl")
889
                {
890
                    if (i == list.Count() - 1)
891
                    {
892
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
893
                        {
894

    
895
                        }
896
                        else
897
                        {
898
                            tm.Visibility = System.Windows.Visibility.Collapsed;
899
                        }
900
                    }
901
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
902
                    {
903
                        tm.Visibility = System.Windows.Visibility.Collapsed;
904
                    }
905
                }
906
                
907
                this.ContainerContent.Children.Add(tm);
908
                Canvas.SetLeft(tm, list[count].X);
909
                Canvas.SetTop(tm, list[count].Y);
910
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
911
                {
912
                    Canvas.SetZIndex(tm, 95);
913
                }
914
                else
915
                {
916
                    Canvas.SetZIndex(tm, 99);
917
                }
918

    
919
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
920
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
921
                tm.DragDelta += ResizeTm_DragDelta;
922
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
923
                count++;
924
            }
925
        }
926

    
927
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
928
        {
929
            if (this.Members.Count > 1) return;
930
            if (reSizePoint != new Point(0, 0))
931
            {
932
                MyThumb thumb = sender as MyThumb;
933
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
934
                thumb.Translate(e.HorizontalChange, e.VerticalChange, this.AngleValue);
935
                
936
                AdornerMember control = (from userThumb in this.Members
937
                                         where userThumb.ThumbList.Contains(thumb)
938
                                         select userThumb).FirstOrDefault();
939

    
940
                IPath AllControl = control.DrawingData as IPath;
941
                ((control.DrawingData) as CommentUserInfo).OnMoveCtrlPoint(setPoint, e.HorizontalChange, e.VerticalChange);
942
                DynamicThumbUpdate(control);
943
                BorderUpdate();
944
            }
945
        }
946

    
947
        #endregion
948
        #region 이벤트
949

    
950
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
951
        {
952
            this.isDragging = false;
953
            DraggerThumb = null;
954

    
955
            var comments = (from drawing in this.Members
956
                            select drawing.DrawingData as CommentUserInfo).ToList();
957
            UndoCommand.Instance.Push(comments, this.AngleValue);
958
        }
959

    
960
        /// <summary>
961
        /// start drag
962
        /// </summary>
963
        /// <param name="sender"></param>
964
        /// <param name="e"></param>
965
        void tm_DragStarted(object sender, DragStartedEventArgs e)
966
        {
967
            this.DraggerThumb = sender as Thumb;
968
            this.isDragging = true;
969

    
970
            if (ViewerDataModel.Instance.UndoDataList == null)
971
            {
972
                return;
973
            }
974

    
975
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
976
            {
977
                return;
978
            }
979

    
980
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
981
            {
982
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
983
                {
984
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
985
                    {
986
                        return;
987
                    }
988
                }
989
            }
990

    
991
            var comments = (from drawing in this.Members
992
                            select drawing.DrawingData as CommentUserInfo).ToList();
993
            UndoCommand.Instance.Push(comments, this.AngleValue);
994
        }
995

    
996
        private void rotate_MouseMove(object sender, MouseEventArgs e)
997
        {
998
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
999
            {
1000
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1001
                    IsTextAngle = true;
1002
                else
1003
                    IsTextAngle = false;
1004
                LastRotateVerticalValue = e.GetPosition(this).X;
1005
            }
1006
            else
1007
            {
1008
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1009
                {
1010
                    RotateFlag = true;
1011
                }
1012
                else
1013
                {
1014
                    RotateFlag = false;
1015
                }
1016
                LastRotateHorizontalValue = e.GetPosition(this).X;
1017
            }
1018
        }
1019

    
1020
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1021
        {
1022
            try
1023
            {
1024
                double dx = this.MouseDownPoint.X + e.HorizontalChange - this.CurrentMousePoint.X;
1025
                double dy = this.MouseDownPoint.Y + e.VerticalChange - this.CurrentMousePoint.Y;
1026

    
1027
                DragThumb.Cursor = Cursors.SizeAll;
1028
                Thumb thumb = sender as Thumb;
1029
                this.TranslateItems(e.HorizontalChange, e.VerticalChange);
1030
                System.Diagnostics.Debug.WriteLine(String.Format("dx={0}, dy={1}", e.HorizontalChange - dx, e.VerticalChange - dy));
1031
            }
1032
            finally
1033
            {
1034
                /// update CurrentMousePoint
1035
                this.CurrentMousePoint.X = this.MouseDownPoint.X + e.HorizontalChange;
1036
                this.CurrentMousePoint.Y = this.MouseDownPoint.Y + e.VerticalChange;
1037
            }
1038
        }
1039

    
1040
        /// <summary>
1041
        /// translate all members
1042
        /// </summary>
1043
        /// <param name="e"></param>
1044
        public void TranslateItems(double dx, double dy)
1045
        {
1046
            Dispatcher.BeginInvoke((Action)(() =>
1047
            {
1048
                foreach (var item in this.Members)
1049
                {
1050
                    this.TranslateItem(dx, dy, item);
1051
                }
1052
            }));
1053
            ///this.BorderUpdate();
1054
        }
1055

    
1056
        /// <summary>
1057
        /// translate a item
1058
        /// </summary>
1059
        /// <param name="e"></param>
1060
        /// <param name="item"></param>
1061
        private void TranslateItem(double dx, double dy, AdornerMember item)
1062
        {
1063
            ///dx = this.CurrentMousePoint.X - this.MouseDownPoint.X + dx;
1064
            ///dy = this.CurrentMousePoint.Y - this.MouseDownPoint.Y + dy;
1065

    
1066
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), this.trRotate.Angle);
1067
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1068
            for (int i = 0; i < item.ThumbList.Count(); i++)
1069
            {
1070
                (item.ThumbList[i] as MyThumb).Translate(dx, dy , this.trRotate.Angle);
1071
            }
1072
        }
1073

    
1074
        public void DynamicThumbUpdate(AdornerMember item)
1075
        {
1076
            var AllControl = item.DrawingData as IPath;
1077
            List<Point> point = AllControl.PointSet;
1078

    
1079
            for (int i = 0; i < AllControl.PointSet.Count(); i++)
1080
            {
1081
                Canvas.SetLeft(item.ThumbList[i], AllControl.PointSet[i].X);
1082
                Canvas.SetTop(item.ThumbList[i], AllControl.PointSet[i].Y);
1083
            }
1084

    
1085

    
1086
            if (item.DrawingData as ArrowTextControl != null)
1087
            {
1088
                if (!(item.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
1089
                {
1090
                    List<Point> ps = new List<Point>();
1091

    
1092
                    var temp = item.DrawingData as ArrowTextControl;
1093
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1094
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1095
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1096
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1097

    
1098
                    if (temp.isFixed)
1099
                    {
1100
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1101
                        var testP = endP;
1102
                        if (ps[0] == endP) //상단
1103
                        {
1104
                            testP = new Point(endP.X, endP.Y - 50);
1105
                            //System.Diagnostics.Debug.WriteLine("상단");
1106
                        }
1107
                        else if (ps[1] == endP) //하단
1108
                        {
1109
                            testP = new Point(endP.X, endP.Y + 50);
1110
                            //System.Diagnostics.Debug.WriteLine("하단");
1111
                        }
1112
                        else if (ps[2] == endP) //좌단
1113
                        {
1114
                            testP = new Point(endP.X - 50, endP.Y);
1115
                            //System.Diagnostics.Debug.WriteLine("좌단");
1116
                        }
1117
                        else if (ps[3] == endP) //우단
1118
                        {
1119
                            testP = new Point(endP.X + 50, endP.Y);
1120
                            //System.Diagnostics.Debug.WriteLine("우단");
1121
                        }
1122
                        Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], testP.X);
1123
                        Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], testP.Y);
1124
                    }
1125
                    else
1126
                    {
1127
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1128
                        var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1129
                        Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1130
                        Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1131
                    }
1132
                }
1133
            }
1134
        }
1135

    
1136
        public void Set_Rotate()
1137
        {
1138
            double dDeltaAngle = 0;
1139
            List<Point> AllPointSet = new List<Point>();
1140
            Point CenterPoint = new Point();
1141

    
1142
            if (AngleValue >= 360)
1143
            {
1144
                AngleValue -= 360;
1145
            }
1146
            else if (AngleValue <= -360)
1147
            {
1148
                AngleValue += 360;
1149
            }
1150

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

    
1167
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1168

    
1169
            Dispatcher.BeginInvoke((Action)(() =>
1170
            {
1171
                foreach (var item in this.Members)
1172
                {
1173
                    foreach (var thumb in item.ThumbList)
1174
                    {
1175
                        double x = Canvas.GetLeft(thumb);
1176
                        double y = Canvas.GetTop(thumb);
1177

    
1178
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1179
                        Canvas.SetLeft(thumb, value.X);
1180
                        Canvas.SetTop(thumb, value.Y);
1181

    
1182
                        if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last())
1183
                        {
1184

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

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

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

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

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

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

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

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

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

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

    
1267
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1268
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);                                                      
1269

    
1270
                            DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
1271
                            DragThumb.RenderTransform = new RotateTransform()
1272
                            {
1273
                                Angle = (item.DrawingData as TextControl).Angle,
1274

    
1275
                            };
1276

    
1277
                            AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
1278
                            AdornerBorder.RenderTransform = new RotateTransform()
1279
                            {
1280
                                Angle = (item.DrawingData as TextControl).Angle,
1281

    
1282
                            };
1283

    
1284
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1285
                            {
1286
                                Angle = (item.DrawingData as TextControl).Angle,
1287
                            };
1288
                            BorderUpdate();
1289
                            break;
1290

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

    
1385
        private void resize_MouseMove(object sender, MouseEventArgs e)
1386
        {
1387
            reSizePoint = e.GetPosition(this);
1388
        }
1389

    
1390
        /// <summary>
1391
        /// 회전
1392
        /// </summary>
1393
        /// <param name="sender"></param>
1394
        /// <param name="e"></param>
1395
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1396
        {
1397
            MoveRotate(e);
1398
        }
1399

    
1400
        double LastRotateHorizontalValue = 0;
1401
        double LastRotateVerticalValue = 0;
1402
        //double LastWidthValue = 0;
1403
        //double SetWidth = 0;
1404
        bool RotateFlag = false;
1405

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

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

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

    
1446
            //System.Diagnostics.Debug.WriteLine("vec1 : " + vec1.X + "/" + vec1.Y);
1447
            //System.Diagnostics.Debug.WriteLine("vec2 : " + vec2.X + "/" + vec2.Y);
1448
            //System.Diagnostics.Debug.WriteLine("dDeltaAngle : " + dDeltaAngle);
1449

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

    
1455
            Dispatcher.BeginInvoke((Action)(() =>
1456
            {
1457
                foreach (var item in this.Members)
1458
                {
1459
                    foreach (var thumb in item.ThumbList)
1460
                    {
1461
                        double x = Canvas.GetLeft(thumb);
1462
                        double y = Canvas.GetTop(thumb);
1463

    
1464
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1465
                        Canvas.SetLeft(thumb, value.X);
1466
                        Canvas.SetTop(thumb, value.Y);
1467
                    }
1468

    
1469
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1470
                    {
1471
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1472
                    }
1473
                }
1474
                #region 보더 업데이트
1475
                foreach (var item in this.Members)
1476
                {
1477
                    switch (item.Drawingtype)
1478
                    {
1479
                        case ControlType.TextControl:
1480
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1481

    
1482
                            RectangleGeometry Data = new RectangleGeometry
1483
                            {
1484
                                Rect = new Rect()
1485
                                {
1486
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1487
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1488
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1489
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1490
                                }
1491
                            };
1492

    
1493
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1494
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);
1495

    
1496
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1497
                            DragThumb.RenderTransform = new RotateTransform()
1498
                            {
1499
                                Angle = (item.DrawingData as TextControl).Angle,
1500
                                //CenterX = middle.X,
1501
                                //CenterY = middle.Y,
1502
                            };
1503

    
1504
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1505
                            AdornerBorder.RenderTransform = new RotateTransform()
1506
                            {
1507
                                Angle = (item.DrawingData as TextControl).Angle,
1508
                                //CenterX = middle.X,
1509
                                //CenterY = middle.Y,
1510
                            };
1511

    
1512
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1513
                            {
1514
                                Angle = (item.DrawingData as TextControl).Angle,
1515
                            };
1516

    
1517
                            BorderUpdate();
1518
                            break;
1519

    
1520
                        case ControlType.Date:
1521
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1522
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1523
                            BorderUpdate();                          
1524
                            break;
1525
                        case ControlType.ArrowMultiLine:
1526
                        case ControlType.ArcLine:
1527
                        case ControlType.ArcArrow:
1528
                        case ControlType.SingleLine:
1529
                        case ControlType.Triangle:
1530
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1531
                            BorderUpdate();
1532
                            break;
1533
                        case ControlType.ArrowTextControl:
1534
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1535
                            BorderUpdate();
1536
                            break;
1537
                        case ControlType.RectCloud:
1538
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1539
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1540
                            BorderUpdate();
1541
                            break;
1542
                        case ControlType.Rectangle:
1543
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1544
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1545
                            BorderUpdate();
1546
                            break;
1547
                        case ControlType.ImgControl:
1548
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1549
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1550
                            BorderUpdate();
1551
                            break;                        
1552
                        case ControlType.Sign:
1553
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1554
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1555
                            BorderUpdate();
1556
                            break;                        
1557
                        case ControlType.Symbol:
1558
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1559
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1560
                            BorderUpdate();
1561
                            break;
1562
                        case ControlType.Stamp:
1563
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1564
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1565
                            BorderUpdate();
1566
                            break;
1567
                        case ControlType.PolygonControl:
1568
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1569
                            BorderUpdate();
1570
                            break;
1571
                        case ControlType.PolygonCloud:
1572
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1573
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1574
                            BorderUpdate();
1575
                            break;
1576
                        case ControlType.Circle:
1577
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1578
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1579
                            ((CircleControl)item.DrawingData).SetCenterXY();
1580
                            BorderUpdate();
1581
                            break;
1582
                        case ControlType.Ink:
1583
                            for (int i = 0; i < (item.DrawingData as InkControl).PointC.Count(); i++)
1584
                            {
1585
                                for (int j = 0; j < (item.DrawingData as InkControl).PointC[i].pointSet.Count; j++)
1586
                                {
1587
                                    (item.DrawingData as InkControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as InkControl).PointC[i].pointSet[j], dDeltaAngle);
1588
                                }
1589
                            }
1590
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1591
                            BorderUpdate();
1592
                            break;
1593
                        
1594
                        default:
1595
                            break;
1596
                    }
1597
                }
1598
                #endregion
1599
            }));
1600
            BorderUpdate();
1601
        }
1602

    
1603
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1604
        {            
1605

    
1606
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1607
            rotateTop.Cursor = Cursors.SizeAll;
1608

    
1609
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1610
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1611
            {
1612
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).Angle;
1613
            }
1614
            /// up to here
1615

    
1616

    
1617

    
1618
            if (ViewerDataModel.Instance.UndoDataList == null)
1619
            {
1620
                return;
1621
            }
1622

    
1623
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1624
            {
1625
                return;
1626
            }
1627

    
1628
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1629
            {
1630
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1631
                {
1632
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1633
                    {
1634
                        return;
1635
                    }
1636
                }
1637
            }
1638

    
1639
            var comments = (from drawing in this.Members
1640
                            select drawing.DrawingData as CommentUserInfo).ToList();
1641
            UndoCommand.Instance.Push(comments, this.AngleValue);
1642
        }
1643
        
1644
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1645
        {
1646
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1647

    
1648
            var comments = (from drawing in this.Members
1649
                            select drawing.DrawingData as CommentUserInfo).ToList();
1650
            UndoCommand.Instance.Push(comments, this.AngleValue);
1651
        }
1652

    
1653
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1654
        {
1655
            /// save mouse down and current mouse point
1656
            this.MouseDownPoint.X = e.HorizontalOffset;
1657
            this.MouseDownPoint.Y = e.VerticalOffset;
1658
            this.CurrentMousePoint.X = e.HorizontalOffset;
1659
            this.CurrentMousePoint.Y = e.VerticalOffset;
1660
            /// up to here
1661

    
1662
            if (ViewerDataModel.Instance.UndoDataList == null)
1663
            {
1664
                return;
1665
            }
1666
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1667
            {
1668
                return;
1669
            }
1670
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1671
            {
1672
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1673
                {
1674
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1675
                    {
1676
                        return;
1677
                    }
1678
                }
1679
            }
1680

    
1681
            var comments = (from drawing in this.Members
1682
                            select drawing.DrawingData as CommentUserInfo).ToList();
1683
            UndoCommand.Instance.Push(comments, this.AngleValue);
1684
        }
1685

    
1686
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1687
        {          
1688
            DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1689

    
1690
            var comments = (from drawing in this.Members
1691
                            select drawing.DrawingData as CommentUserInfo).ToList();
1692
            UndoCommand.Instance.Push(comments, this.AngleValue);
1693
        }
1694

    
1695
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1696
        {
1697
            AdornerMember control = this.Members.FirstOrDefault();
1698

    
1699
            if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null)
1700
            {
1701
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1702
                {
1703
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1704
                }
1705
            }
1706

    
1707
        }
1708

    
1709
        public void TextControlChanger()
1710
        {
1711
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1712
            {
1713
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1714
                AllControl.Base_TextBox.Focus();
1715
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1716
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1717
                AllControl.Base_TextBox.Focus();
1718
                AllControl.SizeChanged += (sen, ea) =>
1719
                {
1720
                    if (AllControl.Base_TextBox != null)
1721
                    {
1722
                        RectangleGeometry Data = new RectangleGeometry
1723
                        {
1724
                            Rect = new Rect()
1725
                            {
1726
                                X = AllControl.StartPoint.X,
1727
                                Y = AllControl.StartPoint.Y,
1728
                                Width = AllControl.Base_TextBox.Width,
1729
                                Height = AllControl.Base_TextBox.Height,
1730
                            }
1731
                        };
1732

    
1733
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1734
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1735
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1736
                        {
1737
                            Angle = AllControl.Angle,
1738
                            CenterX = middle.X,
1739
                            CenterY = middle.Y,
1740
                        };
1741
                    }
1742
                    BorderUpdate();
1743
                };
1744
            }
1745
        }
1746

    
1747
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1748
        {
1749
            if (e.ClickCount == 2 && this.Members.Count == 1)
1750
            {
1751

    
1752
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1753
                {
1754
                    TextControlChanger();                    
1755
                }
1756

    
1757
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1758
                {
1759
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1760
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1761
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1762

    
1763
                    //ArrowControl TextBox Thumb없애기
1764
                    tm.Visibility = Visibility.Collapsed;
1765

    
1766
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1767
                    
1768
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1769

    
1770
                    {
1771
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1772
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1773

    
1774
                        List<Point> ps = new List<Point>();
1775
                        
1776
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1777
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1778
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1779
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1780

    
1781

    
1782

    
1783

    
1784
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1785
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1786
                        if (AllControl.isTrans)
1787
                        {
1788
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1789
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1790
                        }
1791
                        else
1792
                        {
1793
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1794
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1795
                        }
1796

    
1797

    
1798
                        BorderUpdate();
1799

    
1800
                    };
1801
                }
1802
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1803
                {
1804
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1805
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1806
                    //dropData.IsOpen = true;
1807
                    RadWindow rc = new RadWindow();
1808
                    rc.Width = 300;
1809
                    rc.Height = 300;
1810
                    rc.Header = "Change Date";
1811
                    rc.Content = instanceCal;
1812
                    rc.BorderThickness = new Thickness(3);
1813
                    rc.ResizeMode = ResizeMode.NoResize;
1814
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1815
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1816
                    rc.ModalBackground.Opacity = 0.6;
1817
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1818
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1819
                    {
1820
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1821
                        rc.Close();
1822
                    };
1823
                    rc.ShowDialog();
1824
                    //CalendarControl.xaml
1825
                }
1826
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1827
                {
1828
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1829
                    if (instance.isTransOn)
1830
                    {
1831
                        instance.isTransOn = false;
1832
                    }
1833
                    else
1834
                    {
1835
                        instance.isTransOn = true;
1836
                    }
1837
                    ///instance.SetArcPath();
1838
                    BorderUpdate();
1839
                }
1840
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1841
                {
1842
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1843
                    if (instance.isTransOn)
1844
                    {
1845
                        instance.isTransOn = false;
1846
                    }
1847
                    else
1848
                    {
1849
                        instance.isTransOn = true;
1850
                    }
1851
                    instance.SetArcPath();
1852
                    BorderUpdate();
1853
                }
1854

    
1855
            }
1856
            
1857
        }
1858
        #endregion
1859

    
1860
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1861
        {
1862
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1863
            {
1864
                DragThumb.Visibility = Visibility.Collapsed;
1865
            }
1866
        }
1867

    
1868
    }
1869
}
클립보드 이미지 추가 (최대 크기: 500 MB)