프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 05009a0e

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

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

    
24
namespace KCOM.Controls
25
{
26
    /// <summary>
27
    /// Interaction logic for AdornerFinal.xaml
28
    /// </summary>
29
    public class AdornerMember
30
    {
31
        public UIElement DrawingData { get; set; }
32
        public ControlType Drawingtype { get; set; }
33
        public double DrawingAngle { get; set; }
34
        public List<Thumb> ThumbList { get; set; }
35
        public string Symbol_ID { get; set; }
36
        public long Group_ID { get; set; }
37
    }
38

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

    
55
        private bool disposed;
56

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

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

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

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

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

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

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

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

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

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

    
161
                }
162
                finally
163
                {
164
                    
165
                }
166
            }
167
            this.SetAdornerMember(objectData);
168
            this.Focus();
169
        }
170

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

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

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

    
301

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

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

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

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

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

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

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

    
453
                            }
454

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

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

    
491
            BorderUpdate();
492
        }
493

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

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

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

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

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

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

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

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

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

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

    
722

    
723
                        switch (Math.Abs(temp.Angle).ToString())
724
                        {
725
                            case "90":
726
                                {
727
                                    ps.Clear();
728
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
729
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
730
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
731

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

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

    
738
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
739
                                }
740
                                break;
741
                            case "270":
742
                                {
743
                                    ps.Clear();
744
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
745
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
746
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
747

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

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

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

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

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

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

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

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

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

    
909

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

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

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

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

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

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

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

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

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

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

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

    
1039

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

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

    
1047
                                AllControl.updateControl();
1048

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1229

    
1230

    
1231
        #endregion
1232
        #region 이벤트
1233

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

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

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

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

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

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

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

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

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

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

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

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

    
1367
                    #endregion
1368

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

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

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

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

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

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

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

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

    
1445

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

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

    
1458

    
1459

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

    
1499
        public void Set_Rotate()
1500
        {
1501

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

    
1506

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

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

    
1532
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1533

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1640
                            };
1641

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

    
1647
                            };
1648

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

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

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

    
1762
            MoveRotate(e);
1763
        }
1764

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1882
                            BorderUpdate();
1883
                            break;
1884

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

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

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

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

    
1981

    
1982

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

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

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

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

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

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

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

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

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

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

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

    
2065
        }
2066

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

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

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

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

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

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

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

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

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

    
2139

    
2140

    
2141

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

    
2155

    
2156
                        BorderUpdate();
2157

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

    
2213
            }
2214
            
2215
        }
2216
        #endregion
2217

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

    
2226
    }
2227
}