프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 5bffa106

이력 | 보기 | 이력해설 | 다운로드 (156 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

    
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>() });
153
                    break;
154
                case "ImgControl": //Angle추가 안했음
155
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<Thumb>() });
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>() });
172
                    break;
173
                case "ArrowControl":
174
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<Thumb>() });
175
                    break;
176
                case "ArrowTextControl":
177
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<Thumb>() });
178
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
179

    
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>() });
193
                    break;
194
                case "ArrowControl_Multi":
195
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<Thumb>() });
196
                    break;
197
                case "RectangleControl":
198
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<Thumb>() });
199
                    break;
200
                case "DateControl":
201
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<Thumb>() });
202
                    AngleValue = (member as DateControl).Angle;
203
                    break;
204
                case "TriControl":
205
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<Thumb>() });
206
                    break;
207
                case "CircleControl":
208
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<Thumb>() });
209
                    break;
210
                case "CloudControl":
211
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<Thumb>() });
212
                    break;
213
                case "RectCloudControl":
214
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<Thumb>() });
215
                    break;
216
                //강인구 추가
217
                case "SignControl":
218
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<Thumb>() });
219
                    AngleValue = (member as SignControl).Angle;
220
                    break;
221
                //강인구 추가
222
                case "SymControl":
223
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<Thumb>() });
224
                    AngleValue = (member as SymControl).Angle;
225
                    break;
226
                //강인구 추가
227
                case "SymControlN":
228
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<Thumb>() });
229
                    AngleValue = (member as SymControlN).Angle;
230
                    break;
231
                case "InkControl": //Angle추가 안했음
232
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<Thumb>() });
233
                    break;
234
                case "TextControl":
235
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<Thumb>() });
236
                    RectangleGeometry Data = new RectangleGeometry
237
                    {
238
                        Rect = new Rect()
239
                        {
240
                            X = Canvas.GetLeft((member as TextControl)),
241
                            Y = Canvas.GetTop((member as TextControl)),
242
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
243
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
244
                            //Width = (member as TextControl).BoxWidth / 2,
245
                            //Height = (member as TextControl).BoxHeight / 2,
246
                        }
247
                    };
248
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
249
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
250

    
251

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

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

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

    
299
                //RegistryPoint(AllControl.PointSet);
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": //Angle추가 안했음
323
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<Thumb>() });
324
                        break;
325
                    case "ImgControl": //Angle추가 안했음
326
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<Thumb>() });
327
                        break;
328
                    //case "SymControl": //Angle추가 안했음
329
                    //    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() });
330
                    //    break;
331
                    //case "SymControlN": //Angle추가 안했음
332
                    //    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() });
333
                    //    ViewBoxRotate(member);
334
                    //    break;
335
                    case "ArrowControl":
336
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<Thumb>() });
337
                        break;
338
                    case "PolygonControl": //Angle추가 안했음
339
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<Thumb>() });
340
                        break;
341
                    case "ArrowTextControl":
342
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<Thumb>() });
343
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
344
                        break;
345
                    case "ArcControl":
346
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<Thumb>() });
347
                        break;
348
                    case "DateControl":
349
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<Thumb>() });
350
                        break;
351
                    case "ArrowControl_Multi":
352
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<Thumb>() });
353
                        break;
354
                    case "RectangleControl":
355
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<Thumb>() });
356
                        break;
357
                    case "TriControl":
358
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<Thumb>() });
359
                        break;
360
                    case "CircleControl":
361
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<Thumb>() });
362
                        break;
363
                    case "CloudControl":
364
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<Thumb>() });
365
                        break;
366
                    case "RectCloudControl":
367
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<Thumb>() });
368
                        break;
369
                    //강인구 추가
370
                    case "SignControl":
371
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<Thumb>() });
372
                        break;
373
                    case "SymControl":
374
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<Thumb>() });
375
                        break;
376
                    case "SymControlN":
377
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<Thumb>() });
378
                        break;
379
                    case "InkControl": //Angle추가 안했음
380
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<Thumb>() });
381
                        break;
382
                    case "TextControl":
383
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<Thumb>() });
384
                        Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
385
                        {
386
                            BorderUpdate();
387
                            try
388
                            {
389
                                ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; //확인 0403
390
                            }
391
                            catch (Exception)
392
                            {
393

    
394
                            }
395

    
396
                        });
397
                        Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
398
                        {
399
                            BorderUpdate();
400
                        });
401
                        break;
402
                    default:
403
                        break;
404
                        #endregion
405
                }
406
                if (member.GetType().Name == "TextControl")
407
                {
408
                    //강인구 추가
409
                    TextControl content = ((TextControl)member);
410
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
411
                    content.EndPoint = content.StartPoint;
412
                    //RegistryPoint(AllControl.PointSet);
413
                }
414
                else
415
                {
416
                    RegistryPoint(member, members.Count);
417
                }
418
            }
419

    
420
            BorderUpdate();
421
        }
422

    
423
        /// <summary>
424
        /// Border 를 갱신
425
        /// </summary>
426
        public void BorderUpdate()
427
        {
428
            AdornerBorder.MinWidth = 10;
429
            AdornerBorder.MinHeight = 10;
430

    
431
            double minX = double.MaxValue;
432
            double minY = double.MaxValue;
433
            double maxX = double.MinValue;
434
            double maxY = double.MinValue;
435

    
436
            if (MemberSet.Count == 1)
437
            {
438
                if (MemberSet.First().DrawingData.GetType().Name == "TextControl")
439
                {
440
                    if ((MemberSet.First().DrawingData as TextControl).Angle != 0)
441
                    {
442
                        trRotate.Angle = (MemberSet.First().DrawingData as TextControl).Angle;
443
                        trRotateThumb.Angle = (MemberSet.First().DrawingData as TextControl).Angle;
444
                    }
445
                    else
446
                    {
447
                        trRotate.Angle = 0;
448
                        trRotateThumb.Angle = 0;
449
                    }
450
                }
451
            }
452
            foreach (var item in MemberSet)
453
            {
454
                UIElement currentControl = (item as AdornerMember).DrawingData;
455
                if (item.DrawingData.GetType().Name == "TextControl")
456
                {
457
                    double textControlWidth;
458
                    double textControlHeight;
459
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
460
                    {
461
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
462
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
463
                    }
464
                    else
465
                    {
466
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
467
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
468
                    }
469

    
470
                    //Border 사이즈 불필요
471

    
472
                    //if ((currentControl as TextControl).LineSize.Left == 0)
473
                    //{
474
                    //    if (TextCompensation)
475
                    //    {
476

    
477
                    //        textControlWidth += 1;
478
                    //        textControlHeight += 1;
479
                    //    }
480
                    //    else
481
                    //    {
482
                    //        textControlWidth += 3;
483
                    //        textControlHeight += 3;
484
                    //    }
485
                    //}
486
                    //else
487
                    //{
488
                    //    if (TextCompensation)
489
                    //    {
490

    
491
                    //        textControlWidth += 1;
492
                    //        textControlHeight += 1;
493
                    //    }
494
                    //    else
495
                    //    {
496
                    //        textControlWidth += 8;
497
                    //        textControlHeight += 8;
498
                    //    }
499
                    //}
500

    
501
                    if ((currentControl as TextControl).EndPoint.X < minX)
502
                    {
503
                        minX = (currentControl as TextControl).EndPoint.X;
504
                    }
505
                    if ((currentControl as TextControl).EndPoint.Y < minY)
506
                    {
507
                        minY = (currentControl as TextControl).EndPoint.Y;
508
                    }
509
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
510
                    {
511
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
512
                    }
513
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
514
                    {
515
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
516
                    }
517
                }
518
                else if ((currentControl as IViewBox) != null)
519
                {
520
                    IViewBox instance = currentControl as IViewBox;
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 if ((currentControl as IPath).PathData == null)
530
                {
531
                    Rect rt = new Rect
532
                    {
533
                        X = (currentControl as IPath).StartPoint.X,
534
                        Y = (currentControl as IPath).StartPoint.Y,
535
                        //Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
536
                        //Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
537
                        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),
538
                        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),
539
                    };
540
                    if (rt.Left < minX) minX = rt.Left;
541
                    if (rt.Top < minY) minY = rt.Top;
542
                    if (rt.Right > maxX) maxX = rt.Right;
543
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
544
                }
545
                else if ((currentControl as IPath) == null)
546
                {
547
                    Rect rt = new Rect
548
                    {
549
                        X = (currentControl as IPath).StartPoint.X,
550
                        Y = (currentControl as IPath).StartPoint.Y,
551
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
552
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
553
                    };
554
                    if (rt.Left < minX) minX = rt.Left;
555
                    if (rt.Top < minY) minY = rt.Top;
556
                    if (rt.Right > maxX) maxX = rt.Right;
557
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
558
                }
559
                else if ((currentControl as CircleControl) != null)
560
                {
561
                    //Rect rt = new Rect
562
                    //{
563
                    //    X = (currentControl as IPath).StartPoint.X,
564
                    //    Y = (currentControl as IPath).StartPoint.Y,
565
                    //    Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
566
                    //    Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
567
                    //};
568

    
569
                    //Rect rt = new Rect((currentControl as IPath).StartPoint, (currentControl as IPath).EndPoint);
570
                    //if (rt.Left < minX) minX = rt.Left;
571
                    //if (rt.Top < minY) minY = rt.Top;
572
                    //if (rt.Right > maxX) maxX = rt.Right;
573
                    //if (rt.Bottom > maxY) maxY = rt.Bottom;
574

    
575
                    List<Point> am = (currentControl as IPath).PointSet;
576
                    List<double> xSet = am.Select(p => p.X).ToList();
577
                    List<double> ySet = am.Select(p => p.Y).ToList();
578
                    if (xSet.Min() < minX) minX = xSet.Min();
579
                    if (ySet.Min() < minY) minY = ySet.Min();
580
                    if (xSet.Max() > maxX) maxX = xSet.Max();
581
                    if (ySet.Max() > maxY) maxY = ySet.Max();
582
                }
583
                else
584
                {
585
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
586
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
587
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
588
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
589
                }
590
            }
591

    
592
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
593
            bool addWidthSize = false;
594
            bool addHeightSize = false;
595
            if (ac.Width <= 10)
596
            {
597
                ac.Width += 10;
598
                addWidthSize = true;
599
            }
600
            if (ac.Height <= 10)
601
            {
602
                ac.Height += 10;
603
                addHeightSize = true;
604
            }
605
            BorderSize = ac;
606
            AdornerBorder.MinWidth = 10;
607
            AdornerBorder.MinHeight = 10;
608
            AdornerBorder.Width = ac.Width;
609
            AdornerBorder.Height = ac.Height;
610
            Canvas.SetLeft(AdornerBorder, minX);
611
            Canvas.SetTop(AdornerBorder, minY);
612

    
613
            DragThumb.Width = ac.Width;
614
            DragThumb.Height = ac.Height;
615

    
616
            DragThumb.MinWidth = 10;
617
            DragThumb.MinHeight = 10;
618
            if (addWidthSize)
619
            {
620
                Canvas.SetLeft(DragThumb, minX - 5);
621
            }
622
            else
623
            {
624
                Canvas.SetLeft(DragThumb, minX);
625
            }
626

    
627
            if (addHeightSize)
628
            {
629
                Canvas.SetTop(DragThumb, minY - 5);
630
            }
631
            else
632
            {
633
                Canvas.SetTop(DragThumb, minY);
634
            }
635
        }
636
        /// <summary>
637
        /// UIElement 해제
638
        /// </summary>
639
        public void unRegister()
640
        {
641
            foreach (var item in this.ContainerContent.Children)
642
            {
643
                if (item is MarkupToPDF.Common.CommentUserInfo)
644
                {
645
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
646
                }
647
            }
648
            this.ContainerContent.Children.Clear();
649
        }
650
        /// <summary>
651
        /// 각 포인트들을 등록합니다.
652
        /// </summary>
653
        /// <param name="pointset">Drawing Point</param>
654
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
655
        {
656
            int count = 0;
657
            double Minx = 100000000;
658
            double Miny = 100000000;
659
            List<Point> list = (member as IPath).PointSet;
660
            if (member.GetType().Name == "InkControl")
661
            {
662
                list.Clear();
663
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
664
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
665
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
666
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
667
            }
668
            ControlType markT = MemberSet.Where(p => p.DrawingData == member).First().Drawingtype;
669
            foreach (var ax in list)
670
            {
671
                Minx = (ax.X < Minx) ? ax.X : Minx;
672
                Miny = (ax.Y < Miny) ? ax.Y : Miny;
673
            }
674
            for (int i = 0; i < list.Count(); i++)
675
            {
676
                Thumb tm = new Thumb
677
                {
678
                    //Name = String.Format("thumb{0}_{1}", count, member.GetType().Name.ToString()),
679
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
680
                };
681

    
682
                MemberSet.Last().ThumbList.Add(tm);
683

    
684
                if (markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint)
685
                {
686
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
687
                }
688
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
689
                {
690
                    //if (MemberSet.Count()<=1)
691
                    //{
692
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
693
                    List<Point> ps = new List<Point>();
694

    
695
                    if ((MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl != null)
696
                    {
697
                        var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
698

    
699

    
700
                        switch (Math.Abs(temp.Angle).ToString())
701
                        {
702
                            case "90":
703
                                {
704
                                    ps.Clear();
705
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
706
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
707
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
708

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

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

    
715
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
716
                                }
717
                                break;
718
                            case "270":
719
                                {
720
                                    ps.Clear();
721
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
722
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
723
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
724

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

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

    
731
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
732
                                }
733
                                break;
734
                            default:
735
                                {
736
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
737
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
738
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
739
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
740
                                }
741
                                break;
742
                        }
743

    
744
                        ArrowTextControl instance = (member as ArrowTextControl);
745
                        if (instance.isTrans)
746
                        {
747
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
748
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
749
                            //list[count] = tempP;
750
                            list[count] = temp.MidPoint;
751
                        }
752
                        else
753
                        {
754
                            if (temp.isFixed)
755
                            {
756
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
757
                                var testP = endP;
758
                                if (ps[0] == endP) //상단
759
                                {
760
                                    testP = new Point(endP.X, endP.Y - 50);
761
                                }
762
                                else if (ps[1] == endP) //하단
763
                                {
764
                                    testP = new Point(endP.X, endP.Y + 50);
765
                                }
766
                                else if (ps[2] == endP) //좌단
767
                                {
768
                                    testP = new Point(endP.X - 50, endP.Y);
769
                                }
770
                                else if (ps[3] == endP) //우단
771
                                {
772
                                    testP = new Point(endP.X + 50, endP.Y);
773
                                }
774
                                list[count] = testP;
775
                            }
776
                            else
777
                            {
778
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
779
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
780
                            }
781
                        }
782
                    }
783
                }
784
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
785
                {
786
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
787
                    tm.Width = (member as ArrowTextControl).BoxWidth;
788
                    tm.Height = (member as ArrowTextControl).BoxHeight;
789
                    var angle = (member as ArrowTextControl).Angle;
790
                    if (Math.Abs(angle).ToString() == "90")
791
                    {
792
                        tm.RenderTransformOrigin = new Point(0, 0);
793
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
794
                    }
795
                    else if (Math.Abs(angle).ToString() == "270")
796
                    {
797
                        tm.RenderTransformOrigin = new Point(0, 0);
798
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
799

    
800
                    }
801
                    else
802
                    {
803
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
804
                        tm.RenderTransform = new RotateTransform()
805
                        {
806
                            Angle = angle,
807
                        };
808
                    }
809
                }
810
                //if (markT == MarkupType.Polygon || markT == MarkupType.Cloud)
811
                //{
812
                //    tm.MouseMove += new MouseEventHandler(resize_MouseMove);
813
                //    tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
814
                //    tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
815
                //}
816
                //else
817
                //{
818
                //    tm.MouseMove += new MouseEventHandler(resize_MouseMove);
819
                //    tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
820
                //    tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
821
                //}
822

    
823
                if (member.GetType().Name == "CloudControl")
824
                {
825
                    if (i == list.Count() - 1)
826
                    {
827
                        tm.Visibility = System.Windows.Visibility.Collapsed;
828
                    }
829
                }
830
                if (member.GetType().Name == "PolygonControl")
831
                {
832
                    if (i == list.Count() - 1)
833
                    {
834
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
835
                        {
836

    
837
                        }
838
                        else
839
                        {
840
                            tm.Visibility = System.Windows.Visibility.Collapsed;
841
                        }
842
                    }
843
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
844
                    {
845
                        tm.Visibility = System.Windows.Visibility.Collapsed;
846
                    }
847
                }
848

    
849
                //강인구 텀브 없애기 보류
850
                //if(cnt > 1)
851
                //{
852
                //    tm.Visibility = System.Windows.Visibility.Collapsed;
853
                //}
854

    
855

    
856

    
857
                //if (member.GetType().Name == "InkControl")
858
                //{
859
                //    tm.Visibility = System.Windows.Visibility.Collapsed;
860
                //}
861

    
862
                this.ContainerContent.Children.Add(tm);
863
                Canvas.SetLeft(tm, list[count].X);
864
                Canvas.SetTop(tm, list[count].Y);
865
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
866
                {
867
                    Canvas.SetZIndex(tm, 95);
868
                }
869
                else
870
                {
871
                    Canvas.SetZIndex(tm, 99);
872
                }
873

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

    
882
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
883
        {
884
            //한개 이상 선택 시 Resize 금지
885
            if (MemberSet.Count > 1)
886
                return;
887
            if (reSizePoint != new Point(0, 0))
888
            {
889
                Thumb thumb = sender as Thumb;
890

    
891
                Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) +
892
                              e.HorizontalChange);
893
                Canvas.SetTop(thumb, Canvas.GetTop(thumb) +
894
                                        e.VerticalChange);
895

    
896
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
897

    
898

    
899

    
900

    
901
                //if (this.isDragging && MemberSet.Count <= 1)
902
                //if (thumb.IsDragging && MemberSet.Count <= 1 && DraggerThumb == thumb)
903
                //if (DraggerThumb == thumb)
904
                //{
905
                //Point setPoint = reSizePoint;
906
                //Canvas.SetLeft(thumb, setPoint.X);
907
                //Canvas.SetTop(thumb, setPoint.Y);
908
                AdornerMember control = (from userThumb in MemberSet
909
                                         where userThumb.ThumbList.Contains(thumb)
910
                                         select userThumb).FirstOrDefault();
911
                Point nearPoint = new Point(0, 0);
912
                IPath AllControl = control.DrawingData as IPath;
913
                if (ControlType.TextControl != control.Drawingtype)
914
                {
915

    
916
                    var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
917
                    List<Point> ps = new List<Point>();
918

    
919
                    nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
920
                    //switch (Math.Abs(temp.Angle).ToString())
921
                    //{
922

    
923
                    //    case "90":
924
                    //        {
925
                    //            nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
926
                    //        }
927
                    //        break;
928
                    //    case "270":
929
                    //        {
930
                    //            nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
931
                    //        }
932
                    //        break;
933
                    //    default:
934
                    //        {
935
                    //            nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
936
                    //        }
937
                    //        break;
938
                    //}
939

    
940
                }
941
                for (int i = 0; i < (control.DrawingData as IPath).PointSet.Count; i++)
942
                {
943
                    switch (control.Drawingtype)
944
                    {
945
                        #region Arc + Line
946
                        case ControlType.ArrowMultiLine:
947
                        case ControlType.ArcLine:
948
                        case ControlType.SingleLine:
949
                        case ControlType.Triangle:
950
                            if (nearPoint.Equals(AllControl.PointSet[i]))
951
                            {
952
                                AllControl.PointSet[i] = setPoint;
953
                                AllControl.updateControl();
954
                                DynamicThumbUpdate(control);
955
                                BorderUpdate();
956

    
957
                                //if (control.DrawingData.GetType().Name == "ArrowTextControl")
958
                                //{
959
                                //    Thumb tm = control.ThumbList.Last();
960
                                //    //Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width / 2));
961
                                //    //Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height / 2));
962
                                //    Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width));
963
                                //    Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height));
964
                                //}
965
                            }
966
                            break;
967
                        #endregion
968
                        #region Shape
969
                        //case ControlType.PolygonCloud:
970
                        case ControlType.RectCloud:
971
                        case ControlType.Rectangle:
972
                            if (nearPoint.Equals(AllControl.PointSet[i]))
973
                            {
974
                                AllControl.PointSet[i] = setPoint;
975
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
976
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
977
                                var NextP = (i + 1) % AllControl.PointSet.Count();
978

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

    
981
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
982
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
983
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
984
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
985
                                    [ReverseP].Y
986
                                    + PreviousV.Y * l);
987

    
988
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
989
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
990
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
991
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
992
                                    NextV.Y * l);
993
                                AllControl.updateControl();
994
                                DynamicThumbUpdate(control);
995
                                BorderUpdate();
996
                            }
997
                            break;
998
                        #endregion
999
                        #region Polygon
1000
                        case ControlType.PolygonControl:
1001
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1002
                            {
1003
                                AllControl.PointSet[i] = setPoint;
1004
                                AllControl.updateControl();
1005
                                BorderUpdate();
1006
                            }
1007
                            break;
1008
                        #endregion
1009
                        #region Cicle
1010
                        case ControlType.Circle:
1011
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1012
                            {
1013
                                AllControl.PointSet[i] = setPoint;
1014
                                List<Point> newPointSet = new List<Point> { };
1015
                                Point middle = new Point(AllControl.PathData.Bounds.X + AllControl.PathData.Bounds.Width * 0.5,
1016
                                    AllControl.PathData.Bounds.Y +
1017
                                    AllControl.PathData.Bounds.Height * 0.5);
1018
                                foreach (Point pt in AllControl.PointSet)
1019
                                {
1020
                                    newPointSet.Add(pt);
1021
                                }
1022
                                var ReverseP = (i + newPointSet.Count() / 2) % newPointSet.Count();
1023
                                var PreviousP = (i + (newPointSet.Count() - 1)) % newPointSet.Count();
1024
                                var NextP = (i + 1) % newPointSet.Count();
1025
                                var distance = MathSet.DistanceTo(newPointSet[ReverseP], newPointSet[i]);
1026
                                var PreviousV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[PreviousP]);
1027
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, newPointSet[i].X - newPointSet[ReverseP].X,
1028
                                    newPointSet[i].Y - newPointSet[ReverseP].Y);
1029
                                newPointSet[PreviousP] = new Point(newPointSet[ReverseP].X + PreviousV.X * l, newPointSet[ReverseP].Y
1030
                                    + PreviousV.Y * l);
1031

    
1032
                                var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]);
1033
                                l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y
1034
                                    - newPointSet[ReverseP].Y);
1035
                                newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l);
1036

    
1037
                                AllControl.PointSet = newPointSet;
1038
                                DynamicThumbUpdate(control);
1039
                                AllControl.updateControl();
1040
                                BorderUpdate();
1041
                            }
1042
                            break;
1043
                        #endregion
1044
                        #region ArrowText
1045
                        case ControlType.ArrowTextControl:
1046
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1047
                            {
1048

    
1049
                                List<Point> GetPointSet = (control.DrawingData as ArrowTextControl).PointSet;
1050

    
1051
                                if ((GetPointSet[0].X > GetPointSet[1].X && e.HorizontalChange > 0) || (GetPointSet[0].X < GetPointSet[1].X && e.HorizontalChange < 0))
1052
                                {
1053
                                    GetPointSet[1] = new Point(GetPointSet[1].X + e.HorizontalChange, GetPointSet[1].Y);
1054
                                }
1055
                                if ((GetPointSet[0].Y > GetPointSet[1].Y && e.VerticalChange > 0) || (GetPointSet[0].Y < GetPointSet[1].Y && e.VerticalChange < 0))
1056
                                {
1057
                                    GetPointSet[1] = new Point(GetPointSet[1].X, GetPointSet[1].Y + e.VerticalChange);
1058
                                }
1059
                                (control.DrawingData as ArrowTextControl).PointSet[1] = GetPointSet[1];
1060

    
1061

    
1062
                                System.Diagnostics.Debug.WriteLine("MidPoint : " + (control.DrawingData as ArrowTextControl).MidPoint);
1063
                                System.Diagnostics.Debug.WriteLine("HorizontalChange : " + e.HorizontalChange);
1064
                                System.Diagnostics.Debug.WriteLine("VerticalChange : " + e.VerticalChange);
1065

    
1066
                                AllControl.PointSet[i] = setPoint;
1067
                                AllControl.updateControl();
1068

    
1069
                                DynamicThumbUpdate(control);
1070
                                BorderUpdate();
1071

    
1072
                                //if (control.DrawingData.GetType().Name == "ArrowTextControl")
1073
                                //{
1074
                                //    Thumb tm = control.ThumbList.Last();
1075
                                //    //Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width / 2));
1076
                                //    //Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height / 2));
1077
                                //    Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width));
1078
                                //    Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height));
1079
                                //}
1080
                            }
1081
                            break;
1082
                        #endregion
1083
                        #region Text
1084
                        case ControlType.TextControl:
1085
                            break;
1086
                        #endregion
1087
                        #region Image
1088
                        case ControlType.ImgControl:
1089
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1090
                            {
1091
                                AllControl.PointSet[i] = setPoint;
1092
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1093
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1094
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1095

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

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

    
1105
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1106
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1107
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1108
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1109
                                    NextV.Y * l);
1110
                                AllControl.updateControl();
1111
                                DynamicThumbUpdate(control);
1112
                                BorderUpdate();
1113
                            }
1114
                            break;
1115
                        #endregion
1116
                        //강인구 추가
1117
                        #region Sign
1118
                        case ControlType.Sign:
1119
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1120
                            {
1121
                                AllControl.PointSet[i] = setPoint;
1122
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1123
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1124
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1125

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

    
1128
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1129
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1130
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1131
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1132
                                    [ReverseP].Y
1133
                                    + PreviousV.Y * l);
1134

    
1135
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1136
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1137
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1138
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1139
                                    NextV.Y * l);
1140
                                AllControl.updateControl();
1141
                                DynamicThumbUpdate(control);
1142
                                BorderUpdate();
1143
                            }
1144
                            break;
1145
                        #endregion
1146
                        #region Cloud
1147
                        case ControlType.PolygonCloud:
1148
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1149
                            {
1150
                                AllControl.PointSet[i] = setPoint;
1151
                                AllControl.updateControl();
1152
                                ((ICloudControl)AllControl).DrawingCloud();
1153
                                BorderUpdate();
1154
                            }
1155
                            break;
1156
                        #endregion
1157
                        #region SymBol
1158
                        case ControlType.Symbol:
1159
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1160
                            {
1161
                                AllControl.PointSet[i] = setPoint;
1162
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1163
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1164
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1165

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

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

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

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

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

    
1202
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1203
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1204
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1205
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1206
                                    NextV.Y * l);
1207
                                AllControl.updateControl();
1208
                                DynamicThumbUpdate(control);
1209
                                BorderUpdate();
1210
                            }
1211
                            break;
1212
                        case ControlType.Date:
1213
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1214
                            {
1215
                                AllControl.PointSet[i] = setPoint;
1216
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1217
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1218
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1219

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

    
1222
                                var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1223
                                var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1224
                                    AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1225
                                AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1226
                                    [ReverseP].Y
1227
                                    + PreviousV.Y * l);
1228

    
1229
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1230
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1231
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1232
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1233
                                    NextV.Y * l);
1234
                                AllControl.updateControl();
1235
                                DynamicThumbUpdate(control);
1236
                                BorderUpdate();
1237
                            }
1238
                            break;
1239
                        //case MarkupType.Viewbox:
1240
                        //    if (nearPoint.Equals(AllControl.PointSet[i]))
1241
                        //    {
1242
                        //        AllControl.PointSet[i] = setPoint;
1243
                        //        var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1244
                        //        var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1245
                        //        var NextP = (i + 1) % AllControl.PointSet.Count();
1246

    
1247
                        //        var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1248

    
1249
                        //        var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1250
                        //        var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1251
                        //            AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1252
                        //        AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1253
                        //            [ReverseP].Y
1254
                        //            + PreviousV.Y * l);
1255

    
1256
                        //        var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1257
                        //        l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1258
                        //            [i].Y - AllControl.PointSet[ReverseP].Y);
1259
                        //        AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1260
                        //            NextV.Y * l);
1261
                        //        AllControl.updateControl();
1262
                        //        DynamicThumbUpdate(control);
1263
                        //        BorderUpdate();
1264
                        //    }
1265
                        //    break;
1266
                        #endregion
1267
                        #region Ink
1268
                        case ControlType.Ink:
1269
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1270
                            {
1271
                                AllControl.PointSet[i] = setPoint;
1272
                                AllControl.updateControl();
1273
                                BorderUpdate();
1274
                            }
1275
                            break;
1276
                        #endregion
1277
                        default:
1278
                            break;
1279
                    }
1280
                }
1281
            }
1282
            //}
1283
        }
1284

    
1285

    
1286

    
1287
        #endregion
1288
        #region 이벤트
1289

    
1290
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1291
        {
1292
            this.isDragging = false;
1293
            DraggerThumb = null;
1294

    
1295
            Undo_Event();
1296
        }
1297

    
1298
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1299
        {
1300
            this.DraggerThumb = sender as Thumb;
1301
            this.isDragging = true;
1302

    
1303
            if (ViewerDataModel.Instance.UndoDataList == null)
1304
            {
1305
                return;
1306
            }
1307

    
1308
            if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1309
            {
1310
                return;
1311
            }
1312

    
1313
            if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1314
            {
1315
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1316
                {
1317
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1318
                    {
1319
                        return;
1320
                    }
1321
                }
1322
            }
1323

    
1324
            Undo_Event();
1325
        }
1326

    
1327
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1328
        {
1329

    
1330
            //double LastRotateHorizontalValue = 0;
1331
            //double LastRotateVerticalValue = 0;
1332
            //double LastWidthValue = 0;
1333
            //double SetWidth = 0;
1334

    
1335

    
1336
            if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1337
            {
1338
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1339
                    IsTextAngle = true;
1340
                else
1341
                    IsTextAngle = false;
1342

    
1343
                //System.Diagnostics.Debug.WriteLine("X축 : " + e.GetPosition(this).X + "LastRotateVerticalValue : " + LastRotateVerticalValue);
1344
                LastRotateVerticalValue = e.GetPosition(this).X;
1345
            }
1346
            else
1347
            {
1348
                //System.Diagnostics.Debug.WriteLine("e.GetPosition(this).X : " + e.GetPosition(this).X);
1349
                //System.Diagnostics.Debug.WriteLine("LastRotateHorizontalValue: " + LastRotateHorizontalValue);
1350

    
1351
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1352
                {
1353
                    RotateFlag = true;
1354
                }
1355
                else
1356
                {
1357
                    RotateFlag = false;
1358
                }
1359
                LastRotateHorizontalValue = e.GetPosition(this).X;
1360
            }
1361
        }
1362

    
1363
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1364
        {
1365
            DragThumb.Cursor = Cursors.SizeAll;
1366
            Thumb thumb = sender as Thumb;
1367
            MoveAdorner(e);
1368
        }
1369

    
1370
        public void MoveAdorner(DragDeltaEventArgs e)
1371
        {
1372
            Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);
1373

    
1374
            Dispatcher.BeginInvoke((Action)(() =>
1375
            {
1376
                foreach (var item in MemberSet)
1377
                {
1378
                    #region 라인  & 아크
1379
                    if (item.Drawingtype == ControlType.SingleLine || item.Drawingtype == ControlType.ArcLine || item.Drawingtype == ControlType.ArrowMultiLine)
1380
                    {
1381
                        DynamicThumbUpdate(e, item);
1382
                    }
1383
                    #endregion
1384
                    #region 지시선화살표
1385
                    if (item.Drawingtype == ControlType.ArrowTextControl)
1386
                    {
1387
                        DynamicThumbUpdate(e, item);
1388
                    }
1389
                    #endregion
1390
                    //강인구 추가 Sign, check, Stamp
1391
                    #region 써클
1392
                    if (item.Drawingtype == ControlType.Circle || item.Drawingtype == ControlType.Sign || item.Drawingtype == ControlType.Symbol || item.Drawingtype == ControlType.Stamp)
1393
                    {
1394
                        DynamicThumbUpdate(e, item);
1395
                    }
1396
                    #endregion
1397
                    #region 쉐이프
1398
                    if (item.Drawingtype == ControlType.Rectangle || item.Drawingtype == ControlType.ImgControl || item.Drawingtype == ControlType.RectCloud || item.Drawingtype == ControlType.Triangle)
1399
                    {
1400
                        DynamicThumbUpdate(e, item);
1401
                    }
1402
                    #endregion
1403
                    #region 텍스트
1404
                    if (item.Drawingtype == ControlType.TextControl)
1405
                    {
1406
                        //Canvas.SetLeft((item.DrawingData as TextControl), Canvas.GetLeft((item.DrawingData as TextControl)) + e.HorizontalChange / 5);
1407
                        //Canvas.SetTop((item.DrawingData as TextControl), Canvas.GetTop((item.DrawingData as TextControl)) + e.VerticalChange / 5);
1408
                        //(item.DrawingData as TextControl).StartPoint = 
1409
                        //new Point(Canvas.GetLeft((item.DrawingData as TextControl)) + e.HorizontalChange / 5, Canvas.GetTop((item.DrawingData as TextControl)) + e.VerticalChange / 5);
1410
                        //(item.DrawingData as TextControl).EndPoint = (item.DrawingData as TextControl).StartPoint;
1411

    
1412
                        Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1413
                        Canvas.SetLeft((item.DrawingData as TextControl), Canvas.GetLeft((item.DrawingData as TextControl)) + dx.X);
1414
                        Canvas.SetTop((item.DrawingData as TextControl), Canvas.GetTop((item.DrawingData as TextControl)) + dx.Y);
1415
                        (item.DrawingData as TextControl).StartPoint =
1416
                        new Point(Canvas.GetLeft((item.DrawingData as TextControl)) + e.HorizontalChange / 5, Canvas.GetTop((item.DrawingData as TextControl)) + e.VerticalChange / 5);
1417
                        (item.DrawingData as TextControl).EndPoint = (item.DrawingData as TextControl).StartPoint;
1418

    
1419
                        //(item.DrawingData as TextControl).CanvasX = (item.DrawingData as TextControl).StartPoint.X;
1420
                        //(item.DrawingData as TextControl).CanvasY = (item.DrawingData as TextControl).StartPoint.Y;
1421
                    }
1422
                    #endregion
1423
                    #region 날짜
1424
                    if (item.Drawingtype == ControlType.Date)
1425
                    {
1426
                        DynamicThumbUpdate(e, item);
1427
                        //Canvas.SetLeft((item.DrawingData as DateControl), Canvas.GetLeft((item.DrawingData as DateControl)) + e.HorizontalChange);
1428
                        //Canvas.SetTop((item.DrawingData as DateControl), Canvas.GetTop((item.DrawingData as DateControl)) + e.VerticalChange);
1429
                        //(item.DrawingData as DateControl).StartPoint = new Point(Canvas.GetLeft((item.DrawingData as DateControl))
1430
                        //                                         + e.HorizontalChange, Canvas.GetTop((item.DrawingData as DateControl)) + e.VerticalChange);
1431
                        //(item.DrawingData as DateControl).EndPoint = (item.DrawingData as DateControl).StartPoint;
1432
                        //MessageBox.Show("잠시 정확도를 위해 막아두었습니다!");
1433

    
1434

    
1435
                    }
1436
                    #endregion
1437
                    #region 클라우드
1438
                    if (item.Drawingtype == ControlType.PolygonCloud)
1439
                    {
1440
                        ICloudControl temp = ((ICloudControl)item.DrawingData);
1441
                        DynamicThumbUpdate(e, item);
1442
                        temp.DrawingCloud();
1443
                    }
1444
                    #endregion
1445
                    #region 심볼
1446
                    //if (item.Drawingtype == MarkupType.Viewbox)
1447
                    //{
1448
                    //    DynamicThumbUpdate(e, item);
1449
                    //    BorderUpdate();
1450
                    //}
1451
                    #endregion
1452
                    #region 폴리곤확장
1453
                    //if (item.Drawingtype == MarkupType.PolygonEx)
1454
                    //{
1455
                    //    Point px = new Point(e.HorizontalChange, e.VerticalChange);
1456
                    //    List<StylusPointSet> StylusPointSet = (item.DrawingData as PolyControl).PointC;
1457
                    //    for (int i = 0; i < StylusPointSet.Count; i++)
1458
                    //    {
1459
                    //        List<Point> lstPoint = StylusPointSet[i].pointSet;
1460
                    //        for (int j = 0; j < lstPoint.Count; j++)
1461
                    //        {
1462
                    //            lstPoint[j] = new Point(lstPoint[j].X + px.X, lstPoint[j].Y + px.Y);
1463
                    //        }
1464
                    //    }
1465

    
1466
                    //    for (int i = 0; i < item.ThumbList.Count; i++)
1467
                    //    {
1468
                    //        Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + px.X);
1469
                    //        Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + px.Y);
1470
                    //    }
1471
                    //    (item.DrawingData as IPath).updateControl();
1472
                    //    BorderUpdate();
1473
                    //    //for (int i = 0; i < (item.DrawingData as PolyControl).PointC.Count(); i++)
1474
                    //    //{
1475
                    //    //    //(item.DrawingData as PolyControl).PointC[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as PolyControl).PointC[i]., dDeltaAngle);
1476
                    //    //    for (int j = 0; j < (item.DrawingData as PolyControl).PointC[i].pointSet.Count; j++)
1477
                    //    //    {
1478
                    //    //        (item.DrawingData as PolyControl).PointC[i].pointSet[j] = new Point { X = (item.DrawingData as PolyControl).PointC[i].pointSet[j].X + dx.X, Y = (item.DrawingData as PolyControl).PointC[i].pointSet[j].Y + dx.Y };
1479
                    //    //        Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1480
                    //    //        Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1481
                    //    //    }
1482
                    //    //}
1483
                    //    //(item.DrawingData as IPath).updateControl();
1484
                    //}
1485
                    #endregion
1486
                    #region 폴리곤
1487
                    if (item.Drawingtype == ControlType.PolygonControl)
1488
                    {
1489
                        DynamicThumbUpdate(e, item);
1490
                        BorderUpdate();
1491
                    }
1492
                    #endregion
1493
                    #region 잉크
1494
                    if (item.Drawingtype == ControlType.Ink)
1495
                    {
1496
                        //DynamicThumbUpdate(e, item);
1497
                        //BorderUpdate();
1498

    
1499
                        Point px = new Point(e.HorizontalChange, e.VerticalChange);
1500
                        List<StylusPointSet> StylusPointSet = (item.DrawingData as InkControl).PointC;
1501
                        for (int i = 0; i < StylusPointSet.Count; i++)
1502
                        {
1503
                            List<Point> lstPoint = StylusPointSet[i].pointSet;
1504
                            for (int j = 0; j < lstPoint.Count; j++)
1505
                            {
1506
                                lstPoint[j] = new Point(lstPoint[j].X + px.X, lstPoint[j].Y + px.Y);
1507
                            }
1508
                        }
1509

    
1510
                        for (int i = 0; i < item.ThumbList.Count; i++)
1511
                        {
1512
                            Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + px.X);
1513
                            Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + px.Y);
1514
                        }
1515
                        (item.DrawingData as IPath).updateControl();
1516
                        BorderUpdate();
1517

    
1518
                    }
1519
                    #endregion
1520
                    BorderUpdate();
1521
                }
1522
            }));
1523
        }
1524

    
1525
        public void DynamicThumbUpdate(DragDeltaEventArgs e, AdornerMember item)
1526
        {
1527
            var AllControl = item.DrawingData as IPath;
1528
            List<Point> point = AllControl.PointSet;
1529
            //for (int i = 0; i < AllControl.PointSet.Count(); i++)
1530
            for (int i = 0; i < item.ThumbList.Count(); i++)
1531
            {
1532
                if (item.DrawingData.GetType().Name == "ArrowTextControl")
1533
                {
1534
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1535
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1536
                    AllControl.updateControl();
1537
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1538
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1539

    
1540
                    Canvas.SetLeft(item.ThumbList.Last(), Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1541
                    Canvas.SetTop(item.ThumbList.Last(), Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1542
                }
1543
                else
1544
                {
1545
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1546
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1547
                    AllControl.updateControl();
1548
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1549
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1550
                }
1551
            }
1552
        }
1553

    
1554
        public void DynamicThumbUpdate(AdornerMember item)
1555
        {
1556
            var AllControl = item.DrawingData as IPath;
1557
            List<Point> point = AllControl.PointSet;
1558

    
1559
            //if (item.DrawingData as ArrowTextControl !=null)
1560
            //{
1561
            //    for (int i = 0; i < AllControl.PointSet.Count(); i++)
1562
            //    {
1563
            //        if ((MemberSet.First() as AdornerMember).ThumbList[1]d)
1564
            //        {
1565

    
1566
            //        }
1567
            //    }
1568
            //    List<Point> ps = new List<Point>();
1569
            //    var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
1570
            //    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1571
            //    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1572
            //    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1573
            //    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1574

    
1575
            //    var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1576
            //    var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1577
            //    Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X);
1578
            //    Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y);    
1579
            //}
1580
            //else
1581
            //{
1582
            for (int i = 0; i < AllControl.PointSet.Count(); i++)
1583
            {
1584

    
1585
                Canvas.SetLeft(item.ThumbList[i], AllControl.PointSet[i].X);
1586
                Canvas.SetTop(item.ThumbList[i], AllControl.PointSet[i].Y);
1587
            }
1588

    
1589

    
1590
            if (item.DrawingData as ArrowTextControl != null)
1591
            {
1592
                if (!(item.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
1593
                {
1594
                    List<Point> ps = new List<Point>();
1595
                    //강인구 수정
1596
                    //var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
1597
                    var temp = item.DrawingData as ArrowTextControl;
1598
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1599
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1600
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1601
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1602

    
1603

    
1604

    
1605
                    if (temp.isFixed)
1606
                    {
1607
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1608
                        var testP = endP;
1609
                        if (ps[0] == endP) //상단
1610
                        {
1611
                            testP = new Point(endP.X, endP.Y - 50);
1612
                            System.Diagnostics.Debug.WriteLine("상단");
1613
                        }
1614
                        else if (ps[1] == endP) //하단
1615
                        {
1616
                            testP = new Point(endP.X, endP.Y + 50);
1617
                            System.Diagnostics.Debug.WriteLine("하단");
1618
                        }
1619
                        else if (ps[2] == endP) //좌단
1620
                        {
1621
                            testP = new Point(endP.X - 50, endP.Y);
1622
                            System.Diagnostics.Debug.WriteLine("좌단");
1623
                        }
1624
                        else if (ps[3] == endP) //우단
1625
                        {
1626
                            testP = new Point(endP.X + 50, endP.Y);
1627
                            System.Diagnostics.Debug.WriteLine("우단");
1628
                        }
1629
                        Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], testP.X);
1630
                        Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], testP.Y);
1631
                    }
1632
                    else
1633
                    {
1634
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1635
                        var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1636
                        Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X);
1637
                        Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y);
1638
                    }
1639
                }
1640
            }
1641
            //}
1642
        }
1643

    
1644
        public void Set_Rotate()
1645
        {
1646

    
1647
            double dDeltaAngle = 0;
1648
            List<Point> AllPointSet = new List<Point>();
1649
            Point CenterPoint = new Point();
1650

    
1651

    
1652
            if (AngleValue >= 360)
1653
            {
1654
                AngleValue -= 360;
1655
            }
1656
            else if (AngleValue <= -360)
1657
            {
1658
                AngleValue += 360;
1659
            }
1660

    
1661
            #region 센터 포인트 구하기 (그룹핑)
1662
            foreach (var item in MemberSet)
1663
            {
1664
                if (item.DrawingData.GetType().Name == "TextControl")
1665
                {
1666
                }
1667
                else
1668
                {
1669
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1670
                    {
1671
                        AllPointSet.Add(itemP);
1672
                    }
1673
                }
1674
            }
1675
            #endregion
1676

    
1677
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1678

    
1679
            Dispatcher.BeginInvoke((Action)(() =>
1680
            {
1681
                foreach (var item in MemberSet)
1682
                {
1683
                    foreach (var thumb in item.ThumbList)
1684
                    {
1685
                        double x = Canvas.GetLeft(thumb);
1686
                        double y = Canvas.GetTop(thumb);
1687

    
1688
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1689
                        Canvas.SetLeft(thumb, value.X);
1690
                        Canvas.SetTop(thumb, value.Y);
1691

    
1692
                        if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last())
1693
                        {
1694

    
1695
                            Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1696
                            Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1697
                            if (!(item.DrawingData as ArrowTextControl).isTrans)
1698
                            {
1699
                                List<Point> ps = new List<Point>();
1700
                                var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
1701
                                switch (Math.Abs(temp.Angle).ToString())
1702
                                {
1703
                                    case "90":
1704
                                        {
1705
                                            ps.Clear();
1706
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1707
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
1708
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
1709

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

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

    
1716
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
1717
                                        }
1718
                                        break;
1719
                                    case "270":
1720
                                        {
1721
                                            ps.Clear();
1722
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1723
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
1724
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
1725

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

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

    
1732
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
1733
                                        }
1734
                                        break;
1735
                                    default:
1736
                                        {
1737
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1738
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1739
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1740
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1741
                                        }
1742
                                        break;
1743
                                }
1744

    
1745
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1746
                                var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1747
                                Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X);
1748
                                Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y);
1749
                            }
1750
                        }
1751
                    }
1752

    
1753
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1754
                    {
1755
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1756
                    }
1757
                }
1758
                #region 컨트롤 업데이트
1759
                foreach (var item in MemberSet)
1760
                {
1761
                    switch (item.Drawingtype)
1762
                    {
1763
                        case ControlType.TextControl:
1764
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1765
                            //trRotate.Angle = AngleValue;
1766

    
1767
                            RectangleGeometry Data = new RectangleGeometry
1768
                            {
1769
                                Rect = new Rect()
1770
                                {
1771
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1772
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1773
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1774
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1775
                                }
1776
                            };
1777
                            //if ((firstCondition as TextControl).Angle != 0)
1778
                            //{
1779
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1780
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);
1781

    
1782

    
1783
                            //AdornerBorder.RenderTransformOrigin = new Point(1, 1);
1784
                            //AdornerBorder.RenderTransform = new RotateTransform()
1785
                            //{
1786
                            //    Angle = (member as TextControl).Angle * -1,
1787
                            //    CenterX = middle.X + ((member as TextControl) as FrameworkElement).ActualWidth /2,
1788
                            //    CenterY = middle.Y + ((member as TextControl) as FrameworkElement).ActualHeight /2,
1789
                            //};
1790

    
1791
                            DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
1792
                            DragThumb.RenderTransform = new RotateTransform()
1793
                            {
1794
                                Angle = (item.DrawingData as TextControl).Angle,
1795
                                //CenterX = middle.X,
1796
                                //CenterY = middle.Y,
1797
                            };
1798

    
1799
                            AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
1800
                            AdornerBorder.RenderTransform = new RotateTransform()
1801
                            {
1802
                                Angle = (item.DrawingData as TextControl).Angle,
1803
                                //CenterX = middle.X,
1804
                                //CenterY = middle.Y,
1805
                            };
1806

    
1807
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1808
                            {
1809
                                Angle = (item.DrawingData as TextControl).Angle,
1810
                            };
1811

    
1812
                            BorderUpdate();
1813
                            break;
1814
                        //case ControlType.Viewbox:
1815
                        //    (item.DrawingData as IPath).updateControl();
1816
                        //    ((IViewBox)item.DrawingData).Angle = AngleValue;
1817
                        //    BorderUpdate();
1818
                        //    break;
1819
                        case ControlType.Date:
1820
                            //강인구 추가(2018.02.22)
1821
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1822
                            (item.DrawingData as IPath).updateControl();
1823
                            BorderUpdate();
1824
                            //MessageBox.Show("잠시 정확도를 위해 막아두었습니다!");
1825
                            break;
1826
                        case ControlType.ArrowMultiLine:
1827
                        case ControlType.ArcLine:
1828
                        case ControlType.SingleLine:
1829
                        case ControlType.Triangle:
1830
                            (item.DrawingData as IPath).updateControl();
1831
                            BorderUpdate();
1832
                            break;
1833
                        case ControlType.ArrowTextControl:
1834
                            (item.DrawingData as IPath).updateControl();
1835
                            BorderUpdate();
1836
                            break;
1837
                        case ControlType.RectCloud:
1838
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1839
                            (item.DrawingData as IPath).updateControl();
1840
                            BorderUpdate();
1841
                            break;
1842
                        case ControlType.Rectangle:
1843
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1844
                            (item.DrawingData as IPath).updateControl();
1845
                            BorderUpdate();
1846
                            break;
1847
                        case ControlType.ImgControl:
1848
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1849
                            (item.DrawingData as IPath).updateControl();
1850
                            BorderUpdate();
1851
                            break;
1852
                        //강인구 추가
1853
                        case ControlType.Sign:
1854
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1855
                            (item.DrawingData as IPath).updateControl();
1856
                            BorderUpdate();
1857
                            break;
1858
                        //강인구 추가
1859
                        case ControlType.Symbol:
1860
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1861
                            (item.DrawingData as IPath).updateControl();
1862
                            BorderUpdate();
1863
                            break;
1864
                        //강인구 추가
1865
                        case ControlType.Stamp:
1866
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1867
                            (item.DrawingData as IPath).updateControl();
1868
                            BorderUpdate();
1869
                            break;
1870
                        case ControlType.PolygonControl:
1871
                            //((IShapeControl)AllControl).Angle = AngleValue;
1872
                            (item.DrawingData as IPath).updateControl();
1873
                            BorderUpdate();
1874
                            break;
1875
                        case ControlType.PolygonCloud:
1876
                            //((IShapeControl)AllControl).Angle = AngleValue;
1877
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1878
                            (item.DrawingData as IPath).updateControl();
1879
                            BorderUpdate();
1880
                            break;
1881
                        case ControlType.Circle:
1882
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1883
                            (item.DrawingData as IPath).updateControl();
1884
                            ((CircleControl)item.DrawingData).SetCenterXY();
1885
                            BorderUpdate();
1886
                            break;
1887
                        case ControlType.Ink:
1888
                            //((IShapeControl)AllControl).Angle = AngleValue;
1889
                            (item.DrawingData as IPath).updateControl();
1890
                            BorderUpdate();
1891
                            break;
1892
                        default:
1893
                            break;
1894
                    }
1895
                }
1896
                #endregion
1897
            }));
1898
            //BorderUpdate();
1899
        }
1900

    
1901
        private void resize_MouseMove(object sender, MouseEventArgs e)
1902
        {
1903
            reSizePoint = e.GetPosition(this);
1904
            //Thumb thumb = sender as Thumb;
1905
            //if (this.isDragging && MemberSet.Count <= 1 && DraggerThumb == thumb)
1906
            ////if (thumb.IsDragging && MemberSet.Count <= 1 && DraggerThumb == thumb)
1907
            ////if (DraggerThumb == thumb)
1908
            //{
1909
            //    Point setPoint = e.GetPosition(this);
1910
            //    Canvas.SetLeft(thumb, setPoint.X);
1911
            //    Canvas.SetTop(thumb, setPoint.Y);
1912
            //    AdornerMember control = (from userThumb in MemberSet
1913
            //                             where userThumb.ThumbList.Contains(thumb)
1914
            //                             select userThumb).FirstOrDefault();
1915
            //    Point nearPoint = new Point(0, 0);
1916
            //    IPath AllControl = control.DrawingData as IPath;
1917
            //    if (ControlType.TextControl != control.Drawingtype)
1918
            //    {
1919

    
1920
            //        var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
1921
            //        List<Point> ps = new List<Point>();
1922

    
1923
            //        nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
1924
            //        //switch (Math.Abs(temp.Angle).ToString())
1925
            //        //{
1926

    
1927
            //        //    case "90":
1928
            //        //        {
1929
            //        //            nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
1930
            //        //        }
1931
            //        //        break;
1932
            //        //    case "270":
1933
            //        //        {
1934
            //        //            nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
1935
            //        //        }
1936
            //        //        break;
1937
            //        //    default:
1938
            //        //        {
1939
            //        //            nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
1940
            //        //        }
1941
            //        //        break;
1942
            //        //}
1943

    
1944
            //    }
1945
            //    for (int i = 0; i < (control.DrawingData as IPath).PointSet.Count; i++)
1946
            //    {
1947
            //        switch (control.Drawingtype)
1948
            //        {
1949
            //            #region Arc + Line
1950
            //            case ControlType.ArcLine:
1951
            //            case ControlType.SingleLine:
1952
            //                if (nearPoint.Equals(AllControl.PointSet[i]))
1953
            //                {
1954
            //                    AllControl.PointSet[i] = setPoint;
1955
            //                    AllControl.updateControl();
1956
            //                    DynamicThumbUpdate(control);
1957
            //                    BorderUpdate();
1958

    
1959
            //                    //if (control.DrawingData.GetType().Name == "ArrowTextControl")
1960
            //                    //{
1961
            //                    //    Thumb tm = control.ThumbList.Last();
1962
            //                    //    //Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width / 2));
1963
            //                    //    //Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height / 2));
1964
            //                    //    Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width));
1965
            //                    //    Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height));
1966
            //                    //}
1967
            //                }
1968
            //                break;
1969
            //            #endregion
1970
            //            #region Shape
1971
            //            case ControlType.Rectangle:
1972
            //                if (nearPoint.Equals(AllControl.PointSet[i]))
1973
            //                {
1974
            //                    AllControl.PointSet[i] = setPoint;
1975
            //                    var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1976
            //                    var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1977
            //                    var NextP = (i + 1) % AllControl.PointSet.Count();
1978

    
1979
            //                    var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
1980

    
1981
            //                    var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
1982
            //                    var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
1983
            //                        AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
1984
            //                    AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
1985
            //                        [ReverseP].Y
1986
            //                        + PreviousV.Y * l);
1987

    
1988
            //                    var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1989
            //                    l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1990
            //                        [i].Y - AllControl.PointSet[ReverseP].Y);
1991
            //                    AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1992
            //                        NextV.Y * l);
1993
            //                    AllControl.updateControl();
1994
            //                    DynamicThumbUpdate(control);
1995
            //                    BorderUpdate();
1996
            //                }
1997
            //                break;
1998
            //            #endregion
1999
            //            #region Polygon
2000
            //            case ControlType.PolygonControl:
2001
            //                if (nearPoint.Equals(AllControl.PointSet[i]))
2002
            //                {
2003
            //                    AllControl.PointSet[i] = setPoint;
2004
            //                    AllControl.updateControl();
2005
            //                    BorderUpdate();
2006
            //                }
2007
            //                break;
2008
            //            #endregion
2009
            //            #region Cicle
2010
            //            case ControlType.Circle:
2011
            //                if (nearPoint.Equals(AllControl.PointSet[i]))
2012
            //                {
2013
            //                    AllControl.PointSet[i] = setPoint;
2014
            //                    List<Point> newPointSet = new List<Point> { };
2015
            //                    Point middle = new Point(AllControl.PathData.Bounds.X + AllControl.PathData.Bounds.Width * 0.5,
2016
            //                        AllControl.PathData.Bounds.Y +
2017
            //                        AllControl.PathData.Bounds.Height * 0.5);
2018
            //                    foreach (Point pt in AllControl.PointSet)
2019
            //                    {
2020
            //                        newPointSet.Add(pt);
2021
            //                    }
2022
            //                    var ReverseP = (i + newPointSet.Count() / 2) % newPointSet.Count();
2023
            //                    var PreviousP = (i + (newPointSet.Count() - 1)) % newPointSet.Count();
2024
            //                    var NextP = (i + 1) % newPointSet.Count();
2025
            //                    var distance = MathSet.DistanceTo(newPointSet[ReverseP], newPointSet[i]);
2026
            //                    var PreviousV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[PreviousP]);
2027
            //                    var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, newPointSet[i].X - newPointSet[ReverseP].X,
2028
            //                        newPointSet[i].Y - newPointSet[ReverseP].Y);
2029
            //                    newPointSet[PreviousP] = new Point(newPointSet[ReverseP].X + PreviousV.X * l, newPointSet[ReverseP].Y
2030
            //                        + PreviousV.Y * l);
2031

    
2032
            //                    var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]);
2033
            //                    l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y
2034
            //                        - newPointSet[ReverseP].Y);
2035
            //                    newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l);
2036

    
2037
            //                    AllControl.PointSet = newPointSet;
2038
            //                    DynamicThumbUpdate(control);
2039
            //                    AllControl.updateControl();
2040
            //                    BorderUpdate();
2041
            //                }
2042
            //                break;
2043
            //            #endregion
2044
            //            #region ArrowText
2045
            //            case ControlType.ArrowTextControl:
2046
            //                if (nearPoint.Equals(AllControl.PointSet[i]))
2047
            //                {
2048
            //                    AllControl.PointSet[i] = setPoint;
2049
            //                    AllControl.updateControl();
2050

    
2051
            //                    DynamicThumbUpdate(control);
2052
            //                    BorderUpdate();
2053

    
2054
            //                    //if (control.DrawingData.GetType().Name == "ArrowTextControl")
2055
            //                    //{
2056
            //                    //    Thumb tm = control.ThumbList.Last();
2057
            //                    //    //Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width / 2));
2058
            //                    //    //Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height / 2));
2059
            //                    //    Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width));
2060
            //                    //    Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height));
2061
            //                    //}
2062
            //                }
2063
            //                break;
2064
            //            #endregion
2065
            //            #region Text
2066
            //            case ControlType.TextControl:
2067
            //                break;
2068
            //            #endregion
2069
            //            #region Image
2070
            //            case ControlType.ImgControl:
2071
            //                if (nearPoint.Equals(AllControl.PointSet[i]))
2072
            //                {
2073
            //                    AllControl.PointSet[i] = setPoint;
2074
            //                    var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
2075
            //                    var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
2076
            //                    var NextP = (i + 1) % AllControl.PointSet.Count();
2077

    
2078
            //                    var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
2079

    
2080
            //                    var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
2081
            //                    var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
2082
            //                        AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
2083
            //                    AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
2084
            //                        [ReverseP].Y
2085
            //                        + PreviousV.Y * l);
2086

    
2087
            //                    var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
2088
            //                    l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
2089
            //                        [i].Y - AllControl.PointSet[ReverseP].Y);
2090
            //                    AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
2091
            //                        NextV.Y * l);
2092
            //                    AllControl.updateControl();
2093
            //                    DynamicThumbUpdate(control);
2094
            //                    BorderUpdate();
2095
            //                }
2096
            //                break;
2097
            //            #endregion
2098
            //            #region Cloud
2099
            //            case ControlType.PolygonCloud:
2100
            //                if (nearPoint.Equals(AllControl.PointSet[i]))
2101
            //                {
2102
            //                    AllControl.PointSet[i] = setPoint;
2103
            //                    AllControl.updateControl();
2104
            //                    ((ICloudControl)AllControl).DrawingCloud();
2105
            //                    BorderUpdate();
2106
            //                }
2107
            //                break;
2108
            //            #endregion
2109
            //            #region SymBol
2110
            //            //case MarkupType.Viewbox:
2111
            //            //    if (nearPoint.Equals(AllControl.PointSet[i]))
2112
            //            //    {
2113
            //            //        AllControl.PointSet[i] = setPoint;
2114
            //            //        var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
2115
            //            //        var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
2116
            //            //        var NextP = (i + 1) % AllControl.PointSet.Count();
2117

    
2118
            //            //        var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]);
2119

    
2120
            //            //        var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]);
2121
            //            //        var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X,
2122
            //            //            AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y);
2123
            //            //        AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet
2124
            //            //            [ReverseP].Y
2125
            //            //            + PreviousV.Y * l);
2126

    
2127
            //            //        var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
2128
            //            //        l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
2129
            //            //            [i].Y - AllControl.PointSet[ReverseP].Y);
2130
            //            //        AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
2131
            //            //            NextV.Y * l);
2132
            //            //        AllControl.updateControl();
2133
            //            //        DynamicThumbUpdate(control);
2134
            //            //        BorderUpdate();
2135
            //            //    }
2136
            //            //    break;
2137
            //            #endregion
2138
            //            default:
2139
            //                break;
2140
            //        }
2141
            //    }
2142
            //}
2143
        }
2144
        /// <summary>
2145
        /// 회전
2146
        /// </summary>
2147
        /// <param name="sender"></param>
2148
        /// <param name="e"></param>
2149
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
2150
        {
2151

    
2152
            MoveRotate(e);
2153
        }
2154

    
2155
        double LastRotateHorizontalValue = 0;
2156
        double LastRotateVerticalValue = 0;
2157
        double LastWidthValue = 0;
2158
        double SetWidth = 0;
2159
        bool RotateFlag = false;
2160

    
2161
        /// <summary>
2162
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
2163
        /// </summary>
2164
        /// <param name="e"></param>
2165
        public void MoveRotate(DragDeltaEventArgs e)
2166
        {
2167
            double dDeltaAngle = 0;
2168

    
2169
            List<Point> AllPointSet = new List<Point>();
2170
            Point CenterPoint = new Point();
2171
            #region 회전율에 따른 DragDelta 값
2172

    
2173
            #region 원본소스
2174
            ////if (Math.Abs(e.HorizontalChange) > Math.Abs(e.VerticalChange))
2175
            ////{
2176
            //    //dDeltaAngle = +2;
2177
            //    //dDeltaAngle = (e.HorizontalChange / 20);
2178
            //    AngleValue = AngleValue + dDeltaAngle;
2179
            //    if (Math.Abs(e.HorizontalChange) > Math.Abs(e.VerticalChange))
2180
            //    {
2181
            //        if (LastRotateHorizontalValue < e.HorizontalChange)
2182
            //        {
2183
            //            dDeltaAngle = 2;
2184
            //            AngleValue = AngleValue + dDeltaAngle;
2185
            //        }
2186
            //        else
2187
            //        {
2188
            //            dDeltaAngle = -2;
2189
            //            AngleValue = AngleValue + dDeltaAngle;
2190
            //        }
2191
            //    }
2192
            //    //else
2193
            //    //{
2194
            //    //    if (LastRotateVerticalValue < e.VerticalChange)
2195
            //    //    {
2196
            //    //        dDeltaAngle = -2;
2197
            //    //        AngleValue = AngleValue + dDeltaAngle;
2198

    
2199
            //    //    }
2200
            //    //    else
2201
            //    //    {
2202
            //    //        dDeltaAngle = 2;
2203
            //    //        AngleValue = AngleValue + dDeltaAngle;
2204
            //    //    }
2205
            //    //}
2206
            ////}
2207
            ////else if (Math.Abs(e.HorizontalChange) < Math.Abs(e.VerticalChange))
2208
            ////{
2209
            ////    //dDeltaAngle = (e.VerticalChange / 20);
2210
            ////    dDeltaAngle = -2;
2211
            ////    AngleValue = AngleValue + dDeltaAngle;
2212
            ////} 
2213
            #endregion
2214

    
2215
            //강인구 수정
2216
            //AngleValue = AngleValue + dDeltaAngle;
2217
            #endregion
2218

    
2219
            #region 센터 포인트 구하기 (그룹핑)
2220
            foreach (var item in MemberSet)
2221
            {
2222
                if (item.DrawingData.GetType().Name == "TextControl")
2223
                {
2224
                    //if (AngleValue == 0)
2225
                    //{
2226
                    //    AngleValue = (item.DrawingData as TextControl).Angle;
2227
                    //}
2228
                    //double X = Canvas.GetLeft((item.DrawingData as TextControl));
2229
                    //double Y = Canvas.GetTop((item.DrawingData as TextControl));
2230
                    //AllPointSet.Add(new Point(X,Y));
2231
                    if (AngleValue == 0)
2232
                    {
2233
                        AngleValue = (item.DrawingData as TextControl).Angle;
2234
                    }
2235
                    double X = Canvas.GetLeft((item.DrawingData as TextControl));
2236
                    double Y = Canvas.GetTop((item.DrawingData as TextControl));
2237
                    AllPointSet.Add(new Point(X, Y));
2238
                }
2239
                else
2240
                {
2241
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
2242
                    {
2243
                        AllPointSet.Add(itemP);
2244
                    }
2245
                }
2246
            }
2247
            #endregion
2248
            CenterPoint = MathSet.FindCentroid(AllPointSet);
2249
            Point pt = Mouse.GetPosition(this);
2250

    
2251

    
2252

    
2253

    
2254
            //if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name != "TextControl")
2255
            //{
2256
            Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
2257
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
2258
            dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
2259

    
2260
            System.Diagnostics.Debug.WriteLine("vec1 : " + vec1.X + "/" + vec1.Y);
2261
            System.Diagnostics.Debug.WriteLine("vec2 : " + vec2.X + "/" + vec2.Y);
2262
            System.Diagnostics.Debug.WriteLine("dDeltaAngle : " + dDeltaAngle);
2263

    
2264
            //}
2265
            //else
2266
            //{
2267
            //if (IsTextAngle || RotateFlag)
2268
            //{
2269
            //    AngleValue = ((MemberSet.First() as AdornerMember).DrawingData as TextControl).Angle + 5;
2270
            //}
2271
            //else
2272
            //{
2273
            //    AngleValue = ((MemberSet.First() as AdornerMember).DrawingData as TextControl).Angle - 5;
2274
            //}
2275
            //}
2276

    
2277
            AngleValue += dDeltaAngle;
2278
            if (AngleValue > 360) AngleValue -= 360;
2279
            if (AngleValue < 0) AngleValue += 360;
2280
            this.rotatePoint = pt;  /// save rotatePoint
2281

    
2282
            Dispatcher.BeginInvoke((Action)(() =>
2283
            {
2284
                foreach (var item in MemberSet)
2285
                {
2286
                    foreach (var thumb in item.ThumbList)
2287
                    {
2288
                        double x = Canvas.GetLeft(thumb);
2289
                        double y = Canvas.GetTop(thumb);
2290

    
2291
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
2292
                        Canvas.SetLeft(thumb, value.X);
2293
                        Canvas.SetTop(thumb, value.Y);
2294

    
2295
                        /*if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last())
2296
                        {
2297
                            Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
2298
                            Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
2299
                            if (!(item.DrawingData as ArrowTextControl).isTrans)
2300
                            {
2301
                                List<Point> ps = new List<Point>();
2302
                                
2303
                                //강인구 추가
2304
                                //var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
2305
                                var temp = item.DrawingData as ArrowTextControl;
2306
                                switch (Math.Abs(temp.Angle).ToString())
2307
                                {
2308
                                    case "90":
2309
                                        {
2310
                                            ps.Clear();
2311
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
2312
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
2313
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
2314

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

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

    
2321
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
2322
                                        }
2323
                                        break;
2324
                                    case "270":
2325
                                        {
2326
                                            ps.Clear();
2327
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
2328
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
2329
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
2330

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

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

    
2337
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
2338
                                        }
2339
                                        break;
2340
                                    default:
2341
                                        {
2342
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
2343
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
2344
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
2345
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
2346
                                        }
2347
                                        break;
2348
                                }
2349

    
2350
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
2351
                                var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
2352

    
2353
                                Canvas.SetLeft((MemberSet.Where(data => data.DrawingData.GetType().Name == "ArrowTextControl")).FirstOrDefault().ThumbList[1], tempP.X);
2354
                                Canvas.SetTop((MemberSet.Where(data => data.DrawingData.GetType().Name == "ArrowTextControl")).FirstOrDefault().ThumbList[1], tempP.Y);
2355
                                //Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X);
2356
                                //Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y);
2357
                            }
2358
                        }*/
2359
                    }
2360

    
2361
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
2362
                    {
2363
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
2364
                    }
2365
                }
2366
                #region 보더 업데이트
2367
                foreach (var item in MemberSet)
2368
                {
2369
                    switch (item.Drawingtype)
2370
                    {
2371
                        case ControlType.TextControl:
2372
                            ((TextControl)item.DrawingData).Angle = AngleValue;
2373
                            //trRotate.Angle = AngleValue;
2374

    
2375
                            RectangleGeometry Data = new RectangleGeometry
2376
                            {
2377
                                Rect = new Rect()
2378
                                {
2379
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
2380
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
2381
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
2382
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
2383
                                }
2384
                            };
2385
                            //if ((firstCondition as TextControl).Angle != 0)
2386
                            //{
2387
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
2388
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);
2389

    
2390

    
2391
                            //AdornerBorder.RenderTransformOrigin = new Point(1, 1);
2392
                            //AdornerBorder.RenderTransform = new RotateTransform()
2393
                            //{
2394
                            //    Angle = (member as TextControl).Angle * -1,
2395
                            //    CenterX = middle.X + ((member as TextControl) as FrameworkElement).ActualWidth /2,
2396
                            //    CenterY = middle.Y + ((member as TextControl) as FrameworkElement).ActualHeight /2,
2397
                            //};
2398

    
2399

    
2400
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
2401
                            DragThumb.RenderTransform = new RotateTransform()
2402
                            {
2403
                                Angle = (item.DrawingData as TextControl).Angle,
2404
                                //CenterX = middle.X,
2405
                                //CenterY = middle.Y,
2406
                            };
2407

    
2408
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
2409
                            AdornerBorder.RenderTransform = new RotateTransform()
2410
                            {
2411
                                Angle = (item.DrawingData as TextControl).Angle,
2412
                                //CenterX = middle.X,
2413
                                //CenterY = middle.Y,
2414
                            };
2415

    
2416
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
2417
                            {
2418
                                Angle = (item.DrawingData as TextControl).Angle,
2419
                            };
2420

    
2421
                            BorderUpdate();
2422
                            break;
2423
                        //case ControlType.Viewbox:
2424
                        //    (item.DrawingData as IPath).updateControl();
2425
                        //    ((IViewBox)item.DrawingData).Angle = AngleValue;
2426
                        //    BorderUpdate();
2427
                        //    break;
2428
                        case ControlType.Date:
2429

    
2430
                            //강인구 추가(2018.02.22)
2431
                            ((DateControl)item.DrawingData).Angle = AngleValue;
2432
                            (item.DrawingData as IPath).updateControl();
2433

    
2434
                            BorderUpdate();
2435
                            //MessageBox.Show("잠시 정확도를 위해 막아두었습니다!");
2436
                            break;
2437
                        case ControlType.ArrowMultiLine:
2438
                        case ControlType.ArcLine:
2439
                        case ControlType.SingleLine:
2440
                        case ControlType.Triangle:
2441
                            (item.DrawingData as IPath).updateControl();
2442
                            BorderUpdate();
2443
                            break;
2444
                        case ControlType.ArrowTextControl:
2445
                            (item.DrawingData as IPath).updateControl();
2446
                            BorderUpdate();
2447
                            break;
2448
                        case ControlType.RectCloud:
2449
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
2450
                            (item.DrawingData as IPath).updateControl();
2451
                            BorderUpdate();
2452
                            break;
2453
                        case ControlType.Rectangle:
2454
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
2455
                            (item.DrawingData as IPath).updateControl();
2456
                            BorderUpdate();
2457
                            break;
2458
                        case ControlType.ImgControl:
2459
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
2460
                            (item.DrawingData as IPath).updateControl();
2461
                            BorderUpdate();
2462
                            break;
2463
                        //강인구 추가
2464
                        case ControlType.Sign:
2465
                            ((SignControl)item.DrawingData).Angle = AngleValue;
2466
                            (item.DrawingData as IPath).updateControl();
2467
                            BorderUpdate();
2468
                            break;
2469
                        //강인구 추가
2470
                        case ControlType.Symbol:
2471
                            ((SymControl)item.DrawingData).Angle = AngleValue;
2472
                            (item.DrawingData as IPath).updateControl();
2473
                            BorderUpdate();
2474
                            break;
2475
                        //강인구 추가
2476
                        case ControlType.Stamp:
2477
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
2478
                            (item.DrawingData as IPath).updateControl();
2479
                            BorderUpdate();
2480
                            break;
2481
                        case ControlType.PolygonControl:
2482
                            //((IShapeControl)AllControl).Angle = AngleValue;
2483
                            (item.DrawingData as IPath).updateControl();
2484
                            BorderUpdate();
2485
                            break;
2486
                        case ControlType.PolygonCloud:
2487
                            //((IShapeControl)AllControl).Angle = AngleValue;
2488
                            ((ICloudControl)item.DrawingData).DrawingCloud();
2489
                            (item.DrawingData as IPath).updateControl();
2490
                            BorderUpdate();
2491
                            break;
2492
                        case ControlType.Circle:
2493
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
2494
                            (item.DrawingData as IPath).updateControl();
2495
                            ((CircleControl)item.DrawingData).SetCenterXY();
2496
                            BorderUpdate();
2497
                            break;
2498
                        case ControlType.Ink:
2499
                            for (int i = 0; i < (item.DrawingData as InkControl).PointC.Count(); i++)
2500
                            {
2501
                                for (int j = 0; j < (item.DrawingData as InkControl).PointC[i].pointSet.Count; j++)
2502
                                {
2503
                                    (item.DrawingData as InkControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as InkControl).PointC[i].pointSet[j], dDeltaAngle);
2504
                                }
2505
                            }
2506
                            (item.DrawingData as IPath).updateControl();
2507
                            BorderUpdate();
2508
                            break;
2509
                        //case MarkupType.PolygonEx:
2510
                        //    //trRotate.Angle = AngleValue;
2511
                        //    for (int i = 0; i < (item.DrawingData as PolyControl).PointC.Count(); i++)
2512
                        //    {
2513
                        //        //(item.DrawingData as PolyControl).PointC[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as PolyControl).PointC[i]., dDeltaAngle);
2514
                        //        for (int j = 0; j < (item.DrawingData as PolyControl).PointC[i].pointSet.Count; j++)
2515
                        //        {
2516
                        //            (item.DrawingData as PolyControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as PolyControl).PointC[i].pointSet[j], dDeltaAngle);
2517
                        //        }
2518
                        //    }
2519
                        //    (item.DrawingData as IPath).updateControl();
2520
                        //    BorderUpdate();
2521
                        //    break;
2522
                        default:
2523
                            break;
2524
                    }
2525
                }
2526
                #endregion
2527
            }));
2528
            BorderUpdate();
2529
        }
2530

    
2531
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
2532
        {
2533
            ////System.Windows.Forms.Cursor.Position = new System.Drawing.Point(System.Windows.Forms.Cursor.Position.X - 150, System.Windows.Forms.Cursor.Position.Y - 150);
2534
            //this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
2535
            //rotateTop.Cursor = Cursors.SizeAll;
2536

    
2537
            ////CustomCursor.SetCursorTemplate(rotateTop, this.Resources["AnimatedCursor"] as DataTemplate);
2538
            ////rotateTop.Cursor = Cursors.None;
2539

    
2540
            ////if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().PointSet != null)
2541
            ////{
2542
            ////    return;
2543
            ////}
2544

    
2545
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
2546
            rotateTop.Cursor = Cursors.SizeAll;
2547

    
2548
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
2549
            if ((1 == MemberSet.Count) && (MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2550
            {
2551
                this.AngleValue = ((MemberSet.First() as AdornerMember).DrawingData as TextControl).Angle;
2552
            }
2553
            /// up to here
2554

    
2555

    
2556

    
2557
            if (ViewerDataModel.Instance.UndoDataList == null)
2558
            {
2559
                return;
2560
            }
2561

    
2562
            if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
2563
            {
2564
                return;
2565
            }
2566
            if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
2567
            {
2568
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
2569
                {
2570
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
2571
                    {
2572
                        return;
2573
                    }
2574
                }
2575
            }
2576

    
2577
            Undo_Event();
2578
        }
2579

    
2580
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
2581
        {
2582
            //CustomCursor.SetCursorTemplate(rotateTop, null);
2583
            rotateTop.Cursor = Cursors.Arrow;
2584

    
2585
            Undo_Event();
2586
        }
2587

    
2588
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
2589
        {
2590
            if (ViewerDataModel.Instance.UndoDataList == null)
2591
            {
2592
                return;
2593
            }
2594
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
2595
            {
2596
                return;
2597
            }
2598
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
2599
            {
2600
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
2601
                {
2602
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
2603
                    {
2604
                        return;
2605
                    }
2606
                }
2607
            }
2608

    
2609
            Undo_Event();
2610
        }
2611

    
2612
        private void Undo_Event()
2613
        {
2614
            List<Point> p_set = new List<Point>();
2615

    
2616
            Undo_data UndoData = new Undo_data()
2617
            {
2618
                IsUndo = false,
2619
                Event = Event_Type.Thumb,
2620
                EventTime = DateTime.Now,
2621
                Markup_List = new List<Multi_Undo_data>(),
2622
            };
2623

    
2624
            Multi_Undo_data multi_Undo_Data = new Multi_Undo_data();
2625

    
2626
            foreach (var control in MemberSet)
2627
            {
2628
                multi_Undo_Data.PointSet = new List<Point>();
2629
                p_set = new List<Point>();
2630

    
2631
                if (control.DrawingData as TextControl != null)
2632
                {
2633
                    multi_Undo_Data.PointSet.Add((control.DrawingData as TextControl).StartPoint);
2634
                    multi_Undo_Data.PointSet.Add((control.DrawingData as TextControl).EndPoint);
2635
                }
2636

    
2637
                foreach (var point in ((control.DrawingData as CommentUserInfo) as IPath).PointSet)
2638
                {
2639
                    multi_Undo_Data.PointSet.Add(point);
2640
                }
2641

    
2642
                multi_Undo_Data.Angle = AngleValue;
2643

    
2644
                multi_Undo_Data.Markup = control.DrawingData as CommentUserInfo;
2645
                UndoData.Markup_List.Add(multi_Undo_Data);
2646
                multi_Undo_Data = new Multi_Undo_data();
2647
            }
2648
            ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i =>
2649
            {
2650
                ViewerDataModel.Instance.UndoDataList.Remove(i);
2651
            });
2652

    
2653
            ViewerDataModel.Instance.UndoDataList.Add(UndoData);
2654

    
2655
        }
2656

    
2657
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
2658
        {
2659
            //CustomCursor.SetCursorTemplate(DragThumb, null);
2660
            DragThumb.Cursor = Cursors.Arrow;
2661

    
2662
            Undo_Event();
2663
        }
2664

    
2665
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
2666
        {
2667
            AdornerMember control = MemberSet.FirstOrDefault();
2668

    
2669
            if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null)
2670
            {
2671
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
2672
                {
2673
                    (control.DrawingData as ArrowTextControl).isTrans = true;
2674
                }
2675
            }
2676

    
2677
        }
2678

    
2679
        public void TextControlChanger()
2680
        {
2681
            if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2682
            {
2683
                TextControl AllControl = (MemberSet.First() as AdornerMember).DrawingData as TextControl;
2684
                AllControl.Base_TextBox.Focus();
2685
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
2686
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
2687
                AllControl.Base_TextBox.Focus();
2688
                AllControl.SizeChanged += (sen, ea) =>
2689
                {
2690
                    if (AllControl.Base_TextBox != null)
2691
                    {
2692
                        RectangleGeometry Data = new RectangleGeometry
2693
                        {
2694
                            Rect = new Rect()
2695
                            {
2696
                                X = AllControl.StartPoint.X,
2697
                                Y = AllControl.StartPoint.Y,
2698
                                Width = AllControl.Base_TextBox.Width,
2699
                                Height = AllControl.Base_TextBox.Height,
2700
                            }
2701
                        };
2702

    
2703
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
2704
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
2705
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
2706
                        {
2707
                            Angle = AllControl.Angle,
2708
                            CenterX = middle.X,
2709
                            CenterY = middle.Y,
2710
                        };
2711
                    }
2712
                    BorderUpdate();
2713
                };
2714
            }
2715
        }
2716

    
2717
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
2718
        {
2719
            if (e.ClickCount == 2 && MemberSet.Count == 1)
2720
            {
2721

    
2722
                if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2723
                {
2724
                    TextControlChanger();
2725
                    //    TextControl AllControl = (MemberSet.First() as AdornerMember).DrawingData as TextControl;
2726
                    //    AllControl.Base_TextBox.Focus();
2727
                    //    AllControl.Base_TextBox.Visibility = Visibility.Visible;
2728
                    //    AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
2729
                    //    AllControl.Base_TextBox.Focus();
2730
                    //    AllControl.SizeChanged += (sen, ea) =>
2731
                    //    {
2732
                    //        if (AllControl.Base_TextBox != null)
2733
                    //        {   
2734
                    //            RectangleGeometry Data = new RectangleGeometry
2735
                    //            {
2736
                    //                Rect = new Rect()
2737
                    //                {
2738
                    //                    X = AllControl.StartPoint.X,
2739
                    //                    Y = AllControl.StartPoint.Y,
2740
                    //                    Width = AllControl.Base_TextBox.Width,
2741
                    //                    Height = AllControl.Base_TextBox.Height,
2742
                    //                }
2743
                    //            };
2744

    
2745
                    //            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
2746
                    //            Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
2747
                    //            AllControl.Base_Grid.RenderTransform = new RotateTransform()
2748
                    //            {
2749
                    //                Angle = AllControl.Angle,
2750
                    //                CenterX = middle.X,
2751
                    //                CenterY = middle.Y,
2752
                    //            };
2753
                    //        }
2754
                    //        BorderUpdate();
2755
                    //    };
2756
                }
2757

    
2758
                else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2759
                {
2760
                    ArrowTextControl AllControl = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl;
2761
                    Thumb tm = (MemberSet.First() as AdornerMember).ThumbList.Last();
2762
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
2763

    
2764
                    //강인구 추가(ArrowControl TextBox Thumb없애기
2765
                    tm.Visibility = Visibility.Collapsed;
2766

    
2767
                    ((MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
2768

    
2769
                    //(sender as System.Windows.Shapes.Rectangle).IsHitTestVisible = false;
2770
                    //(sender as System.Windows.Shapes.Rectangle).Visibility = Visibility.Hidden;
2771
                    //Canvas.SetZIndex(((ArrowTextControl)AllControl).Base_TextBox,9999);
2772
                    //editTextBox = ((ArrowTextControl)AllControl).Base_TextBox;
2773
                    //editTextBox.Style = ((ArrowTextControl)AllControl).Base_TextBox.Style;
2774
                    //editTextBox.Text = (AllControl as ArrowTextControl).ArrowText;
2775
                    //editTextBox.FontSize = (AllControl as ArrowTextControl).FontSize;
2776
                    //editTextBox.Foreground = (AllControl as ArrowTextControl).Foreground;
2777
                    //editTextBox.FontWeight = (AllControl as ArrowTextControl).FontWeight;
2778

    
2779
                    //(AllControl as ArrowTextControl).Base_TextBox.Visibility = Visibility.Collapsed;
2780
                    //editTextBox = (AllControl as ArrowTextControl).Base_TextBox;
2781
                    //editTextBox.TextChanged += (sen, ea) =>
2782
                    //  {
2783
                    //      ((ArrowTextControl)AllControl).ArrowText = editTextBox.Text;
2784
                    //  };
2785

    
2786

    
2787
                    //(sender as System.Windows.Shapes.Rectangle).Visibility = Visibility.Hidden;
2788
                    //((ArrowTextControl)AllControl).Base_TextBox.Background = new SolidColorBrush(Colors.Blue);
2789
                    //((ArrowTextControl)AllControl).Base_TextBox.Opacity = 1;
2790
                    //((ArrowTextControl)AllControl).Base_TextBox.Focus();
2791

    
2792
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
2793

    
2794
                    {
2795
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
2796
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
2797

    
2798
                        List<Point> ps = new List<Point>();
2799
                        //RotateTransform myRotateTransform = new RotateTransform();
2800

    
2801

    
2802
                        //if (control.Angle == -270)
2803
                        //{
2804
                        //    myRotateTransform.Angle = 90;
2805
                        //    myRotateTransform.CenterX = Canvas.GetLeft(control.Base_TextBox);
2806
                        //    myRotateTransform.CenterY = Canvas.GetTop(control.Base_TextBox);
2807
                        //}
2808
                        //else if (control.Angle == -90)
2809
                        //{
2810
                        //    myRotateTransform.Angle = 270;
2811
                        //    myRotateTransform.CenterX = Canvas.GetLeft(control.Base_TextBox);
2812
                        //    myRotateTransform.CenterY = Canvas.GetTop(control.Base_TextBox);
2813
                        //}
2814
                        //TransformGroup myTransformGroup = new TransformGroup();
2815
                        //myTransformGroup.Children.Add(myRotateTransform);
2816

    
2817
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
2818
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
2819
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
2820
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
2821

    
2822

    
2823

    
2824

    
2825
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
2826
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
2827
                        if (AllControl.isTrans)
2828
                        {
2829
                            Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
2830
                            Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
2831
                        }
2832
                        else
2833
                        {
2834
                            Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X);
2835
                            Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y);
2836
                        }
2837

    
2838

    
2839
                        BorderUpdate();
2840

    
2841
                    };
2842
                }
2843
                else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
2844
                {
2845
                    DateControl data = (MemberSet.First() as AdornerMember).DrawingData as DateControl;
2846
                    CalendarControl instanceCal = new CalendarControl(data.Text);
2847
                    //dropData.IsOpen = true;
2848
                    RadWindow rc = new RadWindow();
2849
                    rc.Width = 300;
2850
                    rc.Height = 300;
2851
                    rc.Header = "Change Date";
2852
                    rc.Content = instanceCal;
2853
                    rc.BorderThickness = new Thickness(3);
2854
                    rc.ResizeMode = ResizeMode.NoResize;
2855
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2856
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
2857
                    rc.ModalBackground.Opacity = 0.6;
2858
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
2859
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
2860
                    {
2861
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
2862
                        rc.Close();
2863
                    };
2864
                    rc.ShowDialog();
2865
                    //CalendarControl.xaml
2866
                }
2867
                else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
2868
                {
2869
                    ArcControl instance = ((MemberSet.First() as AdornerMember).DrawingData as ArcControl);
2870
                    if (instance.isTransOn)
2871
                    {
2872
                        instance.isTransOn = false;
2873
                    }
2874
                    else
2875
                    {
2876
                        instance.isTransOn = true;
2877
                    }
2878
                    instance.SetArcPath();
2879
                    BorderUpdate();
2880
                }
2881
                //else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "CloudControl")
2882
                //{
2883
                //    CloudControl instance = ((MemberSet.First() as AdornerMember).DrawingData as CloudControl);
2884
                //    if (!instance.isChain)
2885
                //    {
2886
                //        if (instance.isTransOn)
2887
                //        {
2888
                //            instance.isTransOn = false;
2889
                //        }
2890
                //        else
2891
                //        {
2892
                //            instance.isTransOn = true;
2893
                //        }
2894

    
2895
                //        instance.SetCloud();
2896
                //        BorderUpdate();
2897
                //    }
2898
                //}
2899
                //else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "LineControl")
2900
                //{
2901
                //    LineControl instance = ((MemberSet.First() as AdornerMember).DrawingData as LineControl);
2902
                //    if (instance.LineStyle == LineControl.LineStyleSet.MultiLine)
2903
                //    {
2904
                //        instance.Interval += 1;
2905
                //        instance.SetLinePath();
2906
                //        BorderUpdate();
2907
                //    }
2908

    
2909
                //    //instance.SetCloud();
2910
                //    //BorderUpdate();
2911
                //}
2912

    
2913
            }
2914
            //if (e.ClickCount == 2 && AllControl.GetType().Name == "TextControl") // Edit Mode
2915
            //{
2916
            //    ((TextControl)AllControl).Base_TextBox.Focus();
2917
            //    ((TextControl)AllControl).Base_TextBox.Visibility = Visibility.Visible;
2918
            //    ((TextControl)AllControl).Base_TextBlock.Visibility = Visibility.Collapsed;
2919
            //}
2920
            //if (e.ClickCount == 2 && AllControl.GetType().Name == "ArrowTextControl") // Edit Mode
2921
            //{
2922
            //    Thumb tm = (from kkk in this.ContainerContent.Children
2923
            //                where (kkk as FrameworkElement).Name == "LastThumb"
2924
            //                select kkk).FirstOrDefault() as Thumb;
2925
            //    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
2926
            //    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
2927
            //    {
2928
            //        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
2929
            //        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
2930
            //        Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width / 2));
2931
            //        Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height / 2));
2932
            //        Canvas.SetLeft((AllControl as ArrowTextControl).Base_TextBox, (AllControl.EndPoint.X - tm.Width / 2));
2933
            //        Canvas.SetTop((AllControl as ArrowTextControl).Base_TextBox, (AllControl.EndPoint.Y - tm.Height / 2));
2934
            //    };
2935
            //}
2936
        }
2937
        #endregion
2938

    
2939
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2940
        {
2941
            if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2942
            {
2943
                DragThumb.Visibility = Visibility.Collapsed;
2944
            }
2945
        }
2946

    
2947
        //private void testText_Loaded(object sender, RoutedEventArgs e)
2948
        //{
2949
        //    editTextBox = sender as TextBox;
2950
        //}
2951
    }
2952
}
클립보드 이미지 추가 (최대 크기: 500 MB)