프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 190248a5

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

1
using KCOM.Common;
2
using MarkupToPDF.Common;
3
using MarkupToPDF.Controls.Common;
4
using MarkupToPDF.Controls.Etc;
5
using MarkupToPDF.Controls.Line;
6
using MarkupToPDF.Controls.Polygon;
7
using MarkupToPDF.Controls.Shape;
8
using MarkupToPDF.Controls.Text;
9
using System;
10
using System.Collections.Generic;
11
using System.Linq;
12
using System.Reactive.Linq;
13
using System.Text;
14
using System.Windows;
15
using System.Windows.Controls;
16
using System.Windows.Controls.Primitives;
17
using System.Windows.Input;
18
using System.Windows.Media;
19
using Telerik.Windows.Controls;
20

    
21
namespace KCOM.Controls
22
{
23
    /// <summary>
24
    /// Interaction logic for AdornerFinal.xaml
25
    /// </summary>
26
    public class AdornerMember
27
    {
28
        public UIElement DrawingData { get; set; }
29
        public ControlType Drawingtype { get; set; }
30
        public double DrawingAngle { get; set; }
31
        public List<Thumb> ThumbList { get; set; }
32
        public string Symbol_ID { get; set; }
33
    }
34
    public partial class AdornerFinal : UserControl
35
    {
36
        public TextBox editTextBox { get; set; }
37
        #region 공용 인스턴스
38
        public List<AdornerMember> MemberSet { get; set; }
39
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
40
        public double AngleValue = 0;
41
        public bool IsTextAngle = false;
42
        public Rect BorderSize { get; set; }
43
        public bool TextCompensation = false;
44
        public bool isDragging { get; set; }
45
        public Thumb DraggerThumb { get; set; }
46
        public RadDropDownButton dropData;
47
        public RadCalendar dropCalendar;
48
        public Thumb mainDragThumb { get; set; }
49

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

    
80
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
81
        {
82
            mainDragThumb = DragThumb;
83
        }
84

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

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

    
123
                }
124
            }
125
            SetAdornerMember(objectData);
126
            this.Focus();
127
        }
128

    
129
        #endregion
130
        #region 메서드
131
        public Rect getAdornerSize()
132
        {
133
            return BorderSize;
134
        }
135
        public void addMemberControl(UIElement objectData)
136
        {
137
            this.ContainerContent.Children.Add(objectData);
138
            SetAdornerMember(objectData as CommentUserInfo);
139
            this.Focus();
140
        }
141
        /// <summary>
142
        /// UIElement를 종류에 맞게 등록시킴
143
        /// </summary>
144
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
145
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
146
        {         
147
            
148
            switch (member.GetType().Name)
149
            {
150
                #region 컨트롤 조건
151
                case "LineControl": //Angle추가 안했음
152
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
153
                    break;
154
                case "ImgControl": //Angle추가 안했음
155
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
156
                    //AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);            
157
                    //DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
158
                    AngleValue = (member as ImgControl).Angle;
159
                    break;
160
                //case "SymControl": //Angle추가 안했음
161
                //    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() });
162
                //    AngleValue = (member as SymControl).Angle;
163
                //    //ViewBoxRotate(member);
164
                //    break;
165
                //case "SymControlN": //Angle추가 안했음
166
                //    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() });
167
                //    AngleValue = (member as SymControlN).Angle;
168
                //    //ViewBoxRotate(member);
169
                //    break;
170
                case "PolygonControl": //Angle추가 안했음
171
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
172
                    break;
173
                case "ArrowControl":
174
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
175
                    break;
176
                case "ArrowTextControl":
177
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
178
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
179
                    AngleValue = (member as ArrowTextControl).Angle;
180
                    Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
181
                    {
182
                        TextCompensation = false;
183
                        BorderUpdate();
184
                        if ((a.Sender as TextBox).Text == "") //보류
185
                        {
186
                            this.ContainerContent.Children.Remove(member);
187
                            this.Visibility = Visibility.Collapsed;
188
                        }
189
                    });
190
                    break;
191
                case "ArcControl":
192
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
193
                    break;
194
                case "ArrowArcControl":
195
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
196
                    break;
197
                case "ArrowControl_Multi":
198
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
199
                    break;
200
                case "RectangleControl":
201
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
202
                    break;
203
                case "DateControl":
204
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
205
                    AngleValue = (member as DateControl).Angle;
206
                    break;
207
                case "TriControl":
208
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
209
                    break;
210
                case "CircleControl":
211
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
212
                    break;
213
                case "CloudControl":
214
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
215
                    break;
216
                case "RectCloudControl":
217
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
218
                    break;
219
                case "SignControl":
220
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
221
                    AngleValue = (member as SignControl).Angle;
222
                    break;
223
     
224
                case "SymControl":
225
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
226
                    AngleValue = (member as SymControl).Angle;
227
                    break;
228
                case "SymControlN":
229
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
230
                    AngleValue = (member as SymControlN).Angle;
231
                    break;
232
                case "InkControl": //Angle추가 안했음
233
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
234
                    break;
235
                case "TextControl":
236
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
237
                    RectangleGeometry Data = new RectangleGeometry
238
                    {
239
                        Rect = new Rect()
240
                        {
241
                            X = Canvas.GetLeft((member as TextControl)),
242
                            Y = Canvas.GetTop((member as TextControl)),
243
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
244
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
245
                            //Width = (member as TextControl).BoxWidth / 2,
246
                            //Height = (member as TextControl).BoxHeight / 2,
247
                        }
248
                    };
249
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
250
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
251

    
252

    
253
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
254
                    DragThumb.RenderTransform = new RotateTransform()
255
                    {
256
                        Angle = (member as TextControl).Angle,
257
                        //CenterX = middle.X,
258
                        //CenterY = middle.Y,
259
                    };
260

    
261
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
262
                    AdornerBorder.RenderTransform = new RotateTransform()
263
                    {
264
                        Angle = (member as TextControl).Angle,
265
                        //CenterX = middle.X,
266
                        //CenterY = middle.Y,
267
                    };
268
                    Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
269
                    {
270
                        TextCompensation = true;
271
                        BorderUpdate();
272
                        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
273
                    });
274
                    Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
275
                    {
276
                        TextCompensation = false;
277
                        BorderUpdate();
278
                        if ((a.Sender as TextBox).Text == "") //보류
279
                        {
280
                            this.ContainerContent.Children.Remove(member);
281
                            this.Visibility = Visibility.Collapsed;
282
                        }
283

    
284
                        //((TextControl)member).UnEditingMode();
285
                        //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
286
                        //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
287
                        //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
288
                    });
289
                    break;
290
                default:
291
                    break;
292
                    #endregion
293
            }
294
            if (member.GetType().Name == "TextControl")
295
            {
296
                TextControl content = ((TextControl)member);
297
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
298
                content.EndPoint = content.StartPoint;
299

    
300
            }
301
            else
302
            {
303
                RegistryPoint(member);
304
            }
305
            BorderUpdate();
306
        }
307

    
308
        private void ViewBoxRotate(UIElement member)
309
        {
310
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
311
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
312
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
313
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
314
        }
315
        public void SetAdornerMember(List<CommentUserInfo> members)
316
        {
317
            foreach (var member in members)
318
            {
319
                switch (member.GetType().Name)
320
                {
321
                    #region 컨트롤 조건
322
                    case "LineControl": 
323
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
324
                        break;
325
                    case "ImgControl": 
326
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
327
                        break;                    
328
                    case "ArrowControl":
329
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
330
                        break;
331
                    case "PolygonControl": 
332
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
333
                        break;
334
                    case "ArrowTextControl":
335
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
336
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
337
                        break;
338
                    case "ArcControl":
339
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
340
                        break;
341
                    case "ArrowArcControl":
342
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
343
                        break;
344
                    case "DateControl":
345
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
346
                        break;
347
                    case "ArrowControl_Multi":
348
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
349
                        break;
350
                    case "RectangleControl":
351
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
352
                        break;
353
                    case "TriControl":
354
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
355
                        break;
356
                    case "CircleControl":
357
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
358
                        break;
359
                    case "CloudControl":
360
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
361
                        break;
362
                    case "RectCloudControl":
363
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
364
                        break;
365
                    case "SignControl":
366
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
367
                        break;
368
                    case "SymControl":
369
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
370
                        break;
371
                    case "SymControlN":
372
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
373
                        break;
374
                    case "InkControl": 
375
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
376
                        break;
377
                    case "TextControl":
378
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID });
379
                        Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
380
                        {
381
                            BorderUpdate();
382
                            try
383
                            {
384
                                ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
385
                            }
386
                            catch (Exception)
387
                            {
388

    
389
                            }
390

    
391
                        });
392
                        Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
393
                        {
394
                            BorderUpdate();
395
                        });
396
                        break;
397
                    default:
398
                        break;
399
                        #endregion
400
                }
401
                if (member.GetType().Name == "TextControl")
402
                {
403
                    TextControl content = ((TextControl)member);
404
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
405
                    content.EndPoint = content.StartPoint;
406
                }
407
                else
408
                {
409
                    RegistryPoint(member, members.Count);
410
                }
411
            }
412

    
413
            BorderUpdate();
414
        }
415

    
416
        /// <summary>
417
        /// Border 를 갱신
418
        /// </summary>
419
        public void BorderUpdate()
420
        {
421
            AdornerBorder.MinWidth = 10;
422
            AdornerBorder.MinHeight = 10;
423

    
424
            double minX = double.MaxValue;
425
            double minY = double.MaxValue;
426
            double maxX = double.MinValue;
427
            double maxY = double.MinValue;
428

    
429
            if (MemberSet.Count == 1)
430
            {
431
                if (MemberSet.First().DrawingData.GetType().Name == "TextControl")
432
                {
433
                    if ((MemberSet.First().DrawingData as TextControl).Angle != 0)
434
                    {
435
                        trRotate.Angle = (MemberSet.First().DrawingData as TextControl).Angle;
436
                        trRotateThumb.Angle = (MemberSet.First().DrawingData as TextControl).Angle;
437
                    }
438
                    else
439
                    {
440
                        trRotate.Angle = 0;
441
                        trRotateThumb.Angle = 0;
442
                    }
443
                }
444
            }
445
            foreach (var item in MemberSet)
446
            {
447
                UIElement currentControl = (item as AdornerMember).DrawingData;
448
                if (item.DrawingData.GetType().Name == "TextControl")
449
                {
450
                    double textControlWidth;
451
                    double textControlHeight;
452
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
453
                    {
454
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
455
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
456
                    }
457
                    else
458
                    {
459
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
460
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
461
                    }
462
                    
463
                    if ((currentControl as TextControl).EndPoint.X < minX)
464
                    {
465
                        minX = (currentControl as TextControl).EndPoint.X;
466
                    }
467
                    if ((currentControl as TextControl).EndPoint.Y < minY)
468
                    {
469
                        minY = (currentControl as TextControl).EndPoint.Y;
470
                    }
471
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
472
                    {
473
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
474
                    }
475
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
476
                    {
477
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
478
                    }
479
                }
480
                else if ((currentControl as IViewBox) != null)
481
                {
482
                    IViewBox instance = currentControl as IViewBox;
483
                    List<Point> am = (currentControl as IPath).PointSet;
484
                    List<double> xSet = am.Select(p => p.X).ToList();
485
                    List<double> ySet = am.Select(p => p.Y).ToList();
486
                    if (xSet.Min() < minX) minX = xSet.Min();
487
                    if (ySet.Min() < minY) minY = ySet.Min();
488
                    if (xSet.Max() > maxX) maxX = xSet.Max();
489
                    if (ySet.Max() > maxY) maxY = ySet.Max();
490
                }
491
                else if ((currentControl as IPath).PathData == null)
492
                {
493
                    Rect rt = new Rect
494
                    {
495
                        X = (currentControl as IPath).StartPoint.X,
496
                        Y = (currentControl as IPath).StartPoint.Y,
497
                        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),
498
                        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),
499
                    };
500
                    if (rt.Left < minX) minX = rt.Left;
501
                    if (rt.Top < minY) minY = rt.Top;
502
                    if (rt.Right > maxX) maxX = rt.Right;
503
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
504
                }
505
                else if ((currentControl as IPath) == null)
506
                {
507
                    Rect rt = new Rect
508
                    {
509
                        X = (currentControl as IPath).StartPoint.X,
510
                        Y = (currentControl as IPath).StartPoint.Y,
511
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
512
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
513
                    };
514
                    if (rt.Left < minX) minX = rt.Left;
515
                    if (rt.Top < minY) minY = rt.Top;
516
                    if (rt.Right > maxX) maxX = rt.Right;
517
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
518
                }
519
                else if ((currentControl as CircleControl) != null)
520
                {                    
521
                    List<Point> am = (currentControl as IPath).PointSet;
522
                    List<double> xSet = am.Select(p => p.X).ToList();
523
                    List<double> ySet = am.Select(p => p.Y).ToList();
524
                    if (xSet.Min() < minX) minX = xSet.Min();
525
                    if (ySet.Min() < minY) minY = ySet.Min();
526
                    if (xSet.Max() > maxX) maxX = xSet.Max();
527
                    if (ySet.Max() > maxY) maxY = ySet.Max();
528
                }
529
                else
530
                {
531
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
532
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
533
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
534
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
535
                }
536
            }
537

    
538
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
539
            bool addWidthSize = false;
540
            bool addHeightSize = false;
541
            if (ac.Width <= 10)
542
            {
543
                ac.Width += 10;
544
                addWidthSize = true;
545
            }
546
            if (ac.Height <= 10)
547
            {
548
                ac.Height += 10;
549
                addHeightSize = true;
550
            }
551
            BorderSize = ac;
552
            AdornerBorder.MinWidth = 10;
553
            AdornerBorder.MinHeight = 10;
554
            AdornerBorder.Width = ac.Width;
555
            AdornerBorder.Height = ac.Height;
556
            Canvas.SetLeft(AdornerBorder, minX);
557
            Canvas.SetTop(AdornerBorder, minY);
558

    
559
            DragThumb.Width = ac.Width;
560
            DragThumb.Height = ac.Height;
561

    
562
            DragThumb.MinWidth = 10;
563
            DragThumb.MinHeight = 10;
564
            if (addWidthSize)
565
            {
566
                Canvas.SetLeft(DragThumb, minX - 5);
567
            }
568
            else
569
            {
570
                Canvas.SetLeft(DragThumb, minX);
571
            }
572

    
573
            if (addHeightSize)
574
            {
575
                Canvas.SetTop(DragThumb, minY - 5);
576
            }
577
            else
578
            {
579
                Canvas.SetTop(DragThumb, minY);
580
            }
581
        }
582
        /// <summary>
583
        /// UIElement 해제
584
        /// </summary>
585
        public void unRegister()
586
        {
587
            foreach (var item in this.ContainerContent.Children)
588
            {
589
                if (item is MarkupToPDF.Common.CommentUserInfo)
590
                {
591
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
592
                }
593
            }
594
            this.ContainerContent.Children.Clear();
595
        }
596
        /// <summary>
597
        /// 각 포인트들을 등록합니다.
598
        /// </summary>
599
        /// <param name="pointset">Drawing Point</param>
600
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
601
         {
602
            int count = 0;
603
            double Minx = 100000000;
604
            double Miny = 100000000;
605
            List<Point> list = (member as IPath).PointSet;
606
            if (member.GetType().Name == "InkControl")
607
            {
608
                list.Clear();
609
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
610
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
611
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
612
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
613
            }
614
            ControlType markT = MemberSet.Where(p => p.DrawingData == member).First().Drawingtype;
615
            foreach (var ax in list)
616
            {
617
                Minx = (ax.X < Minx) ? ax.X : Minx;
618
                Miny = (ax.Y < Miny) ? ax.Y : Miny;
619
            }
620
            for (int i = 0; i < list.Count(); i++)
621
            {
622
                Thumb tm = new Thumb
623
                {
624
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
625
                };
626

    
627
                MemberSet.Last().ThumbList.Add(tm);
628

    
629
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MidPoint))
630
                {
631
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
632
                }
633
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
634
                {
635
                    //if (MemberSet.Count()<=1)
636
                    //{
637
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
638
                    List<Point> ps = new List<Point>();
639

    
640
                    if ((MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl != null)
641
                    {
642
                        var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
643

    
644

    
645
                        switch (Math.Abs(temp.Angle).ToString())
646
                        {
647
                            case "90":
648
                                {
649
                                    ps.Clear();
650
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
651
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
652
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
653

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

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

    
660
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
661
                                }
662
                                break;
663
                            case "270":
664
                                {
665
                                    ps.Clear();
666
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
667
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
668
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
669

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

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

    
676
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
677
                                }
678
                                break;
679
                            default:
680
                                {
681
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
682
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
683
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
684
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
685
                                }
686
                                break;
687
                        }
688

    
689
                        ArrowTextControl instance = (member as ArrowTextControl);
690
                        if (instance.isTrans)
691
                        {
692
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
693
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
694
                            //list[count] = tempP;
695
                            list[count] = temp.MidPoint;
696
                        }
697
                        else
698
                        {
699
                            if (temp.isFixed)
700
                            {
701
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
702
                                var testP = endP;
703
                                if (ps[0] == endP) //상단
704
                                {
705
                                    testP = new Point(endP.X, endP.Y - 50);
706
                                }
707
                                else if (ps[1] == endP) //하단
708
                                {
709
                                    testP = new Point(endP.X, endP.Y + 50);
710
                                }
711
                                else if (ps[2] == endP) //좌단
712
                                {
713
                                    testP = new Point(endP.X - 50, endP.Y);
714
                                }
715
                                else if (ps[3] == endP) //우단
716
                                {
717
                                    testP = new Point(endP.X + 50, endP.Y);
718
                                }
719
                                list[count] = testP;
720
                            }
721
                            else
722
                            {
723
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
724
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
725
                            }
726
                        }
727
                    }
728
                }
729
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
730
                {
731
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
732
                    tm.Width = (member as ArrowTextControl).BoxWidth;
733
                    tm.Height = (member as ArrowTextControl).BoxHeight;
734
                    var angle = (member as ArrowTextControl).Angle;
735
                    if (Math.Abs(angle).ToString() == "90")
736
                    {
737
                        tm.RenderTransformOrigin = new Point(0, 0);
738
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
739
                    }
740
                    else if (Math.Abs(angle).ToString() == "270")
741
                    {
742
                        tm.RenderTransformOrigin = new Point(0, 0);
743
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
744

    
745
                    }
746
                    else
747
                    {
748
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
749
                        tm.RenderTransform = new RotateTransform()
750
                        {
751
                            Angle = angle,
752
                        };
753
                    }
754
                }
755
                
756
                if (member.GetType().Name == "CloudControl")
757
                {
758
                    if (i == list.Count() - 1)
759
                    {
760
                        tm.Visibility = System.Windows.Visibility.Collapsed;
761
                    }
762
                }
763
                if (member.GetType().Name == "PolygonControl")
764
                {
765
                    if (i == list.Count() - 1)
766
                    {
767
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
768
                        {
769

    
770
                        }
771
                        else
772
                        {
773
                            tm.Visibility = System.Windows.Visibility.Collapsed;
774
                        }
775
                    }
776
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
777
                    {
778
                        tm.Visibility = System.Windows.Visibility.Collapsed;
779
                    }
780
                }
781
                
782
                this.ContainerContent.Children.Add(tm);
783
                Canvas.SetLeft(tm, list[count].X);
784
                Canvas.SetTop(tm, list[count].Y);
785
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
786
                {
787
                    Canvas.SetZIndex(tm, 95);
788
                }
789
                else
790
                {
791
                    Canvas.SetZIndex(tm, 99);
792
                }
793

    
794
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
795
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
796
                tm.DragDelta += ResizeTm_DragDelta;
797
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
798
                count++;
799
            }
800
        }
801

    
802
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
803
        {
804
            if (MemberSet.Count > 1)
805
                return;
806
            if (reSizePoint != new Point(0, 0))
807
            {
808
                Thumb thumb = sender as Thumb;
809

    
810
                if (AngleValue == -90)
811
                {
812
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.VerticalChange);
813
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.HorizontalChange));
814
                }
815
                else if (AngleValue == -180)
816
                {
817
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.HorizontalChange));
818
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.VerticalChange));
819
                }
820
                else if (AngleValue == -270)
821
                {
822
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.VerticalChange));
823
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.HorizontalChange);
824
                }
825
                else //(AngleValue == 0)
826
                {
827
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.HorizontalChange);
828
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.VerticalChange);
829
                }
830
                
831

    
832
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
833
                
834
                AdornerMember control = (from userThumb in MemberSet
835
                                         where userThumb.ThumbList.Contains(thumb)
836
                                         select userThumb).FirstOrDefault();
837
                Point nearPoint = new Point(0, 0);
838
                IPath AllControl = control.DrawingData as IPath;
839
                if (ControlType.TextControl != control.Drawingtype)
840
                {
841

    
842
                    var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
843
                    List<Point> ps = new List<Point>();
844

    
845
                    nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
846
                    
847

    
848
                }
849
                for (int i = 0; i < (control.DrawingData as IPath).PointSet.Count; i++)
850
                {
851
                    switch (control.Drawingtype)
852
                    {
853
                        #region Arc + Line
854
                        case ControlType.ArrowMultiLine:
855
                        case ControlType.ArcLine:
856
                        case ControlType.ArcArrow:
857
                        case ControlType.SingleLine:
858
                        case ControlType.Triangle:
859
                            if (nearPoint.Equals(AllControl.PointSet[i]))
860
                            {
861
                                AllControl.PointSet[i] = setPoint;
862
                                AllControl.updateControl();
863
                                DynamicThumbUpdate(control);
864
                                BorderUpdate();
865
                                
866
                            }
867
                            break;
868
                        #endregion
869
                        #region Shape                        
870
                        case ControlType.RectCloud:
871
                        case ControlType.Rectangle:
872
                            if (nearPoint.Equals(AllControl.PointSet[i]))
873
                            {
874
                                AllControl.PointSet[i] = setPoint;
875
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
876
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
877
                                var NextP = (i + 1) % AllControl.PointSet.Count();
878

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

    
881
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
882
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
883
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
884
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
885
                                    [ReverseP].Y
886
                                    + PreviousV.Y * l);
887

    
888
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
889
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
890
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
891
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
892
                                    NextV.Y * l);
893
                                AllControl.updateControl();
894
                                DynamicThumbUpdate(control);
895
                                BorderUpdate();
896
                            }
897
                            break;
898
                        #endregion
899
                        #region Polygon
900
                        case ControlType.PolygonControl:
901
                            if (nearPoint.Equals(AllControl.PointSet[i]))
902
                            {
903
                                AllControl.PointSet[i] = setPoint;
904
                                AllControl.updateControl();
905
                                BorderUpdate();
906
                            }
907
                            break;
908
                        #endregion
909
                        #region Cicle
910
                        case ControlType.Circle:
911
                            if (nearPoint.Equals(AllControl.PointSet[i]))
912
                            {
913
                                AllControl.PointSet[i] = setPoint;
914
                                List<Point> newPointSet = new List<Point> { };
915
                                Point middle = new Point(AllControl.PathData.Bounds.X + AllControl.PathData.Bounds.Width * 0.5,
916
                                    AllControl.PathData.Bounds.Y +
917
                                    AllControl.PathData.Bounds.Height * 0.5);
918
                                foreach (Point pt in AllControl.PointSet)
919
                                {
920
                                    newPointSet.Add(pt);
921
                                }
922
                                var ReverseP = (i + newPointSet.Count() / 2) % newPointSet.Count();
923
                                var PreviousP = (i + (newPointSet.Count() - 1)) % newPointSet.Count();
924
                                var NextP = (i + 1) % newPointSet.Count();
925
                                var distance = MathSet.DistanceTo(newPointSet[ReverseP], newPointSet[i]);
926
                                var PreviousV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[PreviousP]);
927
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, newPointSet[i].X - newPointSet[ReverseP].X,
928
                                    newPointSet[i].Y - newPointSet[ReverseP].Y);
929
                                newPointSet[PreviousP] = new Point(newPointSet[ReverseP].X + PreviousV.X * l, newPointSet[ReverseP].Y
930
                                    + PreviousV.Y * l);
931

    
932
                                var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]);
933
                                l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y
934
                                    - newPointSet[ReverseP].Y);
935
                                newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l);
936

    
937
                                AllControl.PointSet = newPointSet;
938
                                DynamicThumbUpdate(control);
939
                                AllControl.updateControl();
940
                                BorderUpdate();
941
                            }
942
                            break;
943
                        #endregion
944
                        #region ArrowText
945
                        case ControlType.ArrowTextControl:
946
                            if (nearPoint.Equals(AllControl.PointSet[i]))
947
                            {
948

    
949
                                List<Point> GetPointSet = (control.DrawingData as ArrowTextControl).PointSet;
950

    
951
                                if ((GetPointSet[0].X > GetPointSet[1].X && e.HorizontalChange > 0) || (GetPointSet[0].X < GetPointSet[1].X && e.HorizontalChange < 0))
952
                                {
953
                                    GetPointSet[1] = new Point(GetPointSet[1].X + e.HorizontalChange, GetPointSet[1].Y);
954
                                }
955
                                if ((GetPointSet[0].Y > GetPointSet[1].Y && e.VerticalChange > 0) || (GetPointSet[0].Y < GetPointSet[1].Y && e.VerticalChange < 0))
956
                                {
957
                                    GetPointSet[1] = new Point(GetPointSet[1].X, GetPointSet[1].Y + e.VerticalChange);
958
                                }
959
                                (control.DrawingData as ArrowTextControl).PointSet[1] = GetPointSet[1];
960

    
961

    
962
                                //System.Diagnostics.Debug.WriteLine("MidPoint : " + (control.DrawingData as ArrowTextControl).MidPoint);
963
                                //System.Diagnostics.Debug.WriteLine("HorizontalChange : " + e.HorizontalChange);
964
                                //System.Diagnostics.Debug.WriteLine("VerticalChange : " + e.VerticalChange);
965

    
966
                                AllControl.PointSet[i] = setPoint;
967
                                AllControl.updateControl();
968

    
969
                                DynamicThumbUpdate(control);
970
                                BorderUpdate();
971
                                                                
972
                            }
973
                            break;
974
                        #endregion
975
                        #region Text
976
                        case ControlType.TextControl:
977
                            break;
978
                        #endregion
979
                        #region Image
980
                        case ControlType.ImgControl:
981
                            if (nearPoint.Equals(AllControl.PointSet[i]))
982
                            {
983
                                AllControl.PointSet[i] = setPoint;
984
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
985
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
986
                                var NextP = (i + 1) % AllControl.PointSet.Count();
987

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

    
990
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
991
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
992
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
993
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
994
                                    [ReverseP].Y
995
                                    + PreviousV.Y * l);
996

    
997
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
998
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
999
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1000
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1001
                                    NextV.Y * l);
1002
                                AllControl.updateControl();
1003
                                DynamicThumbUpdate(control);
1004
                                BorderUpdate();
1005
                            }
1006
                            break;
1007
                        #endregion
1008
                        #region Sign
1009
                        case ControlType.Sign:
1010
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1011
                            {
1012
                                AllControl.PointSet[i] = setPoint;
1013
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1014
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1015
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1016

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

    
1019
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1020
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1021
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1022
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1023
                                    [ReverseP].Y
1024
                                    + PreviousV.Y * l);
1025

    
1026
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1027
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1028
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1029
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1030
                                    NextV.Y * l);
1031
                                AllControl.updateControl();
1032
                                DynamicThumbUpdate(control);
1033
                                BorderUpdate();
1034
                            }
1035
                            break;
1036
                        #endregion
1037
                        #region Cloud
1038
                        case ControlType.PolygonCloud:
1039
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1040
                            {
1041
                                AllControl.PointSet[i] = setPoint;
1042
                                AllControl.updateControl();
1043
                                ((ICloudControl)AllControl).DrawingCloud();
1044
                                BorderUpdate();
1045
                            }
1046
                            break;
1047
                        #endregion
1048
                        #region SymBol
1049
                        case ControlType.Symbol:
1050
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1051
                            {
1052
                                AllControl.PointSet[i] = setPoint;
1053
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1054
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1055
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1056

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

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

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

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

    
1086
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1087
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1088
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1089
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1090
                                    [ReverseP].Y
1091
                                    + PreviousV.Y * l);
1092

    
1093
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1094
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1095
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1096
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1097
                                    NextV.Y * l);
1098
                                AllControl.updateControl();
1099
                                DynamicThumbUpdate(control);
1100
                                BorderUpdate();
1101
                            }
1102
                            break;
1103
                        case ControlType.Date:
1104
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1105
                            {
1106
                                AllControl.PointSet[i] = setPoint;
1107
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1108
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1109
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1110

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

    
1113
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1114
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1115
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1116
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1117
                                    [ReverseP].Y
1118
                                    + PreviousV.Y * l);
1119

    
1120
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1121
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1122
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1123
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1124
                                    NextV.Y * l);
1125
                                AllControl.updateControl();
1126
                                DynamicThumbUpdate(control);
1127
                                BorderUpdate();
1128
                            }
1129
                            break;                        
1130
                        #endregion
1131
                        #region Ink
1132
                        case ControlType.Ink:
1133
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1134
                            {
1135
                                AllControl.PointSet[i] = setPoint;
1136
                                AllControl.updateControl();
1137
                                BorderUpdate();
1138
                            }
1139
                            break;
1140
                        #endregion
1141
                        default:
1142
                            break;
1143
                    }
1144
                }
1145
            }
1146
            //}
1147
        }
1148

    
1149

    
1150

    
1151
        #endregion
1152
        #region 이벤트
1153

    
1154
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1155
        {
1156
            this.isDragging = false;
1157
            DraggerThumb = null;
1158

    
1159
            Undo_Event();
1160
        }
1161

    
1162
        /// <summary>
1163
        /// start drag
1164
        /// </summary>
1165
        /// <param name="sender"></param>
1166
        /// <param name="e"></param>
1167
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1168
        {
1169
            this.DraggerThumb = sender as Thumb;
1170
            this.isDragging = true;
1171

    
1172
            if (ViewerDataModel.Instance.UndoDataList == null)
1173
            {
1174
                return;
1175
            }
1176

    
1177
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1178
            {
1179
                return;
1180
            }
1181

    
1182
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1183
            {
1184
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1185
                {
1186
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1187
                    {
1188
                        return;
1189
                    }
1190
                }
1191
            }
1192

    
1193
            Undo_Event();
1194
        }
1195

    
1196
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1197
        {
1198
            if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1199
            {
1200
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1201
                    IsTextAngle = true;
1202
                else
1203
                    IsTextAngle = false;
1204
                LastRotateVerticalValue = e.GetPosition(this).X;
1205
            }
1206
            else
1207
            {                
1208
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1209
                {
1210
                    RotateFlag = true;
1211
                }
1212
                else
1213
                {
1214
                    RotateFlag = false;
1215
                }
1216
                LastRotateHorizontalValue = e.GetPosition(this).X;
1217
            }
1218
        }
1219

    
1220
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1221
        {
1222
            DragThumb.Cursor = Cursors.SizeAll;
1223
            Thumb thumb = sender as Thumb;
1224
            MoveAdorner(e);
1225
        }
1226

    
1227
        public void MoveAdorner(DragDeltaEventArgs e)
1228
        {
1229
            Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);
1230

    
1231
            Dispatcher.BeginInvoke((Action)(() =>
1232
            {
1233
                foreach (var item in MemberSet)
1234
                {
1235
                    #region 라인  & 아크
1236
                    if (item.Drawingtype == ControlType.SingleLine || item.Drawingtype == ControlType.ArcLine || item.Drawingtype == ControlType.ArrowMultiLine || item.Drawingtype == ControlType.ArcArrow)
1237
                    {
1238
                        DynamicThumbUpdate(e, item);
1239
                    }
1240
                    #endregion
1241
                    #region 지시선화살표
1242
                    if (item.Drawingtype == ControlType.ArrowTextControl)
1243
                    {
1244
                        DynamicThumbUpdate(e, item);
1245
                    }
1246
                    #endregion
1247
                    
1248
                    #region 써클
1249
                    if (item.Drawingtype == ControlType.Circle || item.Drawingtype == ControlType.Sign || item.Drawingtype == ControlType.Symbol || item.Drawingtype == ControlType.Stamp)
1250
                    {
1251
                        DynamicThumbUpdate(e, item);
1252
                    }
1253
                    #endregion
1254
                    #region 쉐이프
1255
                    if (item.Drawingtype == ControlType.Rectangle || item.Drawingtype == ControlType.ImgControl || item.Drawingtype == ControlType.RectCloud || item.Drawingtype == ControlType.Triangle)
1256
                    {
1257
                        DynamicThumbUpdate(e, item);
1258
                    }
1259
                    #endregion
1260
                    #region 텍스트
1261
                    if (item.Drawingtype == ControlType.TextControl)
1262
                    {
1263
                        Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1264
                        Canvas.SetLeft((item.DrawingData as TextControl), Canvas.GetLeft((item.DrawingData as TextControl)) + dx.X);
1265
                        Canvas.SetTop((item.DrawingData as TextControl), Canvas.GetTop((item.DrawingData as TextControl)) + dx.Y);
1266
                        (item.DrawingData as TextControl).StartPoint =
1267
                        new Point(Canvas.GetLeft((item.DrawingData as TextControl)) + e.HorizontalChange / 5, Canvas.GetTop((item.DrawingData as TextControl)) + e.VerticalChange / 5);
1268
                        (item.DrawingData as TextControl).EndPoint = (item.DrawingData as TextControl).StartPoint;
1269

    
1270
                        // Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1271
                        //Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, (item.DrawingData as TextControl).EndPoint);
1272

    
1273
                       // TextControlChanger(); 
1274
                    }
1275
                    #endregion
1276
                    #region 날짜
1277
                    if (item.Drawingtype == ControlType.Date)
1278
                    {
1279
                        DynamicThumbUpdate(e, item);                        
1280
                    }
1281
                    #endregion
1282
                    #region 클라우드
1283
                    if (item.Drawingtype == ControlType.PolygonCloud)
1284
                    {
1285
                        ICloudControl temp = ((ICloudControl)item.DrawingData);
1286
                        DynamicThumbUpdate(e, item);
1287
                        temp.DrawingCloud();
1288
                    }
1289
                    #endregion
1290
                    #region 심볼
1291
                    
1292
                    #endregion
1293
                    
1294
                    #region 폴리곤
1295
                    if (item.Drawingtype == ControlType.PolygonControl)
1296
                    {
1297
                        DynamicThumbUpdate(e, item);
1298
                        BorderUpdate();
1299
                    }
1300
                    #endregion
1301
                    #region 잉크
1302
                    if (item.Drawingtype == ControlType.Ink)
1303
                    {
1304
                        Point px = new Point(e.HorizontalChange, e.VerticalChange);
1305
                        List<StylusPointSet> StylusPointSet = (item.DrawingData as InkControl).PointC;
1306
                        for (int i = 0; i < StylusPointSet.Count; i++)
1307
                        {
1308
                            List<Point> lstPoint = StylusPointSet[i].pointSet;
1309
                            for (int j = 0; j < lstPoint.Count; j++)
1310
                            {
1311
                                lstPoint[j] = new Point(lstPoint[j].X + px.X, lstPoint[j].Y + px.Y);
1312
                            }
1313
                        }
1314

    
1315
                        for (int i = 0; i < item.ThumbList.Count; i++)
1316
                        {
1317
                            Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + px.X);
1318
                            Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + px.Y);
1319
                        }
1320
                        (item.DrawingData as IPath).updateControl();
1321
                        BorderUpdate();
1322

    
1323
                    }
1324
                    #endregion
1325
                    BorderUpdate();
1326
                }
1327
            }));
1328
        }
1329

    
1330
        public void DynamicThumbUpdate(DragDeltaEventArgs e, AdornerMember item)
1331
        {
1332
            var AllControl = item.DrawingData as IPath;
1333
            List<Point> point = AllControl.PointSet;
1334
            for (int i = 0; i < item.ThumbList.Count(); i++)
1335
            {
1336
                if (item.DrawingData.GetType().Name == "ArrowTextControl")
1337
                {
1338
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1339
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1340
                    AllControl.updateControl();
1341
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1342
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1343

    
1344
                    Canvas.SetLeft(item.ThumbList.Last(), Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1345
                    Canvas.SetTop(item.ThumbList.Last(), Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1346
                }
1347
                else
1348
                {
1349
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1350
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1351
                    AllControl.updateControl();
1352
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1353
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1354
                }
1355
            }
1356
        }
1357

    
1358
        public void DynamicThumbUpdate(AdornerMember item)
1359
        {
1360
            var AllControl = item.DrawingData as IPath;
1361
            List<Point> point = AllControl.PointSet;
1362

    
1363
            for (int i = 0; i < AllControl.PointSet.Count(); i++)
1364
            {
1365

    
1366
                Canvas.SetLeft(item.ThumbList[i], AllControl.PointSet[i].X);
1367
                Canvas.SetTop(item.ThumbList[i], AllControl.PointSet[i].Y);
1368
            }
1369

    
1370

    
1371
            if (item.DrawingData as ArrowTextControl != null)
1372
            {
1373
                if (!(item.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
1374
                {
1375
                    List<Point> ps = new List<Point>();
1376
                    
1377
                    var temp = item.DrawingData as ArrowTextControl;
1378
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1379
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1380
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1381
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1382

    
1383

    
1384

    
1385
                    if (temp.isFixed)
1386
                    {
1387
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1388
                        var testP = endP;
1389
                        if (ps[0] == endP) //상단
1390
                        {
1391
                            testP = new Point(endP.X, endP.Y - 50);
1392
                            //System.Diagnostics.Debug.WriteLine("상단");
1393
                        }
1394
                        else if (ps[1] == endP) //하단
1395
                        {
1396
                            testP = new Point(endP.X, endP.Y + 50);
1397
                            //System.Diagnostics.Debug.WriteLine("하단");
1398
                        }
1399
                        else if (ps[2] == endP) //좌단
1400
                        {
1401
                            testP = new Point(endP.X - 50, endP.Y);
1402
                            //System.Diagnostics.Debug.WriteLine("좌단");
1403
                        }
1404
                        else if (ps[3] == endP) //우단
1405
                        {
1406
                            testP = new Point(endP.X + 50, endP.Y);
1407
                            //System.Diagnostics.Debug.WriteLine("우단");
1408
                        }
1409
                        Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], testP.X);
1410
                        Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], testP.Y);
1411
                    }
1412
                    else
1413
                    {
1414
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1415
                        var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1416
                        Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X);
1417
                        Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y);
1418
                    }
1419
                }
1420
            }
1421
            //}
1422
        }
1423

    
1424
        public void Set_Rotate()
1425
        {
1426

    
1427
            double dDeltaAngle = 0;
1428
            List<Point> AllPointSet = new List<Point>();
1429
            Point CenterPoint = new Point();
1430

    
1431

    
1432
            if (AngleValue >= 360)
1433
            {
1434
                AngleValue -= 360;
1435
            }
1436
            else if (AngleValue <= -360)
1437
            {
1438
                AngleValue += 360;
1439
            }
1440

    
1441
            #region 센터 포인트 구하기 (그룹핑)
1442
            foreach (var item in MemberSet)
1443
            {
1444
                if (item.DrawingData.GetType().Name == "TextControl")
1445
                {
1446
                }
1447
                else
1448
                {
1449
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1450
                    {
1451
                        AllPointSet.Add(itemP);
1452
                    }
1453
                }
1454
            }
1455
            #endregion
1456

    
1457
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1458

    
1459
            Dispatcher.BeginInvoke((Action)(() =>
1460
            {
1461
                foreach (var item in MemberSet)
1462
                {
1463
                    foreach (var thumb in item.ThumbList)
1464
                    {
1465
                        double x = Canvas.GetLeft(thumb);
1466
                        double y = Canvas.GetTop(thumb);
1467

    
1468
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1469
                        Canvas.SetLeft(thumb, value.X);
1470
                        Canvas.SetTop(thumb, value.Y);
1471

    
1472
                        if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last())
1473
                        {
1474

    
1475
                            Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1476
                            Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1477
                            if (!(item.DrawingData as ArrowTextControl).isTrans)
1478
                            {
1479
                                List<Point> ps = new List<Point>();
1480
                                var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
1481
                                switch (Math.Abs(temp.Angle).ToString())
1482
                                {
1483
                                    case "90":
1484
                                        {
1485
                                            ps.Clear();
1486
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1487
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
1488
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
1489

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

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

    
1496
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
1497
                                        }
1498
                                        break;
1499
                                    case "270":
1500
                                        {
1501
                                            ps.Clear();
1502
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1503
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
1504
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
1505

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

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

    
1512
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
1513
                                        }
1514
                                        break;
1515
                                    default:
1516
                                        {
1517
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1518
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1519
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1520
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1521
                                        }
1522
                                        break;
1523
                                }
1524

    
1525
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1526
                                var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1527
                                Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X);
1528
                                Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y);
1529
                            }
1530
                        }
1531
                    }
1532

    
1533
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1534
                    {
1535
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1536
                    }
1537
                }
1538
                #region 컨트롤 업데이트
1539
                foreach (var item in MemberSet)
1540
                {
1541
                    switch (item.Drawingtype)
1542
                    {
1543
                        case ControlType.TextControl:
1544
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1545
                            
1546
                            RectangleGeometry Data = new RectangleGeometry
1547
                            {
1548
                                Rect = new Rect()
1549
                                {
1550
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1551
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1552
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1553
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1554
                                }
1555
                            };
1556
                            
1557
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1558
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);                                                      
1559

    
1560
                            DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
1561
                            DragThumb.RenderTransform = new RotateTransform()
1562
                            {
1563
                                Angle = (item.DrawingData as TextControl).Angle,
1564
                                
1565
                            };
1566

    
1567
                            AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
1568
                            AdornerBorder.RenderTransform = new RotateTransform()
1569
                            {
1570
                                Angle = (item.DrawingData as TextControl).Angle,
1571
                                
1572
                            };
1573

    
1574
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1575
                            {
1576
                                Angle = (item.DrawingData as TextControl).Angle,
1577
                            };
1578
                            BorderUpdate();
1579
                            break;
1580
                        
1581
                        case ControlType.Date:                            
1582
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1583
                            (item.DrawingData as IPath).updateControl();
1584
                            BorderUpdate();                            
1585
                            break;
1586
                        case ControlType.ArrowMultiLine:
1587
                        case ControlType.ArcLine:
1588
                        case ControlType.ArcArrow:
1589
                        case ControlType.SingleLine:
1590
                        case ControlType.Triangle:
1591
                            (item.DrawingData as IPath).updateControl();
1592
                            BorderUpdate();
1593
                            break;
1594
                        case ControlType.ArrowTextControl:
1595
                            (item.DrawingData as IPath).updateControl();
1596
                            BorderUpdate();
1597
                            break;
1598
                        case ControlType.RectCloud:
1599
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1600
                            (item.DrawingData as IPath).updateControl();
1601
                            BorderUpdate();
1602
                            break;
1603
                        case ControlType.Rectangle:
1604
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1605
                            (item.DrawingData as IPath).updateControl();
1606
                            BorderUpdate();
1607
                            break;
1608
                        case ControlType.ImgControl:
1609
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1610
                            (item.DrawingData as IPath).updateControl();
1611
                            BorderUpdate();
1612
                            break;                        
1613
                        case ControlType.Sign:
1614
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1615
                            (item.DrawingData as IPath).updateControl();
1616
                            BorderUpdate();
1617
                            break;
1618
                        case ControlType.Symbol:
1619
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1620
                            (item.DrawingData as IPath).updateControl();
1621
                            BorderUpdate();
1622
                            break;
1623
                        case ControlType.Stamp:
1624
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1625
                            (item.DrawingData as IPath).updateControl();
1626
                            BorderUpdate();
1627
                            break;
1628
                        case ControlType.PolygonControl:
1629
                            (item.DrawingData as IPath).updateControl();
1630
                            BorderUpdate();
1631
                            break;
1632
                        case ControlType.PolygonCloud:
1633
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1634
                            (item.DrawingData as IPath).updateControl();
1635
                            BorderUpdate();
1636
                            break;
1637
                        case ControlType.Circle:
1638
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1639
                            (item.DrawingData as IPath).updateControl();
1640
                            ((CircleControl)item.DrawingData).SetCenterXY();
1641
                            BorderUpdate();
1642
                            break;
1643
                        case ControlType.Ink:
1644
                            (item.DrawingData as IPath).updateControl();
1645
                            BorderUpdate();
1646
                            break;
1647
                        default:
1648
                            break;
1649
                    }
1650
                }
1651
                #endregion
1652
            }));
1653
        }
1654

    
1655
        private void resize_MouseMove(object sender, MouseEventArgs e)
1656
        {
1657
            reSizePoint = e.GetPosition(this);            
1658
        }
1659
        /// <summary>
1660
        /// 회전
1661
        /// </summary>
1662
        /// <param name="sender"></param>
1663
        /// <param name="e"></param>
1664
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1665
        {
1666

    
1667
            MoveRotate(e);
1668
        }
1669

    
1670
        double LastRotateHorizontalValue = 0;
1671
        double LastRotateVerticalValue = 0;
1672
        double LastWidthValue = 0;
1673
        double SetWidth = 0;
1674
        bool RotateFlag = false;
1675

    
1676
        /// <summary>
1677
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1678
        /// </summary>
1679
        /// <param name="e"></param>
1680
        public void MoveRotate(DragDeltaEventArgs e)
1681
        {
1682
            double dDeltaAngle = 0;
1683

    
1684
            List<Point> AllPointSet = new List<Point>();
1685
            Point CenterPoint = new Point();
1686
            
1687
            #region 센터 포인트 구하기 (그룹핑)
1688
            foreach (var item in MemberSet)
1689
            {
1690
                if (item.DrawingData.GetType().Name == "TextControl")
1691
                {                    
1692
                    if (AngleValue == 0)
1693
                    {
1694
                        AngleValue = (item.DrawingData as TextControl).Angle;
1695
                    }
1696
                    double X = Canvas.GetLeft((item.DrawingData as TextControl));
1697
                    double Y = Canvas.GetTop((item.DrawingData as TextControl));
1698
                    AllPointSet.Add(new Point(X, Y));
1699
                }
1700
                else
1701
                {
1702
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1703
                    {
1704
                        AllPointSet.Add(itemP);
1705
                    }
1706
                }
1707
            }
1708
            #endregion
1709
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1710
            Point pt = Mouse.GetPosition(this);
1711

    
1712
            Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
1713
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1714
            dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1715

    
1716
            //System.Diagnostics.Debug.WriteLine("vec1 : " + vec1.X + "/" + vec1.Y);
1717
            //System.Diagnostics.Debug.WriteLine("vec2 : " + vec2.X + "/" + vec2.Y);
1718
            //System.Diagnostics.Debug.WriteLine("dDeltaAngle : " + dDeltaAngle);
1719

    
1720
            AngleValue += dDeltaAngle;
1721
            if (AngleValue > 360) AngleValue -= 360;
1722
            if (AngleValue < 0) AngleValue += 360;
1723
            this.rotatePoint = pt;  /// save rotatePoint
1724

    
1725
            Dispatcher.BeginInvoke((Action)(() =>
1726
            {
1727
                foreach (var item in MemberSet)
1728
                {
1729
                    foreach (var thumb in item.ThumbList)
1730
                    {
1731
                        double x = Canvas.GetLeft(thumb);
1732
                        double y = Canvas.GetTop(thumb);
1733

    
1734
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1735
                        Canvas.SetLeft(thumb, value.X);
1736
                        Canvas.SetTop(thumb, value.Y);                        
1737
                    }
1738

    
1739
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1740
                    {
1741
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1742
                    }
1743
                }
1744
                #region 보더 업데이트
1745
                foreach (var item in MemberSet)
1746
                {
1747
                    switch (item.Drawingtype)
1748
                    {
1749
                        case ControlType.TextControl:
1750
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1751
                            
1752
                            RectangleGeometry Data = new RectangleGeometry
1753
                            {
1754
                                Rect = new Rect()
1755
                                {
1756
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1757
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1758
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1759
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1760
                                }
1761
                            };
1762
                            
1763
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1764
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);
1765
                            
1766
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1767
                            DragThumb.RenderTransform = new RotateTransform()
1768
                            {
1769
                                Angle = (item.DrawingData as TextControl).Angle,
1770
                                //CenterX = middle.X,
1771
                                //CenterY = middle.Y,
1772
                            };
1773

    
1774
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1775
                            AdornerBorder.RenderTransform = new RotateTransform()
1776
                            {
1777
                                Angle = (item.DrawingData as TextControl).Angle,
1778
                                //CenterX = middle.X,
1779
                                //CenterY = middle.Y,
1780
                            };
1781

    
1782
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1783
                            {
1784
                                Angle = (item.DrawingData as TextControl).Angle,
1785
                            };
1786

    
1787
                            BorderUpdate();
1788
                            break;
1789
                        
1790
                        case ControlType.Date:
1791
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1792
                            (item.DrawingData as IPath).updateControl();
1793
                            BorderUpdate();                            
1794
                            break;
1795
                        case ControlType.ArrowMultiLine:
1796
                        case ControlType.ArcLine:
1797
                        case ControlType.ArcArrow:
1798
                        case ControlType.SingleLine:
1799
                        case ControlType.Triangle:
1800
                            (item.DrawingData as IPath).updateControl();
1801
                            BorderUpdate();
1802
                            break;
1803
                        case ControlType.ArrowTextControl:
1804
                            (item.DrawingData as IPath).updateControl();
1805
                            BorderUpdate();
1806
                            break;
1807
                        case ControlType.RectCloud:
1808
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1809
                            (item.DrawingData as IPath).updateControl();
1810
                            BorderUpdate();
1811
                            break;
1812
                        case ControlType.Rectangle:
1813
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1814
                            (item.DrawingData as IPath).updateControl();
1815
                            BorderUpdate();
1816
                            break;
1817
                        case ControlType.ImgControl:
1818
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1819
                            (item.DrawingData as IPath).updateControl();
1820
                            BorderUpdate();
1821
                            break;                        
1822
                        case ControlType.Sign:
1823
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1824
                            (item.DrawingData as IPath).updateControl();
1825
                            BorderUpdate();
1826
                            break;                        
1827
                        case ControlType.Symbol:
1828
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1829
                            (item.DrawingData as IPath).updateControl();
1830
                            BorderUpdate();
1831
                            break;
1832
                        case ControlType.Stamp:
1833
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1834
                            (item.DrawingData as IPath).updateControl();
1835
                            BorderUpdate();
1836
                            break;
1837
                        case ControlType.PolygonControl:
1838
                            (item.DrawingData as IPath).updateControl();
1839
                            BorderUpdate();
1840
                            break;
1841
                        case ControlType.PolygonCloud:
1842
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1843
                            (item.DrawingData as IPath).updateControl();
1844
                            BorderUpdate();
1845
                            break;
1846
                        case ControlType.Circle:
1847
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1848
                            (item.DrawingData as IPath).updateControl();
1849
                            ((CircleControl)item.DrawingData).SetCenterXY();
1850
                            BorderUpdate();
1851
                            break;
1852
                        case ControlType.Ink:
1853
                            for (int i = 0; i < (item.DrawingData as InkControl).PointC.Count(); i++)
1854
                            {
1855
                                for (int j = 0; j < (item.DrawingData as InkControl).PointC[i].pointSet.Count; j++)
1856
                                {
1857
                                    (item.DrawingData as InkControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as InkControl).PointC[i].pointSet[j], dDeltaAngle);
1858
                                }
1859
                            }
1860
                            (item.DrawingData as IPath).updateControl();
1861
                            BorderUpdate();
1862
                            break;
1863
                        
1864
                        default:
1865
                            break;
1866
                    }
1867
                }
1868
                #endregion
1869
            }));
1870
            BorderUpdate();
1871
        }
1872

    
1873
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1874
        {            
1875

    
1876
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1877
            rotateTop.Cursor = Cursors.SizeAll;
1878

    
1879
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1880
            if ((1 == MemberSet.Count) && (MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1881
            {
1882
                this.AngleValue = ((MemberSet.First() as AdornerMember).DrawingData as TextControl).Angle;
1883
            }
1884
            /// up to here
1885

    
1886

    
1887

    
1888
            if (ViewerDataModel.Instance.UndoDataList == null)
1889
            {
1890
                return;
1891
            }
1892

    
1893
            if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1894
            {
1895
                return;
1896
            }
1897
            if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1898
            {
1899
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1900
                {
1901
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1902
                    {
1903
                        return;
1904
                    }
1905
                }
1906
            }
1907

    
1908
            Undo_Event();
1909
        }
1910
        
1911
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1912
        {
1913
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1914
            
1915
            Undo_Event();
1916
        }
1917

    
1918
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1919
        {
1920
            if (ViewerDataModel.Instance.UndoDataList == null)
1921
            {
1922
                return;
1923
            }
1924
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1925
            {
1926
                return;
1927
            }
1928
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1929
            {
1930
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1931
                {
1932
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1933
                    {
1934
                        return;
1935
                    }
1936
                }
1937
            }
1938

    
1939
            Undo_Event();
1940
        }
1941

    
1942
        private void Undo_Event()
1943
        {
1944
            List<Point> p_set = new List<Point>();
1945

    
1946
            Undo_data UndoData = new Undo_data()
1947
            {
1948
                IsUndo = false,
1949
                Event = Event_Type.Thumb,
1950
                EventTime = DateTime.Now,
1951
                Markup_List = new List<Multi_Undo_data>(),
1952
            };
1953

    
1954
            Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
1955

    
1956
            foreach (var control in MemberSet)
1957
            {
1958
                multi_Undo_Data.PointSet = new List<Point>();
1959
                p_set = new List<Point>();
1960

    
1961
                if (control.DrawingData as TextControl != null)
1962
                {
1963
                    multi_Undo_Data.PointSet.Add((control.DrawingData as TextControl).StartPoint);
1964
                    multi_Undo_Data.PointSet.Add((control.DrawingData as TextControl).EndPoint);
1965
                }
1966

    
1967
                foreach (var point in ((control.DrawingData as CommentUserInfo) as IPath).PointSet)
1968
                {
1969
                    multi_Undo_Data.PointSet.Add(point);
1970
                }
1971

    
1972
                if (control.DrawingData as ArrowTextControl != null)
1973
                {
1974
                    multi_Undo_Data.Angle = AngleValue = (control.DrawingData as ArrowTextControl).Angle;
1975
                }
1976
                else
1977
                {
1978
                    multi_Undo_Data.Angle = AngleValue;
1979
                }                    
1980

    
1981
                multi_Undo_Data.Markup = control.DrawingData as CommentUserInfo;
1982
                UndoData.Markup_List.Add(multi_Undo_Data);
1983
                multi_Undo_Data = new Multi_Undo_data();
1984
            }
1985
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
1986
            {
1987
                ViewerDataModel.Instance.UndoDataList.Remove(i);
1988
            });
1989

    
1990
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
1991

    
1992
        }
1993

    
1994
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1995
        {          
1996
            DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1997

    
1998
            Undo_Event();
1999
        }
2000

    
2001
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
2002
        {
2003
            AdornerMember control = MemberSet.FirstOrDefault();
2004

    
2005
            if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null)
2006
            {
2007
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
2008
                {
2009
                    (control.DrawingData as ArrowTextControl).isTrans = true;
2010
                }
2011
            }
2012

    
2013
        }
2014

    
2015
        public void TextControlChanger()
2016
        {
2017
            if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2018
            {
2019
                TextControl AllControl = (MemberSet.First() as AdornerMember).DrawingData as TextControl;
2020
                AllControl.Base_TextBox.Focus();
2021
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
2022
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
2023
                AllControl.Base_TextBox.Focus();
2024
                AllControl.SizeChanged += (sen, ea) =>
2025
                {
2026
                    if (AllControl.Base_TextBox != null)
2027
                    {
2028
                        RectangleGeometry Data = new RectangleGeometry
2029
                        {
2030
                            Rect = new Rect()
2031
                            {
2032
                                X = AllControl.StartPoint.X,
2033
                                Y = AllControl.StartPoint.Y,
2034
                                Width = AllControl.Base_TextBox.Width,
2035
                                Height = AllControl.Base_TextBox.Height,
2036
                            }
2037
                        };
2038

    
2039
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
2040
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
2041
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
2042
                        {
2043
                            Angle = AllControl.Angle,
2044
                            CenterX = middle.X,
2045
                            CenterY = middle.Y,
2046
                        };
2047
                    }
2048
                    BorderUpdate();
2049
                };
2050
            }
2051
        }
2052

    
2053
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
2054
        {
2055
            if (e.ClickCount == 2 && MemberSet.Count == 1)
2056
            {
2057

    
2058
                if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2059
                {
2060
                    TextControlChanger();                    
2061
                }
2062

    
2063
                else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2064
                {
2065
                    ArrowTextControl AllControl = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
2066
                    Thumb tm = (MemberSet.First() as AdornerMember).ThumbList.Last();
2067
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
2068

    
2069
                    //ArrowControl TextBox Thumb없애기
2070
                    tm.Visibility = Visibility.Collapsed;
2071

    
2072
                    ((MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
2073
                    
2074
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
2075

    
2076
                    {
2077
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
2078
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
2079

    
2080
                        List<Point> ps = new List<Point>();
2081
                        
2082
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
2083
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
2084
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
2085
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
2086

    
2087

    
2088

    
2089

    
2090
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
2091
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
2092
                        if (AllControl.isTrans)
2093
                        {
2094
                            Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
2095
                            Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
2096
                        }
2097
                        else
2098
                        {
2099
                            Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X);
2100
                            Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y);
2101
                        }
2102

    
2103

    
2104
                        BorderUpdate();
2105

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

    
2161
            }
2162
            
2163
        }
2164
        #endregion
2165

    
2166
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2167
        {
2168
            if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2169
            {
2170
                DragThumb.Visibility = Visibility.Collapsed;
2171
            }
2172
        }
2173

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