프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (95.5 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(DragDeltaEventArgs e, 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 = e.HorizontalChange*cos -e.VerticalChange * sin;
47
            double dy = e.HorizontalChange*sin +e.VerticalChange * 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
        #endregion
106
        #region 생성자
107
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
108
        {
109
            dropData = sender as RadDropDownButton;
110
        }
111

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

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

    
133
        ~AdornerFinal()
134
        {
135
            this.Dispose(false);
136
        }
137

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

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

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

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

    
182
            }
183
           
184
            SetAdornerMember(objectData as CommentUserInfo);
185
            this.Focus();
186
        }
187

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

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

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

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

    
346

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

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

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

    
406
            }
407
            else
408
            {
409
                RegistryPoint(member);
410
            }
411
            BorderUpdate();
412

    
413
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
414
        }
415

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

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

    
498
                            }
499

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

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

    
536
            BorderUpdate();
537
        }
538

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

    
547
            double minX = double.MaxValue;
548
            double minY = double.MaxValue;
549
            double maxX = double.MinValue;
550
            double maxY = double.MinValue;
551

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

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

    
682
            DragThumb.Width = ac.Width;
683
            DragThumb.Height = ac.Height;
684

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

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

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

    
751
                this.Members.Last().ThumbList.Add(tm);
752

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

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

    
768

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

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

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

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

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

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

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

    
813
                        ArrowTextControl instance = (member as ArrowTextControl);
814
                        if (instance.isTrans)
815
                        {
816
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
817
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
818
                            //list[count] = tempP;
819
                            list[count] = temp.MidPoint;
820
                        }
821
                        else
822
                        {
823
                            if (temp.isFixed)
824
                            {
825
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
826
                                var testP = endP;
827
                                if (ps[0] == endP) //상단
828
                                {
829
                                    testP = new Point(endP.X, endP.Y - 50);
830
                                }
831
                                else if (ps[1] == endP) //하단
832
                                {
833
                                    testP = new Point(endP.X, endP.Y + 50);
834
                                }
835
                                else if (ps[2] == endP) //좌단
836
                                {
837
                                    testP = new Point(endP.X - 50, endP.Y);
838
                                }
839
                                else if (ps[3] == endP) //우단
840
                                {
841
                                    testP = new Point(endP.X + 50, endP.Y);
842
                                }
843
                                list[count] = testP;
844
                            }
845
                            else
846
                            {
847
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
848
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
849
                            }
850
                        }
851
                    }
852
                }
853
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
854
                {
855
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
856
                    tm.Width = (member as ArrowTextControl).BoxWidth;
857
                    tm.Height = (member as ArrowTextControl).BoxHeight;
858
                    var angle = (member as ArrowTextControl).Angle;
859
                    if (Math.Abs(angle).ToString() == "90")
860
                    {
861
                        tm.RenderTransformOrigin = new Point(0, 0);
862
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
863
                    }
864
                    else if (Math.Abs(angle).ToString() == "270")
865
                    {
866
                        tm.RenderTransformOrigin = new Point(0, 0);
867
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
868

    
869
                    }
870
                    else
871
                    {
872
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
873
                        tm.RenderTransform = new RotateTransform()
874
                        {
875
                            Angle = angle,
876
                        };
877
                    }
878
                }
879
                
880
                if (member.GetType().Name == "CloudControl")
881
                {
882
                    if (i == list.Count() - 1)
883
                    {
884
                        tm.Visibility = System.Windows.Visibility.Collapsed;
885
                    }
886
                }
887
                if (member.GetType().Name == "PolygonControl")
888
                {
889
                    if (i == list.Count() - 1)
890
                    {
891
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
892
                        {
893

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

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

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

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

    
946
        #endregion
947
        #region 이벤트
948

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

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

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

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

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

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

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

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

    
1019
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1020
        {
1021
            DragThumb.Cursor = Cursors.SizeAll;
1022
            Thumb thumb = sender as Thumb;
1023
            MoveAdorner(e);
1024
        }
1025

    
1026
        public void MoveAdorner(DragDeltaEventArgs e)
1027
        {
1028
            Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);
1029

    
1030
            Dispatcher.BeginInvoke((Action)(() =>
1031
            {
1032
                foreach (var item in this.Members)
1033
                {
1034
                    #region 라인  & 아크
1035
                    if (item.Drawingtype == ControlType.SingleLine || item.Drawingtype == ControlType.ArcLine || item.Drawingtype == ControlType.ArrowMultiLine || item.Drawingtype == ControlType.ArcArrow)
1036
                    {
1037
                        DynamicThumbUpdate(e, item);
1038
                    }
1039
                    #endregion
1040
                    #region 지시선화살표
1041
                    if (item.Drawingtype == ControlType.ArrowTextControl)
1042
                    {
1043
                        DynamicThumbUpdate(e, item);
1044
                    }
1045
                    #endregion
1046

    
1047
                    #region 써클
1048
                    if (item.Drawingtype == ControlType.Circle || item.Drawingtype == ControlType.Sign || item.Drawingtype == ControlType.Symbol || item.Drawingtype == ControlType.Stamp)
1049
                    {
1050
                        DynamicThumbUpdate(e, item);
1051
                    }
1052
                    #endregion
1053
                    #region 쉐이프
1054
                    if (item.Drawingtype == ControlType.Rectangle || item.Drawingtype == ControlType.ImgControl || item.Drawingtype == ControlType.RectCloud || item.Drawingtype == ControlType.Triangle)
1055
                    {
1056
                        DynamicThumbUpdate(e, item);
1057
                    }
1058
                    #endregion
1059
                    #region 텍스트
1060
                    if (item.Drawingtype == ControlType.TextControl)
1061
                    {
1062
                        //DynamicThumbUpdate(e, item);
1063
                        (item.DrawingData as TextControl).Move(e.HorizontalChange, e.VerticalChange);
1064
                    }
1065
                    #endregion
1066
                    #region 날짜
1067
                    if (item.Drawingtype == ControlType.Date)
1068
                    {
1069
                        DynamicThumbUpdate(e, item);
1070
                    }
1071
                    #endregion
1072
                    #region 클라우드
1073
                    if (item.Drawingtype == ControlType.PolygonCloud)
1074
                    {
1075
                        ICloudControl temp = ((ICloudControl)item.DrawingData);
1076
                        DynamicThumbUpdate(e, item);
1077
                        temp.DrawingCloud();
1078
                    }
1079
                    #endregion
1080
                    #region 심볼
1081

    
1082
                    #endregion
1083

    
1084
                    #region 폴리곤
1085
                    if (item.Drawingtype == ControlType.PolygonControl)
1086
                    {
1087
                        DynamicThumbUpdate(e, item);
1088
                        BorderUpdate();
1089
                    }
1090
                    #endregion
1091
                    #region 잉크
1092
                    if (item.Drawingtype == ControlType.Ink)
1093
                    {
1094
                        Point px = new Point(e.HorizontalChange, e.VerticalChange);
1095
                        List<StylusPointSet> StylusPointSet = (item.DrawingData as InkControl).PointC;
1096
                        for (int i = 0; i < StylusPointSet.Count; i++)
1097
                        {
1098
                            List<Point> lstPoint = StylusPointSet[i].pointSet;
1099
                            for (int j = 0; j < lstPoint.Count; j++)
1100
                            {
1101
                                lstPoint[j] = new Point(lstPoint[j].X + px.X, lstPoint[j].Y + px.Y);
1102
                            }
1103
                        }
1104

    
1105
                        for (int i = 0; i < item.ThumbList.Count; i++)
1106
                        {
1107
                            Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + px.X);
1108
                            Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + px.Y);
1109
                        }
1110
                        (item.DrawingData as IPath).updateControl();
1111
                        BorderUpdate();
1112

    
1113
                    }
1114
                    #endregion
1115
                    BorderUpdate();
1116
                }
1117
            }));
1118
        }
1119

    
1120
        public void DynamicThumbUpdate(DragDeltaEventArgs e, AdornerMember item)
1121
        {
1122
            var AllControl = item.DrawingData as IPath;
1123
            List<Point> point = AllControl.PointSet;
1124
            for (int i = 0; i < item.ThumbList.Count(); i++)
1125
            {
1126
                if (item.DrawingData.GetType().Name == "ArrowTextControl")
1127
                {
1128
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1129
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1130
                    AllControl.updateControl();
1131
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1132
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1133

    
1134
                    Canvas.SetLeft(item.ThumbList.Last(), Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1135
                    Canvas.SetTop(item.ThumbList.Last(), Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1136
                }
1137
                else
1138
                {
1139
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1140
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1141
                    AllControl.updateControl();
1142
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1143
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1144
                }
1145
            }
1146
        }
1147

    
1148
        public void DynamicThumbUpdate(AdornerMember item)
1149
        {
1150
            var AllControl = item.DrawingData as IPath;
1151
            List<Point> point = AllControl.PointSet;
1152

    
1153
            for (int i = 0; i < AllControl.PointSet.Count(); i++)
1154
            {
1155

    
1156
                Canvas.SetLeft(item.ThumbList[i], AllControl.PointSet[i].X);
1157
                Canvas.SetTop(item.ThumbList[i], AllControl.PointSet[i].Y);
1158
            }
1159

    
1160

    
1161
            if (item.DrawingData as ArrowTextControl != null)
1162
            {
1163
                if (!(item.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
1164
                {
1165
                    List<Point> ps = new List<Point>();
1166

    
1167
                    var temp = item.DrawingData as ArrowTextControl;
1168
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1169
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1170
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1171
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1172

    
1173
                    if (temp.isFixed)
1174
                    {
1175
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1176
                        var testP = endP;
1177
                        if (ps[0] == endP) //상단
1178
                        {
1179
                            testP = new Point(endP.X, endP.Y - 50);
1180
                            //System.Diagnostics.Debug.WriteLine("상단");
1181
                        }
1182
                        else if (ps[1] == endP) //하단
1183
                        {
1184
                            testP = new Point(endP.X, endP.Y + 50);
1185
                            //System.Diagnostics.Debug.WriteLine("하단");
1186
                        }
1187
                        else if (ps[2] == endP) //좌단
1188
                        {
1189
                            testP = new Point(endP.X - 50, endP.Y);
1190
                            //System.Diagnostics.Debug.WriteLine("좌단");
1191
                        }
1192
                        else if (ps[3] == endP) //우단
1193
                        {
1194
                            testP = new Point(endP.X + 50, endP.Y);
1195
                            //System.Diagnostics.Debug.WriteLine("우단");
1196
                        }
1197
                        Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], testP.X);
1198
                        Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], testP.Y);
1199
                    }
1200
                    else
1201
                    {
1202
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1203
                        var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1204
                        Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1205
                        Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1206
                    }
1207
                }
1208
            }
1209
        }
1210

    
1211
        public void Set_Rotate()
1212
        {
1213
            double dDeltaAngle = 0;
1214
            List<Point> AllPointSet = new List<Point>();
1215
            Point CenterPoint = new Point();
1216

    
1217
            if (AngleValue >= 360)
1218
            {
1219
                AngleValue -= 360;
1220
            }
1221
            else if (AngleValue <= -360)
1222
            {
1223
                AngleValue += 360;
1224
            }
1225

    
1226
            #region 센터 포인트 구하기 (그룹핑)
1227
            foreach (var item in this.Members)
1228
            {
1229
                if (item.DrawingData.GetType().Name == "TextControl")
1230
                {
1231
                }
1232
                else
1233
                {
1234
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1235
                    {
1236
                        AllPointSet.Add(itemP);
1237
                    }
1238
                }
1239
            }
1240
            #endregion
1241

    
1242
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1243

    
1244
            Dispatcher.BeginInvoke((Action)(() =>
1245
            {
1246
                foreach (var item in this.Members)
1247
                {
1248
                    foreach (var thumb in item.ThumbList)
1249
                    {
1250
                        double x = Canvas.GetLeft(thumb);
1251
                        double y = Canvas.GetTop(thumb);
1252

    
1253
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1254
                        Canvas.SetLeft(thumb, value.X);
1255
                        Canvas.SetTop(thumb, value.Y);
1256

    
1257
                        if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last())
1258
                        {
1259

    
1260
                            Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1261
                            Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1262
                            if (!(item.DrawingData as ArrowTextControl).isTrans)
1263
                            {
1264
                                List<Point> ps = new List<Point>();
1265
                                var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1266
                                switch (Math.Abs(temp.Angle).ToString())
1267
                                {
1268
                                    case "90":
1269
                                        {
1270
                                            ps.Clear();
1271
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1272
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
1273
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
1274

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

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

    
1281
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
1282
                                        }
1283
                                        break;
1284
                                    case "270":
1285
                                        {
1286
                                            ps.Clear();
1287
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1288
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
1289
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
1290

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

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

    
1297
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
1298
                                        }
1299
                                        break;
1300
                                    default:
1301
                                        {
1302
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1303
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1304
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1305
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1306
                                        }
1307
                                        break;
1308
                                }
1309

    
1310
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1311
                                var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1312
                                Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1313
                                Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1314
                            }
1315
                        }
1316
                    }
1317

    
1318
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1319
                    {
1320
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1321
                    }
1322
                }
1323
                #region 컨트롤 업데이트
1324
                foreach (var item in this.Members)
1325
                {
1326
                    switch (item.Drawingtype)
1327
                    {
1328
                        case ControlType.TextControl:
1329
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1330

    
1331
                            RectangleGeometry Data = new RectangleGeometry
1332
                            {
1333
                                Rect = new Rect()
1334
                                {
1335
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1336
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1337
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1338
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1339
                                }
1340
                            };
1341

    
1342
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1343
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);                                                      
1344

    
1345
                            DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
1346
                            DragThumb.RenderTransform = new RotateTransform()
1347
                            {
1348
                                Angle = (item.DrawingData as TextControl).Angle,
1349

    
1350
                            };
1351

    
1352
                            AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
1353
                            AdornerBorder.RenderTransform = new RotateTransform()
1354
                            {
1355
                                Angle = (item.DrawingData as TextControl).Angle,
1356

    
1357
                            };
1358

    
1359
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1360
                            {
1361
                                Angle = (item.DrawingData as TextControl).Angle,
1362
                            };
1363
                            BorderUpdate();
1364
                            break;
1365

    
1366
                        case ControlType.Date:
1367
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1368
                            (item.DrawingData as IPath).updateControl();
1369
                            BorderUpdate();
1370
                            break;
1371
                        case ControlType.ArrowMultiLine:
1372
                        case ControlType.ArcLine:
1373
                        case ControlType.ArcArrow:
1374
                        case ControlType.SingleLine:
1375
                        case ControlType.Triangle:
1376
                            (item.DrawingData as IPath).updateControl();
1377
                            BorderUpdate();
1378
                            break;
1379
                        case ControlType.ArrowTextControl:
1380
                            (item.DrawingData as IPath).updateControl();
1381
                            BorderUpdate();
1382
                            break;
1383
                        case ControlType.RectCloud:
1384
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1385
                            (item.DrawingData as IPath).updateControl();
1386
                            BorderUpdate();
1387
                            break;
1388
                        case ControlType.Rectangle:
1389
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1390
                            (item.DrawingData as IPath).updateControl();
1391
                            BorderUpdate();
1392
                            break;
1393
                        case ControlType.ImgControl:
1394
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1395
                            (item.DrawingData as IPath).updateControl();
1396
                            BorderUpdate();
1397
                            break;
1398
                        case ControlType.Sign:
1399
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1400
                            (item.DrawingData as IPath).updateControl();
1401
                            BorderUpdate();
1402
                            break;
1403
                        case ControlType.Symbol:
1404
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1405
                            (item.DrawingData as IPath).updateControl();
1406
                            BorderUpdate();
1407
                            break;
1408
                        case ControlType.Stamp:
1409
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1410
                            (item.DrawingData as IPath).updateControl();
1411
                            BorderUpdate();
1412
                            break;
1413
                        case ControlType.PolygonControl:
1414
                            (item.DrawingData as IPath).updateControl();
1415
                            BorderUpdate();
1416
                            break;
1417
                        case ControlType.PolygonCloud:
1418
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1419
                            (item.DrawingData as IPath).updateControl();
1420
                            BorderUpdate();
1421
                            break;
1422
                        case ControlType.Circle:
1423
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1424
                            (item.DrawingData as IPath).updateControl();
1425
                            ((CircleControl)item.DrawingData).SetCenterXY();
1426
                            BorderUpdate();
1427
                            break;
1428
                        case ControlType.Ink:
1429
                            (item.DrawingData as IPath).updateControl();
1430
                            BorderUpdate();
1431
                            break;
1432
                        case ControlType.InsideWhite:
1433
                            ((InsideWhiteControl)item.DrawingData).Angle = AngleValue;
1434
                            (item.DrawingData as IPath).updateControl();
1435
                            BorderUpdate();
1436
                            break;
1437
                        case ControlType.OverlapWhite:
1438
                            ((OverlapWhiteControl)item.DrawingData).Angle = AngleValue;
1439
                            (item.DrawingData as IPath).updateControl();
1440
                            BorderUpdate();
1441
                            break;
1442
                        case ControlType.ClipWhite:
1443
                            ((ClipWhiteControl)item.DrawingData).Angle = AngleValue;
1444
                            (item.DrawingData as IPath).updateControl();
1445
                            BorderUpdate();
1446
                            break;
1447
                        case ControlType.Coordinate:
1448
                            ((CoordinateControl)item.DrawingData).Angle = AngleValue;
1449
                            (item.DrawingData as IPath).updateControl();
1450
                            BorderUpdate();
1451
                            break;
1452
                        default:
1453
                            break;
1454
                    }
1455
                }
1456
                #endregion
1457
            }));
1458
        }
1459

    
1460
        private void resize_MouseMove(object sender, MouseEventArgs e)
1461
        {
1462
            reSizePoint = e.GetPosition(this);
1463
        }
1464
        /// <summary>
1465
        /// 회전
1466
        /// </summary>
1467
        /// <param name="sender"></param>
1468
        /// <param name="e"></param>
1469
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1470
        {
1471

    
1472
            MoveRotate(e);
1473
        }
1474

    
1475
        double LastRotateHorizontalValue = 0;
1476
        double LastRotateVerticalValue = 0;
1477
        //double LastWidthValue = 0;
1478
        //double SetWidth = 0;
1479
        bool RotateFlag = false;
1480

    
1481
        /// <summary>
1482
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1483
        /// </summary>
1484
        /// <param name="e"></param>
1485
        public void MoveRotate(DragDeltaEventArgs e)
1486
        {
1487
            double dDeltaAngle = 0;
1488

    
1489
            List<Point> AllPointSet = new List<Point>();
1490
            Point CenterPoint = new Point();
1491
            
1492
            #region 센터 포인트 구하기 (그룹핑)
1493
            foreach (var item in this.Members)
1494
            {
1495
                if (item.DrawingData.GetType().Name == "TextControl")
1496
                {                    
1497
                    if (AngleValue == 0)
1498
                    {
1499
                        AngleValue = (item.DrawingData as TextControl).Angle;
1500
                    }
1501
                    double X = Canvas.GetLeft((item.DrawingData as TextControl));
1502
                    double Y = Canvas.GetTop((item.DrawingData as TextControl));
1503
                    AllPointSet.Add(new Point(X, Y));
1504
                }
1505
                else
1506
                {
1507
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1508
                    {
1509
                        AllPointSet.Add(itemP);
1510
                    }
1511
                }
1512
            }
1513
            #endregion
1514
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1515
            Point pt = Mouse.GetPosition(this);
1516

    
1517
            Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
1518
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1519
            dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1520

    
1521
            //System.Diagnostics.Debug.WriteLine("vec1 : " + vec1.X + "/" + vec1.Y);
1522
            //System.Diagnostics.Debug.WriteLine("vec2 : " + vec2.X + "/" + vec2.Y);
1523
            //System.Diagnostics.Debug.WriteLine("dDeltaAngle : " + dDeltaAngle);
1524

    
1525
            AngleValue += dDeltaAngle;
1526
            if (AngleValue > 360) AngleValue -= 360;
1527
            if (AngleValue < 0) AngleValue += 360;
1528
            this.rotatePoint = pt;  /// save rotatePoint
1529

    
1530
            Dispatcher.BeginInvoke((Action)(() =>
1531
            {
1532
                foreach (var item in this.Members)
1533
                {
1534
                    foreach (var thumb in item.ThumbList)
1535
                    {
1536
                        double x = Canvas.GetLeft(thumb);
1537
                        double y = Canvas.GetTop(thumb);
1538

    
1539
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1540
                        Canvas.SetLeft(thumb, value.X);
1541
                        Canvas.SetTop(thumb, value.Y);
1542
                    }
1543

    
1544
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1545
                    {
1546
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1547
                    }
1548
                }
1549
                #region 보더 업데이트
1550
                foreach (var item in this.Members)
1551
                {
1552
                    switch (item.Drawingtype)
1553
                    {
1554
                        case ControlType.TextControl:
1555
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1556

    
1557
                            RectangleGeometry Data = new RectangleGeometry
1558
                            {
1559
                                Rect = new Rect()
1560
                                {
1561
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1562
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1563
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1564
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1565
                                }
1566
                            };
1567

    
1568
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1569
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);
1570

    
1571
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1572
                            DragThumb.RenderTransform = new RotateTransform()
1573
                            {
1574
                                Angle = (item.DrawingData as TextControl).Angle,
1575
                                //CenterX = middle.X,
1576
                                //CenterY = middle.Y,
1577
                            };
1578

    
1579
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1580
                            AdornerBorder.RenderTransform = new RotateTransform()
1581
                            {
1582
                                Angle = (item.DrawingData as TextControl).Angle,
1583
                                //CenterX = middle.X,
1584
                                //CenterY = middle.Y,
1585
                            };
1586

    
1587
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1588
                            {
1589
                                Angle = (item.DrawingData as TextControl).Angle,
1590
                            };
1591

    
1592
                            BorderUpdate();
1593
                            break;
1594

    
1595
                        case ControlType.Date:
1596
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1597
                            (item.DrawingData as IPath).updateControl();
1598
                            BorderUpdate();                          
1599
                            break;
1600
                        case ControlType.ArrowMultiLine:
1601
                        case ControlType.ArcLine:
1602
                        case ControlType.ArcArrow:
1603
                        case ControlType.SingleLine:
1604
                        case ControlType.Triangle:
1605
                            (item.DrawingData as IPath).updateControl();
1606
                            BorderUpdate();
1607
                            break;
1608
                        case ControlType.ArrowTextControl:
1609
                            (item.DrawingData as IPath).updateControl();
1610
                            BorderUpdate();
1611
                            break;
1612
                        case ControlType.RectCloud:
1613
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1614
                            (item.DrawingData as IPath).updateControl();
1615
                            BorderUpdate();
1616
                            break;
1617
                        case ControlType.Rectangle:
1618
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1619
                            (item.DrawingData as IPath).updateControl();
1620
                            BorderUpdate();
1621
                            break;
1622
                        case ControlType.ImgControl:
1623
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1624
                            (item.DrawingData as IPath).updateControl();
1625
                            BorderUpdate();
1626
                            break;                        
1627
                        case ControlType.Sign:
1628
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1629
                            (item.DrawingData as IPath).updateControl();
1630
                            BorderUpdate();
1631
                            break;                        
1632
                        case ControlType.Symbol:
1633
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1634
                            (item.DrawingData as IPath).updateControl();
1635
                            BorderUpdate();
1636
                            break;
1637
                        case ControlType.Stamp:
1638
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1639
                            (item.DrawingData as IPath).updateControl();
1640
                            BorderUpdate();
1641
                            break;
1642
                        case ControlType.PolygonControl:
1643
                            (item.DrawingData as IPath).updateControl();
1644
                            BorderUpdate();
1645
                            break;
1646
                        case ControlType.PolygonCloud:
1647
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1648
                            (item.DrawingData as IPath).updateControl();
1649
                            BorderUpdate();
1650
                            break;
1651
                        case ControlType.Circle:
1652
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1653
                            (item.DrawingData as IPath).updateControl();
1654
                            ((CircleControl)item.DrawingData).SetCenterXY();
1655
                            BorderUpdate();
1656
                            break;
1657
                        case ControlType.Ink:
1658
                            for (int i = 0; i < (item.DrawingData as InkControl).PointC.Count(); i++)
1659
                            {
1660
                                for (int j = 0; j < (item.DrawingData as InkControl).PointC[i].pointSet.Count; j++)
1661
                                {
1662
                                    (item.DrawingData as InkControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as InkControl).PointC[i].pointSet[j], dDeltaAngle);
1663
                                }
1664
                            }
1665
                            (item.DrawingData as IPath).updateControl();
1666
                            BorderUpdate();
1667
                            break;
1668
                        
1669
                        default:
1670
                            break;
1671
                    }
1672
                }
1673
                #endregion
1674
            }));
1675
            BorderUpdate();
1676
        }
1677

    
1678
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1679
        {            
1680

    
1681
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1682
            rotateTop.Cursor = Cursors.SizeAll;
1683

    
1684
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1685
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1686
            {
1687
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).Angle;
1688
            }
1689
            /// up to here
1690

    
1691

    
1692

    
1693
            if (ViewerDataModel.Instance.UndoDataList == null)
1694
            {
1695
                return;
1696
            }
1697

    
1698
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1699
            {
1700
                return;
1701
            }
1702

    
1703
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1704
            {
1705
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1706
                {
1707
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1708
                    {
1709
                        return;
1710
                    }
1711
                }
1712
            }
1713

    
1714
            var comments = (from drawing in this.Members
1715
                            select drawing.DrawingData as CommentUserInfo).ToList();
1716
            UndoCommand.Instance.Push(comments, this.AngleValue);
1717
        }
1718
        
1719
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1720
        {
1721
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1722

    
1723
            var comments = (from drawing in this.Members
1724
                            select drawing.DrawingData as CommentUserInfo).ToList();
1725
            UndoCommand.Instance.Push(comments, this.AngleValue);
1726
        }
1727

    
1728
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1729
        {
1730
            if (ViewerDataModel.Instance.UndoDataList == null)
1731
            {
1732
                return;
1733
            }
1734
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1735
            {
1736
                return;
1737
            }
1738
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1739
            {
1740
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1741
                {
1742
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1743
                    {
1744
                        return;
1745
                    }
1746
                }
1747
            }
1748

    
1749
            var comments = (from drawing in this.Members
1750
                            select drawing.DrawingData as CommentUserInfo).ToList();
1751
            UndoCommand.Instance.Push(comments, this.AngleValue);
1752
        }
1753

    
1754
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1755
        {          
1756
            DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1757

    
1758
            var comments = (from drawing in this.Members
1759
                            select drawing.DrawingData as CommentUserInfo).ToList();
1760
            UndoCommand.Instance.Push(comments, this.AngleValue);
1761
        }
1762

    
1763
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1764
        {
1765
            AdornerMember control = this.Members.FirstOrDefault();
1766

    
1767
            if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null)
1768
            {
1769
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1770
                {
1771
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1772
                }
1773
            }
1774

    
1775
        }
1776

    
1777
        public void TextControlChanger()
1778
        {
1779
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1780
            {
1781
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1782
                AllControl.Base_TextBox.Focus();
1783
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1784
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1785
                AllControl.Base_TextBox.Focus();
1786
                AllControl.SizeChanged += (sen, ea) =>
1787
                {
1788
                    if (AllControl.Base_TextBox != null)
1789
                    {
1790
                        RectangleGeometry Data = new RectangleGeometry
1791
                        {
1792
                            Rect = new Rect()
1793
                            {
1794
                                X = AllControl.StartPoint.X,
1795
                                Y = AllControl.StartPoint.Y,
1796
                                Width = AllControl.Base_TextBox.Width,
1797
                                Height = AllControl.Base_TextBox.Height,
1798
                            }
1799
                        };
1800

    
1801
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1802
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1803
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1804
                        {
1805
                            Angle = AllControl.Angle,
1806
                            CenterX = middle.X,
1807
                            CenterY = middle.Y,
1808
                        };
1809
                    }
1810
                    BorderUpdate();
1811
                };
1812
            }
1813
        }
1814

    
1815
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1816
        {
1817
            if (e.ClickCount == 2 && this.Members.Count == 1)
1818
            {
1819

    
1820
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1821
                {
1822
                    TextControlChanger();                    
1823
                }
1824

    
1825
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1826
                {
1827
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1828
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1829
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1830

    
1831
                    //ArrowControl TextBox Thumb없애기
1832
                    tm.Visibility = Visibility.Collapsed;
1833

    
1834
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1835
                    
1836
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1837

    
1838
                    {
1839
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1840
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1841

    
1842
                        List<Point> ps = new List<Point>();
1843
                        
1844
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1845
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1846
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1847
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1848

    
1849

    
1850

    
1851

    
1852
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1853
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1854
                        if (AllControl.isTrans)
1855
                        {
1856
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1857
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1858
                        }
1859
                        else
1860
                        {
1861
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1862
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1863
                        }
1864

    
1865

    
1866
                        BorderUpdate();
1867

    
1868
                    };
1869
                }
1870
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1871
                {
1872
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1873
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1874
                    //dropData.IsOpen = true;
1875
                    RadWindow rc = new RadWindow();
1876
                    rc.Width = 300;
1877
                    rc.Height = 300;
1878
                    rc.Header = "Change Date";
1879
                    rc.Content = instanceCal;
1880
                    rc.BorderThickness = new Thickness(3);
1881
                    rc.ResizeMode = ResizeMode.NoResize;
1882
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1883
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1884
                    rc.ModalBackground.Opacity = 0.6;
1885
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1886
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1887
                    {
1888
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1889
                        rc.Close();
1890
                    };
1891
                    rc.ShowDialog();
1892
                    //CalendarControl.xaml
1893
                }
1894
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1895
                {
1896
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1897
                    if (instance.isTransOn)
1898
                    {
1899
                        instance.isTransOn = false;
1900
                    }
1901
                    else
1902
                    {
1903
                        instance.isTransOn = true;
1904
                    }
1905
                    ///instance.SetArcPath();
1906
                    BorderUpdate();
1907
                }
1908
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1909
                {
1910
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1911
                    if (instance.isTransOn)
1912
                    {
1913
                        instance.isTransOn = false;
1914
                    }
1915
                    else
1916
                    {
1917
                        instance.isTransOn = true;
1918
                    }
1919
                    instance.SetArcPath();
1920
                    BorderUpdate();
1921
                }
1922

    
1923
            }
1924
            
1925
        }
1926
        #endregion
1927

    
1928
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1929
        {
1930
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1931
            {
1932
                DragThumb.Visibility = Visibility.Collapsed;
1933
            }
1934
        }
1935

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