프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 4913851c

이력 | 보기 | 이력해설 | 다운로드 (115 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
    /// <summary>
27
    /// Interaction logic for AdornerFinal.xaml
28
    /// </summary>
29
    public class AdornerMember
30
    {
31
        public UIElement DrawingData { get; set; }
32
        public ControlType Drawingtype { get; set; }
33
        public double DrawingAngle { get; set; }
34
        public List<Thumb> ThumbList { get; set; }
35
        public string Symbol_ID { get; set; }
36
        public long Group_ID { get; set; }
37
    }
38

    
39
    public partial class AdornerFinal : UserControl
40
    {
41
        public TextBox editTextBox { get; set; }
42
        #region 공용 인스턴스
43
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
44
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
45
        public double AngleValue = 0;
46
        public bool IsTextAngle = false;
47
        public Rect BorderSize { get; set; }
48
        public bool TextCompensation = false;
49
        public bool isDragging { get; set; }
50
        public Thumb DraggerThumb { get; set; }
51
        public RadDropDownButton dropData;
52
        public RadCalendar dropCalendar;
53
        public Thumb mainDragThumb { get; set; }
54

    
55
        private bool disposed;
56

    
57
        public Point reSizePoint { get; set; }
58
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
59
        #endregion
60
        #region 생성자
61
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
62
        {
63
            dropData = sender as RadDropDownButton;
64
        }
65

    
66
        private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
67
        {
68
            dropCalendar = sender as RadCalendar;
69
            dropCalendar.SelectionChanged += (sen, ea) =>
70
            {
71
                dropData.IsOpen = false;
72
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
73
                {
74
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
75
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
76
                }
77
            };
78
        }
79

    
80
        public AdornerFinal()
81
        {
82
            InitializeComponent();
83
            BorderSize = new Rect();
84
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
85
        }
86

    
87
        ~AdornerFinal()
88
        {
89
            this.Dispose(false);
90
        }
91

    
92
        public void Dispose()
93
        {
94
            this.Dispose(true);
95
            GC.SuppressFinalize(this);
96
        }
97

    
98
        protected virtual void Dispose(bool disposing)
99
        {
100
            if (this.disposed) return;
101
            if (disposing)
102
            {
103
                foreach (var member in this.Members)
104
                {
105
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
106
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
107
                }
108
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
109
            }
110
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
111
            this.disposed = true;
112
        }
113

    
114
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
115
        {
116
            mainDragThumb = DragThumb;
117
        }
118

    
119
        public AdornerFinal(CommentUserInfo objectData) : this()
120
        {
121
            InitializeComponent();
122
            objectData.IsHitTestVisible = false;
123
            if ((objectData as ArrowTextControl) != null)
124
            {
125
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
126
            }
127
            Canvas.SetZIndex(objectData, 84);
128
            try
129
            {
130
                this.ContainerContent.Children.Add(objectData);
131
            }
132
            catch //(Exception ex)
133
            {
134

    
135
            }
136
            SetAdornerMember(objectData as CommentUserInfo);
137
            this.Focus();
138
        }
139

    
140
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
141
        {
142
            InitializeComponent();
143
            foreach (var item in objectData)
144
            {
145
                //item.IsHitTestVisible = false;
146
                if ((item as ArrowTextControl) != null)
147
                {
148
                    (item as ArrowTextControl).Base_TextBox.Focusable = true;
149
                }
150
                try
151
                {
152
                    Canvas.SetZIndex(item, 80);
153
                    this.ContainerContent.Children.Add(item);
154
                }
155
                catch //(Exception ex)
156
                {
157

    
158
                }
159
            }
160
            this.SetAdornerMember(objectData);
161
            this.Focus();
162
        }
163

    
164
        #endregion
165
        #region 메서드
166
        public Rect getAdornerSize()
167
        {
168
            return BorderSize;
169
        }
170
        public void addMemberControl(UIElement objectData)
171
        {
172
            this.ContainerContent.Children.Add(objectData);
173
            SetAdornerMember(objectData as CommentUserInfo);
174
            this.Focus();
175
        }
176
        /// <summary>
177
        /// UIElement를 종류에 맞게 등록시킴
178
        /// </summary>
179
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
180
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
181
        {
182

    
183
            switch (member.GetType().Name)
184
            {
185
                #region 컨트롤 조건
186
                case "LineControl": //Angle추가 안했음
187
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
188
                    break;
189
                case "ImgControl": //Angle추가 안했음
190
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
191
                    //AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);            
192
                    //DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
193
                    AngleValue = (member as ImgControl).Angle;
194
                    break;
195
                //case "SymControl": //Angle추가 안했음
196
                //    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() });
197
                //    AngleValue = (member as SymControl).Angle;
198
                //    //ViewBoxRotate(member);
199
                //    break;
200
                //case "SymControlN": //Angle추가 안했음
201
                //    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() });
202
                //    AngleValue = (member as SymControlN).Angle;
203
                //    //ViewBoxRotate(member);
204
                //    break;
205
                case "PolygonControl": //Angle추가 안했음
206
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
207
                    break;
208
                case "ArrowControl":
209
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
210
                    break;
211
                case "ArrowTextControl":
212
                    this.Members.Add(new AdornerMember
213
                    {
214
                        DrawingData = member,
215
                        Drawingtype = ControlType.ArrowTextControl,
216
                        ThumbList = new List<Thumb>(),
217
                        Symbol_ID = member.SymbolID,
218
                        Group_ID = member.GroupID,
219
                    });
220
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
221
                    AngleValue = (member as ArrowTextControl).Angle;
222
                    Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
223
                    {
224
                        TextCompensation = false;
225
                        BorderUpdate();
226
                        if ((a.Sender as TextBox).Text == "") //보류
227
                        {
228
                            this.ContainerContent.Children.Remove(member);
229
                            this.Visibility = Visibility.Collapsed;
230
                        }
231
                    });
232
                    break;
233
                case "ArcControl":
234
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
235
                    break;
236
                case "ArrowArcControl":
237
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
238
                    break;
239
                case "ArrowControl_Multi":
240
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
241
                    break;
242
                case "RectangleControl":
243
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
244
                    break;
245
                case "DateControl":
246
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
247
                    AngleValue = (member as DateControl).Angle;
248
                    break;
249
                case "TriControl":
250
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
251
                    break;
252
                case "CircleControl":
253
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
254
                    break;
255
                case "CloudControl":
256
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
257
                    break;
258
                case "RectCloudControl":
259
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
260
                    break;
261
                case "SignControl":
262
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
263
                    AngleValue = (member as SignControl).Angle;
264
                    break;
265

    
266
                case "SymControl":
267
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
268
                    AngleValue = (member as SymControl).Angle;
269
                    break;
270
                case "SymControlN":
271
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
272
                    AngleValue = (member as SymControlN).Angle;
273
                    break;
274
                case "InkControl": //Angle추가 안했음
275
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
276
                    break;
277
                case "TextControl":
278
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
279
                    RectangleGeometry Data = new RectangleGeometry
280
                    {
281
                        Rect = new Rect()
282
                        {
283
                            X = Canvas.GetLeft((member as TextControl)),
284
                            Y = Canvas.GetTop((member as TextControl)),
285
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
286
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
287
                            //Width = (member as TextControl).BoxWidth / 2,
288
                            //Height = (member as TextControl).BoxHeight / 2,
289
                        }
290
                    };
291
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
292
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
293

    
294

    
295
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
296
                    DragThumb.RenderTransform = new RotateTransform()
297
                    {
298
                        Angle = (member as TextControl).Angle,
299
                        //CenterX = middle.X,
300
                        //CenterY = middle.Y,
301
                    };
302

    
303
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
304
                    AdornerBorder.RenderTransform = new RotateTransform()
305
                    {
306
                        Angle = (member as TextControl).Angle,
307
                        //CenterX = middle.X,
308
                        //CenterY = middle.Y,
309
                    };
310
                    Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
311
                    {
312
                        TextCompensation = true;
313
                        BorderUpdate();
314
                        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
315
                    });
316
                    Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
317
                    {
318
                        TextCompensation = false;
319
                        BorderUpdate();
320
                        if ((a.Sender as TextBox).Text == "") //보류
321
                        {
322
                            this.ContainerContent.Children.Remove(member);
323
                            this.Visibility = Visibility.Collapsed;
324
                        }
325

    
326
                        //((TextControl)member).UnEditingMode();
327
                        //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
328
                        //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
329
                        //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
330
                    });
331
                    break;
332
                case "InsideWhiteControl":
333
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
334
                    break;
335
                case "OverlapWhiteControl":
336
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
337
                    break;
338
                case "ClipWhiteControl":
339
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
340
                    break;
341
                case "CoordinateControl":
342
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
343
                    break;
344
                default:
345
                    break;
346
                    #endregion
347
            }
348
            if (member.GetType().Name == "TextControl")
349
            {
350
                TextControl content = ((TextControl)member);
351
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
352
                content.EndPoint = content.StartPoint;
353

    
354
            }
355
            else
356
            {
357
                RegistryPoint(member);
358
            }
359
            BorderUpdate();
360

    
361
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
362
        }
363

    
364
        private void ViewBoxRotate(UIElement member)
365
        {
366
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
367
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
368
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
369
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
370
        }
371

    
372
        public void SetAdornerMember(List<CommentUserInfo> members)
373
        {
374
            foreach (var member in members)
375
            {
376
                switch (member.GetType().Name)
377
                {
378
                    #region 컨트롤 조건
379
                    case "LineControl":
380
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
381
                        break;
382
                    case "ImgControl":
383
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
384
                        break;
385
                    case "ArrowControl":
386
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
387
                        break;
388
                    case "PolygonControl":
389
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
390
                        break;
391
                    case "ArrowTextControl":
392
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
393
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
394
                        break;
395
                    case "ArcControl":
396
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
397
                        break;
398
                    case "ArrowArcControl":
399
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
400
                        break;
401
                    case "DateControl":
402
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
403
                        break;
404
                    case "ArrowControl_Multi":
405
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
406
                        break;
407
                    case "RectangleControl":
408
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
409
                        break;
410
                    case "TriControl":
411
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
412
                        break;
413
                    case "CircleControl":
414
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
415
                        break;
416
                    case "CloudControl":
417
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
418
                        break;
419
                    case "RectCloudControl":
420
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
421
                        break;
422
                    case "SignControl":
423
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
424
                        break;
425
                    case "SymControl":
426
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
427
                        break;
428
                    case "SymControlN":
429
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
430
                        break;
431
                    case "InkControl":
432
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
433
                        break;
434
                    case "TextControl":
435
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
436
                        Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
437
                        {
438
                            BorderUpdate();
439
                            try
440
                            {
441
                                ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
442
                            }
443
                            catch (Exception)
444
                            {
445

    
446
                            }
447

    
448
                        });
449
                        Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
450
                        {
451
                            BorderUpdate();
452
                        });
453
                        break;
454
                    case "InsideWhiteControl":
455
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
456
                        break;
457
                    case "OverlapWhiteControl":
458
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
459
                        break;
460
                    case "ClipWhiteControl":
461
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
462
                        break;
463
                    case "CoordinateControl":
464
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
465
                        break;
466
                    default:
467
                        break;
468
                        #endregion
469
                }
470
                if (member.GetType().Name == "TextControl")
471
                {
472
                    TextControl content = ((TextControl)member);
473
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
474
                    content.EndPoint = content.StartPoint;
475
                }
476
                else
477
                {
478
                    RegistryPoint(member, members.Count);
479
                }
480

    
481
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))  Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
482
            }
483

    
484
            BorderUpdate();
485
        }
486

    
487
        /// <summary>
488
        /// Border 를 갱신
489
        /// </summary>
490
        public void BorderUpdate()
491
        {
492
            AdornerBorder.MinWidth = 10;
493
            AdornerBorder.MinHeight = 10;
494

    
495
            double minX = double.MaxValue;
496
            double minY = double.MaxValue;
497
            double maxX = double.MinValue;
498
            double maxY = double.MinValue;
499

    
500
            if (this.Members.Count == 1)
501
            {
502
                if (this.Members.First().DrawingData.GetType().Name == "TextControl")
503
                {
504
                    if ((this.Members.First().DrawingData as TextControl).Angle != 0)
505
                    {
506
                        trRotate.Angle = (this.Members.First().DrawingData as TextControl).Angle;
507
                        trRotateThumb.Angle = (this.Members.First().DrawingData as TextControl).Angle;
508
                    }
509
                    else
510
                    {
511
                        trRotate.Angle = 0;
512
                        trRotateThumb.Angle = 0;
513
                    }
514
                }
515
            }
516
            foreach (var item in this.Members)
517
            {
518
                UIElement currentControl = (item as AdornerMember).DrawingData;
519
                if (item.DrawingData.GetType().Name == "TextControl")
520
                {
521
                    double textControlWidth;
522
                    double textControlHeight;
523
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
524
                    {
525
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
526
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
527
                    }
528
                    else
529
                    {
530
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
531
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
532
                    }
533
                    
534
                    if ((currentControl as TextControl).EndPoint.X < minX)
535
                    {
536
                        minX = (currentControl as TextControl).EndPoint.X;
537
                    }
538
                    if ((currentControl as TextControl).EndPoint.Y < minY)
539
                    {
540
                        minY = (currentControl as TextControl).EndPoint.Y;
541
                    }
542
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
543
                    {
544
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
545
                    }
546
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
547
                    {
548
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
549
                    }
550
                }
551
                else if ((currentControl as IViewBox) != null)
552
                {
553
                    IViewBox instance = currentControl as IViewBox;
554
                    List<Point> am = (currentControl as IPath).PointSet;
555
                    List<double> xSet = am.Select(p => p.X).ToList();
556
                    List<double> ySet = am.Select(p => p.Y).ToList();
557
                    if (xSet.Min() < minX) minX = xSet.Min();
558
                    if (ySet.Min() < minY) minY = ySet.Min();
559
                    if (xSet.Max() > maxX) maxX = xSet.Max();
560
                    if (ySet.Max() > maxY) maxY = ySet.Max();
561
                }
562
                else if ((currentControl as IPath).PathData == null)
563
                {
564
                    Rect rt = new Rect
565
                    {
566
                        X = (currentControl as IPath).StartPoint.X,
567
                        Y = (currentControl as IPath).StartPoint.Y,
568
                        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),
569
                        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),
570
                    };
571
                    if (rt.Left < minX) minX = rt.Left;
572
                    if (rt.Top < minY) minY = rt.Top;
573
                    if (rt.Right > maxX) maxX = rt.Right;
574
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
575
                }
576
                else if ((currentControl as IPath) == null)
577
                {
578
                    Rect rt = new Rect
579
                    {
580
                        X = (currentControl as IPath).StartPoint.X,
581
                        Y = (currentControl as IPath).StartPoint.Y,
582
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
583
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
584
                    };
585
                    if (rt.Left < minX) minX = rt.Left;
586
                    if (rt.Top < minY) minY = rt.Top;
587
                    if (rt.Right > maxX) maxX = rt.Right;
588
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
589
                }
590
                else if ((currentControl as CircleControl) != null)
591
                {                    
592
                    List<Point> am = (currentControl as IPath).PointSet;
593
                    List<double> xSet = am.Select(p => p.X).ToList();
594
                    List<double> ySet = am.Select(p => p.Y).ToList();
595
                    if (xSet.Min() < minX) minX = xSet.Min();
596
                    if (ySet.Min() < minY) minY = ySet.Min();
597
                    if (xSet.Max() > maxX) maxX = xSet.Max();
598
                    if (ySet.Max() > maxY) maxY = ySet.Max();
599
                }
600
                else
601
                {
602
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
603
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
604
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
605
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
606
                }
607
            }
608

    
609
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
610
            bool addWidthSize = false;
611
            bool addHeightSize = false;
612
            if (ac.Width <= 10)
613
            {
614
                ac.Width += 10;
615
                addWidthSize = true;
616
            }
617
            if (ac.Height <= 10)
618
            {
619
                ac.Height += 10;
620
                addHeightSize = true;
621
            }
622
            BorderSize = ac;
623
            AdornerBorder.MinWidth = 10;
624
            AdornerBorder.MinHeight = 10;
625
            AdornerBorder.Width = ac.Width;
626
            AdornerBorder.Height = ac.Height;
627
            Canvas.SetLeft(AdornerBorder, minX);
628
            Canvas.SetTop(AdornerBorder, minY);
629

    
630
            DragThumb.Width = ac.Width;
631
            DragThumb.Height = ac.Height;
632

    
633
            DragThumb.MinWidth = 10;
634
            DragThumb.MinHeight = 10;
635
            if (addWidthSize)
636
            {
637
                Canvas.SetLeft(DragThumb, minX - 5);
638
            }
639
            else
640
            {
641
                Canvas.SetLeft(DragThumb, minX);
642
            }
643

    
644
            if (addHeightSize)
645
            {
646
                Canvas.SetTop(DragThumb, minY - 5);
647
            }
648
            else
649
            {
650
                Canvas.SetTop(DragThumb, minY);
651
            }
652
        }
653
        /// <summary>
654
        /// UIElement 해제
655
        /// </summary>
656
        public void unRegister()
657
        {
658
            foreach (var item in this.ContainerContent.Children)
659
            {
660
                if (item is MarkupToPDF.Common.CommentUserInfo)
661
                {
662
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
663
                }
664
            }
665
            this.ContainerContent.Children.Clear();
666
        }
667
        /// <summary>
668
        /// 각 포인트들을 등록합니다.
669
        /// </summary>
670
        /// <param name="pointset">Drawing Point</param>
671
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
672
        {
673
            int count = 0;
674
            double Minx = 100000000;
675
            double Miny = 100000000;
676
            List<Point> list = (member as IPath).PointSet;
677
            if (member.GetType().Name == "InkControl")
678
            {
679
                list.Clear();
680
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
681
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
682
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
683
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
684
            }
685
            ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype;
686
            foreach (var ax in list)
687
            {
688
                Minx = (ax.X < Minx) ? ax.X : Minx;
689
                Miny = (ax.Y < Miny) ? ax.Y : Miny;
690
            }
691
            for (int i = 0; i < list.Count(); i++)
692
            {
693
                Thumb tm = new Thumb
694
                {
695
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
696
                };
697

    
698
                this.Members.Last().ThumbList.Add(tm);
699

    
700
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MidPoint))
701
                {
702
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
703
                }
704
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
705
                {
706
                    //if (this.Members.Count()<=1)
707
                    //{
708
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
709
                    List<Point> ps = new List<Point>();
710

    
711
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
712
                    {
713
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
714

    
715

    
716
                        switch (Math.Abs(temp.Angle).ToString())
717
                        {
718
                            case "90":
719
                                {
720
                                    ps.Clear();
721
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
722
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
723
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
724

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

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

    
731
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
732
                                }
733
                                break;
734
                            case "270":
735
                                {
736
                                    ps.Clear();
737
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
738
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
739
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
740

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

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

    
747
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
748
                                }
749
                                break;
750
                            default:
751
                                {
752
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
753
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
754
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
755
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
756
                                }
757
                                break;
758
                        }
759

    
760
                        ArrowTextControl instance = (member as ArrowTextControl);
761
                        if (instance.isTrans)
762
                        {
763
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
764
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
765
                            //list[count] = tempP;
766
                            list[count] = temp.MidPoint;
767
                        }
768
                        else
769
                        {
770
                            if (temp.isFixed)
771
                            {
772
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
773
                                var testP = endP;
774
                                if (ps[0] == endP) //상단
775
                                {
776
                                    testP = new Point(endP.X, endP.Y - 50);
777
                                }
778
                                else if (ps[1] == endP) //하단
779
                                {
780
                                    testP = new Point(endP.X, endP.Y + 50);
781
                                }
782
                                else if (ps[2] == endP) //좌단
783
                                {
784
                                    testP = new Point(endP.X - 50, endP.Y);
785
                                }
786
                                else if (ps[3] == endP) //우단
787
                                {
788
                                    testP = new Point(endP.X + 50, endP.Y);
789
                                }
790
                                list[count] = testP;
791
                            }
792
                            else
793
                            {
794
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
795
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
796
                            }
797
                        }
798
                    }
799
                }
800
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
801
                {
802
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
803
                    tm.Width = (member as ArrowTextControl).BoxWidth;
804
                    tm.Height = (member as ArrowTextControl).BoxHeight;
805
                    var angle = (member as ArrowTextControl).Angle;
806
                    if (Math.Abs(angle).ToString() == "90")
807
                    {
808
                        tm.RenderTransformOrigin = new Point(0, 0);
809
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
810
                    }
811
                    else if (Math.Abs(angle).ToString() == "270")
812
                    {
813
                        tm.RenderTransformOrigin = new Point(0, 0);
814
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
815

    
816
                    }
817
                    else
818
                    {
819
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
820
                        tm.RenderTransform = new RotateTransform()
821
                        {
822
                            Angle = angle,
823
                        };
824
                    }
825
                }
826
                
827
                if (member.GetType().Name == "CloudControl")
828
                {
829
                    if (i == list.Count() - 1)
830
                    {
831
                        tm.Visibility = System.Windows.Visibility.Collapsed;
832
                    }
833
                }
834
                if (member.GetType().Name == "PolygonControl")
835
                {
836
                    if (i == list.Count() - 1)
837
                    {
838
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
839
                        {
840

    
841
                        }
842
                        else
843
                        {
844
                            tm.Visibility = System.Windows.Visibility.Collapsed;
845
                        }
846
                    }
847
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
848
                    {
849
                        tm.Visibility = System.Windows.Visibility.Collapsed;
850
                    }
851
                }
852
                
853
                this.ContainerContent.Children.Add(tm);
854
                Canvas.SetLeft(tm, list[count].X);
855
                Canvas.SetTop(tm, list[count].Y);
856
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
857
                {
858
                    Canvas.SetZIndex(tm, 95);
859
                }
860
                else
861
                {
862
                    Canvas.SetZIndex(tm, 99);
863
                }
864

    
865
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
866
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
867
                tm.DragDelta += ResizeTm_DragDelta;
868
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
869
                count++;
870
            }
871
        }
872

    
873
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
874
        {
875
            if (this.Members.Count > 1)
876
                return;
877
            if (reSizePoint != new Point(0, 0))
878
            {
879
                Thumb thumb = sender as Thumb;
880

    
881
                if (AngleValue == -90)
882
                {
883
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.VerticalChange);
884
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.HorizontalChange));
885
                }
886
                else if (AngleValue == -180)
887
                {
888
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.HorizontalChange));
889
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.VerticalChange));
890
                }
891
                else if (AngleValue == -270)
892
                {
893
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.VerticalChange));
894
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.HorizontalChange);
895
                }
896
                else //(AngleValue == 0)
897
                {
898
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.HorizontalChange);
899
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.VerticalChange);
900
                }
901

    
902

    
903
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
904
                
905
                AdornerMember control = (from userThumb in this.Members
906
                                         where userThumb.ThumbList.Contains(thumb)
907
                                         select userThumb).FirstOrDefault();
908
                Point nearPoint = new Point(0, 0);
909
                IPath AllControl = control.DrawingData as IPath;
910
                if (ControlType.TextControl != control.Drawingtype)
911
                {
912

    
913
                    var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
914
                    List<Point> ps = new List<Point>();
915

    
916
                    nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
917
                    
918

    
919
                }
920
                for (int i = 0; i < (control.DrawingData as IPath).PointSet.Count; i++)
921
                {
922
                    switch (control.Drawingtype)
923
                    {
924
                        #region Arc + Line
925
                        case ControlType.ArrowMultiLine:
926
                        case ControlType.ArcLine:
927
                        case ControlType.ArcArrow:
928
                        case ControlType.SingleLine:
929
                        case ControlType.Triangle:
930
                            if (nearPoint.Equals(AllControl.PointSet[i]))
931
                            {
932
                                AllControl.PointSet[i] = setPoint;
933
                                AllControl.updateControl();
934
                                DynamicThumbUpdate(control);
935
                                BorderUpdate();
936
                                
937
                            }
938
                            break;
939
                        #endregion
940
                        #region Shape                        
941
                        case ControlType.RectCloud:
942
                        case ControlType.Rectangle:
943
                            if (nearPoint.Equals(AllControl.PointSet[i]))
944
                            {
945
                                AllControl.PointSet[i] = setPoint;
946
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
947
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
948
                                var NextP = (i + 1) % AllControl.PointSet.Count();
949

    
950
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
951

    
952
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
953
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
954
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
955
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
956
                                    [ReverseP].Y
957
                                    + PreviousV.Y * l);
958

    
959
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
960
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
961
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
962
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
963
                                    NextV.Y * l);
964
                                AllControl.updateControl();
965
                                DynamicThumbUpdate(control);
966
                                BorderUpdate();
967
                            }
968
                            break;
969
                        #endregion
970
                        #region Polygon
971
                        case ControlType.PolygonControl:
972
                            if (nearPoint.Equals(AllControl.PointSet[i]))
973
                            {
974
                                AllControl.PointSet[i] = setPoint;
975
                                AllControl.updateControl();
976
                                BorderUpdate();
977
                            }
978
                            break;
979
                        #endregion
980
                        #region Cicle
981
                        case ControlType.Circle:
982
                            if (nearPoint.Equals(AllControl.PointSet[i]))
983
                            {
984
                                AllControl.PointSet[i] = setPoint;
985
                                List<Point> newPointSet = new List<Point> { };
986
                                Point middle = new Point(AllControl.PathData.Bounds.X + AllControl.PathData.Bounds.Width * 0.5,
987
                                    AllControl.PathData.Bounds.Y +
988
                                    AllControl.PathData.Bounds.Height * 0.5);
989
                                foreach (Point pt in AllControl.PointSet)
990
                                {
991
                                    newPointSet.Add(pt);
992
                                }
993
                                var ReverseP = (i + newPointSet.Count() / 2) % newPointSet.Count();
994
                                var PreviousP = (i + (newPointSet.Count() - 1)) % newPointSet.Count();
995
                                var NextP = (i + 1) % newPointSet.Count();
996
                                var distance = MathSet.DistanceTo(newPointSet[ReverseP], newPointSet[i]);
997
                                var PreviousV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[PreviousP]);
998
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, newPointSet[i].X - newPointSet[ReverseP].X,
999
                                    newPointSet[i].Y - newPointSet[ReverseP].Y);
1000
                                newPointSet[PreviousP] = new Point(newPointSet[ReverseP].X + PreviousV.X * l, newPointSet[ReverseP].Y
1001
                                    + PreviousV.Y * l);
1002

    
1003
                                var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]);
1004
                                l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y
1005
                                    - newPointSet[ReverseP].Y);
1006
                                newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l);
1007

    
1008
                                AllControl.PointSet = newPointSet;
1009
                                DynamicThumbUpdate(control);
1010
                                AllControl.updateControl();
1011
                                BorderUpdate();
1012
                            }
1013
                            break;
1014
                        #endregion
1015
                        #region ArrowText
1016
                        case ControlType.ArrowTextControl:
1017
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1018
                            {
1019

    
1020
                                List<Point> GetPointSet = (control.DrawingData as ArrowTextControl).PointSet;
1021

    
1022
                                if ((GetPointSet[0].X > GetPointSet[1].X && e.HorizontalChange > 0) || (GetPointSet[0].X < GetPointSet[1].X && e.HorizontalChange < 0))
1023
                                {
1024
                                    GetPointSet[1] = new Point(GetPointSet[1].X + e.HorizontalChange, GetPointSet[1].Y);
1025
                                }
1026
                                if ((GetPointSet[0].Y > GetPointSet[1].Y && e.VerticalChange > 0) || (GetPointSet[0].Y < GetPointSet[1].Y && e.VerticalChange < 0))
1027
                                {
1028
                                    GetPointSet[1] = new Point(GetPointSet[1].X, GetPointSet[1].Y + e.VerticalChange);
1029
                                }
1030
                                (control.DrawingData as ArrowTextControl).PointSet[1] = GetPointSet[1];
1031

    
1032

    
1033
                                //System.Diagnostics.Debug.WriteLine("MidPoint : " + (control.DrawingData as ArrowTextControl).MidPoint);
1034
                                //System.Diagnostics.Debug.WriteLine("HorizontalChange : " + e.HorizontalChange);
1035
                                //System.Diagnostics.Debug.WriteLine("VerticalChange : " + e.VerticalChange);
1036

    
1037
                                AllControl.PointSet[i] = setPoint;
1038
                                //System.Diagnostics.Debug.WriteLine("PointSet : " + AllControl.PointSet[i]);
1039

    
1040
                                AllControl.updateControl();
1041

    
1042
                                DynamicThumbUpdate(control);
1043
                                BorderUpdate();
1044
                                                                
1045
                            }
1046
                            break;
1047
                        #endregion
1048
                        #region Text
1049
                        case ControlType.TextControl:
1050
                            break;
1051
                        #endregion
1052
                        #region Image
1053
                        case ControlType.ImgControl:
1054
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1055
                            {
1056
                                AllControl.PointSet[i] = setPoint;
1057
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1058
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1059
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1060

    
1061
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1062

    
1063
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1064
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1065
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1066
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1067
                                    [ReverseP].Y
1068
                                    + PreviousV.Y * l);
1069

    
1070
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1071
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1072
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1073
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1074
                                    NextV.Y * l);
1075
                                AllControl.updateControl();
1076
                                DynamicThumbUpdate(control);
1077
                                BorderUpdate();
1078
                            }
1079
                            break;
1080
                        #endregion
1081
                        #region Sign
1082
                        case ControlType.Sign:
1083
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1084
                            {
1085
                                AllControl.PointSet[i] = setPoint;
1086
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1087
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1088
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1089

    
1090
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1091

    
1092
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1093
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1094
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1095
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1096
                                    [ReverseP].Y
1097
                                    + PreviousV.Y * l);
1098

    
1099
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1100
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1101
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1102
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1103
                                    NextV.Y * l);
1104
                                AllControl.updateControl();
1105
                                DynamicThumbUpdate(control);
1106
                                BorderUpdate();
1107
                            }
1108
                            break;
1109
                        #endregion
1110
                        #region Cloud
1111
                        case ControlType.PolygonCloud:
1112
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1113
                            {
1114
                                AllControl.PointSet[i] = setPoint;
1115
                                AllControl.updateControl();
1116
                                ((ICloudControl)AllControl).DrawingCloud();
1117
                                BorderUpdate();
1118
                            }
1119
                            break;
1120
                        #endregion
1121
                        #region SymBol
1122
                        case ControlType.Symbol:
1123
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1124
                            {
1125
                                AllControl.PointSet[i] = setPoint;
1126
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1127
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1128
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1129

    
1130
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1131

    
1132
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1133
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1134
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1135
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1136
                                    [ReverseP].Y
1137
                                    + PreviousV.Y * l);
1138

    
1139
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1140
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1141
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1142
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1143
                                    NextV.Y * l);
1144
                                AllControl.updateControl();
1145
                                DynamicThumbUpdate(control);
1146
                                BorderUpdate();
1147
                            }
1148
                            break;
1149
                        case ControlType.Stamp:
1150
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1151
                            {
1152
                                AllControl.PointSet[i] = setPoint;
1153
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1154
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1155
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1156

    
1157
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1158

    
1159
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1160
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1161
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1162
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1163
                                    [ReverseP].Y
1164
                                    + PreviousV.Y * l);
1165

    
1166
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1167
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1168
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1169
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1170
                                    NextV.Y * l);
1171
                                AllControl.updateControl();
1172
                                DynamicThumbUpdate(control);
1173
                                BorderUpdate();
1174
                            }
1175
                            break;
1176
                        case ControlType.Date:
1177
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1178
                            {
1179
                                AllControl.PointSet[i] = setPoint;
1180
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1181
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1182
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1183

    
1184
                                var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1185

    
1186
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1187
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1188
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1189
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1190
                                    [ReverseP].Y
1191
                                    + PreviousV.Y * l);
1192

    
1193
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1194
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1195
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1196
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1197
                                    NextV.Y * l);
1198
                                AllControl.updateControl();
1199
                                DynamicThumbUpdate(control);
1200
                                BorderUpdate();
1201
                            }
1202
                            break;
1203
                        #endregion
1204
                        #region Ink
1205
                        case ControlType.Ink:
1206
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1207
                            {
1208
                                AllControl.PointSet[i] = setPoint;
1209
                                AllControl.updateControl();
1210
                                BorderUpdate();
1211
                            }
1212
                            break;
1213
                        #endregion
1214
                        default:
1215
                            break;
1216
                    }
1217
                }
1218
            }
1219
            //}
1220
        }
1221

    
1222

    
1223

    
1224
        #endregion
1225
        #region 이벤트
1226

    
1227
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1228
        {
1229
            this.isDragging = false;
1230
            DraggerThumb = null;
1231

    
1232
            var comments = (from drawing in this.Members
1233
                            select drawing.DrawingData as CommentUserInfo).ToList();
1234
            UndoCommand.Instance.Push(comments, this.AngleValue);
1235
        }
1236

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

    
1247
            if (ViewerDataModel.Instance.UndoDataList == null)
1248
            {
1249
                return;
1250
            }
1251

    
1252
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1253
            {
1254
                return;
1255
            }
1256

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

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

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

    
1297
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1298
        {
1299
            DragThumb.Cursor = Cursors.SizeAll;
1300
            Thumb thumb = sender as Thumb;
1301
            MoveAdorner(e);
1302
        }
1303

    
1304
        public void MoveAdorner(DragDeltaEventArgs e)
1305
        {
1306
            Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);
1307

    
1308
            Dispatcher.BeginInvoke((Action)(() =>
1309
            {
1310
                foreach (var item in this.Members)
1311
                {
1312
                    #region 라인  & 아크
1313
                    if (item.Drawingtype == ControlType.SingleLine || item.Drawingtype == ControlType.ArcLine || item.Drawingtype == ControlType.ArrowMultiLine || item.Drawingtype == ControlType.ArcArrow)
1314
                    {
1315
                        DynamicThumbUpdate(e, item);
1316
                    }
1317
                    #endregion
1318
                    #region 지시선화살표
1319
                    if (item.Drawingtype == ControlType.ArrowTextControl)
1320
                    {
1321
                        DynamicThumbUpdate(e, item);
1322
                    }
1323
                    #endregion
1324

    
1325
                    #region 써클
1326
                    if (item.Drawingtype == ControlType.Circle || item.Drawingtype == ControlType.Sign || item.Drawingtype == ControlType.Symbol || item.Drawingtype == ControlType.Stamp)
1327
                    {
1328
                        DynamicThumbUpdate(e, item);
1329
                    }
1330
                    #endregion
1331
                    #region 쉐이프
1332
                    if (item.Drawingtype == ControlType.Rectangle || item.Drawingtype == ControlType.ImgControl || item.Drawingtype == ControlType.RectCloud || item.Drawingtype == ControlType.Triangle)
1333
                    {
1334
                        DynamicThumbUpdate(e, item);
1335
                    }
1336
                    #endregion
1337
                    #region 텍스트
1338
                    if (item.Drawingtype == ControlType.TextControl)
1339
                    {
1340
                        (item.DrawingData as TextControl).Move(e.HorizontalChange, e.VerticalChange);
1341
                    }
1342
                    #endregion
1343
                    #region 날짜
1344
                    if (item.Drawingtype == ControlType.Date)
1345
                    {
1346
                        DynamicThumbUpdate(e, item);
1347
                    }
1348
                    #endregion
1349
                    #region 클라우드
1350
                    if (item.Drawingtype == ControlType.PolygonCloud)
1351
                    {
1352
                        ICloudControl temp = ((ICloudControl)item.DrawingData);
1353
                        DynamicThumbUpdate(e, item);
1354
                        temp.DrawingCloud();
1355
                    }
1356
                    #endregion
1357
                    #region 심볼
1358

    
1359
                    #endregion
1360

    
1361
                    #region 폴리곤
1362
                    if (item.Drawingtype == ControlType.PolygonControl)
1363
                    {
1364
                        DynamicThumbUpdate(e, item);
1365
                        BorderUpdate();
1366
                    }
1367
                    #endregion
1368
                    #region 잉크
1369
                    if (item.Drawingtype == ControlType.Ink)
1370
                    {
1371
                        Point px = new Point(e.HorizontalChange, e.VerticalChange);
1372
                        List<StylusPointSet> StylusPointSet = (item.DrawingData as InkControl).PointC;
1373
                        for (int i = 0; i < StylusPointSet.Count; i++)
1374
                        {
1375
                            List<Point> lstPoint = StylusPointSet[i].pointSet;
1376
                            for (int j = 0; j < lstPoint.Count; j++)
1377
                            {
1378
                                lstPoint[j] = new Point(lstPoint[j].X + px.X, lstPoint[j].Y + px.Y);
1379
                            }
1380
                        }
1381

    
1382
                        for (int i = 0; i < item.ThumbList.Count; i++)
1383
                        {
1384
                            Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + px.X);
1385
                            Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + px.Y);
1386
                        }
1387
                        (item.DrawingData as IPath).updateControl();
1388
                        BorderUpdate();
1389

    
1390
                    }
1391
                    #endregion
1392
                    BorderUpdate();
1393
                }
1394
            }));
1395
        }
1396

    
1397
        public void DynamicThumbUpdate(DragDeltaEventArgs e, AdornerMember item)
1398
        {
1399
            var AllControl = item.DrawingData as IPath;
1400
            List<Point> point = AllControl.PointSet;
1401
            for (int i = 0; i < item.ThumbList.Count(); i++)
1402
            {
1403
                if (item.DrawingData.GetType().Name == "ArrowTextControl")
1404
                {
1405
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1406
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1407
                    AllControl.updateControl();
1408
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1409
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1410

    
1411
                    Canvas.SetLeft(item.ThumbList.Last(), Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1412
                    Canvas.SetTop(item.ThumbList.Last(), Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1413
                }
1414
                else
1415
                {
1416
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1417
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1418
                    AllControl.updateControl();
1419
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1420
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1421
                }
1422
            }
1423
        }
1424

    
1425
        public void DynamicThumbUpdate(AdornerMember item)
1426
        {
1427
            var AllControl = item.DrawingData as IPath;
1428
            List<Point> point = AllControl.PointSet;
1429

    
1430
            for (int i = 0; i < AllControl.PointSet.Count(); i++)
1431
            {
1432

    
1433
                Canvas.SetLeft(item.ThumbList[i], AllControl.PointSet[i].X);
1434
                Canvas.SetTop(item.ThumbList[i], AllControl.PointSet[i].Y);
1435
            }
1436

    
1437

    
1438
            if (item.DrawingData as ArrowTextControl != null)
1439
            {
1440
                if (!(item.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
1441
                {
1442
                    List<Point> ps = new List<Point>();
1443

    
1444
                    var temp = item.DrawingData as ArrowTextControl;
1445
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1446
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1447
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1448
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1449

    
1450

    
1451

    
1452
                    if (temp.isFixed)
1453
                    {
1454
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1455
                        var testP = endP;
1456
                        if (ps[0] == endP) //상단
1457
                        {
1458
                            testP = new Point(endP.X, endP.Y - 50);
1459
                            //System.Diagnostics.Debug.WriteLine("상단");
1460
                        }
1461
                        else if (ps[1] == endP) //하단
1462
                        {
1463
                            testP = new Point(endP.X, endP.Y + 50);
1464
                            //System.Diagnostics.Debug.WriteLine("하단");
1465
                        }
1466
                        else if (ps[2] == endP) //좌단
1467
                        {
1468
                            testP = new Point(endP.X - 50, endP.Y);
1469
                            //System.Diagnostics.Debug.WriteLine("좌단");
1470
                        }
1471
                        else if (ps[3] == endP) //우단
1472
                        {
1473
                            testP = new Point(endP.X + 50, endP.Y);
1474
                            //System.Diagnostics.Debug.WriteLine("우단");
1475
                        }
1476
                        Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], testP.X);
1477
                        Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], testP.Y);
1478
                    }
1479
                    else
1480
                    {
1481
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1482
                        var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1483
                        Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1484
                        Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1485
                    }
1486
                }
1487
            }
1488
            //}
1489
        }
1490

    
1491
        public void Set_Rotate()
1492
        {
1493

    
1494
            double dDeltaAngle = 0;
1495
            List<Point> AllPointSet = new List<Point>();
1496
            Point CenterPoint = new Point();
1497

    
1498

    
1499
            if (AngleValue >= 360)
1500
            {
1501
                AngleValue -= 360;
1502
            }
1503
            else if (AngleValue <= -360)
1504
            {
1505
                AngleValue += 360;
1506
            }
1507

    
1508
            #region 센터 포인트 구하기 (그룹핑)
1509
            foreach (var item in this.Members)
1510
            {
1511
                if (item.DrawingData.GetType().Name == "TextControl")
1512
                {
1513
                }
1514
                else
1515
                {
1516
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1517
                    {
1518
                        AllPointSet.Add(itemP);
1519
                    }
1520
                }
1521
            }
1522
            #endregion
1523

    
1524
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1525

    
1526
            Dispatcher.BeginInvoke((Action)(() =>
1527
            {
1528
                foreach (var item in this.Members)
1529
                {
1530
                    foreach (var thumb in item.ThumbList)
1531
                    {
1532
                        double x = Canvas.GetLeft(thumb);
1533
                        double y = Canvas.GetTop(thumb);
1534

    
1535
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1536
                        Canvas.SetLeft(thumb, value.X);
1537
                        Canvas.SetTop(thumb, value.Y);
1538

    
1539
                        if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last())
1540
                        {
1541

    
1542
                            Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1543
                            Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1544
                            if (!(item.DrawingData as ArrowTextControl).isTrans)
1545
                            {
1546
                                List<Point> ps = new List<Point>();
1547
                                var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1548
                                switch (Math.Abs(temp.Angle).ToString())
1549
                                {
1550
                                    case "90":
1551
                                        {
1552
                                            ps.Clear();
1553
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1554
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
1555
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
1556

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

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

    
1563
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
1564
                                        }
1565
                                        break;
1566
                                    case "270":
1567
                                        {
1568
                                            ps.Clear();
1569
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1570
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
1571
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
1572

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

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

    
1579
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
1580
                                        }
1581
                                        break;
1582
                                    default:
1583
                                        {
1584
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1585
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1586
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1587
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1588
                                        }
1589
                                        break;
1590
                                }
1591

    
1592
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1593
                                var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1594
                                Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1595
                                Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1596
                            }
1597
                        }
1598
                    }
1599

    
1600
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1601
                    {
1602
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1603
                    }
1604
                }
1605
                #region 컨트롤 업데이트
1606
                foreach (var item in this.Members)
1607
                {
1608
                    switch (item.Drawingtype)
1609
                    {
1610
                        case ControlType.TextControl:
1611
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1612

    
1613
                            RectangleGeometry Data = new RectangleGeometry
1614
                            {
1615
                                Rect = new Rect()
1616
                                {
1617
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1618
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1619
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1620
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1621
                                }
1622
                            };
1623

    
1624
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1625
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);                                                      
1626

    
1627
                            DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
1628
                            DragThumb.RenderTransform = new RotateTransform()
1629
                            {
1630
                                Angle = (item.DrawingData as TextControl).Angle,
1631

    
1632
                            };
1633

    
1634
                            AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
1635
                            AdornerBorder.RenderTransform = new RotateTransform()
1636
                            {
1637
                                Angle = (item.DrawingData as TextControl).Angle,
1638

    
1639
                            };
1640

    
1641
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1642
                            {
1643
                                Angle = (item.DrawingData as TextControl).Angle,
1644
                            };
1645
                            BorderUpdate();
1646
                            break;
1647

    
1648
                        case ControlType.Date:
1649
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1650
                            (item.DrawingData as IPath).updateControl();
1651
                            BorderUpdate();
1652
                            break;
1653
                        case ControlType.ArrowMultiLine:
1654
                        case ControlType.ArcLine:
1655
                        case ControlType.ArcArrow:
1656
                        case ControlType.SingleLine:
1657
                        case ControlType.Triangle:
1658
                            (item.DrawingData as IPath).updateControl();
1659
                            BorderUpdate();
1660
                            break;
1661
                        case ControlType.ArrowTextControl:
1662
                            (item.DrawingData as IPath).updateControl();
1663
                            BorderUpdate();
1664
                            break;
1665
                        case ControlType.RectCloud:
1666
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1667
                            (item.DrawingData as IPath).updateControl();
1668
                            BorderUpdate();
1669
                            break;
1670
                        case ControlType.Rectangle:
1671
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1672
                            (item.DrawingData as IPath).updateControl();
1673
                            BorderUpdate();
1674
                            break;
1675
                        case ControlType.ImgControl:
1676
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1677
                            (item.DrawingData as IPath).updateControl();
1678
                            BorderUpdate();
1679
                            break;
1680
                        case ControlType.Sign:
1681
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1682
                            (item.DrawingData as IPath).updateControl();
1683
                            BorderUpdate();
1684
                            break;
1685
                        case ControlType.Symbol:
1686
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1687
                            (item.DrawingData as IPath).updateControl();
1688
                            BorderUpdate();
1689
                            break;
1690
                        case ControlType.Stamp:
1691
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1692
                            (item.DrawingData as IPath).updateControl();
1693
                            BorderUpdate();
1694
                            break;
1695
                        case ControlType.PolygonControl:
1696
                            (item.DrawingData as IPath).updateControl();
1697
                            BorderUpdate();
1698
                            break;
1699
                        case ControlType.PolygonCloud:
1700
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1701
                            (item.DrawingData as IPath).updateControl();
1702
                            BorderUpdate();
1703
                            break;
1704
                        case ControlType.Circle:
1705
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1706
                            (item.DrawingData as IPath).updateControl();
1707
                            ((CircleControl)item.DrawingData).SetCenterXY();
1708
                            BorderUpdate();
1709
                            break;
1710
                        case ControlType.Ink:
1711
                            (item.DrawingData as IPath).updateControl();
1712
                            BorderUpdate();
1713
                            break;
1714
                        case ControlType.InsideWhite:
1715
                            ((InsideWhiteControl)item.DrawingData).Angle = AngleValue;
1716
                            (item.DrawingData as IPath).updateControl();
1717
                            BorderUpdate();
1718
                            break;
1719
                        case ControlType.OverlapWhite:
1720
                            ((OverlapWhiteControl)item.DrawingData).Angle = AngleValue;
1721
                            (item.DrawingData as IPath).updateControl();
1722
                            BorderUpdate();
1723
                            break;
1724
                        case ControlType.ClipWhite:
1725
                            ((ClipWhiteControl)item.DrawingData).Angle = AngleValue;
1726
                            (item.DrawingData as IPath).updateControl();
1727
                            BorderUpdate();
1728
                            break;
1729
                        case ControlType.Coordinate:
1730
                            ((CoordinateControl)item.DrawingData).Angle = AngleValue;
1731
                            (item.DrawingData as IPath).updateControl();
1732
                            BorderUpdate();
1733
                            break;
1734
                        default:
1735
                            break;
1736
                    }
1737
                }
1738
                #endregion
1739
            }));
1740
        }
1741

    
1742
        private void resize_MouseMove(object sender, MouseEventArgs e)
1743
        {
1744
            reSizePoint = e.GetPosition(this);
1745
        }
1746
        /// <summary>
1747
        /// 회전
1748
        /// </summary>
1749
        /// <param name="sender"></param>
1750
        /// <param name="e"></param>
1751
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1752
        {
1753

    
1754
            MoveRotate(e);
1755
        }
1756

    
1757
        double LastRotateHorizontalValue = 0;
1758
        double LastRotateVerticalValue = 0;
1759
        //double LastWidthValue = 0;
1760
        //double SetWidth = 0;
1761
        bool RotateFlag = false;
1762

    
1763
        /// <summary>
1764
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1765
        /// </summary>
1766
        /// <param name="e"></param>
1767
        public void MoveRotate(DragDeltaEventArgs e)
1768
        {
1769
            double dDeltaAngle = 0;
1770

    
1771
            List<Point> AllPointSet = new List<Point>();
1772
            Point CenterPoint = new Point();
1773
            
1774
            #region 센터 포인트 구하기 (그룹핑)
1775
            foreach (var item in this.Members)
1776
            {
1777
                if (item.DrawingData.GetType().Name == "TextControl")
1778
                {                    
1779
                    if (AngleValue == 0)
1780
                    {
1781
                        AngleValue = (item.DrawingData as TextControl).Angle;
1782
                    }
1783
                    double X = Canvas.GetLeft((item.DrawingData as TextControl));
1784
                    double Y = Canvas.GetTop((item.DrawingData as TextControl));
1785
                    AllPointSet.Add(new Point(X, Y));
1786
                }
1787
                else
1788
                {
1789
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1790
                    {
1791
                        AllPointSet.Add(itemP);
1792
                    }
1793
                }
1794
            }
1795
            #endregion
1796
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1797
            Point pt = Mouse.GetPosition(this);
1798

    
1799
            Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
1800
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1801
            dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1802

    
1803
            //System.Diagnostics.Debug.WriteLine("vec1 : " + vec1.X + "/" + vec1.Y);
1804
            //System.Diagnostics.Debug.WriteLine("vec2 : " + vec2.X + "/" + vec2.Y);
1805
            //System.Diagnostics.Debug.WriteLine("dDeltaAngle : " + dDeltaAngle);
1806

    
1807
            AngleValue += dDeltaAngle;
1808
            if (AngleValue > 360) AngleValue -= 360;
1809
            if (AngleValue < 0) AngleValue += 360;
1810
            this.rotatePoint = pt;  /// save rotatePoint
1811

    
1812
            Dispatcher.BeginInvoke((Action)(() =>
1813
            {
1814
                foreach (var item in this.Members)
1815
                {
1816
                    foreach (var thumb in item.ThumbList)
1817
                    {
1818
                        double x = Canvas.GetLeft(thumb);
1819
                        double y = Canvas.GetTop(thumb);
1820

    
1821
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1822
                        Canvas.SetLeft(thumb, value.X);
1823
                        Canvas.SetTop(thumb, value.Y);
1824
                    }
1825

    
1826
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1827
                    {
1828
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1829
                    }
1830
                }
1831
                #region 보더 업데이트
1832
                foreach (var item in this.Members)
1833
                {
1834
                    switch (item.Drawingtype)
1835
                    {
1836
                        case ControlType.TextControl:
1837
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1838

    
1839
                            RectangleGeometry Data = new RectangleGeometry
1840
                            {
1841
                                Rect = new Rect()
1842
                                {
1843
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1844
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1845
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1846
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1847
                                }
1848
                            };
1849

    
1850
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1851
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);
1852

    
1853
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1854
                            DragThumb.RenderTransform = new RotateTransform()
1855
                            {
1856
                                Angle = (item.DrawingData as TextControl).Angle,
1857
                                //CenterX = middle.X,
1858
                                //CenterY = middle.Y,
1859
                            };
1860

    
1861
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1862
                            AdornerBorder.RenderTransform = new RotateTransform()
1863
                            {
1864
                                Angle = (item.DrawingData as TextControl).Angle,
1865
                                //CenterX = middle.X,
1866
                                //CenterY = middle.Y,
1867
                            };
1868

    
1869
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1870
                            {
1871
                                Angle = (item.DrawingData as TextControl).Angle,
1872
                            };
1873

    
1874
                            BorderUpdate();
1875
                            break;
1876

    
1877
                        case ControlType.Date:
1878
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1879
                            (item.DrawingData as IPath).updateControl();
1880
                            BorderUpdate();                          
1881
                            break;
1882
                        case ControlType.ArrowMultiLine:
1883
                        case ControlType.ArcLine:
1884
                        case ControlType.ArcArrow:
1885
                        case ControlType.SingleLine:
1886
                        case ControlType.Triangle:
1887
                            (item.DrawingData as IPath).updateControl();
1888
                            BorderUpdate();
1889
                            break;
1890
                        case ControlType.ArrowTextControl:
1891
                            (item.DrawingData as IPath).updateControl();
1892
                            BorderUpdate();
1893
                            break;
1894
                        case ControlType.RectCloud:
1895
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1896
                            (item.DrawingData as IPath).updateControl();
1897
                            BorderUpdate();
1898
                            break;
1899
                        case ControlType.Rectangle:
1900
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1901
                            (item.DrawingData as IPath).updateControl();
1902
                            BorderUpdate();
1903
                            break;
1904
                        case ControlType.ImgControl:
1905
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1906
                            (item.DrawingData as IPath).updateControl();
1907
                            BorderUpdate();
1908
                            break;                        
1909
                        case ControlType.Sign:
1910
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1911
                            (item.DrawingData as IPath).updateControl();
1912
                            BorderUpdate();
1913
                            break;                        
1914
                        case ControlType.Symbol:
1915
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1916
                            (item.DrawingData as IPath).updateControl();
1917
                            BorderUpdate();
1918
                            break;
1919
                        case ControlType.Stamp:
1920
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1921
                            (item.DrawingData as IPath).updateControl();
1922
                            BorderUpdate();
1923
                            break;
1924
                        case ControlType.PolygonControl:
1925
                            (item.DrawingData as IPath).updateControl();
1926
                            BorderUpdate();
1927
                            break;
1928
                        case ControlType.PolygonCloud:
1929
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1930
                            (item.DrawingData as IPath).updateControl();
1931
                            BorderUpdate();
1932
                            break;
1933
                        case ControlType.Circle:
1934
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1935
                            (item.DrawingData as IPath).updateControl();
1936
                            ((CircleControl)item.DrawingData).SetCenterXY();
1937
                            BorderUpdate();
1938
                            break;
1939
                        case ControlType.Ink:
1940
                            for (int i = 0; i < (item.DrawingData as InkControl).PointC.Count(); i++)
1941
                            {
1942
                                for (int j = 0; j < (item.DrawingData as InkControl).PointC[i].pointSet.Count; j++)
1943
                                {
1944
                                    (item.DrawingData as InkControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as InkControl).PointC[i].pointSet[j], dDeltaAngle);
1945
                                }
1946
                            }
1947
                            (item.DrawingData as IPath).updateControl();
1948
                            BorderUpdate();
1949
                            break;
1950
                        
1951
                        default:
1952
                            break;
1953
                    }
1954
                }
1955
                #endregion
1956
            }));
1957
            BorderUpdate();
1958
        }
1959

    
1960
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1961
        {            
1962

    
1963
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1964
            rotateTop.Cursor = Cursors.SizeAll;
1965

    
1966
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1967
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1968
            {
1969
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).Angle;
1970
            }
1971
            /// up to here
1972

    
1973

    
1974

    
1975
            if (ViewerDataModel.Instance.UndoDataList == null)
1976
            {
1977
                return;
1978
            }
1979

    
1980
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1981
            {
1982
                return;
1983
            }
1984

    
1985
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1986
            {
1987
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1988
                {
1989
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1990
                    {
1991
                        return;
1992
                    }
1993
                }
1994
            }
1995

    
1996
            var comments = (from drawing in this.Members
1997
                            select drawing.DrawingData as CommentUserInfo).ToList();
1998
            UndoCommand.Instance.Push(comments, this.AngleValue);
1999
        }
2000
        
2001
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
2002
        {
2003
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2004

    
2005
            var comments = (from drawing in this.Members
2006
                            select drawing.DrawingData as CommentUserInfo).ToList();
2007
            UndoCommand.Instance.Push(comments, this.AngleValue);
2008
        }
2009

    
2010
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
2011
        {
2012
            if (ViewerDataModel.Instance.UndoDataList == null)
2013
            {
2014
                return;
2015
            }
2016
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
2017
            {
2018
                return;
2019
            }
2020
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
2021
            {
2022
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
2023
                {
2024
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
2025
                    {
2026
                        return;
2027
                    }
2028
                }
2029
            }
2030

    
2031
            var comments = (from drawing in this.Members
2032
                            select drawing.DrawingData as CommentUserInfo).ToList();
2033
            UndoCommand.Instance.Push(comments, this.AngleValue);
2034
        }
2035

    
2036
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
2037
        {          
2038
            DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2039

    
2040
            var comments = (from drawing in this.Members
2041
                            select drawing.DrawingData as CommentUserInfo).ToList();
2042
            UndoCommand.Instance.Push(comments, this.AngleValue);
2043
        }
2044

    
2045
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
2046
        {
2047
            AdornerMember control = this.Members.FirstOrDefault();
2048

    
2049
            if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null)
2050
            {
2051
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
2052
                {
2053
                    (control.DrawingData as ArrowTextControl).isTrans = true;
2054
                }
2055
            }
2056

    
2057
        }
2058

    
2059
        public void TextControlChanger()
2060
        {
2061
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2062
            {
2063
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
2064
                AllControl.Base_TextBox.Focus();
2065
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
2066
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
2067
                AllControl.Base_TextBox.Focus();
2068
                AllControl.SizeChanged += (sen, ea) =>
2069
                {
2070
                    if (AllControl.Base_TextBox != null)
2071
                    {
2072
                        RectangleGeometry Data = new RectangleGeometry
2073
                        {
2074
                            Rect = new Rect()
2075
                            {
2076
                                X = AllControl.StartPoint.X,
2077
                                Y = AllControl.StartPoint.Y,
2078
                                Width = AllControl.Base_TextBox.Width,
2079
                                Height = AllControl.Base_TextBox.Height,
2080
                            }
2081
                        };
2082

    
2083
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
2084
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
2085
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
2086
                        {
2087
                            Angle = AllControl.Angle,
2088
                            CenterX = middle.X,
2089
                            CenterY = middle.Y,
2090
                        };
2091
                    }
2092
                    BorderUpdate();
2093
                };
2094
            }
2095
        }
2096

    
2097
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
2098
        {
2099
            if (e.ClickCount == 2 && this.Members.Count == 1)
2100
            {
2101

    
2102
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2103
                {
2104
                    TextControlChanger();                    
2105
                }
2106

    
2107
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2108
                {
2109
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
2110
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
2111
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
2112

    
2113
                    //ArrowControl TextBox Thumb없애기
2114
                    tm.Visibility = Visibility.Collapsed;
2115

    
2116
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
2117
                    
2118
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
2119

    
2120
                    {
2121
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
2122
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
2123

    
2124
                        List<Point> ps = new List<Point>();
2125
                        
2126
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
2127
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
2128
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
2129
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
2130

    
2131

    
2132

    
2133

    
2134
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
2135
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
2136
                        if (AllControl.isTrans)
2137
                        {
2138
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
2139
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
2140
                        }
2141
                        else
2142
                        {
2143
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
2144
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
2145
                        }
2146

    
2147

    
2148
                        BorderUpdate();
2149

    
2150
                    };
2151
                }
2152
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
2153
                {
2154
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
2155
                    CalendarControl instanceCal = new CalendarControl(data.Text);
2156
                    //dropData.IsOpen = true;
2157
                    RadWindow rc = new RadWindow();
2158
                    rc.Width = 300;
2159
                    rc.Height = 300;
2160
                    rc.Header = "Change Date";
2161
                    rc.Content = instanceCal;
2162
                    rc.BorderThickness = new Thickness(3);
2163
                    rc.ResizeMode = ResizeMode.NoResize;
2164
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2165
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
2166
                    rc.ModalBackground.Opacity = 0.6;
2167
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
2168
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
2169
                    {
2170
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
2171
                        rc.Close();
2172
                    };
2173
                    rc.ShowDialog();
2174
                    //CalendarControl.xaml
2175
                }
2176
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
2177
                {
2178
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
2179
                    if (instance.isTransOn)
2180
                    {
2181
                        instance.isTransOn = false;
2182
                    }
2183
                    else
2184
                    {
2185
                        instance.isTransOn = true;
2186
                    }
2187
                    ///instance.SetArcPath();
2188
                    BorderUpdate();
2189
                }
2190
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
2191
                {
2192
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
2193
                    if (instance.isTransOn)
2194
                    {
2195
                        instance.isTransOn = false;
2196
                    }
2197
                    else
2198
                    {
2199
                        instance.isTransOn = true;
2200
                    }
2201
                    instance.SetArcPath();
2202
                    BorderUpdate();
2203
                }
2204

    
2205
            }
2206
            
2207
        }
2208
        #endregion
2209

    
2210
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2211
        {
2212
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2213
            {
2214
                DragThumb.Visibility = Visibility.Collapsed;
2215
            }
2216
        }
2217

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