프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (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
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
131
                this.ContainerContent.Children.Add(objectData);
132
            }
133
            catch (Exception ex)
134
            {
135

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

    
142
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
143
        {
144
            InitializeComponent();
145
            foreach (var item in objectData)
146
            {
147
                //item.IsHitTestVisible = false;
148
                if ((item as ArrowTextControl) != null)
149
                {
150
                    (item as ArrowTextControl).Base_TextBox.Focusable = true;
151
                }
152
                try
153
                {
154
                    Canvas.SetZIndex(item, 80);
155
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
156
                    this.ContainerContent.Children.Add(item);
157
                }
158
                catch //(Exception ex)
159
                {
160
                }
161
                finally
162
                {
163
                    
164
                }
165
            }
166
            this.SetAdornerMember(objectData);
167
            this.Focus();
168
        }
169

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

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

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

    
300

    
301
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
302
                    DragThumb.RenderTransform = new RotateTransform()
303
                    {
304
                        Angle = (member as TextControl).Angle,
305
                        //CenterX = middle.X,
306
                        //CenterY = middle.Y,
307
                    };
308

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

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

    
360
            }
361
            else
362
            {
363
                RegistryPoint(member);
364
            }
365
            BorderUpdate();
366

    
367
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
368
        }
369

    
370
        private void ViewBoxRotate(UIElement member)
371
        {
372
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
373
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
374
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
375
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
376
        }
377

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

    
452
                            }
453

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

    
487
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))  Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
488
            }
489

    
490
            BorderUpdate();
491
        }
492

    
493
        /// <summary>
494
        /// Border 를 갱신
495
        /// </summary>
496
        public void BorderUpdate()
497
        {
498
            AdornerBorder.MinWidth = 10;
499
            AdornerBorder.MinHeight = 10;
500

    
501
            double minX = double.MaxValue;
502
            double minY = double.MaxValue;
503
            double maxX = double.MinValue;
504
            double maxY = double.MinValue;
505

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

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

    
636
            DragThumb.Width = ac.Width;
637
            DragThumb.Height = ac.Height;
638

    
639
            DragThumb.MinWidth = 10;
640
            DragThumb.MinHeight = 10;
641
            if (addWidthSize)
642
            {
643
                Canvas.SetLeft(DragThumb, minX - 5);
644
            }
645
            else
646
            {
647
                Canvas.SetLeft(DragThumb, minX);
648
            }
649

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

    
704
                this.Members.Last().ThumbList.Add(tm);
705

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

    
717
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
718
                    {
719
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
720

    
721

    
722
                        switch (Math.Abs(temp.Angle).ToString())
723
                        {
724
                            case "90":
725
                                {
726
                                    ps.Clear();
727
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
728
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
729
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), 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))); //왼쪽 중간
732
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단
733

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

    
737
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
738
                                }
739
                                break;
740
                            case "270":
741
                                {
742
                                    ps.Clear();
743
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
744
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
745
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), 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))); //왼쪽 중간
748
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단
749

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

    
753
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
754
                                }
755
                                break;
756
                            default:
757
                                {
758
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
759
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
760
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
761
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
762
                                }
763
                                break;
764
                        }
765

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

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

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

    
871
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
872
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
873
                tm.DragDelta += ResizeTm_DragDelta;
874
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
875
                count++;
876
            }
877
        }
878

    
879
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
880
        {
881
            if (this.Members.Count > 1)
882
                return;
883
            if (reSizePoint != new Point(0, 0))
884
            {
885
                Thumb thumb = sender as Thumb;
886

    
887
                if (AngleValue == -90)
888
                {
889
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.VerticalChange);
890
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.HorizontalChange));
891
                }
892
                else if (AngleValue == -180)
893
                {
894
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.HorizontalChange));
895
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.VerticalChange));
896
                }
897
                else if (AngleValue == -270)
898
                {
899
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.VerticalChange));
900
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.HorizontalChange);
901
                }
902
                else //(AngleValue == 0)
903
                {
904
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.HorizontalChange);
905
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.VerticalChange);
906
                }
907

    
908

    
909
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
910
                
911
                AdornerMember control = (from userThumb in this.Members
912
                                         where userThumb.ThumbList.Contains(thumb)
913
                                         select userThumb).FirstOrDefault();
914
                Point nearPoint = new Point(0, 0);
915
                IPath AllControl = control.DrawingData as IPath;
916
                if (ControlType.TextControl != control.Drawingtype)
917
                {
918

    
919
                    var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
920
                    List<Point> ps = new List<Point>();
921

    
922
                    nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
923
                    
924

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

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

    
958
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
959
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
960
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
961
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
962
                                    [ReverseP].Y
963
                                    + PreviousV.Y * l);
964

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

    
1009
                                var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]);
1010
                                l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y
1011
                                    - newPointSet[ReverseP].Y);
1012
                                newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l);
1013

    
1014
                                AllControl.PointSet = newPointSet;
1015
                                DynamicThumbUpdate(control);
1016
                                AllControl.updateControl();
1017
                                BorderUpdate();
1018
                            }
1019
                            break;
1020
                        #endregion
1021
                        #region ArrowText
1022
                        case ControlType.ArrowTextControl:
1023
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1024
                            {
1025

    
1026
                                List<Point> GetPointSet = (control.DrawingData as ArrowTextControl).PointSet;
1027

    
1028
                                if ((GetPointSet[0].X > GetPointSet[1].X && e.HorizontalChange > 0) || (GetPointSet[0].X < GetPointSet[1].X && e.HorizontalChange < 0))
1029
                                {
1030
                                    GetPointSet[1] = new Point(GetPointSet[1].X + e.HorizontalChange, GetPointSet[1].Y);
1031
                                }
1032
                                if ((GetPointSet[0].Y > GetPointSet[1].Y && e.VerticalChange > 0) || (GetPointSet[0].Y < GetPointSet[1].Y && e.VerticalChange < 0))
1033
                                {
1034
                                    GetPointSet[1] = new Point(GetPointSet[1].X, GetPointSet[1].Y + e.VerticalChange);
1035
                                }
1036
                                (control.DrawingData as ArrowTextControl).PointSet[1] = GetPointSet[1];
1037

    
1038

    
1039
                                //System.Diagnostics.Debug.WriteLine("MidPoint : " + (control.DrawingData as ArrowTextControl).MidPoint);
1040
                                //System.Diagnostics.Debug.WriteLine("HorizontalChange : " + e.HorizontalChange);
1041
                                //System.Diagnostics.Debug.WriteLine("VerticalChange : " + e.VerticalChange);
1042

    
1043
                                AllControl.PointSet[i] = setPoint;
1044
                                //System.Diagnostics.Debug.WriteLine("PointSet : " + AllControl.PointSet[i]);
1045

    
1046
                                AllControl.updateControl();
1047

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

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

    
1069
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1070
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1071
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1072
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1073
                                    [ReverseP].Y
1074
                                    + PreviousV.Y * l);
1075

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

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

    
1098
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1099
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1100
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1101
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1102
                                    [ReverseP].Y
1103
                                    + PreviousV.Y * l);
1104

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

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

    
1138
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1139
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1140
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1141
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1142
                                    [ReverseP].Y
1143
                                    + PreviousV.Y * l);
1144

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

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

    
1165
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1166
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1167
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1168
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1169
                                    [ReverseP].Y
1170
                                    + PreviousV.Y * l);
1171

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

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

    
1192
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1193
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1194
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1195
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1196
                                    [ReverseP].Y
1197
                                    + PreviousV.Y * l);
1198

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

    
1228

    
1229

    
1230
        #endregion
1231
        #region 이벤트
1232

    
1233
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1234
        {
1235
            this.isDragging = false;
1236
            DraggerThumb = null;
1237

    
1238
            var comments = (from drawing in this.Members
1239
                            select drawing.DrawingData as CommentUserInfo).ToList();
1240
            UndoCommand.Instance.Push(comments, this.AngleValue);
1241
        }
1242

    
1243
        /// <summary>
1244
        /// start drag
1245
        /// </summary>
1246
        /// <param name="sender"></param>
1247
        /// <param name="e"></param>
1248
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1249
        {
1250
            this.DraggerThumb = sender as Thumb;
1251
            this.isDragging = true;
1252

    
1253
            if (ViewerDataModel.Instance.UndoDataList == null)
1254
            {
1255
                return;
1256
            }
1257

    
1258
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1259
            {
1260
                return;
1261
            }
1262

    
1263
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1264
            {
1265
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1266
                {
1267
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1268
                    {
1269
                        return;
1270
                    }
1271
                }
1272
            }
1273

    
1274
            var comments = (from drawing in this.Members
1275
                            select drawing.DrawingData as CommentUserInfo).ToList();
1276
            UndoCommand.Instance.Push(comments, this.AngleValue);
1277
        }
1278

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

    
1303
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1304
        {
1305
            DragThumb.Cursor = Cursors.SizeAll;
1306
            Thumb thumb = sender as Thumb;
1307
            MoveAdorner(e);
1308
        }
1309

    
1310
        public void MoveAdorner(DragDeltaEventArgs e)
1311
        {
1312
            Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);
1313

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

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

    
1366
                    #endregion
1367

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

    
1389
                        for (int i = 0; i < item.ThumbList.Count; i++)
1390
                        {
1391
                            Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + px.X);
1392
                            Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + px.Y);
1393
                        }
1394
                        (item.DrawingData as IPath).updateControl();
1395
                        BorderUpdate();
1396

    
1397
                    }
1398
                    #endregion
1399
                    BorderUpdate();
1400
                }
1401
            }));
1402
        }
1403

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

    
1418
                    Canvas.SetLeft(item.ThumbList.Last(), Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1419
                    Canvas.SetTop(item.ThumbList.Last(), Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1420
                }
1421
                else
1422
                {
1423
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1424
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1425
                    AllControl.updateControl();
1426
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1427
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1428
                }
1429
            }
1430
        }
1431

    
1432
        public void DynamicThumbUpdate(AdornerMember item)
1433
        {
1434
            var AllControl = item.DrawingData as IPath;
1435
            List<Point> point = AllControl.PointSet;
1436

    
1437
            for (int i = 0; i < AllControl.PointSet.Count(); i++)
1438
            {
1439

    
1440
                Canvas.SetLeft(item.ThumbList[i], AllControl.PointSet[i].X);
1441
                Canvas.SetTop(item.ThumbList[i], AllControl.PointSet[i].Y);
1442
            }
1443

    
1444

    
1445
            if (item.DrawingData as ArrowTextControl != null)
1446
            {
1447
                if (!(item.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
1448
                {
1449
                    List<Point> ps = new List<Point>();
1450

    
1451
                    var temp = item.DrawingData as ArrowTextControl;
1452
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1453
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1454
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1455
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1456

    
1457

    
1458

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

    
1498
        public void Set_Rotate()
1499
        {
1500

    
1501
            double dDeltaAngle = 0;
1502
            List<Point> AllPointSet = new List<Point>();
1503
            Point CenterPoint = new Point();
1504

    
1505

    
1506
            if (AngleValue >= 360)
1507
            {
1508
                AngleValue -= 360;
1509
            }
1510
            else if (AngleValue <= -360)
1511
            {
1512
                AngleValue += 360;
1513
            }
1514

    
1515
            #region 센터 포인트 구하기 (그룹핑)
1516
            foreach (var item in this.Members)
1517
            {
1518
                if (item.DrawingData.GetType().Name == "TextControl")
1519
                {
1520
                }
1521
                else
1522
                {
1523
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1524
                    {
1525
                        AllPointSet.Add(itemP);
1526
                    }
1527
                }
1528
            }
1529
            #endregion
1530

    
1531
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1532

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

    
1542
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1543
                        Canvas.SetLeft(thumb, value.X);
1544
                        Canvas.SetTop(thumb, value.Y);
1545

    
1546
                        if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last())
1547
                        {
1548

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

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

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

    
1570
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
1571
                                        }
1572
                                        break;
1573
                                    case "270":
1574
                                        {
1575
                                            ps.Clear();
1576
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1577
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
1578
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
1579

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

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

    
1586
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
1587
                                        }
1588
                                        break;
1589
                                    default:
1590
                                        {
1591
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1592
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1593
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1594
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1595
                                        }
1596
                                        break;
1597
                                }
1598

    
1599
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1600
                                var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1601
                                Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1602
                                Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1603
                            }
1604
                        }
1605
                    }
1606

    
1607
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1608
                    {
1609
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1610
                    }
1611
                }
1612
                #region 컨트롤 업데이트
1613
                foreach (var item in this.Members)
1614
                {
1615
                    switch (item.Drawingtype)
1616
                    {
1617
                        case ControlType.TextControl:
1618
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1619

    
1620
                            RectangleGeometry Data = new RectangleGeometry
1621
                            {
1622
                                Rect = new Rect()
1623
                                {
1624
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1625
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1626
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1627
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1628
                                }
1629
                            };
1630

    
1631
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1632
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);                                                      
1633

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

    
1639
                            };
1640

    
1641
                            AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
1642
                            AdornerBorder.RenderTransform = new RotateTransform()
1643
                            {
1644
                                Angle = (item.DrawingData as TextControl).Angle,
1645

    
1646
                            };
1647

    
1648
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1649
                            {
1650
                                Angle = (item.DrawingData as TextControl).Angle,
1651
                            };
1652
                            BorderUpdate();
1653
                            break;
1654

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

    
1749
        private void resize_MouseMove(object sender, MouseEventArgs e)
1750
        {
1751
            reSizePoint = e.GetPosition(this);
1752
        }
1753
        /// <summary>
1754
        /// 회전
1755
        /// </summary>
1756
        /// <param name="sender"></param>
1757
        /// <param name="e"></param>
1758
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1759
        {
1760

    
1761
            MoveRotate(e);
1762
        }
1763

    
1764
        double LastRotateHorizontalValue = 0;
1765
        double LastRotateVerticalValue = 0;
1766
        //double LastWidthValue = 0;
1767
        //double SetWidth = 0;
1768
        bool RotateFlag = false;
1769

    
1770
        /// <summary>
1771
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1772
        /// </summary>
1773
        /// <param name="e"></param>
1774
        public void MoveRotate(DragDeltaEventArgs e)
1775
        {
1776
            double dDeltaAngle = 0;
1777

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

    
1806
            Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
1807
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1808
            dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1809

    
1810
            //System.Diagnostics.Debug.WriteLine("vec1 : " + vec1.X + "/" + vec1.Y);
1811
            //System.Diagnostics.Debug.WriteLine("vec2 : " + vec2.X + "/" + vec2.Y);
1812
            //System.Diagnostics.Debug.WriteLine("dDeltaAngle : " + dDeltaAngle);
1813

    
1814
            AngleValue += dDeltaAngle;
1815
            if (AngleValue > 360) AngleValue -= 360;
1816
            if (AngleValue < 0) AngleValue += 360;
1817
            this.rotatePoint = pt;  /// save rotatePoint
1818

    
1819
            Dispatcher.BeginInvoke((Action)(() =>
1820
            {
1821
                foreach (var item in this.Members)
1822
                {
1823
                    foreach (var thumb in item.ThumbList)
1824
                    {
1825
                        double x = Canvas.GetLeft(thumb);
1826
                        double y = Canvas.GetTop(thumb);
1827

    
1828
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1829
                        Canvas.SetLeft(thumb, value.X);
1830
                        Canvas.SetTop(thumb, value.Y);
1831
                    }
1832

    
1833
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1834
                    {
1835
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1836
                    }
1837
                }
1838
                #region 보더 업데이트
1839
                foreach (var item in this.Members)
1840
                {
1841
                    switch (item.Drawingtype)
1842
                    {
1843
                        case ControlType.TextControl:
1844
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1845

    
1846
                            RectangleGeometry Data = new RectangleGeometry
1847
                            {
1848
                                Rect = new Rect()
1849
                                {
1850
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1851
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1852
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1853
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1854
                                }
1855
                            };
1856

    
1857
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1858
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);
1859

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

    
1868
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1869
                            AdornerBorder.RenderTransform = new RotateTransform()
1870
                            {
1871
                                Angle = (item.DrawingData as TextControl).Angle,
1872
                                //CenterX = middle.X,
1873
                                //CenterY = middle.Y,
1874
                            };
1875

    
1876
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1877
                            {
1878
                                Angle = (item.DrawingData as TextControl).Angle,
1879
                            };
1880

    
1881
                            BorderUpdate();
1882
                            break;
1883

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

    
1967
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1968
        {            
1969

    
1970
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1971
            rotateTop.Cursor = Cursors.SizeAll;
1972

    
1973
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1974
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1975
            {
1976
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).Angle;
1977
            }
1978
            /// up to here
1979

    
1980

    
1981

    
1982
            if (ViewerDataModel.Instance.UndoDataList == null)
1983
            {
1984
                return;
1985
            }
1986

    
1987
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1988
            {
1989
                return;
1990
            }
1991

    
1992
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1993
            {
1994
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1995
                {
1996
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1997
                    {
1998
                        return;
1999
                    }
2000
                }
2001
            }
2002

    
2003
            var comments = (from drawing in this.Members
2004
                            select drawing.DrawingData as CommentUserInfo).ToList();
2005
            UndoCommand.Instance.Push(comments, this.AngleValue);
2006
        }
2007
        
2008
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
2009
        {
2010
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2011

    
2012
            var comments = (from drawing in this.Members
2013
                            select drawing.DrawingData as CommentUserInfo).ToList();
2014
            UndoCommand.Instance.Push(comments, this.AngleValue);
2015
        }
2016

    
2017
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
2018
        {
2019
            if (ViewerDataModel.Instance.UndoDataList == null)
2020
            {
2021
                return;
2022
            }
2023
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
2024
            {
2025
                return;
2026
            }
2027
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
2028
            {
2029
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
2030
                {
2031
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
2032
                    {
2033
                        return;
2034
                    }
2035
                }
2036
            }
2037

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

    
2043
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
2044
        {          
2045
            DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2046

    
2047
            var comments = (from drawing in this.Members
2048
                            select drawing.DrawingData as CommentUserInfo).ToList();
2049
            UndoCommand.Instance.Push(comments, this.AngleValue);
2050
        }
2051

    
2052
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
2053
        {
2054
            AdornerMember control = this.Members.FirstOrDefault();
2055

    
2056
            if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null)
2057
            {
2058
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
2059
                {
2060
                    (control.DrawingData as ArrowTextControl).isTrans = true;
2061
                }
2062
            }
2063

    
2064
        }
2065

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

    
2090
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
2091
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
2092
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
2093
                        {
2094
                            Angle = AllControl.Angle,
2095
                            CenterX = middle.X,
2096
                            CenterY = middle.Y,
2097
                        };
2098
                    }
2099
                    BorderUpdate();
2100
                };
2101
            }
2102
        }
2103

    
2104
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
2105
        {
2106
            if (e.ClickCount == 2 && this.Members.Count == 1)
2107
            {
2108

    
2109
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2110
                {
2111
                    TextControlChanger();                    
2112
                }
2113

    
2114
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2115
                {
2116
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
2117
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
2118
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
2119

    
2120
                    //ArrowControl TextBox Thumb없애기
2121
                    tm.Visibility = Visibility.Collapsed;
2122

    
2123
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
2124
                    
2125
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
2126

    
2127
                    {
2128
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
2129
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
2130

    
2131
                        List<Point> ps = new List<Point>();
2132
                        
2133
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
2134
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
2135
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
2136
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
2137

    
2138

    
2139

    
2140

    
2141
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
2142
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
2143
                        if (AllControl.isTrans)
2144
                        {
2145
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
2146
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
2147
                        }
2148
                        else
2149
                        {
2150
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
2151
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
2152
                        }
2153

    
2154

    
2155
                        BorderUpdate();
2156

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

    
2212
            }
2213
            
2214
        }
2215
        #endregion
2216

    
2217
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2218
        {
2219
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2220
            {
2221
                DragThumb.Visibility = Visibility.Collapsed;
2222
            }
2223
        }
2224

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