프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (116 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
    public class MyThumb : Thumb
27
    {
28
        public MyThumb()
29
        {
30
            this.Opacity = 0.6;
31
            this.MouseEnter += MyThumb_MouseEnter;
32
            this.MouseLeave += MyThumb_MouseLeave;
33
        }
34

    
35
        /// <summary>
36
        /// </summary>
37
        /// <param name="sender"></param>
38
        /// <param name="e"></param>
39
        private void MyThumb_MouseLeave(object sender, MouseEventArgs e)
40
        {
41
            this.Opacity = 0.6;
42
        }
43

    
44
        /// <summary>
45
        /// 
46
        /// </summary>
47
        /// <param name="sender"></param>
48
        /// <param name="e"></param>
49
        private void MyThumb_MouseEnter(object sender, MouseEventArgs e)
50
        {
51
            this.Opacity = 1.0;
52
        }
53
    }
54

    
55
    /// <summary>
56
    /// Interaction logic for AdornerFinal.xaml
57
    /// </summary>
58
    public class AdornerMember
59
    {
60
        public UIElement DrawingData { get; set; }
61
        public ControlType Drawingtype { get; set; }
62
        public double DrawingAngle { get; set; }
63
        public List<MyThumb> ThumbList { get; set; }
64
        public string Symbol_ID { get; set; }
65
        public long Group_ID { get; set; }
66
    }
67

    
68
    public partial class AdornerFinal : UserControl
69
    {
70
        public TextBox editTextBox { get; set; }
71
        #region 공용 인스턴스
72
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
73
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
74
        public double AngleValue = 0;
75
        public bool IsTextAngle = false;
76
        public Rect BorderSize { get; set; }
77
        public bool TextCompensation = false;
78
        public bool isDragging { get; set; }
79
        public Thumb DraggerThumb { get; set; }
80
        public RadDropDownButton dropData;
81
        public RadCalendar dropCalendar;
82
        public Thumb mainDragThumb { get; set; }
83

    
84
        private bool disposed;
85

    
86
        public Point reSizePoint { get; set; }
87
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
88
        #endregion
89
        #region 생성자
90
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
91
        {
92
            dropData = sender as RadDropDownButton;
93
        }
94

    
95
        private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
96
        {
97
            dropCalendar = sender as RadCalendar;
98
            dropCalendar.SelectionChanged += (sen, ea) =>
99
            {
100
                dropData.IsOpen = false;
101
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
102
                {
103
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
104
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
105
                }
106
            };
107
        }
108

    
109
        public AdornerFinal()
110
        {
111
            InitializeComponent();
112
            BorderSize = new Rect();
113
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
114
        }
115

    
116
        ~AdornerFinal()
117
        {
118
            this.Dispose(false);
119
        }
120

    
121
        public void Dispose()
122
        {
123
            this.Dispose(true);
124
            GC.SuppressFinalize(this);
125
        }
126

    
127
        protected virtual void Dispose(bool disposing)
128
        {
129
            if (this.disposed) return;
130
            if (disposing)
131
            {
132
                foreach (var member in this.Members)
133
                {
134
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
135
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
136
                }
137
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
138
            }
139
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
140
            this.disposed = true;
141
        }
142

    
143
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
144
        {
145
            mainDragThumb = DragThumb;
146
        }
147

    
148
        public AdornerFinal(CommentUserInfo objectData) : this()
149
        {
150
            InitializeComponent();
151
            objectData.IsHitTestVisible = false;
152
            if ((objectData as ArrowTextControl) != null)
153
            {
154
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
155
            }
156
            Canvas.SetZIndex(objectData, 84);
157
            try
158
            {
159
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
160
                this.ContainerContent.Children.Add(objectData);
161
            }
162
            catch (Exception ex)
163
            {
164

    
165
            }
166
           
167
            SetAdornerMember(objectData as CommentUserInfo);
168
            this.Focus();
169
        }
170

    
171
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
172
        {
173
            InitializeComponent();
174
            foreach (var item in objectData)
175
            {
176
                //item.IsHitTestVisible = false;
177
                if ((item as ArrowTextControl) != null)
178
                {
179
                    (item as ArrowTextControl).Base_TextBox.Focusable = true;
180
                }
181
                try
182
                {
183
                    Canvas.SetZIndex(item, 80);
184
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
185
                    this.ContainerContent.Children.Add(item);
186
                }
187
                catch //(Exception ex)
188
                {
189
                }
190
                finally
191
                {
192
                    
193
                }
194
            }
195
            this.SetAdornerMember(objectData);
196
            this.Focus();
197
        }
198

    
199
        #endregion
200
        #region 메서드
201
        public Rect getAdornerSize()
202
        {
203
            return BorderSize;
204
        }
205
        public void addMemberControl(UIElement objectData)
206
        {
207
            this.ContainerContent.Children.Add(objectData);
208
            SetAdornerMember(objectData as CommentUserInfo);
209
            this.Focus();
210
        }
211
        /// <summary>
212
        /// UIElement를 종류에 맞게 등록시킴
213
        /// </summary>
214
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
215
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
216
        {
217

    
218
            switch (member.GetType().Name)
219
            {
220
                #region 컨트롤 조건
221
                case "LineControl": //Angle추가 안했음
222
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
223
                    break;
224
                case "ImgControl": //Angle추가 안했음
225
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
226
                    //AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);            
227
                    //DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
228
                    AngleValue = (member as ImgControl).Angle;
229
                    break;
230
                //case "SymControl": //Angle추가 안했음
231
                //    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<MyThumb>() });
232
                //    AngleValue = (member as SymControl).Angle;
233
                //    //ViewBoxRotate(member);
234
                //    break;
235
                //case "SymControlN": //Angle추가 안했음
236
                //    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<MyThumb>() });
237
                //    AngleValue = (member as SymControlN).Angle;
238
                //    //ViewBoxRotate(member);
239
                //    break;
240
                case "PolygonControl": //Angle추가 안했음
241
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
242
                    break;
243
                case "ArrowControl":
244
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
245
                    break;
246
                case "ArrowTextControl":
247
                    this.Members.Add(new AdornerMember
248
                    {
249
                        DrawingData = member,
250
                        Drawingtype = ControlType.ArrowTextControl,
251
                        ThumbList = new List<MyThumb>(),
252
                        Symbol_ID = member.SymbolID,
253
                        Group_ID = member.GroupID,
254
                    });
255
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
256
                    AngleValue = (member as ArrowTextControl).Angle;
257
                    Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
258
                    {
259
                        TextCompensation = false;
260
                        BorderUpdate();
261
                        if ((a.Sender as TextBox).Text == "") //보류
262
                        {
263
                            this.ContainerContent.Children.Remove(member);
264
                            this.Visibility = Visibility.Collapsed;
265
                        }
266
                    });
267
                    break;
268
                case "ArcControl":
269
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
270
                    break;
271
                case "ArrowArcControl":
272
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
273
                    break;
274
                case "ArrowControl_Multi":
275
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
276
                    break;
277
                case "RectangleControl":
278
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
279
                    break;
280
                case "DateControl":
281
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
282
                    AngleValue = (member as DateControl).Angle;
283
                    break;
284
                case "TriControl":
285
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
286
                    break;
287
                case "CircleControl":
288
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
289
                    break;
290
                case "CloudControl":
291
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
292
                    break;
293
                case "RectCloudControl":
294
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
295
                    break;
296
                case "SignControl":
297
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
298
                    AngleValue = (member as SignControl).Angle;
299
                    break;
300

    
301
                case "SymControl":
302
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
303
                    AngleValue = (member as SymControl).Angle;
304
                    break;
305
                case "SymControlN":
306
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
307
                    AngleValue = (member as SymControlN).Angle;
308
                    break;
309
                case "InkControl": //Angle추가 안했음
310
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
311
                    break;
312
                case "TextControl":
313
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
314
                    RectangleGeometry Data = new RectangleGeometry
315
                    {
316
                        Rect = new Rect()
317
                        {
318
                            X = Canvas.GetLeft((member as TextControl)),
319
                            Y = Canvas.GetTop((member as TextControl)),
320
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
321
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
322
                            //Width = (member as TextControl).BoxWidth / 2,
323
                            //Height = (member as TextControl).BoxHeight / 2,
324
                        }
325
                    };
326
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
327
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
328

    
329

    
330
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
331
                    DragThumb.RenderTransform = new RotateTransform()
332
                    {
333
                        Angle = (member as TextControl).Angle,
334
                        //CenterX = middle.X,
335
                        //CenterY = middle.Y,
336
                    };
337

    
338
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
339
                    AdornerBorder.RenderTransform = new RotateTransform()
340
                    {
341
                        Angle = (member as TextControl).Angle,
342
                        //CenterX = middle.X,
343
                        //CenterY = middle.Y,
344
                    };
345
                    Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
346
                    {
347
                        TextCompensation = true;
348
                        BorderUpdate();
349
                        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
350
                    });
351
                    Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
352
                    {
353
                        TextCompensation = false;
354
                        BorderUpdate();
355
                        if ((a.Sender as TextBox).Text == "") //보류
356
                        {
357
                            this.ContainerContent.Children.Remove(member);
358
                            this.Visibility = Visibility.Collapsed;
359
                        }
360

    
361
                        //((TextControl)member).UnEditingMode();
362
                        //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
363
                        //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
364
                        //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
365
                    });
366
                    break;
367
                case "InsideWhiteControl":
368
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
369
                    break;
370
                case "OverlapWhiteControl":
371
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
372
                    break;
373
                case "ClipWhiteControl":
374
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
375
                    break;
376
                case "CoordinateControl":
377
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
378
                    break;
379
                default:
380
                    break;
381
                    #endregion
382
            }
383
            if (member.GetType().Name == "TextControl")
384
            {
385
                TextControl content = ((TextControl)member);
386
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
387
                content.EndPoint = content.StartPoint;
388

    
389
            }
390
            else
391
            {
392
                RegistryPoint(member);
393
            }
394
            BorderUpdate();
395

    
396
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
397
        }
398

    
399
        private void ViewBoxRotate(UIElement member)
400
        {
401
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
402
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
403
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
404
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
405
        }
406

    
407
        public void SetAdornerMember(List<CommentUserInfo> members)
408
        {
409
            foreach (var member in members)
410
            {
411
                switch (member.GetType().Name)
412
                {
413
                    #region 컨트롤 조건
414
                    case "LineControl":
415
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
416
                        break;
417
                    case "ImgControl":
418
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
419
                        break;
420
                    case "ArrowControl":
421
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
422
                        break;
423
                    case "PolygonControl":
424
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
425
                        break;
426
                    case "ArrowTextControl":
427
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
428
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
429
                        break;
430
                    case "ArcControl":
431
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
432
                        break;
433
                    case "ArrowArcControl":
434
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
435
                        break;
436
                    case "DateControl":
437
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
438
                        break;
439
                    case "ArrowControl_Multi":
440
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
441
                        break;
442
                    case "RectangleControl":
443
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
444
                        break;
445
                    case "TriControl":
446
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
447
                        break;
448
                    case "CircleControl":
449
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
450
                        break;
451
                    case "CloudControl":
452
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
453
                        break;
454
                    case "RectCloudControl":
455
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
456
                        break;
457
                    case "SignControl":
458
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
459
                        break;
460
                    case "SymControl":
461
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
462
                        break;
463
                    case "SymControlN":
464
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
465
                        break;
466
                    case "InkControl":
467
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
468
                        break;
469
                    case "TextControl":
470
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
471
                        Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
472
                        {
473
                            BorderUpdate();
474
                            try
475
                            {
476
                                ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
477
                            }
478
                            catch (Exception)
479
                            {
480

    
481
                            }
482

    
483
                        });
484
                        Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
485
                        {
486
                            BorderUpdate();
487
                        });
488
                        break;
489
                    case "InsideWhiteControl":
490
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
491
                        break;
492
                    case "OverlapWhiteControl":
493
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
494
                        break;
495
                    case "ClipWhiteControl":
496
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
497
                        break;
498
                    case "CoordinateControl":
499
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
500
                        break;
501
                    default:
502
                        break;
503
                        #endregion
504
                }
505
                if (member.GetType().Name == "TextControl")
506
                {
507
                    TextControl content = ((TextControl)member);
508
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
509
                    content.EndPoint = content.StartPoint;
510
                }
511
                else
512
                {
513
                    RegistryPoint(member, members.Count);
514
                }
515

    
516
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))  Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
517
            }
518

    
519
            BorderUpdate();
520
        }
521

    
522
        /// <summary>
523
        /// Border 를 갱신
524
        /// </summary>
525
        public void BorderUpdate()
526
        {
527
            AdornerBorder.MinWidth = 10;
528
            AdornerBorder.MinHeight = 10;
529

    
530
            double minX = double.MaxValue;
531
            double minY = double.MaxValue;
532
            double maxX = double.MinValue;
533
            double maxY = double.MinValue;
534

    
535
            if (this.Members.Count == 1)
536
            {
537
                if (this.Members.First().DrawingData.GetType().Name == "TextControl")
538
                {
539
                    if ((this.Members.First().DrawingData as TextControl).Angle != 0)
540
                    {
541
                        trRotate.Angle = (this.Members.First().DrawingData as TextControl).Angle;
542
                        trRotateThumb.Angle = (this.Members.First().DrawingData as TextControl).Angle;
543
                    }
544
                    else
545
                    {
546
                        trRotate.Angle = 0;
547
                        trRotateThumb.Angle = 0;
548
                    }
549
                }
550
            }
551
            foreach (var item in this.Members)
552
            {
553
                UIElement currentControl = (item as AdornerMember).DrawingData;
554
                if (item.DrawingData.GetType().Name == "TextControl")
555
                {
556
                    double textControlWidth;
557
                    double textControlHeight;
558
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
559
                    {
560
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
561
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
562
                    }
563
                    else
564
                    {
565
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
566
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
567
                    }
568
                    
569
                    if ((currentControl as TextControl).EndPoint.X < minX)
570
                    {
571
                        minX = (currentControl as TextControl).EndPoint.X;
572
                    }
573
                    if ((currentControl as TextControl).EndPoint.Y < minY)
574
                    {
575
                        minY = (currentControl as TextControl).EndPoint.Y;
576
                    }
577
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
578
                    {
579
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
580
                    }
581
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
582
                    {
583
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
584
                    }
585
                }
586
                else if ((currentControl as IViewBox) != null)
587
                {
588
                    IViewBox instance = currentControl as IViewBox;
589
                    List<Point> am = (currentControl as IPath).PointSet;
590
                    List<double> xSet = am.Select(p => p.X).ToList();
591
                    List<double> ySet = am.Select(p => p.Y).ToList();
592
                    if (xSet.Min() < minX) minX = xSet.Min();
593
                    if (ySet.Min() < minY) minY = ySet.Min();
594
                    if (xSet.Max() > maxX) maxX = xSet.Max();
595
                    if (ySet.Max() > maxY) maxY = ySet.Max();
596
                }
597
                else if ((currentControl as IPath).PathData == null)
598
                {
599
                    Rect rt = new Rect
600
                    {
601
                        X = (currentControl as IPath).StartPoint.X,
602
                        Y = (currentControl as IPath).StartPoint.Y,
603
                        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),
604
                        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),
605
                    };
606
                    if (rt.Left < minX) minX = rt.Left;
607
                    if (rt.Top < minY) minY = rt.Top;
608
                    if (rt.Right > maxX) maxX = rt.Right;
609
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
610
                }
611
                else if ((currentControl as IPath) == null)
612
                {
613
                    Rect rt = new Rect
614
                    {
615
                        X = (currentControl as IPath).StartPoint.X,
616
                        Y = (currentControl as IPath).StartPoint.Y,
617
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
618
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
619
                    };
620
                    if (rt.Left < minX) minX = rt.Left;
621
                    if (rt.Top < minY) minY = rt.Top;
622
                    if (rt.Right > maxX) maxX = rt.Right;
623
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
624
                }
625
                else if ((currentControl as CircleControl) != null)
626
                {                    
627
                    List<Point> am = (currentControl as IPath).PointSet;
628
                    List<double> xSet = am.Select(p => p.X).ToList();
629
                    List<double> ySet = am.Select(p => p.Y).ToList();
630
                    if (xSet.Min() < minX) minX = xSet.Min();
631
                    if (ySet.Min() < minY) minY = ySet.Min();
632
                    if (xSet.Max() > maxX) maxX = xSet.Max();
633
                    if (ySet.Max() > maxY) maxY = ySet.Max();
634
                }
635
                else
636
                {
637
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
638
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
639
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
640
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
641
                }
642
            }
643

    
644
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
645
            bool addWidthSize = false;
646
            bool addHeightSize = false;
647
            if (ac.Width <= 10)
648
            {
649
                ac.Width += 10;
650
                addWidthSize = true;
651
            }
652
            if (ac.Height <= 10)
653
            {
654
                ac.Height += 10;
655
                addHeightSize = true;
656
            }
657
            BorderSize = ac;
658
            AdornerBorder.MinWidth = 10;
659
            AdornerBorder.MinHeight = 10;
660
            AdornerBorder.Width = ac.Width;
661
            AdornerBorder.Height = ac.Height;
662
            Canvas.SetLeft(AdornerBorder, minX);
663
            Canvas.SetTop(AdornerBorder, minY);
664

    
665
            DragThumb.Width = ac.Width;
666
            DragThumb.Height = ac.Height;
667

    
668
            DragThumb.MinWidth = 10;
669
            DragThumb.MinHeight = 10;
670
            if (addWidthSize)
671
            {
672
                Canvas.SetLeft(DragThumb, minX - 5);
673
            }
674
            else
675
            {
676
                Canvas.SetLeft(DragThumb, minX);
677
            }
678

    
679
            if (addHeightSize)
680
            {
681
                Canvas.SetTop(DragThumb, minY - 5);
682
            }
683
            else
684
            {
685
                Canvas.SetTop(DragThumb, minY);
686
            }
687
        }
688
        /// <summary>
689
        /// UIElement 해제
690
        /// </summary>
691
        public void unRegister()
692
        {
693
            foreach (var item in this.ContainerContent.Children)
694
            {
695
                if (item is MarkupToPDF.Common.CommentUserInfo)
696
                {
697
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
698
                }
699
            }
700
            this.ContainerContent.Children.Clear();
701
        }
702

    
703
        /// <summary>
704
        /// 각 포인트들을 등록합니다.
705
        /// </summary>
706
        /// <param name="pointset">Drawing Point</param>
707
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
708
        {
709
            int count = 0;
710
            double Minx = 100000000;
711
            double Miny = 100000000;
712
            List<Point> list = (member as IPath).PointSet;
713
            if (member.GetType().Name == "InkControl")
714
            {
715
                list.Clear();
716
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
717
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
718
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
719
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
720
            }
721
            ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype;
722
            foreach (var ax in list)
723
            {
724
                Minx = (ax.X < Minx) ? ax.X : Minx;
725
                Miny = (ax.Y < Miny) ? ax.Y : Miny;
726
            }
727
            for (int i = 0; i < list.Count(); i++)
728
            {
729
                MyThumb tm = new MyThumb
730
                {
731
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
732
                };
733

    
734
                this.Members.Last().ThumbList.Add(tm);
735

    
736
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MidPoint))
737
                {
738
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
739
                }
740
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
741
                {
742
                    //if (this.Members.Count()<=1)
743
                    //{
744
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
745
                    List<Point> ps = new List<Point>();
746

    
747
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
748
                    {
749
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
750

    
751

    
752
                        switch (Math.Abs(temp.Angle).ToString())
753
                        {
754
                            case "90":
755
                                {
756
                                    ps.Clear();
757
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
758
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
759
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
760

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

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

    
767
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
768
                                }
769
                                break;
770
                            case "270":
771
                                {
772
                                    ps.Clear();
773
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
774
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
775
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
776

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

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

    
783
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
784
                                }
785
                                break;
786
                            default:
787
                                {
788
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
789
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
790
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
791
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
792
                                }
793
                                break;
794
                        }
795

    
796
                        ArrowTextControl instance = (member as ArrowTextControl);
797
                        if (instance.isTrans)
798
                        {
799
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
800
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
801
                            //list[count] = tempP;
802
                            list[count] = temp.MidPoint;
803
                        }
804
                        else
805
                        {
806
                            if (temp.isFixed)
807
                            {
808
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
809
                                var testP = endP;
810
                                if (ps[0] == endP) //상단
811
                                {
812
                                    testP = new Point(endP.X, endP.Y - 50);
813
                                }
814
                                else if (ps[1] == endP) //하단
815
                                {
816
                                    testP = new Point(endP.X, endP.Y + 50);
817
                                }
818
                                else if (ps[2] == endP) //좌단
819
                                {
820
                                    testP = new Point(endP.X - 50, endP.Y);
821
                                }
822
                                else if (ps[3] == endP) //우단
823
                                {
824
                                    testP = new Point(endP.X + 50, endP.Y);
825
                                }
826
                                list[count] = testP;
827
                            }
828
                            else
829
                            {
830
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
831
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
832
                            }
833
                        }
834
                    }
835
                }
836
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
837
                {
838
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
839
                    tm.Width = (member as ArrowTextControl).BoxWidth;
840
                    tm.Height = (member as ArrowTextControl).BoxHeight;
841
                    var angle = (member as ArrowTextControl).Angle;
842
                    if (Math.Abs(angle).ToString() == "90")
843
                    {
844
                        tm.RenderTransformOrigin = new Point(0, 0);
845
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
846
                    }
847
                    else if (Math.Abs(angle).ToString() == "270")
848
                    {
849
                        tm.RenderTransformOrigin = new Point(0, 0);
850
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
851

    
852
                    }
853
                    else
854
                    {
855
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
856
                        tm.RenderTransform = new RotateTransform()
857
                        {
858
                            Angle = angle,
859
                        };
860
                    }
861
                }
862
                
863
                if (member.GetType().Name == "CloudControl")
864
                {
865
                    if (i == list.Count() - 1)
866
                    {
867
                        tm.Visibility = System.Windows.Visibility.Collapsed;
868
                    }
869
                }
870
                if (member.GetType().Name == "PolygonControl")
871
                {
872
                    if (i == list.Count() - 1)
873
                    {
874
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
875
                        {
876

    
877
                        }
878
                        else
879
                        {
880
                            tm.Visibility = System.Windows.Visibility.Collapsed;
881
                        }
882
                    }
883
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
884
                    {
885
                        tm.Visibility = System.Windows.Visibility.Collapsed;
886
                    }
887
                }
888
                
889
                this.ContainerContent.Children.Add(tm);
890
                Canvas.SetLeft(tm, list[count].X);
891
                Canvas.SetTop(tm, list[count].Y);
892
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
893
                {
894
                    Canvas.SetZIndex(tm, 95);
895
                }
896
                else
897
                {
898
                    Canvas.SetZIndex(tm, 99);
899
                }
900

    
901
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
902
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
903
                tm.DragDelta += ResizeTm_DragDelta;
904
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
905
                count++;
906
            }
907
        }
908

    
909
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
910
        {
911
            if (this.Members.Count > 1)
912
                return;
913
            if (reSizePoint != new Point(0, 0))
914
            {
915
                Thumb thumb = sender as Thumb;
916

    
917
                if (AngleValue == -90)
918
                {
919
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.VerticalChange);
920
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.HorizontalChange));
921
                }
922
                else if (AngleValue == -180)
923
                {
924
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.HorizontalChange));
925
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + (-e.VerticalChange));
926
                }
927
                else if (AngleValue == -270)
928
                {
929
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + (-e.VerticalChange));
930
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.HorizontalChange);
931
                }
932
                else //(AngleValue == 0)
933
                {
934
                    Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + e.HorizontalChange);
935
                    Canvas.SetTop(thumb, Canvas.GetTop(thumb) + e.VerticalChange);
936
                }
937

    
938

    
939
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
940
                
941
                AdornerMember control = (from userThumb in this.Members
942
                                         where userThumb.ThumbList.Contains(thumb)
943
                                         select userThumb).FirstOrDefault();
944
                Point nearPoint = new Point(0, 0);
945
                IPath AllControl = control.DrawingData as IPath;
946
                if (ControlType.TextControl != control.Drawingtype)
947
                {
948

    
949
                    var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
950
                    List<Point> ps = new List<Point>();
951

    
952
                    nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint);
953
                    
954

    
955
                }
956
                for (int i = 0; i < (control.DrawingData as IPath).PointSet.Count; i++)
957
                {
958
                    switch (control.Drawingtype)
959
                    {
960
                        #region Arc + Line
961
                        case ControlType.ArrowMultiLine:
962
                        case ControlType.ArcLine:
963
                        case ControlType.ArcArrow:
964
                        case ControlType.SingleLine:
965
                        case ControlType.Triangle:
966
                            if (nearPoint.Equals(AllControl.PointSet[i]))
967
                            {
968
                                AllControl.PointSet[i] = setPoint;
969
                                AllControl.updateControl();
970
                                DynamicThumbUpdate(control);
971
                                BorderUpdate();
972
                                
973
                            }
974
                            break;
975
                        #endregion
976
                        #region Shape                        
977
                        case ControlType.RectCloud:
978
                        case ControlType.Rectangle:
979
                            if (nearPoint.Equals(AllControl.PointSet[i]))
980
                            {
981
                                AllControl.PointSet[i] = setPoint;
982
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
983
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
984
                                var NextP = (i + 1) % AllControl.PointSet.Count();
985

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

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

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

    
1039
                                var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]);
1040
                                l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y
1041
                                    - newPointSet[ReverseP].Y);
1042
                                newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l);
1043

    
1044
                                AllControl.PointSet = newPointSet;
1045
                                DynamicThumbUpdate(control);
1046
                                AllControl.updateControl();
1047
                                BorderUpdate();
1048
                            }
1049
                            break;
1050
                        #endregion
1051
                        #region ArrowText
1052
                        case ControlType.ArrowTextControl:
1053
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1054
                            {
1055

    
1056
                                List<Point> GetPointSet = (control.DrawingData as ArrowTextControl).PointSet;
1057

    
1058
                                if ((GetPointSet[0].X > GetPointSet[1].X && e.HorizontalChange > 0) || (GetPointSet[0].X < GetPointSet[1].X && e.HorizontalChange < 0))
1059
                                {
1060
                                    GetPointSet[1] = new Point(GetPointSet[1].X + e.HorizontalChange, GetPointSet[1].Y);
1061
                                }
1062
                                if ((GetPointSet[0].Y > GetPointSet[1].Y && e.VerticalChange > 0) || (GetPointSet[0].Y < GetPointSet[1].Y && e.VerticalChange < 0))
1063
                                {
1064
                                    GetPointSet[1] = new Point(GetPointSet[1].X, GetPointSet[1].Y + e.VerticalChange);
1065
                                }
1066
                                (control.DrawingData as ArrowTextControl).PointSet[1] = GetPointSet[1];
1067

    
1068

    
1069
                                //System.Diagnostics.Debug.WriteLine("MidPoint : " + (control.DrawingData as ArrowTextControl).MidPoint);
1070
                                //System.Diagnostics.Debug.WriteLine("HorizontalChange : " + e.HorizontalChange);
1071
                                //System.Diagnostics.Debug.WriteLine("VerticalChange : " + e.VerticalChange);
1072

    
1073
                                AllControl.PointSet[i] = setPoint;
1074
                                //System.Diagnostics.Debug.WriteLine("PointSet : " + AllControl.PointSet[i]);
1075

    
1076
                                AllControl.updateControl();
1077

    
1078
                                DynamicThumbUpdate(control);
1079
                                BorderUpdate();
1080
                                                                
1081
                            }
1082
                            break;
1083
                        #endregion
1084
                        #region Text
1085
                        case ControlType.TextControl:
1086
                            break;
1087
                        #endregion
1088
                        #region Image
1089
                        case ControlType.ImgControl:
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 Sign
1118
                        case ControlType.Sign:
1119
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1120
                            {
1121
                                AllControl.PointSet[i] = setPoint;
1122
                                var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count();
1123
                                var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count();
1124
                                var NextP = (i + 1) % AllControl.PointSet.Count();
1125

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

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

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

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

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

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

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

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

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

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

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

    
1229
                                var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]);
1230
                                l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet
1231
                                    [i].Y - AllControl.PointSet[ReverseP].Y);
1232
                                AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y +
1233
                                    NextV.Y * l);
1234
                                AllControl.updateControl();
1235
                                DynamicThumbUpdate(control);
1236
                                BorderUpdate();
1237
                            }
1238
                            break;
1239
                        #endregion
1240
                        #region Ink
1241
                        case ControlType.Ink:
1242
                            if (nearPoint.Equals(AllControl.PointSet[i]))
1243
                            {
1244
                                AllControl.PointSet[i] = setPoint;
1245
                                AllControl.updateControl();
1246
                                BorderUpdate();
1247
                            }
1248
                            break;
1249
                        #endregion
1250
                        default:
1251
                            break;
1252
                    }
1253
                }
1254
            }
1255
            //}
1256
        }
1257

    
1258

    
1259

    
1260
        #endregion
1261
        #region 이벤트
1262

    
1263
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1264
        {
1265
            this.isDragging = false;
1266
            DraggerThumb = null;
1267

    
1268
            var comments = (from drawing in this.Members
1269
                            select drawing.DrawingData as CommentUserInfo).ToList();
1270
            UndoCommand.Instance.Push(comments, this.AngleValue);
1271
        }
1272

    
1273
        /// <summary>
1274
        /// start drag
1275
        /// </summary>
1276
        /// <param name="sender"></param>
1277
        /// <param name="e"></param>
1278
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1279
        {
1280
            this.DraggerThumb = sender as Thumb;
1281
            this.isDragging = true;
1282

    
1283
            if (ViewerDataModel.Instance.UndoDataList == null)
1284
            {
1285
                return;
1286
            }
1287

    
1288
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1289
            {
1290
                return;
1291
            }
1292

    
1293
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1294
            {
1295
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1296
                {
1297
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1298
                    {
1299
                        return;
1300
                    }
1301
                }
1302
            }
1303

    
1304
            var comments = (from drawing in this.Members
1305
                            select drawing.DrawingData as CommentUserInfo).ToList();
1306
            UndoCommand.Instance.Push(comments, this.AngleValue);
1307
        }
1308

    
1309
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1310
        {
1311
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1312
            {
1313
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1314
                    IsTextAngle = true;
1315
                else
1316
                    IsTextAngle = false;
1317
                LastRotateVerticalValue = e.GetPosition(this).X;
1318
            }
1319
            else
1320
            {
1321
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1322
                {
1323
                    RotateFlag = true;
1324
                }
1325
                else
1326
                {
1327
                    RotateFlag = false;
1328
                }
1329
                LastRotateHorizontalValue = e.GetPosition(this).X;
1330
            }
1331
        }
1332

    
1333
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1334
        {
1335
            DragThumb.Cursor = Cursors.SizeAll;
1336
            Thumb thumb = sender as Thumb;
1337
            MoveAdorner(e);
1338
        }
1339

    
1340
        public void MoveAdorner(DragDeltaEventArgs e)
1341
        {
1342
            Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange);
1343

    
1344
            Dispatcher.BeginInvoke((Action)(() =>
1345
            {
1346
                foreach (var item in this.Members)
1347
                {
1348
                    #region 라인  & 아크
1349
                    if (item.Drawingtype == ControlType.SingleLine || item.Drawingtype == ControlType.ArcLine || item.Drawingtype == ControlType.ArrowMultiLine || item.Drawingtype == ControlType.ArcArrow)
1350
                    {
1351
                        DynamicThumbUpdate(e, item);
1352
                    }
1353
                    #endregion
1354
                    #region 지시선화살표
1355
                    if (item.Drawingtype == ControlType.ArrowTextControl)
1356
                    {
1357
                        DynamicThumbUpdate(e, item);
1358
                    }
1359
                    #endregion
1360

    
1361
                    #region 써클
1362
                    if (item.Drawingtype == ControlType.Circle || item.Drawingtype == ControlType.Sign || item.Drawingtype == ControlType.Symbol || item.Drawingtype == ControlType.Stamp)
1363
                    {
1364
                        DynamicThumbUpdate(e, item);
1365
                    }
1366
                    #endregion
1367
                    #region 쉐이프
1368
                    if (item.Drawingtype == ControlType.Rectangle || item.Drawingtype == ControlType.ImgControl || item.Drawingtype == ControlType.RectCloud || item.Drawingtype == ControlType.Triangle)
1369
                    {
1370
                        DynamicThumbUpdate(e, item);
1371
                    }
1372
                    #endregion
1373
                    #region 텍스트
1374
                    if (item.Drawingtype == ControlType.TextControl)
1375
                    {
1376
                        //DynamicThumbUpdate(e, item);
1377
                        (item.DrawingData as TextControl).Move(e.HorizontalChange, e.VerticalChange);
1378
                    }
1379
                    #endregion
1380
                    #region 날짜
1381
                    if (item.Drawingtype == ControlType.Date)
1382
                    {
1383
                        DynamicThumbUpdate(e, item);
1384
                    }
1385
                    #endregion
1386
                    #region 클라우드
1387
                    if (item.Drawingtype == ControlType.PolygonCloud)
1388
                    {
1389
                        ICloudControl temp = ((ICloudControl)item.DrawingData);
1390
                        DynamicThumbUpdate(e, item);
1391
                        temp.DrawingCloud();
1392
                    }
1393
                    #endregion
1394
                    #region 심볼
1395

    
1396
                    #endregion
1397

    
1398
                    #region 폴리곤
1399
                    if (item.Drawingtype == ControlType.PolygonControl)
1400
                    {
1401
                        DynamicThumbUpdate(e, item);
1402
                        BorderUpdate();
1403
                    }
1404
                    #endregion
1405
                    #region 잉크
1406
                    if (item.Drawingtype == ControlType.Ink)
1407
                    {
1408
                        Point px = new Point(e.HorizontalChange, e.VerticalChange);
1409
                        List<StylusPointSet> StylusPointSet = (item.DrawingData as InkControl).PointC;
1410
                        for (int i = 0; i < StylusPointSet.Count; i++)
1411
                        {
1412
                            List<Point> lstPoint = StylusPointSet[i].pointSet;
1413
                            for (int j = 0; j < lstPoint.Count; j++)
1414
                            {
1415
                                lstPoint[j] = new Point(lstPoint[j].X + px.X, lstPoint[j].Y + px.Y);
1416
                            }
1417
                        }
1418

    
1419
                        for (int i = 0; i < item.ThumbList.Count; i++)
1420
                        {
1421
                            Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + px.X);
1422
                            Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + px.Y);
1423
                        }
1424
                        (item.DrawingData as IPath).updateControl();
1425
                        BorderUpdate();
1426

    
1427
                    }
1428
                    #endregion
1429
                    BorderUpdate();
1430
                }
1431
            }));
1432
        }
1433

    
1434
        public void DynamicThumbUpdate(DragDeltaEventArgs e, AdornerMember item)
1435
        {
1436
            var AllControl = item.DrawingData as IPath;
1437
            List<Point> point = AllControl.PointSet;
1438
            for (int i = 0; i < item.ThumbList.Count(); i++)
1439
            {
1440
                if (item.DrawingData.GetType().Name == "ArrowTextControl")
1441
                {
1442
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1443
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1444
                    AllControl.updateControl();
1445
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1446
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1447

    
1448
                    Canvas.SetLeft(item.ThumbList.Last(), Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1449
                    Canvas.SetTop(item.ThumbList.Last(), Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1450
                }
1451
                else
1452
                {
1453
                    Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle);
1454
                    AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y };
1455
                    AllControl.updateControl();
1456
                    Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X);
1457
                    Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y);
1458
                }
1459
            }
1460
        }
1461

    
1462
        public void DynamicThumbUpdate(AdornerMember item)
1463
        {
1464
            var AllControl = item.DrawingData as IPath;
1465
            List<Point> point = AllControl.PointSet;
1466

    
1467
            for (int i = 0; i < AllControl.PointSet.Count(); i++)
1468
            {
1469

    
1470
                Canvas.SetLeft(item.ThumbList[i], AllControl.PointSet[i].X);
1471
                Canvas.SetTop(item.ThumbList[i], AllControl.PointSet[i].Y);
1472
            }
1473

    
1474

    
1475
            if (item.DrawingData as ArrowTextControl != null)
1476
            {
1477
                if (!(item.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
1478
                {
1479
                    List<Point> ps = new List<Point>();
1480

    
1481
                    var temp = item.DrawingData as ArrowTextControl;
1482
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1483
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1484
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1485
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1486

    
1487
                    if (temp.isFixed)
1488
                    {
1489
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1490
                        var testP = endP;
1491
                        if (ps[0] == endP) //상단
1492
                        {
1493
                            testP = new Point(endP.X, endP.Y - 50);
1494
                            //System.Diagnostics.Debug.WriteLine("상단");
1495
                        }
1496
                        else if (ps[1] == endP) //하단
1497
                        {
1498
                            testP = new Point(endP.X, endP.Y + 50);
1499
                            //System.Diagnostics.Debug.WriteLine("하단");
1500
                        }
1501
                        else if (ps[2] == endP) //좌단
1502
                        {
1503
                            testP = new Point(endP.X - 50, endP.Y);
1504
                            //System.Diagnostics.Debug.WriteLine("좌단");
1505
                        }
1506
                        else if (ps[3] == endP) //우단
1507
                        {
1508
                            testP = new Point(endP.X + 50, endP.Y);
1509
                            //System.Diagnostics.Debug.WriteLine("우단");
1510
                        }
1511
                        Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], testP.X);
1512
                        Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], testP.Y);
1513
                    }
1514
                    else
1515
                    {
1516
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1517
                        var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1518
                        Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1519
                        Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1520
                    }
1521
                }
1522
            }
1523
        }
1524

    
1525
        public void Set_Rotate()
1526
        {
1527
            double dDeltaAngle = 0;
1528
            List<Point> AllPointSet = new List<Point>();
1529
            Point CenterPoint = new Point();
1530

    
1531
            if (AngleValue >= 360)
1532
            {
1533
                AngleValue -= 360;
1534
            }
1535
            else if (AngleValue <= -360)
1536
            {
1537
                AngleValue += 360;
1538
            }
1539

    
1540
            #region 센터 포인트 구하기 (그룹핑)
1541
            foreach (var item in this.Members)
1542
            {
1543
                if (item.DrawingData.GetType().Name == "TextControl")
1544
                {
1545
                }
1546
                else
1547
                {
1548
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1549
                    {
1550
                        AllPointSet.Add(itemP);
1551
                    }
1552
                }
1553
            }
1554
            #endregion
1555

    
1556
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1557

    
1558
            Dispatcher.BeginInvoke((Action)(() =>
1559
            {
1560
                foreach (var item in this.Members)
1561
                {
1562
                    foreach (var thumb in item.ThumbList)
1563
                    {
1564
                        double x = Canvas.GetLeft(thumb);
1565
                        double y = Canvas.GetTop(thumb);
1566

    
1567
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1568
                        Canvas.SetLeft(thumb, value.X);
1569
                        Canvas.SetTop(thumb, value.Y);
1570

    
1571
                        if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last())
1572
                        {
1573

    
1574
                            Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1575
                            Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1576
                            if (!(item.DrawingData as ArrowTextControl).isTrans)
1577
                            {
1578
                                List<Point> ps = new List<Point>();
1579
                                var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1580
                                switch (Math.Abs(temp.Angle).ToString())
1581
                                {
1582
                                    case "90":
1583
                                        {
1584
                                            ps.Clear();
1585
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1586
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
1587
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
1588

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

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

    
1595
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
1596
                                        }
1597
                                        break;
1598
                                    case "270":
1599
                                        {
1600
                                            ps.Clear();
1601
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1602
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
1603
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
1604

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

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

    
1611
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
1612
                                        }
1613
                                        break;
1614
                                    default:
1615
                                        {
1616
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1617
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1618
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1619
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1620
                                        }
1621
                                        break;
1622
                                }
1623

    
1624
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1625
                                var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1626
                                Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1627
                                Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1628
                            }
1629
                        }
1630
                    }
1631

    
1632
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1633
                    {
1634
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1635
                    }
1636
                }
1637
                #region 컨트롤 업데이트
1638
                foreach (var item in this.Members)
1639
                {
1640
                    switch (item.Drawingtype)
1641
                    {
1642
                        case ControlType.TextControl:
1643
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1644

    
1645
                            RectangleGeometry Data = new RectangleGeometry
1646
                            {
1647
                                Rect = new Rect()
1648
                                {
1649
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1650
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1651
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1652
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1653
                                }
1654
                            };
1655

    
1656
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1657
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);                                                      
1658

    
1659
                            DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
1660
                            DragThumb.RenderTransform = new RotateTransform()
1661
                            {
1662
                                Angle = (item.DrawingData as TextControl).Angle,
1663

    
1664
                            };
1665

    
1666
                            AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
1667
                            AdornerBorder.RenderTransform = new RotateTransform()
1668
                            {
1669
                                Angle = (item.DrawingData as TextControl).Angle,
1670

    
1671
                            };
1672

    
1673
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1674
                            {
1675
                                Angle = (item.DrawingData as TextControl).Angle,
1676
                            };
1677
                            BorderUpdate();
1678
                            break;
1679

    
1680
                        case ControlType.Date:
1681
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1682
                            (item.DrawingData as IPath).updateControl();
1683
                            BorderUpdate();
1684
                            break;
1685
                        case ControlType.ArrowMultiLine:
1686
                        case ControlType.ArcLine:
1687
                        case ControlType.ArcArrow:
1688
                        case ControlType.SingleLine:
1689
                        case ControlType.Triangle:
1690
                            (item.DrawingData as IPath).updateControl();
1691
                            BorderUpdate();
1692
                            break;
1693
                        case ControlType.ArrowTextControl:
1694
                            (item.DrawingData as IPath).updateControl();
1695
                            BorderUpdate();
1696
                            break;
1697
                        case ControlType.RectCloud:
1698
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1699
                            (item.DrawingData as IPath).updateControl();
1700
                            BorderUpdate();
1701
                            break;
1702
                        case ControlType.Rectangle:
1703
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1704
                            (item.DrawingData as IPath).updateControl();
1705
                            BorderUpdate();
1706
                            break;
1707
                        case ControlType.ImgControl:
1708
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1709
                            (item.DrawingData as IPath).updateControl();
1710
                            BorderUpdate();
1711
                            break;
1712
                        case ControlType.Sign:
1713
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1714
                            (item.DrawingData as IPath).updateControl();
1715
                            BorderUpdate();
1716
                            break;
1717
                        case ControlType.Symbol:
1718
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1719
                            (item.DrawingData as IPath).updateControl();
1720
                            BorderUpdate();
1721
                            break;
1722
                        case ControlType.Stamp:
1723
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1724
                            (item.DrawingData as IPath).updateControl();
1725
                            BorderUpdate();
1726
                            break;
1727
                        case ControlType.PolygonControl:
1728
                            (item.DrawingData as IPath).updateControl();
1729
                            BorderUpdate();
1730
                            break;
1731
                        case ControlType.PolygonCloud:
1732
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1733
                            (item.DrawingData as IPath).updateControl();
1734
                            BorderUpdate();
1735
                            break;
1736
                        case ControlType.Circle:
1737
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1738
                            (item.DrawingData as IPath).updateControl();
1739
                            ((CircleControl)item.DrawingData).SetCenterXY();
1740
                            BorderUpdate();
1741
                            break;
1742
                        case ControlType.Ink:
1743
                            (item.DrawingData as IPath).updateControl();
1744
                            BorderUpdate();
1745
                            break;
1746
                        case ControlType.InsideWhite:
1747
                            ((InsideWhiteControl)item.DrawingData).Angle = AngleValue;
1748
                            (item.DrawingData as IPath).updateControl();
1749
                            BorderUpdate();
1750
                            break;
1751
                        case ControlType.OverlapWhite:
1752
                            ((OverlapWhiteControl)item.DrawingData).Angle = AngleValue;
1753
                            (item.DrawingData as IPath).updateControl();
1754
                            BorderUpdate();
1755
                            break;
1756
                        case ControlType.ClipWhite:
1757
                            ((ClipWhiteControl)item.DrawingData).Angle = AngleValue;
1758
                            (item.DrawingData as IPath).updateControl();
1759
                            BorderUpdate();
1760
                            break;
1761
                        case ControlType.Coordinate:
1762
                            ((CoordinateControl)item.DrawingData).Angle = AngleValue;
1763
                            (item.DrawingData as IPath).updateControl();
1764
                            BorderUpdate();
1765
                            break;
1766
                        default:
1767
                            break;
1768
                    }
1769
                }
1770
                #endregion
1771
            }));
1772
        }
1773

    
1774
        private void resize_MouseMove(object sender, MouseEventArgs e)
1775
        {
1776
            reSizePoint = e.GetPosition(this);
1777
        }
1778
        /// <summary>
1779
        /// 회전
1780
        /// </summary>
1781
        /// <param name="sender"></param>
1782
        /// <param name="e"></param>
1783
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1784
        {
1785

    
1786
            MoveRotate(e);
1787
        }
1788

    
1789
        double LastRotateHorizontalValue = 0;
1790
        double LastRotateVerticalValue = 0;
1791
        //double LastWidthValue = 0;
1792
        //double SetWidth = 0;
1793
        bool RotateFlag = false;
1794

    
1795
        /// <summary>
1796
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1797
        /// </summary>
1798
        /// <param name="e"></param>
1799
        public void MoveRotate(DragDeltaEventArgs e)
1800
        {
1801
            double dDeltaAngle = 0;
1802

    
1803
            List<Point> AllPointSet = new List<Point>();
1804
            Point CenterPoint = new Point();
1805
            
1806
            #region 센터 포인트 구하기 (그룹핑)
1807
            foreach (var item in this.Members)
1808
            {
1809
                if (item.DrawingData.GetType().Name == "TextControl")
1810
                {                    
1811
                    if (AngleValue == 0)
1812
                    {
1813
                        AngleValue = (item.DrawingData as TextControl).Angle;
1814
                    }
1815
                    double X = Canvas.GetLeft((item.DrawingData as TextControl));
1816
                    double Y = Canvas.GetTop((item.DrawingData as TextControl));
1817
                    AllPointSet.Add(new Point(X, Y));
1818
                }
1819
                else
1820
                {
1821
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1822
                    {
1823
                        AllPointSet.Add(itemP);
1824
                    }
1825
                }
1826
            }
1827
            #endregion
1828
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1829
            Point pt = Mouse.GetPosition(this);
1830

    
1831
            Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
1832
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1833
            dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1834

    
1835
            //System.Diagnostics.Debug.WriteLine("vec1 : " + vec1.X + "/" + vec1.Y);
1836
            //System.Diagnostics.Debug.WriteLine("vec2 : " + vec2.X + "/" + vec2.Y);
1837
            //System.Diagnostics.Debug.WriteLine("dDeltaAngle : " + dDeltaAngle);
1838

    
1839
            AngleValue += dDeltaAngle;
1840
            if (AngleValue > 360) AngleValue -= 360;
1841
            if (AngleValue < 0) AngleValue += 360;
1842
            this.rotatePoint = pt;  /// save rotatePoint
1843

    
1844
            Dispatcher.BeginInvoke((Action)(() =>
1845
            {
1846
                foreach (var item in this.Members)
1847
                {
1848
                    foreach (var thumb in item.ThumbList)
1849
                    {
1850
                        double x = Canvas.GetLeft(thumb);
1851
                        double y = Canvas.GetTop(thumb);
1852

    
1853
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1854
                        Canvas.SetLeft(thumb, value.X);
1855
                        Canvas.SetTop(thumb, value.Y);
1856
                    }
1857

    
1858
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1859
                    {
1860
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1861
                    }
1862
                }
1863
                #region 보더 업데이트
1864
                foreach (var item in this.Members)
1865
                {
1866
                    switch (item.Drawingtype)
1867
                    {
1868
                        case ControlType.TextControl:
1869
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1870

    
1871
                            RectangleGeometry Data = new RectangleGeometry
1872
                            {
1873
                                Rect = new Rect()
1874
                                {
1875
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1876
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1877
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1878
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1879
                                }
1880
                            };
1881

    
1882
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1883
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);
1884

    
1885
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1886
                            DragThumb.RenderTransform = new RotateTransform()
1887
                            {
1888
                                Angle = (item.DrawingData as TextControl).Angle,
1889
                                //CenterX = middle.X,
1890
                                //CenterY = middle.Y,
1891
                            };
1892

    
1893
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1894
                            AdornerBorder.RenderTransform = new RotateTransform()
1895
                            {
1896
                                Angle = (item.DrawingData as TextControl).Angle,
1897
                                //CenterX = middle.X,
1898
                                //CenterY = middle.Y,
1899
                            };
1900

    
1901
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1902
                            {
1903
                                Angle = (item.DrawingData as TextControl).Angle,
1904
                            };
1905

    
1906
                            BorderUpdate();
1907
                            break;
1908

    
1909
                        case ControlType.Date:
1910
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1911
                            (item.DrawingData as IPath).updateControl();
1912
                            BorderUpdate();                          
1913
                            break;
1914
                        case ControlType.ArrowMultiLine:
1915
                        case ControlType.ArcLine:
1916
                        case ControlType.ArcArrow:
1917
                        case ControlType.SingleLine:
1918
                        case ControlType.Triangle:
1919
                            (item.DrawingData as IPath).updateControl();
1920
                            BorderUpdate();
1921
                            break;
1922
                        case ControlType.ArrowTextControl:
1923
                            (item.DrawingData as IPath).updateControl();
1924
                            BorderUpdate();
1925
                            break;
1926
                        case ControlType.RectCloud:
1927
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1928
                            (item.DrawingData as IPath).updateControl();
1929
                            BorderUpdate();
1930
                            break;
1931
                        case ControlType.Rectangle:
1932
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1933
                            (item.DrawingData as IPath).updateControl();
1934
                            BorderUpdate();
1935
                            break;
1936
                        case ControlType.ImgControl:
1937
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1938
                            (item.DrawingData as IPath).updateControl();
1939
                            BorderUpdate();
1940
                            break;                        
1941
                        case ControlType.Sign:
1942
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1943
                            (item.DrawingData as IPath).updateControl();
1944
                            BorderUpdate();
1945
                            break;                        
1946
                        case ControlType.Symbol:
1947
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1948
                            (item.DrawingData as IPath).updateControl();
1949
                            BorderUpdate();
1950
                            break;
1951
                        case ControlType.Stamp:
1952
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1953
                            (item.DrawingData as IPath).updateControl();
1954
                            BorderUpdate();
1955
                            break;
1956
                        case ControlType.PolygonControl:
1957
                            (item.DrawingData as IPath).updateControl();
1958
                            BorderUpdate();
1959
                            break;
1960
                        case ControlType.PolygonCloud:
1961
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1962
                            (item.DrawingData as IPath).updateControl();
1963
                            BorderUpdate();
1964
                            break;
1965
                        case ControlType.Circle:
1966
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1967
                            (item.DrawingData as IPath).updateControl();
1968
                            ((CircleControl)item.DrawingData).SetCenterXY();
1969
                            BorderUpdate();
1970
                            break;
1971
                        case ControlType.Ink:
1972
                            for (int i = 0; i < (item.DrawingData as InkControl).PointC.Count(); i++)
1973
                            {
1974
                                for (int j = 0; j < (item.DrawingData as InkControl).PointC[i].pointSet.Count; j++)
1975
                                {
1976
                                    (item.DrawingData as InkControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as InkControl).PointC[i].pointSet[j], dDeltaAngle);
1977
                                }
1978
                            }
1979
                            (item.DrawingData as IPath).updateControl();
1980
                            BorderUpdate();
1981
                            break;
1982
                        
1983
                        default:
1984
                            break;
1985
                    }
1986
                }
1987
                #endregion
1988
            }));
1989
            BorderUpdate();
1990
        }
1991

    
1992
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1993
        {            
1994

    
1995
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1996
            rotateTop.Cursor = Cursors.SizeAll;
1997

    
1998
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1999
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2000
            {
2001
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).Angle;
2002
            }
2003
            /// up to here
2004

    
2005

    
2006

    
2007
            if (ViewerDataModel.Instance.UndoDataList == null)
2008
            {
2009
                return;
2010
            }
2011

    
2012
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
2013
            {
2014
                return;
2015
            }
2016

    
2017
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
2018
            {
2019
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
2020
                {
2021
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
2022
                    {
2023
                        return;
2024
                    }
2025
                }
2026
            }
2027

    
2028
            var comments = (from drawing in this.Members
2029
                            select drawing.DrawingData as CommentUserInfo).ToList();
2030
            UndoCommand.Instance.Push(comments, this.AngleValue);
2031
        }
2032
        
2033
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
2034
        {
2035
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2036

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

    
2042
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
2043
        {
2044
            if (ViewerDataModel.Instance.UndoDataList == null)
2045
            {
2046
                return;
2047
            }
2048
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
2049
            {
2050
                return;
2051
            }
2052
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
2053
            {
2054
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
2055
                {
2056
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
2057
                    {
2058
                        return;
2059
                    }
2060
                }
2061
            }
2062

    
2063
            var comments = (from drawing in this.Members
2064
                            select drawing.DrawingData as CommentUserInfo).ToList();
2065
            UndoCommand.Instance.Push(comments, this.AngleValue);
2066
        }
2067

    
2068
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
2069
        {          
2070
            DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
2071

    
2072
            var comments = (from drawing in this.Members
2073
                            select drawing.DrawingData as CommentUserInfo).ToList();
2074
            UndoCommand.Instance.Push(comments, this.AngleValue);
2075
        }
2076

    
2077
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
2078
        {
2079
            AdornerMember control = this.Members.FirstOrDefault();
2080

    
2081
            if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null)
2082
            {
2083
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
2084
                {
2085
                    (control.DrawingData as ArrowTextControl).isTrans = true;
2086
                }
2087
            }
2088

    
2089
        }
2090

    
2091
        public void TextControlChanger()
2092
        {
2093
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2094
            {
2095
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
2096
                AllControl.Base_TextBox.Focus();
2097
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
2098
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
2099
                AllControl.Base_TextBox.Focus();
2100
                AllControl.SizeChanged += (sen, ea) =>
2101
                {
2102
                    if (AllControl.Base_TextBox != null)
2103
                    {
2104
                        RectangleGeometry Data = new RectangleGeometry
2105
                        {
2106
                            Rect = new Rect()
2107
                            {
2108
                                X = AllControl.StartPoint.X,
2109
                                Y = AllControl.StartPoint.Y,
2110
                                Width = AllControl.Base_TextBox.Width,
2111
                                Height = AllControl.Base_TextBox.Height,
2112
                            }
2113
                        };
2114

    
2115
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
2116
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
2117
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
2118
                        {
2119
                            Angle = AllControl.Angle,
2120
                            CenterX = middle.X,
2121
                            CenterY = middle.Y,
2122
                        };
2123
                    }
2124
                    BorderUpdate();
2125
                };
2126
            }
2127
        }
2128

    
2129
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
2130
        {
2131
            if (e.ClickCount == 2 && this.Members.Count == 1)
2132
            {
2133

    
2134
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
2135
                {
2136
                    TextControlChanger();                    
2137
                }
2138

    
2139
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2140
                {
2141
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
2142
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
2143
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
2144

    
2145
                    //ArrowControl TextBox Thumb없애기
2146
                    tm.Visibility = Visibility.Collapsed;
2147

    
2148
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
2149
                    
2150
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
2151

    
2152
                    {
2153
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
2154
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
2155

    
2156
                        List<Point> ps = new List<Point>();
2157
                        
2158
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
2159
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
2160
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
2161
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
2162

    
2163

    
2164

    
2165

    
2166
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
2167
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
2168
                        if (AllControl.isTrans)
2169
                        {
2170
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
2171
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
2172
                        }
2173
                        else
2174
                        {
2175
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
2176
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
2177
                        }
2178

    
2179

    
2180
                        BorderUpdate();
2181

    
2182
                    };
2183
                }
2184
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
2185
                {
2186
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
2187
                    CalendarControl instanceCal = new CalendarControl(data.Text);
2188
                    //dropData.IsOpen = true;
2189
                    RadWindow rc = new RadWindow();
2190
                    rc.Width = 300;
2191
                    rc.Height = 300;
2192
                    rc.Header = "Change Date";
2193
                    rc.Content = instanceCal;
2194
                    rc.BorderThickness = new Thickness(3);
2195
                    rc.ResizeMode = ResizeMode.NoResize;
2196
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
2197
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
2198
                    rc.ModalBackground.Opacity = 0.6;
2199
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
2200
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
2201
                    {
2202
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
2203
                        rc.Close();
2204
                    };
2205
                    rc.ShowDialog();
2206
                    //CalendarControl.xaml
2207
                }
2208
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
2209
                {
2210
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
2211
                    if (instance.isTransOn)
2212
                    {
2213
                        instance.isTransOn = false;
2214
                    }
2215
                    else
2216
                    {
2217
                        instance.isTransOn = true;
2218
                    }
2219
                    ///instance.SetArcPath();
2220
                    BorderUpdate();
2221
                }
2222
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
2223
                {
2224
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
2225
                    if (instance.isTransOn)
2226
                    {
2227
                        instance.isTransOn = false;
2228
                    }
2229
                    else
2230
                    {
2231
                        instance.isTransOn = true;
2232
                    }
2233
                    instance.SetArcPath();
2234
                    BorderUpdate();
2235
                }
2236

    
2237
            }
2238
            
2239
        }
2240
        #endregion
2241

    
2242
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
2243
        {
2244
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
2245
            {
2246
                DragThumb.Visibility = Visibility.Collapsed;
2247
            }
2248
        }
2249

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