프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (113 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
    public partial class AdornerFinal : UserControl
39
    {
40
        public TextBox editTextBox { get; set; }
41
        #region 공용 인스턴스
42
        public List<AdornerMember> MemberSet { get; set; }
43
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
44
        public double AngleValue = 0;
45
        public bool IsTextAngle = false;
46
        public Rect BorderSize { get; set; }
47
        public bool TextCompensation = false;
48
        public bool isDragging { get; set; }
49
        public Thumb DraggerThumb { get; set; }
50
        public RadDropDownButton dropData;
51
        public RadCalendar dropCalendar;
52
        public Thumb mainDragThumb { get; set; }
53

    
54
        public Point reSizePoint { get; set; }
55
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
56
        #endregion
57
        #region 생성자
58
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
59
        {
60
            dropData = sender as RadDropDownButton;
61
        }
62
        private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
63
        {
64
            dropCalendar = sender as RadCalendar;
65
            dropCalendar.SelectionChanged += (sen, ea) =>
66
            {
67
                dropData.IsOpen = false;
68
                if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
69
                {
70
                    DateControl data = (MemberSet.First() as AdornerMember).DrawingData as DateControl;
71
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
72
                }
73
            };
74
        }
75
        public AdornerFinal()
76
        {
77
            InitializeComponent();
78
            MemberSet = new List<AdornerMember>();
79
            BorderSize = new Rect();
80
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
81
            //_dragData.Add(rotateCenter, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
82
        }
83

    
84
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
85
        {
86
            mainDragThumb = DragThumb;
87
        }
88

    
89
        public AdornerFinal(CommentUserInfo objectData) : this()
90
        {
91
            InitializeComponent();
92
            objectData.IsHitTestVisible = false;
93
            if ((objectData as ArrowTextControl) != null)
94
            {
95
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
96
            }
97
            Canvas.SetZIndex(objectData, 84);
98
            try
99
            {
100
                this.ContainerContent.Children.Add(objectData);
101
            }
102
            catch //(Exception ex)
103
            {
104

    
105
            }
106
            SetAdornerMember(objectData as CommentUserInfo);
107
            this.Focus();
108
        }
109
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
110
        {
111
            InitializeComponent();
112
            foreach (var item in objectData)
113
            {
114
                //item.IsHitTestVisible = false;
115
                if ((item as ArrowTextControl) != null)
116
                {
117
                    (item as ArrowTextControl).Base_TextBox.Focusable = true;
118
                }
119
                try
120
                {
121
                    Canvas.SetZIndex(item, 80);
122
                    this.ContainerContent.Children.Add(item);
123
                }
124
                catch //(Exception ex)
125
                {
126

    
127
                }
128
            }
129
            SetAdornerMember(objectData);
130
            this.Focus();
131
        }
132

    
133
        #endregion
134
        #region 메서드
135
        public Rect getAdornerSize()
136
        {
137
            return BorderSize;
138
        }
139
        public void addMemberControl(UIElement objectData)
140
        {
141
            this.ContainerContent.Children.Add(objectData);
142
            SetAdornerMember(objectData as CommentUserInfo);
143
            this.Focus();
144
        }
145
        /// <summary>
146
        /// UIElement를 종류에 맞게 등록시킴
147
        /// </summary>
148
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
149
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
150
        {
151

    
152
            switch (member.GetType().Name)
153
            {
154
                #region 컨트롤 조건
155
                case "LineControl": //Angle추가 안했음
156
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
157
                    break;
158
                case "ImgControl": //Angle추가 안했음
159
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
160
                    //AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);            
161
                    //DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
162
                    AngleValue = (member as ImgControl).Angle;
163
                    break;
164
                //case "SymControl": //Angle추가 안했음
165
                //    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() });
166
                //    AngleValue = (member as SymControl).Angle;
167
                //    //ViewBoxRotate(member);
168
                //    break;
169
                //case "SymControlN": //Angle추가 안했음
170
                //    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() });
171
                //    AngleValue = (member as SymControlN).Angle;
172
                //    //ViewBoxRotate(member);
173
                //    break;
174
                case "PolygonControl": //Angle추가 안했음
175
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
176
                    break;
177
                case "ArrowControl":
178
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
179
                    break;
180
                case "ArrowTextControl":
181
                    MemberSet.Add(new AdornerMember
182
                    {
183
                        DrawingData = member,
184
                        Drawingtype = ControlType.ArrowTextControl,
185
                        ThumbList = new List<Thumb>(),
186
                        Symbol_ID = member.SymbolID,
187
                        Group_ID = member.GroupID,
188
                    });
189
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
190
                    AngleValue = (member as ArrowTextControl).Angle;
191
                    Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
192
                    {
193
                        TextCompensation = false;
194
                        BorderUpdate();
195
                        if ((a.Sender as TextBox).Text == "") //보류
196
                        {
197
                            this.ContainerContent.Children.Remove(member);
198
                            this.Visibility = Visibility.Collapsed;
199
                        }
200
                    });
201
                    break;
202
                case "ArcControl":
203
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
204
                    break;
205
                case "ArrowArcControl":
206
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
207
                    break;
208
                case "ArrowControl_Multi":
209
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
210
                    break;
211
                case "RectangleControl":
212
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
213
                    break;
214
                case "DateControl":
215
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
216
                    AngleValue = (member as DateControl).Angle;
217
                    break;
218
                case "TriControl":
219
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
220
                    break;
221
                case "CircleControl":
222
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
223
                    break;
224
                case "CloudControl":
225
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
226
                    break;
227
                case "RectCloudControl":
228
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
229
                    break;
230
                case "SignControl":
231
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
232
                    AngleValue = (member as SignControl).Angle;
233
                    break;
234

    
235
                case "SymControl":
236
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
237
                    AngleValue = (member as SymControl).Angle;
238
                    break;
239
                case "SymControlN":
240
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
241
                    AngleValue = (member as SymControlN).Angle;
242
                    break;
243
                case "InkControl": //Angle추가 안했음
244
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
245
                    break;
246
                case "TextControl":
247
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
248
                    RectangleGeometry Data = new RectangleGeometry
249
                    {
250
                        Rect = new Rect()
251
                        {
252
                            X = Canvas.GetLeft((member as TextControl)),
253
                            Y = Canvas.GetTop((member as TextControl)),
254
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
255
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
256
                            //Width = (member as TextControl).BoxWidth / 2,
257
                            //Height = (member as TextControl).BoxHeight / 2,
258
                        }
259
                    };
260
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
261
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
262

    
263

    
264
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
265
                    DragThumb.RenderTransform = new RotateTransform()
266
                    {
267
                        Angle = (member as TextControl).Angle,
268
                        //CenterX = middle.X,
269
                        //CenterY = middle.Y,
270
                    };
271

    
272
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
273
                    AdornerBorder.RenderTransform = new RotateTransform()
274
                    {
275
                        Angle = (member as TextControl).Angle,
276
                        //CenterX = middle.X,
277
                        //CenterY = middle.Y,
278
                    };
279
                    Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
280
                    {
281
                        TextCompensation = true;
282
                        BorderUpdate();
283
                        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
284
                    });
285
                    Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
286
                    {
287
                        TextCompensation = false;
288
                        BorderUpdate();
289
                        if ((a.Sender as TextBox).Text == "") //보류
290
                        {
291
                            this.ContainerContent.Children.Remove(member);
292
                            this.Visibility = Visibility.Collapsed;
293
                        }
294

    
295
                        //((TextControl)member).UnEditingMode();
296
                        //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
297
                        //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
298
                        //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
299
                    });
300
                    break;
301
                case "InsideWhiteControl":
302
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
303
                    break;
304
                case "OverlapWhiteControl":
305
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
306
                    break;
307
                case "ClipWhiteControl":
308
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
309
                    break;
310
                case "CoordinateControl":
311
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
312
                    break;
313
                default:
314
                    break;
315
                    #endregion
316
            }
317
            if (member.GetType().Name == "TextControl")
318
            {
319
                TextControl content = ((TextControl)member);
320
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
321
                content.EndPoint = content.StartPoint;
322

    
323
            }
324
            else
325
            {
326
                RegistryPoint(member);
327
            }
328
            BorderUpdate();
329
        }
330

    
331
        private void ViewBoxRotate(UIElement member)
332
        {
333
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
334
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
335
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
336
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
337
        }
338
        public void SetAdornerMember(List<CommentUserInfo> members)
339
        {
340
            foreach (var member in members)
341
            {
342
                switch (member.GetType().Name)
343
                {
344
                    #region 컨트롤 조건
345
                    case "LineControl":
346
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
347
                        break;
348
                    case "ImgControl":
349
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
350
                        break;
351
                    case "ArrowControl":
352
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
353
                        break;
354
                    case "PolygonControl":
355
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
356
                        break;
357
                    case "ArrowTextControl":
358
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
359
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
360
                        break;
361
                    case "ArcControl":
362
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
363
                        break;
364
                    case "ArrowArcControl":
365
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
366
                        break;
367
                    case "DateControl":
368
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
369
                        break;
370
                    case "ArrowControl_Multi":
371
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
372
                        break;
373
                    case "RectangleControl":
374
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
375
                        break;
376
                    case "TriControl":
377
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
378
                        break;
379
                    case "CircleControl":
380
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
381
                        break;
382
                    case "CloudControl":
383
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
384
                        break;
385
                    case "RectCloudControl":
386
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
387
                        break;
388
                    case "SignControl":
389
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
390
                        break;
391
                    case "SymControl":
392
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
393
                        break;
394
                    case "SymControlN":
395
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
396
                        break;
397
                    case "InkControl":
398
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
399
                        break;
400
                    case "TextControl":
401
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
402
                        Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
403
                        {
404
                            BorderUpdate();
405
                            try
406
                            {
407
                                ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
408
                            }
409
                            catch (Exception)
410
                            {
411

    
412
                            }
413

    
414
                        });
415
                        Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
416
                        {
417
                            BorderUpdate();
418
                        });
419
                        break;
420
                    case "InsideWhiteControl":
421
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
422
                        break;
423
                    case "OverlapWhiteControl":
424
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
425
                        break;
426
                    case "ClipWhiteControl":
427
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
428
                        break;
429
                    case "CoordinateControl":
430
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
431
                        break;
432
                    default:
433
                        break;
434
                        #endregion
435
                }
436
                if (member.GetType().Name == "TextControl")
437
                {
438
                    TextControl content = ((TextControl)member);
439
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
440
                    content.EndPoint = content.StartPoint;
441
                }
442
                else
443
                {
444
                    RegistryPoint(member, members.Count);
445
                }
446
            }
447

    
448
            BorderUpdate();
449
        }
450

    
451
        /// <summary>
452
        /// Border 를 갱신
453
        /// </summary>
454
        public void BorderUpdate()
455
        {
456
            AdornerBorder.MinWidth = 10;
457
            AdornerBorder.MinHeight = 10;
458

    
459
            double minX = double.MaxValue;
460
            double minY = double.MaxValue;
461
            double maxX = double.MinValue;
462
            double maxY = double.MinValue;
463

    
464
            if (MemberSet.Count == 1)
465
            {
466
                if (MemberSet.First().DrawingData.GetType().Name == "TextControl")
467
                {
468
                    if ((MemberSet.First().DrawingData as TextControl).Angle != 0)
469
                    {
470
                        trRotate.Angle = (MemberSet.First().DrawingData as TextControl).Angle;
471
                        trRotateThumb.Angle = (MemberSet.First().DrawingData as TextControl).Angle;
472
                    }
473
                    else
474
                    {
475
                        trRotate.Angle = 0;
476
                        trRotateThumb.Angle = 0;
477
                    }
478
                }
479
            }
480
            foreach (var item in MemberSet)
481
            {
482
                UIElement currentControl = (item as AdornerMember).DrawingData;
483
                if (item.DrawingData.GetType().Name == "TextControl")
484
                {
485
                    double textControlWidth;
486
                    double textControlHeight;
487
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
488
                    {
489
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
490
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
491
                    }
492
                    else
493
                    {
494
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
495
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
496
                    }
497
                    
498
                    if ((currentControl as TextControl).EndPoint.X < minX)
499
                    {
500
                        minX = (currentControl as TextControl).EndPoint.X;
501
                    }
502
                    if ((currentControl as TextControl).EndPoint.Y < minY)
503
                    {
504
                        minY = (currentControl as TextControl).EndPoint.Y;
505
                    }
506
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
507
                    {
508
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
509
                    }
510
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
511
                    {
512
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
513
                    }
514
                }
515
                else if ((currentControl as IViewBox) != null)
516
                {
517
                    IViewBox instance = currentControl as IViewBox;
518
                    List<Point> am = (currentControl as IPath).PointSet;
519
                    List<double> xSet = am.Select(p => p.X).ToList();
520
                    List<double> ySet = am.Select(p => p.Y).ToList();
521
                    if (xSet.Min() < minX) minX = xSet.Min();
522
                    if (ySet.Min() < minY) minY = ySet.Min();
523
                    if (xSet.Max() > maxX) maxX = xSet.Max();
524
                    if (ySet.Max() > maxY) maxY = ySet.Max();
525
                }
526
                else if ((currentControl as IPath).PathData == null)
527
                {
528
                    Rect rt = new Rect
529
                    {
530
                        X = (currentControl as IPath).StartPoint.X,
531
                        Y = (currentControl as IPath).StartPoint.Y,
532
                        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),
533
                        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),
534
                    };
535
                    if (rt.Left < minX) minX = rt.Left;
536
                    if (rt.Top < minY) minY = rt.Top;
537
                    if (rt.Right > maxX) maxX = rt.Right;
538
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
539
                }
540
                else if ((currentControl as IPath) == null)
541
                {
542
                    Rect rt = new Rect
543
                    {
544
                        X = (currentControl as IPath).StartPoint.X,
545
                        Y = (currentControl as IPath).StartPoint.Y,
546
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
547
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
548
                    };
549
                    if (rt.Left < minX) minX = rt.Left;
550
                    if (rt.Top < minY) minY = rt.Top;
551
                    if (rt.Right > maxX) maxX = rt.Right;
552
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
553
                }
554
                else if ((currentControl as CircleControl) != null)
555
                {                    
556
                    List<Point> am = (currentControl as IPath).PointSet;
557
                    List<double> xSet = am.Select(p => p.X).ToList();
558
                    List<double> ySet = am.Select(p => p.Y).ToList();
559
                    if (xSet.Min() < minX) minX = xSet.Min();
560
                    if (ySet.Min() < minY) minY = ySet.Min();
561
                    if (xSet.Max() > maxX) maxX = xSet.Max();
562
                    if (ySet.Max() > maxY) maxY = ySet.Max();
563
                }
564
                else
565
                {
566
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
567
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
568
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
569
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
570
                }
571
            }
572

    
573
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
574
            bool addWidthSize = false;
575
            bool addHeightSize = false;
576
            if (ac.Width <= 10)
577
            {
578
                ac.Width += 10;
579
                addWidthSize = true;
580
            }
581
            if (ac.Height <= 10)
582
            {
583
                ac.Height += 10;
584
                addHeightSize = true;
585
            }
586
            BorderSize = ac;
587
            AdornerBorder.MinWidth = 10;
588
            AdornerBorder.MinHeight = 10;
589
            AdornerBorder.Width = ac.Width;
590
            AdornerBorder.Height = ac.Height;
591
            Canvas.SetLeft(AdornerBorder, minX);
592
            Canvas.SetTop(AdornerBorder, minY);
593

    
594
            DragThumb.Width = ac.Width;
595
            DragThumb.Height = ac.Height;
596

    
597
            DragThumb.MinWidth = 10;
598
            DragThumb.MinHeight = 10;
599
            if (addWidthSize)
600
            {
601
                Canvas.SetLeft(DragThumb, minX - 5);
602
            }
603
            else
604
            {
605
                Canvas.SetLeft(DragThumb, minX);
606
            }
607

    
608
            if (addHeightSize)
609
            {
610
                Canvas.SetTop(DragThumb, minY - 5);
611
            }
612
            else
613
            {
614
                Canvas.SetTop(DragThumb, minY);
615
            }
616
        }
617
        /// <summary>
618
        /// UIElement 해제
619
        /// </summary>
620
        public void unRegister()
621
        {
622
            foreach (var item in this.ContainerContent.Children)
623
            {
624
                if (item is MarkupToPDF.Common.CommentUserInfo)
625
                {
626
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
627
                }
628
            }
629
            this.ContainerContent.Children.Clear();
630
        }
631
        /// <summary>
632
        /// 각 포인트들을 등록합니다.
633
        /// </summary>
634
        /// <param name="pointset">Drawing Point</param>
635
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
636
        {
637
            int count = 0;
638
            double Minx = 100000000;
639
            double Miny = 100000000;
640
            List<Point> list = (member as IPath).PointSet;
641
            if (member.GetType().Name == "InkControl")
642
            {
643
                list.Clear();
644
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
645
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
646
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
647
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
648
            }
649
            ControlType markT = MemberSet.Where(p => p.DrawingData == member).First().Drawingtype;
650
            foreach (var ax in list)
651
            {
652
                Minx = (ax.X < Minx) ? ax.X : Minx;
653
                Miny = (ax.Y < Miny) ? ax.Y : Miny;
654
            }
655
            for (int i = 0; i < list.Count(); i++)
656
            {
657
                Thumb tm = new Thumb
658
                {
659
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
660
                };
661

    
662
                MemberSet.Last().ThumbList.Add(tm);
663

    
664
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MidPoint))
665
                {
666
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
667
                }
668
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
669
                {
670
                    //if (MemberSet.Count()<=1)
671
                    //{
672
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
673
                    List<Point> ps = new List<Point>();
674

    
675
                    if ((MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl != null)
676
                    {
677
                        var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
678

    
679

    
680
                        switch (Math.Abs(temp.Angle).ToString())
681
                        {
682
                            case "90":
683
                                {
684
                                    ps.Clear();
685
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
686
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
687
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
688

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

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

    
695
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
696
                                }
697
                                break;
698
                            case "270":
699
                                {
700
                                    ps.Clear();
701
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
702
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
703
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
704

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

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

    
711
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
712
                                }
713
                                break;
714
                            default:
715
                                {
716
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
717
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
718
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
719
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
720
                                }
721
                                break;
722
                        }
723

    
724
                        ArrowTextControl instance = (member as ArrowTextControl);
725
                        if (instance.isTrans)
726
                        {
727
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
728
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
729
                            //list[count] = tempP;
730
                            list[count] = temp.MidPoint;
731
                        }
732
                        else
733
                        {
734
                            if (temp.isFixed)
735
                            {
736
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
737
                                var testP = endP;
738
                                if (ps[0] == endP) //상단
739
                                {
740
                                    testP = new Point(endP.X, endP.Y - 50);
741
                                }
742
                                else if (ps[1] == endP) //하단
743
                                {
744
                                    testP = new Point(endP.X, endP.Y + 50);
745
                                }
746
                                else if (ps[2] == endP) //좌단
747
                                {
748
                                    testP = new Point(endP.X - 50, endP.Y);
749
                                }
750
                                else if (ps[3] == endP) //우단
751
                                {
752
                                    testP = new Point(endP.X + 50, endP.Y);
753
                                }
754
                                list[count] = testP;
755
                            }
756
                            else
757
                            {
758
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
759
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
760
                            }
761
                        }
762
                    }
763
                }
764
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
765
                {
766
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
767
                    tm.Width = (member as ArrowTextControl).BoxWidth;
768
                    tm.Height = (member as ArrowTextControl).BoxHeight;
769
                    var angle = (member as ArrowTextControl).Angle;
770
                    if (Math.Abs(angle).ToString() == "90")
771
                    {
772
                        tm.RenderTransformOrigin = new Point(0, 0);
773
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
774
                    }
775
                    else if (Math.Abs(angle).ToString() == "270")
776
                    {
777
                        tm.RenderTransformOrigin = new Point(0, 0);
778
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
779

    
780
                    }
781
                    else
782
                    {
783
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
784
                        tm.RenderTransform = new RotateTransform()
785
                        {
786
                            Angle = angle,
787
                        };
788
                    }
789
                }
790
                
791
                if (member.GetType().Name == "CloudControl")
792
                {
793
                    if (i == list.Count() - 1)
794
                    {
795
                        tm.Visibility = System.Windows.Visibility.Collapsed;
796
                    }
797
                }
798
                if (member.GetType().Name == "PolygonControl")
799
                {
800
                    if (i == list.Count() - 1)
801
                    {
802
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
803
                        {
804

    
805
                        }
806
                        else
807
                        {
808
                            tm.Visibility = System.Windows.Visibility.Collapsed;
809
                        }
810
                    }
811
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
812
                    {
813
                        tm.Visibility = System.Windows.Visibility.Collapsed;
814
                    }
815
                }
816
                
817
                this.ContainerContent.Children.Add(tm);
818
                Canvas.SetLeft(tm, list[count].X);
819
                Canvas.SetTop(tm, list[count].Y);
820
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
821
                {
822
                    Canvas.SetZIndex(tm, 95);
823
                }
824
                else
825
                {
826
                    Canvas.SetZIndex(tm, 99);
827
                }
828

    
829
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
830
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
831
                tm.DragDelta += ResizeTm_DragDelta;
832
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
833
                count++;
834
            }
835
        }
836

    
837
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
838
        {
839
            if (MemberSet.Count > 1)
840
                return;
841
            if (reSizePoint != new Point(0, 0))
842
            {
843
                Thumb thumb = sender as Thumb;
844

    
845
                if (AngleValue == -90)
846
                {
847
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.VerticalChange);
848
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.HorizontalChange));
849
                }
850
                else if (AngleValue == -180)
851
                {
852
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.HorizontalChange));
853
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.VerticalChange));
854
                }
855
                else if (AngleValue == -270)
856
                {
857
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.VerticalChange));
858
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.HorizontalChange);
859
                }
860
                else //(AngleValue == 0)
861
                {
862
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.HorizontalChange);
863
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.VerticalChange);
864
                }
865

    
866

    
867
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
868
                
869
                AdornerMember control = (from userThumb in MemberSet
870
                                         where userThumb.ThumbList.Contains(thumb)
871
                                         select userThumb).FirstOrDefault();
872
                Point nearPoint = new Point(0, 0);
873
                IPath AllControl = control.DrawingData as IPath;
874
                if (ControlType.TextControl != control.Drawingtype)
875
                {
876

    
877
                    var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
878
                    List<Point> ps = new List<Point>();
879

    
880
                    nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
881
                    
882

    
883
                }
884
                for (int i = 0; i < (control.DrawingData as IPath).PointSet.Count; i++)
885
                {
886
                    switch (control.Drawingtype)
887
                    {
888
                        #region Arc + Line
889
                        case ControlType.ArrowMultiLine:
890
                        case ControlType.ArcLine:
891
                        case ControlType.ArcArrow:
892
                        case ControlType.SingleLine:
893
                        case ControlType.Triangle:
894
                            if (nearPoint.Equals(AllControl.PointSet[i]))
895
                            {
896
                                AllControl.PointSet[i] = setPoint;
897
                                AllControl.updateControl();
898
                                DynamicThumbUpdate(control);
899
                                BorderUpdate();
900
                                
901
                            }
902
                            break;
903
                        #endregion
904
                        #region Shape                        
905
                        case ControlType.RectCloud:
906
                        case ControlType.Rectangle:
907
                            if (nearPoint.Equals(AllControl.PointSet[i]))
908
                            {
909
                                AllControl.PointSet[i] = setPoint;
910
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
911
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
912
                                var NextP = (i + 1) % AllControl.PointSet.Count();
913

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

    
916
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
917
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
918
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
919
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
920
                                    [ReverseP].Y
921
                                    + PreviousV.Y * l);
922

    
923
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
924
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
925
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
926
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
927
                                    NextV.Y * l);
928
                                AllControl.updateControl();
929
                                DynamicThumbUpdate(control);
930
                                BorderUpdate();
931
                            }
932
                            break;
933
                        #endregion
934
                        #region Polygon
935
                        case ControlType.PolygonControl:
936
                            if (nearPoint.Equals(AllControl.PointSet[i]))
937
                            {
938
                                AllControl.PointSet[i] = setPoint;
939
                                AllControl.updateControl();
940
                                BorderUpdate();
941
                            }
942
                            break;
943
                        #endregion
944
                        #region Cicle
945
                        case ControlType.Circle:
946
                            if (nearPoint.Equals(AllControl.PointSet[i]))
947
                            {
948
                                AllControl.PointSet[i] = setPoint;
949
                                List<Point> newPointSet = new List<Point> { };
950
                                Point middle = new Point(AllControl.PathData.Bounds.X + AllControl.PathData.Bounds.Width * 0.5,
951
                                    AllControl.PathData.Bounds.Y +
952
                                    AllControl.PathData.Bounds.Height * 0.5);
953
                                foreach (Point pt in AllControl.PointSet)
954
                                {
955
                                    newPointSet.Add(pt);
956
                                }
957
                                var ReverseP = (i + newPointSet.Count() / 2) % newPointSet.Count();
958
                                var PreviousP = (i + (newPointSet.Count() - 1)) % newPointSet.Count();
959
                                var NextP = (i + 1) % newPointSet.Count();
960
                                var distance = MathSet.DistanceTo(newPointSet[ReverseP], newPointSet[i]);
961
                                var PreviousV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[PreviousP]);
962
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, newPointSet[i].X - newPointSet[ReverseP].X,
963
                                    newPointSet[i].Y - newPointSet[ReverseP].Y);
964
                                newPointSet[PreviousP] = new Point(newPointSet[ReverseP].X + PreviousV.X * l, newPointSet[ReverseP].Y
965
                                    + PreviousV.Y * l);
966

    
967
                                var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]);
968
                                l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y
969
                                    - newPointSet[ReverseP].Y);
970
                                newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l);
971

    
972
                                AllControl.PointSet = newPointSet;
973
                                DynamicThumbUpdate(control);
974
                                AllControl.updateControl();
975
                                BorderUpdate();
976
                            }
977
                            break;
978
                        #endregion
979
                        #region ArrowText
980
                        case ControlType.ArrowTextControl:
981
                            if (nearPoint.Equals(AllControl.PointSet[i]))
982
                            {
983

    
984
                                List<Point> GetPointSet = (control.DrawingData as ArrowTextControl).PointSet;
985

    
986
                                if ((GetPointSet[0].X > GetPointSet[1].X && e.HorizontalChange > 0) || (GetPointSet[0].X < GetPointSet[1].X && e.HorizontalChange < 0))
987
                                {
988
                                    GetPointSet[1] = new Point(GetPointSet[1].X + e.HorizontalChange, GetPointSet[1].Y);
989
                                }
990
                                if ((GetPointSet[0].Y > GetPointSet[1].Y && e.VerticalChange > 0) || (GetPointSet[0].Y < GetPointSet[1].Y && e.VerticalChange < 0))
991
                                {
992
                                    GetPointSet[1] = new Point(GetPointSet[1].X, GetPointSet[1].Y + e.VerticalChange);
993
                                }
994
                                (control.DrawingData as ArrowTextControl).PointSet[1] = GetPointSet[1];
995

    
996

    
997
                                //System.Diagnostics.Debug.WriteLine("MidPoint : " + (control.DrawingData as ArrowTextControl).MidPoint);
998
                                //System.Diagnostics.Debug.WriteLine("HorizontalChange : " + e.HorizontalChange);
999
                                //System.Diagnostics.Debug.WriteLine("VerticalChange : " + e.VerticalChange);
1000

    
1001
                                AllControl.PointSet[i] = setPoint;
1002
                                //System.Diagnostics.Debug.WriteLine("PointSet : " + AllControl.PointSet[i]);
1003

    
1004
                                AllControl.updateControl();
1005

    
1006
                                DynamicThumbUpdate(control);
1007
                                BorderUpdate();
1008
                                                                
1009
                            }
1010
                            break;
1011
                        #endregion
1012
                        #region Text
1013
                        case ControlType.TextControl:
1014
                            break;
1015
                        #endregion
1016
                        #region Image
1017
                        case ControlType.ImgControl:
1018
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1019
                            {
1020
                                AllControl.PointSet[i] = setPoint;
1021
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1022
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1023
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1024

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

    
1027
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1028
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1029
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1030
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1031
                                    [ReverseP].Y
1032
                                    + PreviousV.Y * l);
1033

    
1034
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1035
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1036
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1037
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1038
                                    NextV.Y * l);
1039
                                AllControl.updateControl();
1040
                                DynamicThumbUpdate(control);
1041
                                BorderUpdate();
1042
                            }
1043
                            break;
1044
                        #endregion
1045
                        #region Sign
1046
                        case ControlType.Sign:
1047
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1048
                            {
1049
                                AllControl.PointSet[i] = setPoint;
1050
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1051
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1052
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1053

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

    
1056
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1057
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1058
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1059
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1060
                                    [ReverseP].Y
1061
                                    + PreviousV.Y * l);
1062

    
1063
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1064
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1065
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1066
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1067
                                    NextV.Y * l);
1068
                                AllControl.updateControl();
1069
                                DynamicThumbUpdate(control);
1070
                                BorderUpdate();
1071
                            }
1072
                            break;
1073
                        #endregion
1074
                        #region Cloud
1075
                        case ControlType.PolygonCloud:
1076
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1077
                            {
1078
                                AllControl.PointSet[i] = setPoint;
1079
                                AllControl.updateControl();
1080
                                ((ICloudControl)AllControl).DrawingCloud();
1081
                                BorderUpdate();
1082
                            }
1083
                            break;
1084
                        #endregion
1085
                        #region SymBol
1086
                        case ControlType.Symbol:
1087
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1088
                            {
1089
                                AllControl.PointSet[i] = setPoint;
1090
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1091
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1092
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1093

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

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

    
1103
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1104
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1105
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1106
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1107
                                    NextV.Y * l);
1108
                                AllControl.updateControl();
1109
                                DynamicThumbUpdate(control);
1110
                                BorderUpdate();
1111
                            }
1112
                            break;
1113
                        case ControlType.Stamp:
1114
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1115
                            {
1116
                                AllControl.PointSet[i] = setPoint;
1117
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1118
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1119
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1120

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

    
1123
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1124
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1125
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1126
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1127
                                    [ReverseP].Y
1128
                                    + PreviousV.Y * l);
1129

    
1130
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1131
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1132
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1133
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1134
                                    NextV.Y * l);
1135
                                AllControl.updateControl();
1136
                                DynamicThumbUpdate(control);
1137
                                BorderUpdate();
1138
                            }
1139
                            break;
1140
                        case ControlType.Date:
1141
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1142
                            {
1143
                                AllControl.PointSet[i] = setPoint;
1144
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1145
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1146
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1147

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

    
1150
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1151
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1152
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1153
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1154
                                    [ReverseP].Y
1155
                                    + PreviousV.Y * l);
1156

    
1157
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1158
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1159
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1160
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1161
                                    NextV.Y * l);
1162
                                AllControl.updateControl();
1163
                                DynamicThumbUpdate(control);
1164
                                BorderUpdate();
1165
                            }
1166
                            break;
1167
                        #endregion
1168
                        #region Ink
1169
                        case ControlType.Ink:
1170
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1171
                            {
1172
                                AllControl.PointSet[i] = setPoint;
1173
                                AllControl.updateControl();
1174
                                BorderUpdate();
1175
                            }
1176
                            break;
1177
                        #endregion
1178
                        default:
1179
                            break;
1180
                    }
1181
                }
1182
            }
1183
            //}
1184
        }
1185

    
1186

    
1187

    
1188
        #endregion
1189
        #region 이벤트
1190

    
1191
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1192
        {
1193
            this.isDragging = false;
1194
            DraggerThumb = null;
1195

    
1196
            var comments = (from drawing in this.MemberSet
1197
                            select drawing.DrawingData as CommentUserInfo).ToList();
1198
            UndoCommand.Instance.Push(comments, this.AngleValue);
1199
        }
1200

    
1201
        /// <summary>
1202
        /// start drag
1203
        /// </summary>
1204
        /// <param name="sender"></param>
1205
        /// <param name="e"></param>
1206
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1207
        {
1208
            this.DraggerThumb = sender as Thumb;
1209
            this.isDragging = true;
1210

    
1211
            if (ViewerDataModel.Instance.UndoDataList == null)
1212
            {
1213
                return;
1214
            }
1215

    
1216
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1217
            {
1218
                return;
1219
            }
1220

    
1221
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1222
            {
1223
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1224
                {
1225
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1226
                    {
1227
                        return;
1228
                    }
1229
                }
1230
            }
1231

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

    
1237
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1238
        {
1239
            if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1240
            {
1241
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1242
                    IsTextAngle = true;
1243
                else
1244
                    IsTextAngle = false;
1245
                LastRotateVerticalValue = e.GetPosition(this).X;
1246
            }
1247
            else
1248
            {
1249
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1250
                {
1251
                    RotateFlag = true;
1252
                }
1253
                else
1254
                {
1255
                    RotateFlag = false;
1256
                }
1257
                LastRotateHorizontalValue = e.GetPosition(this).X;
1258
            }
1259
        }
1260

    
1261
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1262
        {
1263
            DragThumb.Cursor = Cursors.SizeAll;
1264
            Thumb thumb = sender as Thumb;
1265
            MoveAdorner(e);
1266
        }
1267

    
1268
        public void MoveAdorner(DragDeltaEventArgs e)
1269
        {
1270
            Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);
1271

    
1272
            Dispatcher.BeginInvoke((Action)(() =>
1273
            {
1274
                foreach (var item in MemberSet)
1275
                {
1276
                    #region 라인  & 아크
1277
                    if (item.Drawingtype == ControlType.SingleLine || item.Drawingtype == ControlType.ArcLine || item.Drawingtype == ControlType.ArrowMultiLine || item.Drawingtype == ControlType.ArcArrow)
1278
                    {
1279
                        DynamicThumbUpdate(e, item);
1280
                    }
1281
                    #endregion
1282
                    #region 지시선화살표
1283
                    if (item.Drawingtype == ControlType.ArrowTextControl)
1284
                    {
1285
                        DynamicThumbUpdate(e, item);
1286
                    }
1287
                    #endregion
1288

    
1289
                    #region 써클
1290
                    if (item.Drawingtype == ControlType.Circle || item.Drawingtype == ControlType.Sign || item.Drawingtype == ControlType.Symbol || item.Drawingtype == ControlType.Stamp)
1291
                    {
1292
                        DynamicThumbUpdate(e, item);
1293
                    }
1294
                    #endregion
1295
                    #region 쉐이프
1296
                    if (item.Drawingtype == ControlType.Rectangle || item.Drawingtype == ControlType.ImgControl || item.Drawingtype == ControlType.RectCloud || item.Drawingtype == ControlType.Triangle)
1297
                    {
1298
                        DynamicThumbUpdate(e, item);
1299
                    }
1300
                    #endregion
1301
                    #region 텍스트
1302
                    if (item.Drawingtype == ControlType.TextControl)
1303
                    {
1304
                        (item.DrawingData as TextControl).Move(e.HorizontalChange, e.VerticalChange);
1305
                    }
1306
                    #endregion
1307
                    #region 날짜
1308
                    if (item.Drawingtype == ControlType.Date)
1309
                    {
1310
                        DynamicThumbUpdate(e, item);
1311
                    }
1312
                    #endregion
1313
                    #region 클라우드
1314
                    if (item.Drawingtype == ControlType.PolygonCloud)
1315
                    {
1316
                        ICloudControl temp = ((ICloudControl)item.DrawingData);
1317
                        DynamicThumbUpdate(e, item);
1318
                        temp.DrawingCloud();
1319
                    }
1320
                    #endregion
1321
                    #region 심볼
1322

    
1323
                    #endregion
1324

    
1325
                    #region 폴리곤
1326
                    if (item.Drawingtype == ControlType.PolygonControl)
1327
                    {
1328
                        DynamicThumbUpdate(e, item);
1329
                        BorderUpdate();
1330
                    }
1331
                    #endregion
1332
                    #region 잉크
1333
                    if (item.Drawingtype == ControlType.Ink)
1334
                    {
1335
                        Point px = new Point(e.HorizontalChange, e.VerticalChange);
1336
                        List<StylusPointSet> StylusPointSet = (item.DrawingData as InkControl).PointC;
1337
                        for (int i = 0; i < StylusPointSet.Count; i++)
1338
                        {
1339
                            List<Point> lstPoint = StylusPointSet[i].pointSet;
1340
                            for (int j = 0; j < lstPoint.Count; j++)
1341
                            {
1342
                                lstPoint[j] = new Point(lstPoint[j].X + px.X, lstPoint[j].Y + px.Y);
1343
                            }
1344
                        }
1345

    
1346
                        for (int i = 0; i < item.ThumbList.Count; i++)
1347
                        {
1348
                            Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + px.X);
1349
                            Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + px.Y);
1350
                        }
1351
                        (item.DrawingData as IPath).updateControl();
1352
                        BorderUpdate();
1353

    
1354
                    }
1355
                    #endregion
1356
                    BorderUpdate();
1357
                }
1358
            }));
1359
        }
1360

    
1361
        public void DynamicThumbUpdate(DragDeltaEventArgs e, AdornerMember item)
1362
        {
1363
            var AllControl = item.DrawingData as IPath;
1364
            List<Point> point = AllControl.PointSet;
1365
            for (int i = 0; i < item.ThumbList.Count(); i++)
1366
            {
1367
                if (item.DrawingData.GetType().Name == "ArrowTextControl")
1368
                {
1369
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1370
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1371
                    AllControl.updateControl();
1372
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1373
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1374

    
1375
                    Canvas.SetLeft(item.ThumbList.Last(), Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1376
                    Canvas.SetTop(item.ThumbList.Last(), Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1377
                }
1378
                else
1379
                {
1380
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1381
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1382
                    AllControl.updateControl();
1383
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1384
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1385
                }
1386
            }
1387
        }
1388

    
1389
        public void DynamicThumbUpdate(AdornerMember item)
1390
        {
1391
            var AllControl = item.DrawingData as IPath;
1392
            List<Point> point = AllControl.PointSet;
1393

    
1394
            for (int i = 0; i < AllControl.PointSet.Count(); i++)
1395
            {
1396

    
1397
                Canvas.SetLeft(item.ThumbList[i], AllControl.PointSet[i].X);
1398
                Canvas.SetTop(item.ThumbList[i], AllControl.PointSet[i].Y);
1399
            }
1400

    
1401

    
1402
            if (item.DrawingData as ArrowTextControl != null)
1403
            {
1404
                if (!(item.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
1405
                {
1406
                    List<Point> ps = new List<Point>();
1407

    
1408
                    var temp = item.DrawingData as ArrowTextControl;
1409
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1410
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1411
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1412
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1413

    
1414

    
1415

    
1416
                    if (temp.isFixed)
1417
                    {
1418
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1419
                        var testP = endP;
1420
                        if (ps[0] == endP) //상단
1421
                        {
1422
                            testP = new Point(endP.X, endP.Y - 50);
1423
                            //System.Diagnostics.Debug.WriteLine("상단");
1424
                        }
1425
                        else if (ps[1] == endP) //하단
1426
                        {
1427
                            testP = new Point(endP.X, endP.Y + 50);
1428
                            //System.Diagnostics.Debug.WriteLine("하단");
1429
                        }
1430
                        else if (ps[2] == endP) //좌단
1431
                        {
1432
                            testP = new Point(endP.X - 50, endP.Y);
1433
                            //System.Diagnostics.Debug.WriteLine("좌단");
1434
                        }
1435
                        else if (ps[3] == endP) //우단
1436
                        {
1437
                            testP = new Point(endP.X + 50, endP.Y);
1438
                            //System.Diagnostics.Debug.WriteLine("우단");
1439
                        }
1440
                        Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], testP.X);
1441
                        Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], testP.Y);
1442
                    }
1443
                    else
1444
                    {
1445
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1446
                        var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1447
                        Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X);
1448
                        Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y);
1449
                    }
1450
                }
1451
            }
1452
            //}
1453
        }
1454

    
1455
        public void Set_Rotate()
1456
        {
1457

    
1458
            double dDeltaAngle = 0;
1459
            List<Point> AllPointSet = new List<Point>();
1460
            Point CenterPoint = new Point();
1461

    
1462

    
1463
            if (AngleValue >= 360)
1464
            {
1465
                AngleValue -= 360;
1466
            }
1467
            else if (AngleValue <= -360)
1468
            {
1469
                AngleValue += 360;
1470
            }
1471

    
1472
            #region 센터 포인트 구하기 (그룹핑)
1473
            foreach (var item in MemberSet)
1474
            {
1475
                if (item.DrawingData.GetType().Name == "TextControl")
1476
                {
1477
                }
1478
                else
1479
                {
1480
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1481
                    {
1482
                        AllPointSet.Add(itemP);
1483
                    }
1484
                }
1485
            }
1486
            #endregion
1487

    
1488
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1489

    
1490
            Dispatcher.BeginInvoke((Action)(() =>
1491
            {
1492
                foreach (var item in MemberSet)
1493
                {
1494
                    foreach (var thumb in item.ThumbList)
1495
                    {
1496
                        double x = Canvas.GetLeft(thumb);
1497
                        double y = Canvas.GetTop(thumb);
1498

    
1499
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1500
                        Canvas.SetLeft(thumb, value.X);
1501
                        Canvas.SetTop(thumb, value.Y);
1502

    
1503
                        if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last())
1504
                        {
1505

    
1506
                            Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1507
                            Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1508
                            if (!(item.DrawingData as ArrowTextControl).isTrans)
1509
                            {
1510
                                List<Point> ps = new List<Point>();
1511
                                var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
1512
                                switch (Math.Abs(temp.Angle).ToString())
1513
                                {
1514
                                    case "90":
1515
                                        {
1516
                                            ps.Clear();
1517
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1518
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
1519
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
1520

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

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

    
1527
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
1528
                                        }
1529
                                        break;
1530
                                    case "270":
1531
                                        {
1532
                                            ps.Clear();
1533
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1534
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
1535
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
1536

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

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

    
1543
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
1544
                                        }
1545
                                        break;
1546
                                    default:
1547
                                        {
1548
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1549
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1550
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1551
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1552
                                        }
1553
                                        break;
1554
                                }
1555

    
1556
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1557
                                var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1558
                                Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X);
1559
                                Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y);
1560
                            }
1561
                        }
1562
                    }
1563

    
1564
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1565
                    {
1566
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1567
                    }
1568
                }
1569
                #region 컨트롤 업데이트
1570
                foreach (var item in MemberSet)
1571
                {
1572
                    switch (item.Drawingtype)
1573
                    {
1574
                        case ControlType.TextControl:
1575
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1576

    
1577
                            RectangleGeometry Data = new RectangleGeometry
1578
                            {
1579
                                Rect = new Rect()
1580
                                {
1581
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1582
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1583
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1584
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1585
                                }
1586
                            };
1587

    
1588
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1589
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);                                                      
1590

    
1591
                            DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
1592
                            DragThumb.RenderTransform = new RotateTransform()
1593
                            {
1594
                                Angle = (item.DrawingData as TextControl).Angle,
1595

    
1596
                            };
1597

    
1598
                            AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
1599
                            AdornerBorder.RenderTransform = new RotateTransform()
1600
                            {
1601
                                Angle = (item.DrawingData as TextControl).Angle,
1602

    
1603
                            };
1604

    
1605
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1606
                            {
1607
                                Angle = (item.DrawingData as TextControl).Angle,
1608
                            };
1609
                            BorderUpdate();
1610
                            break;
1611

    
1612
                        case ControlType.Date:
1613
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1614
                            (item.DrawingData as IPath).updateControl();
1615
                            BorderUpdate();
1616
                            break;
1617
                        case ControlType.ArrowMultiLine:
1618
                        case ControlType.ArcLine:
1619
                        case ControlType.ArcArrow:
1620
                        case ControlType.SingleLine:
1621
                        case ControlType.Triangle:
1622
                            (item.DrawingData as IPath).updateControl();
1623
                            BorderUpdate();
1624
                            break;
1625
                        case ControlType.ArrowTextControl:
1626
                            (item.DrawingData as IPath).updateControl();
1627
                            BorderUpdate();
1628
                            break;
1629
                        case ControlType.RectCloud:
1630
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1631
                            (item.DrawingData as IPath).updateControl();
1632
                            BorderUpdate();
1633
                            break;
1634
                        case ControlType.Rectangle:
1635
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1636
                            (item.DrawingData as IPath).updateControl();
1637
                            BorderUpdate();
1638
                            break;
1639
                        case ControlType.ImgControl:
1640
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1641
                            (item.DrawingData as IPath).updateControl();
1642
                            BorderUpdate();
1643
                            break;
1644
                        case ControlType.Sign:
1645
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1646
                            (item.DrawingData as IPath).updateControl();
1647
                            BorderUpdate();
1648
                            break;
1649
                        case ControlType.Symbol:
1650
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1651
                            (item.DrawingData as IPath).updateControl();
1652
                            BorderUpdate();
1653
                            break;
1654
                        case ControlType.Stamp:
1655
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1656
                            (item.DrawingData as IPath).updateControl();
1657
                            BorderUpdate();
1658
                            break;
1659
                        case ControlType.PolygonControl:
1660
                            (item.DrawingData as IPath).updateControl();
1661
                            BorderUpdate();
1662
                            break;
1663
                        case ControlType.PolygonCloud:
1664
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1665
                            (item.DrawingData as IPath).updateControl();
1666
                            BorderUpdate();
1667
                            break;
1668
                        case ControlType.Circle:
1669
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1670
                            (item.DrawingData as IPath).updateControl();
1671
                            ((CircleControl)item.DrawingData).SetCenterXY();
1672
                            BorderUpdate();
1673
                            break;
1674
                        case ControlType.Ink:
1675
                            (item.DrawingData as IPath).updateControl();
1676
                            BorderUpdate();
1677
                            break;
1678
                        case ControlType.InsideWhite:
1679
                            ((InsideWhiteControl)item.DrawingData).Angle = AngleValue;
1680
                            (item.DrawingData as IPath).updateControl();
1681
                            BorderUpdate();
1682
                            break;
1683
                        case ControlType.OverlapWhite:
1684
                            ((OverlapWhiteControl)item.DrawingData).Angle = AngleValue;
1685
                            (item.DrawingData as IPath).updateControl();
1686
                            BorderUpdate();
1687
                            break;
1688
                        case ControlType.ClipWhite:
1689
                            ((ClipWhiteControl)item.DrawingData).Angle = AngleValue;
1690
                            (item.DrawingData as IPath).updateControl();
1691
                            BorderUpdate();
1692
                            break;
1693
                        case ControlType.Coordinate:
1694
                            ((CoordinateControl)item.DrawingData).Angle = AngleValue;
1695
                            (item.DrawingData as IPath).updateControl();
1696
                            BorderUpdate();
1697
                            break;
1698
                        default:
1699
                            break;
1700
                    }
1701
                }
1702
                #endregion
1703
            }));
1704
        }
1705

    
1706
        private void resize_MouseMove(object sender, MouseEventArgs e)
1707
        {
1708
            reSizePoint = e.GetPosition(this);
1709
        }
1710
        /// <summary>
1711
        /// 회전
1712
        /// </summary>
1713
        /// <param name="sender"></param>
1714
        /// <param name="e"></param>
1715
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1716
        {
1717

    
1718
            MoveRotate(e);
1719
        }
1720

    
1721
        double LastRotateHorizontalValue = 0;
1722
        double LastRotateVerticalValue = 0;
1723
        //double LastWidthValue = 0;
1724
        //double SetWidth = 0;
1725
        bool RotateFlag = false;
1726

    
1727
        /// <summary>
1728
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1729
        /// </summary>
1730
        /// <param name="e"></param>
1731
        public void MoveRotate(DragDeltaEventArgs e)
1732
        {
1733
            double dDeltaAngle = 0;
1734

    
1735
            List<Point> AllPointSet = new List<Point>();
1736
            Point CenterPoint = new Point();
1737
            
1738
            #region 센터 포인트 구하기 (그룹핑)
1739
            foreach (var item in MemberSet)
1740
            {
1741
                if (item.DrawingData.GetType().Name == "TextControl")
1742
                {                    
1743
                    if (AngleValue == 0)
1744
                    {
1745
                        AngleValue = (item.DrawingData as TextControl).Angle;
1746
                    }
1747
                    double X = Canvas.GetLeft((item.DrawingData as TextControl));
1748
                    double Y = Canvas.GetTop((item.DrawingData as TextControl));
1749
                    AllPointSet.Add(new Point(X, Y));
1750
                }
1751
                else
1752
                {
1753
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1754
                    {
1755
                        AllPointSet.Add(itemP);
1756
                    }
1757
                }
1758
            }
1759
            #endregion
1760
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1761
            Point pt = Mouse.GetPosition(this);
1762

    
1763
            Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
1764
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1765
            dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1766

    
1767
            //System.Diagnostics.Debug.WriteLine("vec1 : " + vec1.X + "/" + vec1.Y);
1768
            //System.Diagnostics.Debug.WriteLine("vec2 : " + vec2.X + "/" + vec2.Y);
1769
            //System.Diagnostics.Debug.WriteLine("dDeltaAngle : " + dDeltaAngle);
1770

    
1771
            AngleValue += dDeltaAngle;
1772
            if (AngleValue > 360) AngleValue -= 360;
1773
            if (AngleValue < 0) AngleValue += 360;
1774
            this.rotatePoint = pt;  /// save rotatePoint
1775

    
1776
            Dispatcher.BeginInvoke((Action)(() =>
1777
            {
1778
                foreach (var item in MemberSet)
1779
                {
1780
                    foreach (var thumb in item.ThumbList)
1781
                    {
1782
                        double x = Canvas.GetLeft(thumb);
1783
                        double y = Canvas.GetTop(thumb);
1784

    
1785
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1786
                        Canvas.SetLeft(thumb, value.X);
1787
                        Canvas.SetTop(thumb, value.Y);
1788
                    }
1789

    
1790
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1791
                    {
1792
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1793
                    }
1794
                }
1795
                #region 보더 업데이트
1796
                foreach (var item in MemberSet)
1797
                {
1798
                    switch (item.Drawingtype)
1799
                    {
1800
                        case ControlType.TextControl:
1801
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1802

    
1803
                            RectangleGeometry Data = new RectangleGeometry
1804
                            {
1805
                                Rect = new Rect()
1806
                                {
1807
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1808
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1809
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1810
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1811
                                }
1812
                            };
1813

    
1814
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1815
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);
1816

    
1817
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1818
                            DragThumb.RenderTransform = new RotateTransform()
1819
                            {
1820
                                Angle = (item.DrawingData as TextControl).Angle,
1821
                                //CenterX = middle.X,
1822
                                //CenterY = middle.Y,
1823
                            };
1824

    
1825
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1826
                            AdornerBorder.RenderTransform = new RotateTransform()
1827
                            {
1828
                                Angle = (item.DrawingData as TextControl).Angle,
1829
                                //CenterX = middle.X,
1830
                                //CenterY = middle.Y,
1831
                            };
1832

    
1833
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1834
                            {
1835
                                Angle = (item.DrawingData as TextControl).Angle,
1836
                            };
1837

    
1838
                            BorderUpdate();
1839
                            break;
1840

    
1841
                        case ControlType.Date:
1842
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1843
                            (item.DrawingData as IPath).updateControl();
1844
                            BorderUpdate();                          
1845
                            break;
1846
                        case ControlType.ArrowMultiLine:
1847
                        case ControlType.ArcLine:
1848
                        case ControlType.ArcArrow:
1849
                        case ControlType.SingleLine:
1850
                        case ControlType.Triangle:
1851
                            (item.DrawingData as IPath).updateControl();
1852
                            BorderUpdate();
1853
                            break;
1854
                        case ControlType.ArrowTextControl:
1855
                            (item.DrawingData as IPath).updateControl();
1856
                            BorderUpdate();
1857
                            break;
1858
                        case ControlType.RectCloud:
1859
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1860
                            (item.DrawingData as IPath).updateControl();
1861
                            BorderUpdate();
1862
                            break;
1863
                        case ControlType.Rectangle:
1864
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1865
                            (item.DrawingData as IPath).updateControl();
1866
                            BorderUpdate();
1867
                            break;
1868
                        case ControlType.ImgControl:
1869
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1870
                            (item.DrawingData as IPath).updateControl();
1871
                            BorderUpdate();
1872
                            break;                        
1873
                        case ControlType.Sign:
1874
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1875
                            (item.DrawingData as IPath).updateControl();
1876
                            BorderUpdate();
1877
                            break;                        
1878
                        case ControlType.Symbol:
1879
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1880
                            (item.DrawingData as IPath).updateControl();
1881
                            BorderUpdate();
1882
                            break;
1883
                        case ControlType.Stamp:
1884
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1885
                            (item.DrawingData as IPath).updateControl();
1886
                            BorderUpdate();
1887
                            break;
1888
                        case ControlType.PolygonControl:
1889
                            (item.DrawingData as IPath).updateControl();
1890
                            BorderUpdate();
1891
                            break;
1892
                        case ControlType.PolygonCloud:
1893
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1894
                            (item.DrawingData as IPath).updateControl();
1895
                            BorderUpdate();
1896
                            break;
1897
                        case ControlType.Circle:
1898
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1899
                            (item.DrawingData as IPath).updateControl();
1900
                            ((CircleControl)item.DrawingData).SetCenterXY();
1901
                            BorderUpdate();
1902
                            break;
1903
                        case ControlType.Ink:
1904
                            for (int i = 0; i < (item.DrawingData as InkControl).PointC.Count(); i++)
1905
                            {
1906
                                for (int j = 0; j < (item.DrawingData as InkControl).PointC[i].pointSet.Count; j++)
1907
                                {
1908
                                    (item.DrawingData as InkControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as InkControl).PointC[i].pointSet[j], dDeltaAngle);
1909
                                }
1910
                            }
1911
                            (item.DrawingData as IPath).updateControl();
1912
                            BorderUpdate();
1913
                            break;
1914
                        
1915
                        default:
1916
                            break;
1917
                    }
1918
                }
1919
                #endregion
1920
            }));
1921
            BorderUpdate();
1922
        }
1923

    
1924
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1925
        {            
1926

    
1927
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1928
            rotateTop.Cursor = Cursors.SizeAll;
1929

    
1930
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1931
            if ((1 == MemberSet.Count) && (MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1932
            {
1933
                this.AngleValue = ((MemberSet.First() as AdornerMember).DrawingData as TextControl).Angle;
1934
            }
1935
            /// up to here
1936

    
1937

    
1938

    
1939
            if (ViewerDataModel.Instance.UndoDataList == null)
1940
            {
1941
                return;
1942
            }
1943

    
1944
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1945
            {
1946
                return;
1947
            }
1948

    
1949
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1950
            {
1951
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1952
                {
1953
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1954
                    {
1955
                        return;
1956
                    }
1957
                }
1958
            }
1959

    
1960
            var comments = (from drawing in this.MemberSet
1961
                            select drawing.DrawingData as CommentUserInfo).ToList();
1962
            UndoCommand.Instance.Push(comments, this.AngleValue);
1963
        }
1964
        
1965
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1966
        {
1967
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1968

    
1969
            var comments = (from drawing in this.MemberSet
1970
                            select drawing.DrawingData as CommentUserInfo).ToList();
1971
            UndoCommand.Instance.Push(comments, this.AngleValue);
1972
        }
1973

    
1974
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1975
        {
1976
            if (ViewerDataModel.Instance.UndoDataList == null)
1977
            {
1978
                return;
1979
            }
1980
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1981
            {
1982
                return;
1983
            }
1984
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1985
            {
1986
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1987
                {
1988
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1989
                    {
1990
                        return;
1991
                    }
1992
                }
1993
            }
1994

    
1995
            var comments = (from drawing in this.MemberSet
1996
                            select drawing.DrawingData as CommentUserInfo).ToList();
1997
            UndoCommand.Instance.Push(comments, this.AngleValue);
1998
        }
1999

    
2000
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
2001
        {          
2002
            DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2003

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

    
2009
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
2010
        {
2011
            AdornerMember control = MemberSet.FirstOrDefault();
2012

    
2013
            if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null)
2014
            {
2015
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
2016
                {
2017
                    (control.DrawingData as ArrowTextControl).isTrans = true;
2018
                }
2019
            }
2020

    
2021
        }
2022

    
2023
        public void TextControlChanger()
2024
        {
2025
            if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2026
            {
2027
                TextControl AllControl = (MemberSet.First() as AdornerMember).DrawingData as TextControl;
2028
                AllControl.Base_TextBox.Focus();
2029
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
2030
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
2031
                AllControl.Base_TextBox.Focus();
2032
                AllControl.SizeChanged += (sen, ea) =>
2033
                {
2034
                    if (AllControl.Base_TextBox != null)
2035
                    {
2036
                        RectangleGeometry Data = new RectangleGeometry
2037
                        {
2038
                            Rect = new Rect()
2039
                            {
2040
                                X = AllControl.StartPoint.X,
2041
                                Y = AllControl.StartPoint.Y,
2042
                                Width = AllControl.Base_TextBox.Width,
2043
                                Height = AllControl.Base_TextBox.Height,
2044
                            }
2045
                        };
2046

    
2047
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
2048
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
2049
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
2050
                        {
2051
                            Angle = AllControl.Angle,
2052
                            CenterX = middle.X,
2053
                            CenterY = middle.Y,
2054
                        };
2055
                    }
2056
                    BorderUpdate();
2057
                };
2058
            }
2059
        }
2060

    
2061
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
2062
        {
2063
            if (e.ClickCount == 2 && MemberSet.Count == 1)
2064
            {
2065

    
2066
                if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2067
                {
2068
                    TextControlChanger();                    
2069
                }
2070

    
2071
                else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2072
                {
2073
                    ArrowTextControl AllControl = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
2074
                    Thumb tm = (MemberSet.First() as AdornerMember).ThumbList.Last();
2075
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
2076

    
2077
                    //ArrowControl TextBox Thumb없애기
2078
                    tm.Visibility = Visibility.Collapsed;
2079

    
2080
                    ((MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
2081
                    
2082
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
2083

    
2084
                    {
2085
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
2086
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
2087

    
2088
                        List<Point> ps = new List<Point>();
2089
                        
2090
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
2091
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
2092
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
2093
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
2094

    
2095

    
2096

    
2097

    
2098
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
2099
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
2100
                        if (AllControl.isTrans)
2101
                        {
2102
                            Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
2103
                            Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
2104
                        }
2105
                        else
2106
                        {
2107
                            Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X);
2108
                            Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y);
2109
                        }
2110

    
2111

    
2112
                        BorderUpdate();
2113

    
2114
                    };
2115
                }
2116
                else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
2117
                {
2118
                    DateControl data = (MemberSet.First() as AdornerMember).DrawingData as DateControl;
2119
                    CalendarControl instanceCal = new CalendarControl(data.Text);
2120
                    //dropData.IsOpen = true;
2121
                    RadWindow rc = new RadWindow();
2122
                    rc.Width = 300;
2123
                    rc.Height = 300;
2124
                    rc.Header = "Change Date";
2125
                    rc.Content = instanceCal;
2126
                    rc.BorderThickness = new Thickness(3);
2127
                    rc.ResizeMode = ResizeMode.NoResize;
2128
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2129
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
2130
                    rc.ModalBackground.Opacity = 0.6;
2131
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
2132
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
2133
                    {
2134
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
2135
                        rc.Close();
2136
                    };
2137
                    rc.ShowDialog();
2138
                    //CalendarControl.xaml
2139
                }
2140
                else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
2141
                {
2142
                    ArcControl instance = ((MemberSet.First() as AdornerMember).DrawingData as ArcControl);
2143
                    if (instance.isTransOn)
2144
                    {
2145
                        instance.isTransOn = false;
2146
                    }
2147
                    else
2148
                    {
2149
                        instance.isTransOn = true;
2150
                    }
2151
                    ///instance.SetArcPath();
2152
                    BorderUpdate();
2153
                }
2154
                else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
2155
                {
2156
                    ArrowArcControl instance = ((MemberSet.First() as AdornerMember).DrawingData as ArrowArcControl);
2157
                    if (instance.isTransOn)
2158
                    {
2159
                        instance.isTransOn = false;
2160
                    }
2161
                    else
2162
                    {
2163
                        instance.isTransOn = true;
2164
                    }
2165
                    instance.SetArcPath();
2166
                    BorderUpdate();
2167
                }
2168

    
2169
            }
2170
            
2171
        }
2172
        #endregion
2173

    
2174
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2175
        {
2176
            if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2177
            {
2178
                DragThumb.Visibility = Visibility.Collapsed;
2179
            }
2180
        }
2181

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