프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 8771edc4

이력 | 보기 | 이력해설 | 다운로드 (91.9 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
        /// translate thumb with given delta and angle
37
        /// </summary>
38
        /// <param name="e"></param>
39
        /// <param name="angle"></param>
40
        public void Translate(double dx, double dy, double angle)
41
        {
42
            double radian = angle * Math.PI / 180;
43
            double cos = Math.Cos(radian);
44
            double sin = Math.Sin(radian);
45

    
46
            double _dx = dx * cos - dy * sin;
47
            double _dy = dx * sin + dy * cos;
48
            Canvas.SetLeft(this, Canvas.GetLeft(this) + _dx);
49
            Canvas.SetTop(this, Canvas.GetTop(this) + _dy);
50
        }
51

    
52
        /// <summary>
53
        /// </summary>
54
        /// <param name="sender"></param>
55
        /// <param name="e"></param>
56
        private void MyThumb_MouseLeave(object sender, MouseEventArgs e)
57
        {
58
            this.Opacity = 0.6;
59
        }
60

    
61
        /// <summary>
62
        /// 
63
        /// </summary>
64
        /// <param name="sender"></param>
65
        /// <param name="e"></param>
66
        private void MyThumb_MouseEnter(object sender, MouseEventArgs e)
67
        {
68
            this.Opacity = 1.0;
69
        }
70
    }
71

    
72
    /// <summary>
73
    /// Interaction logic for AdornerFinal.xaml
74
    /// </summary>
75
    public class AdornerMember
76
    {
77
        public UIElement DrawingData { get; set; }
78
        public ControlType Drawingtype { get; set; }
79
        public double DrawingAngle { get; set; }
80
        public List<MyThumb> ThumbList { get; set; }
81
        public string Symbol_ID { get; set; }
82
        public long Group_ID { get; set; }
83
    }
84

    
85
    public partial class AdornerFinal : UserControl
86
    {
87
        public TextBox editTextBox { get; set; }
88
        #region 공용 인스턴스
89
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
90
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
91
        public double AngleValue = 0;
92
        public bool IsTextAngle = false;
93
        public Rect BorderSize { get; set; }
94
        public bool TextCompensation = false;
95
        public bool isDragging { get; set; }
96
        public Thumb DraggerThumb { get; set; }
97
        public RadDropDownButton dropData;
98
        public RadCalendar dropCalendar;
99
        public Thumb mainDragThumb { get; set; }
100

    
101
        private bool disposed;
102

    
103
        public Point reSizePoint { get; set; }
104
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
105
        private Point MouseDownPoint = new Point();
106
        private Point CurrentMousePoint = new Point();
107
        #endregion
108
        #region 생성자
109
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
110
        {
111
            dropData = sender as RadDropDownButton;
112
        }
113

    
114
        private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
115
        {
116
            dropCalendar = sender as RadCalendar;
117
            dropCalendar.SelectionChanged += (sen, ea) =>
118
            {
119
                dropData.IsOpen = false;
120
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
121
                {
122
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
123
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
124
                }
125
            };
126
        }
127

    
128
        public AdornerFinal()
129
        {
130
            InitializeComponent();
131
            BorderSize = new Rect();
132
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
133
        }
134

    
135
        ~AdornerFinal()
136
        {
137
            this.Dispose(false);
138
        }
139

    
140
        public void Dispose()
141
        {
142
            this.Dispose(true);
143
            GC.SuppressFinalize(this);
144
        }
145

    
146
        protected virtual void Dispose(bool disposing)
147
        {
148
            if (this.disposed) return;
149
            if (disposing)
150
            {
151
                foreach (var member in this.Members)
152
                {
153
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
154
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
155
                }
156
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
157
            }
158
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
159
            this.disposed = true;
160
        }
161

    
162
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
163
        {
164
            mainDragThumb = DragThumb;
165
        }
166

    
167
        public AdornerFinal(CommentUserInfo objectData) : this()
168
        {
169
            InitializeComponent();
170
            objectData.IsHitTestVisible = false;
171
            if ((objectData as ArrowTextControl) != null)
172
            {
173
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
174
            }
175
            Canvas.SetZIndex(objectData, 84);
176
            try
177
            {
178
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
179
                this.ContainerContent.Children.Add(objectData);
180
            }
181
            catch (Exception ex)
182
            {
183

    
184
            }
185
           
186
            SetAdornerMember(objectData as CommentUserInfo);
187
            this.Focus();
188
        }
189

    
190
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
191
        {
192
            InitializeComponent();
193
            foreach (var item in objectData)
194
            {
195
                //item.IsHitTestVisible = false;
196
                if ((item as ArrowTextControl) != null)
197
                {
198
                    (item as ArrowTextControl).Base_TextBox.Focusable = true;
199
                }
200
                try
201
                {
202
                    Canvas.SetZIndex(item, 80);
203
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
204
                    this.ContainerContent.Children.Add(item);
205
                }
206
                catch //(Exception ex)
207
                {
208
                }
209
                finally
210
                {
211
                    
212
                }
213
            }
214
            this.SetAdornerMember(objectData);
215
            this.Focus();
216
        }
217

    
218
        #endregion
219
        #region 메서드
220
        public Rect getAdornerSize()
221
        {
222
            return BorderSize;
223
        }
224
        public void addMemberControl(UIElement objectData)
225
        {
226
            this.ContainerContent.Children.Add(objectData);
227
            SetAdornerMember(objectData as CommentUserInfo);
228
            this.Focus();
229
        }
230
        /// <summary>
231
        /// UIElement를 종류에 맞게 등록시킴
232
        /// </summary>
233
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
234
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
235
        {
236

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

    
320
                case "SymControl":
321
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
322
                    AngleValue = (member as SymControl).Angle;
323
                    break;
324
                case "SymControlN":
325
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
326
                    AngleValue = (member as SymControlN).Angle;
327
                    break;
328
                case "InkControl": //Angle추가 안했음
329
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
330
                    break;
331
                case "TextControl":
332
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
333
                    RectangleGeometry Data = new RectangleGeometry
334
                    {
335
                        Rect = new Rect()
336
                        {
337
                            X = Canvas.GetLeft((member as TextControl)),
338
                            Y = Canvas.GetTop((member as TextControl)),
339
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
340
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
341
                            //Width = (member as TextControl).BoxWidth / 2,
342
                            //Height = (member as TextControl).BoxHeight / 2,
343
                        }
344
                    };
345
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
346
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
347

    
348

    
349
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
350
                    DragThumb.RenderTransform = new RotateTransform()
351
                    {
352
                        Angle = (member as TextControl).Angle,
353
                        //CenterX = middle.X,
354
                        //CenterY = middle.Y,
355
                    };
356

    
357
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
358
                    AdornerBorder.RenderTransform = new RotateTransform()
359
                    {
360
                        Angle = (member as TextControl).Angle,
361
                        //CenterX = middle.X,
362
                        //CenterY = middle.Y,
363
                    };
364
                    Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
365
                    {
366
                        TextCompensation = true;
367
                        BorderUpdate();
368
                        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
369
                    });
370
                    Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
371
                    {
372
                        TextCompensation = false;
373
                        BorderUpdate();
374
                        if ((a.Sender as TextBox).Text == "") //보류
375
                        {
376
                            this.ContainerContent.Children.Remove(member);
377
                            this.Visibility = Visibility.Collapsed;
378
                        }
379

    
380
                        //((TextControl)member).UnEditingMode();
381
                        //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
382
                        //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
383
                        //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
384
                    });
385
                    break;
386
                case "InsideWhiteControl":
387
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
388
                    break;
389
                case "OverlapWhiteControl":
390
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
391
                    break;
392
                case "ClipWhiteControl":
393
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
394
                    break;
395
                case "CoordinateControl":
396
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
397
                    break;
398
                default:
399
                    break;
400
                    #endregion
401
            }
402
            if (member.GetType().Name == "TextControl")
403
            {
404
                TextControl content = ((TextControl)member);
405
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
406
                content.EndPoint = content.StartPoint;
407

    
408
            }
409
            else
410
            {
411
                RegistryPoint(member);
412
            }
413
            BorderUpdate();
414

    
415
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
416
        }
417

    
418
        private void ViewBoxRotate(UIElement member)
419
        {
420
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
421
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
422
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
423
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle };
424
        }
425

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

    
500
                            }
501

    
502
                        });
503
                        Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
504
                        {
505
                            BorderUpdate();
506
                        });
507
                        break;
508
                    case "InsideWhiteControl":
509
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
510
                        break;
511
                    case "OverlapWhiteControl":
512
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
513
                        break;
514
                    case "ClipWhiteControl":
515
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
516
                        break;
517
                    case "CoordinateControl":
518
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
519
                        break;
520
                    default:
521
                        break;
522
                        #endregion
523
                }
524
                if (member.GetType().Name == "TextControl")
525
                {
526
                    TextControl content = ((TextControl)member);
527
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
528
                    content.EndPoint = content.StartPoint;
529
                }
530
                else
531
                {
532
                    RegistryPoint(member, members.Count);
533
                }
534

    
535
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))  Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
536
            }
537

    
538
            BorderUpdate();
539
        }
540

    
541
        /// <summary>
542
        /// Border 를 갱신
543
        /// </summary>
544
        public void BorderUpdate()
545
        {
546
            AdornerBorder.MinWidth = 10;
547
            AdornerBorder.MinHeight = 10;
548

    
549
            double minX = double.MaxValue;
550
            double minY = double.MaxValue;
551
            double maxX = double.MinValue;
552
            double maxY = double.MinValue;
553

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

    
663
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
664
            bool addWidthSize = false;
665
            bool addHeightSize = false;
666
            if (ac.Width <= 10)
667
            {
668
                ac.Width += 10;
669
                addWidthSize = true;
670
            }
671
            if (ac.Height <= 10)
672
            {
673
                ac.Height += 10;
674
                addHeightSize = true;
675
            }
676
            BorderSize = ac;
677
            AdornerBorder.MinWidth = 10;
678
            AdornerBorder.MinHeight = 10;
679
            AdornerBorder.Width = ac.Width;
680
            AdornerBorder.Height = ac.Height;
681
            Canvas.SetLeft(AdornerBorder, minX);
682
            Canvas.SetTop(AdornerBorder, minY);
683

    
684
            DragThumb.Width = ac.Width;
685
            DragThumb.Height = ac.Height;
686

    
687
            DragThumb.MinWidth = 10;
688
            DragThumb.MinHeight = 10;
689
            if (addWidthSize)
690
            {
691
                Canvas.SetLeft(DragThumb, minX - 5);
692
            }
693
            else
694
            {
695
                Canvas.SetLeft(DragThumb, minX);
696
            }
697

    
698
            if (addHeightSize)
699
            {
700
                Canvas.SetTop(DragThumb, minY - 5);
701
            }
702
            else
703
            {
704
                Canvas.SetTop(DragThumb, minY);
705
            }
706
        }
707
        /// <summary>
708
        /// UIElement 해제
709
        /// </summary>
710
        public void unRegister()
711
        {
712
            foreach (var item in this.ContainerContent.Children)
713
            {
714
                if (item is MarkupToPDF.Common.CommentUserInfo)
715
                {
716
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
717
                }
718
            }
719
            this.ContainerContent.Children.Clear();
720
        }
721

    
722
        /// <summary>
723
        /// 각 포인트들을 등록합니다.
724
        /// </summary>
725
        /// <param name="pointset">Drawing Point</param>
726
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
727
        {
728
            int count = 0;
729
            double Minx = 100000000;
730
            double Miny = 100000000;
731
            List<Point> list = (member as IPath).PointSet;
732
            if (member.GetType().Name == "InkControl")
733
            {
734
                list.Clear();
735
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
736
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
737
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
738
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
739
            }
740
            ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype;
741
            foreach (var ax in list)
742
            {
743
                Minx = (ax.X < Minx) ? ax.X : Minx;
744
                Miny = (ax.Y < Miny) ? ax.Y : Miny;
745
            }
746
            for (int i = 0; i < list.Count(); i++)
747
            {
748
                MyThumb tm = new MyThumb
749
                {
750
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
751
                };
752

    
753
                this.Members.Last().ThumbList.Add(tm);
754

    
755
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MidPoint))
756
                {
757
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
758
                }
759
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
760
                {
761
                    //if (this.Members.Count()<=1)
762
                    //{
763
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
764
                    List<Point> ps = new List<Point>();
765

    
766
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
767
                    {
768
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
769

    
770

    
771
                        switch (Math.Abs(temp.Angle).ToString())
772
                        {
773
                            case "90":
774
                                {
775
                                    ps.Clear();
776
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
777
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
778
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
779

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

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

    
786
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
787
                                }
788
                                break;
789
                            case "270":
790
                                {
791
                                    ps.Clear();
792
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
793
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
794
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
795

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

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

    
802
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
803
                                }
804
                                break;
805
                            default:
806
                                {
807
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
808
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
809
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
810
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
811
                                }
812
                                break;
813
                        }
814

    
815
                        ArrowTextControl instance = (member as ArrowTextControl);
816
                        if (instance.isTrans)
817
                        {
818
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
819
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
820
                            //list[count] = tempP;
821
                            list[count] = temp.MidPoint;
822
                        }
823
                        else
824
                        {
825
                            if (temp.isFixed)
826
                            {
827
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
828
                                var testP = endP;
829
                                if (ps[0] == endP) //상단
830
                                {
831
                                    testP = new Point(endP.X, endP.Y - 50);
832
                                }
833
                                else if (ps[1] == endP) //하단
834
                                {
835
                                    testP = new Point(endP.X, endP.Y + 50);
836
                                }
837
                                else if (ps[2] == endP) //좌단
838
                                {
839
                                    testP = new Point(endP.X - 50, endP.Y);
840
                                }
841
                                else if (ps[3] == endP) //우단
842
                                {
843
                                    testP = new Point(endP.X + 50, endP.Y);
844
                                }
845
                                list[count] = testP;
846
                            }
847
                            else
848
                            {
849
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
850
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
851
                            }
852
                        }
853
                    }
854
                }
855
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
856
                {
857
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
858
                    tm.Width = (member as ArrowTextControl).BoxWidth;
859
                    tm.Height = (member as ArrowTextControl).BoxHeight;
860
                    var angle = (member as ArrowTextControl).Angle;
861
                    if (Math.Abs(angle).ToString() == "90")
862
                    {
863
                        tm.RenderTransformOrigin = new Point(0, 0);
864
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
865
                    }
866
                    else if (Math.Abs(angle).ToString() == "270")
867
                    {
868
                        tm.RenderTransformOrigin = new Point(0, 0);
869
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
870
                    }
871
                    else
872
                    {
873
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
874
                        tm.RenderTransform = new RotateTransform()
875
                        {
876
                            Angle = angle,
877
                        };
878
                    }
879
                }
880
                
881
                if (member.GetType().Name == "CloudControl")
882
                {
883
                    if (i == list.Count() - 1)
884
                    {
885
                        tm.Visibility = System.Windows.Visibility.Collapsed;
886
                    }
887
                }
888
                if (member.GetType().Name == "PolygonControl")
889
                {
890
                    if (i == list.Count() - 1)
891
                    {
892
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
893
                        {
894

    
895
                        }
896
                        else
897
                        {
898
                            tm.Visibility = System.Windows.Visibility.Collapsed;
899
                        }
900
                    }
901
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
902
                    {
903
                        tm.Visibility = System.Windows.Visibility.Collapsed;
904
                    }
905
                }
906
                
907
                this.ContainerContent.Children.Add(tm);
908
                Canvas.SetLeft(tm, list[count].X);
909
                Canvas.SetTop(tm, list[count].Y);
910
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
911
                {
912
                    Canvas.SetZIndex(tm, 95);
913
                }
914
                else
915
                {
916
                    Canvas.SetZIndex(tm, 99);
917
                }
918

    
919
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
920
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
921
                tm.DragDelta += ResizeTm_DragDelta;
922
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
923
                count++;
924
            }
925
        }
926

    
927
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
928
        {
929
            if (this.Members.Count > 1) return;
930
            if (reSizePoint != new Point(0, 0))
931
            {
932
                MyThumb thumb = sender as MyThumb;
933
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
934
                thumb.Translate(e.HorizontalChange, e.VerticalChange, this.AngleValue);
935
                
936
                AdornerMember control = (from userThumb in this.Members
937
                                         where userThumb.ThumbList.Contains(thumb)
938
                                         select userThumb).FirstOrDefault();
939

    
940
                IPath AllControl = control.DrawingData as IPath;
941
                ((control.DrawingData) as CommentUserInfo).OnMoveCtrlPoint(setPoint, e.HorizontalChange, e.VerticalChange);
942
                DynamicThumbUpdate(control);
943
                BorderUpdate();
944
            }
945
        }
946

    
947
        #endregion
948
        #region 이벤트
949

    
950
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
951
        {
952
            this.isDragging = false;
953
            DraggerThumb = null;
954

    
955
            var comments = (from drawing in this.Members
956
                            select drawing.DrawingData as CommentUserInfo).ToList();
957
            UndoCommand.Instance.Push(comments, this.AngleValue);
958
        }
959

    
960
        /// <summary>
961
        /// start drag
962
        /// </summary>
963
        /// <param name="sender"></param>
964
        /// <param name="e"></param>
965
        void tm_DragStarted(object sender, DragStartedEventArgs e)
966
        {
967
            this.DraggerThumb = sender as Thumb;
968
            this.isDragging = true;
969

    
970
            if (ViewerDataModel.Instance.UndoDataList == null)
971
            {
972
                return;
973
            }
974

    
975
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
976
            {
977
                return;
978
            }
979

    
980
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
981
            {
982
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
983
                {
984
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
985
                    {
986
                        return;
987
                    }
988
                }
989
            }
990

    
991
            var comments = (from drawing in this.Members
992
                            select drawing.DrawingData as CommentUserInfo).ToList();
993
            UndoCommand.Instance.Push(comments, this.AngleValue);
994
        }
995

    
996
        private void rotate_MouseMove(object sender, MouseEventArgs e)
997
        {
998
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
999
            {
1000
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1001
                    IsTextAngle = true;
1002
                else
1003
                    IsTextAngle = false;
1004
                LastRotateVerticalValue = e.GetPosition(this).X;
1005
            }
1006
            else
1007
            {
1008
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1009
                {
1010
                    RotateFlag = true;
1011
                }
1012
                else
1013
                {
1014
                    RotateFlag = false;
1015
                }
1016
                LastRotateHorizontalValue = e.GetPosition(this).X;
1017
            }
1018
        }
1019

    
1020
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1021
        {
1022
            /// save mouse down and current mouse point
1023
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1024
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1025
            /// up to here
1026

    
1027
            if (ViewerDataModel.Instance.UndoDataList == null)
1028
            {
1029
                return;
1030
            }
1031
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1032
            {
1033
                return;
1034
            }
1035
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1036
            {
1037
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1038
                {
1039
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1040
                    {
1041
                        return;
1042
                    }
1043
                }
1044
            }
1045

    
1046
            var comments = (from drawing in this.Members
1047
                            select drawing.DrawingData as CommentUserInfo).ToList();
1048
            UndoCommand.Instance.Push(comments, this.AngleValue);
1049
        }
1050

    
1051
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1052
        {
1053
            DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1054

    
1055
            var comments = (from drawing in this.Members
1056
                            select drawing.DrawingData as CommentUserInfo).ToList();
1057
            UndoCommand.Instance.Push(comments, this.AngleValue);
1058
        }
1059

    
1060
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1061
        {
1062
            var tmp = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1063
            var horzChange = Math.Round(tmp.X - this.CurrentMousePoint.X);
1064
            var vertChange = Math.Round(tmp.Y - this.CurrentMousePoint.Y);
1065
            try
1066
            {
1067
                DragThumb.Cursor = Cursors.SizeAll;
1068
                this.TranslateItems(horzChange, vertChange);
1069
            }
1070
            finally
1071
            {
1072
                /// update CurrentMousePoint
1073
                this.CurrentMousePoint = tmp;
1074
            }
1075
        }
1076

    
1077
        /// <summary>
1078
        /// translate all members
1079
        /// </summary>
1080
        /// <param name="e"></param>
1081
        public void TranslateItems(double dx, double dy)
1082
        {
1083
            Dispatcher.BeginInvoke((Action)(() =>
1084
            {
1085
                foreach (var item in this.Members)
1086
                {
1087
                    this.TranslateItem(dx, dy, item);
1088
                }
1089
            }));
1090
            this.BorderUpdate();
1091
        }
1092

    
1093
        /// <summary>
1094
        /// translate a item
1095
        /// </summary>
1096
        /// <param name="e"></param>
1097
        /// <param name="item"></param>
1098
        private void TranslateItem(double dx, double dy, AdornerMember item)
1099
        {
1100
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), 0);
1101
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1102
            for (int i = 0; i < item.ThumbList.Count(); i++)
1103
            {
1104
                (item.ThumbList[i] as MyThumb).Translate(dx, dy , this.trRotate.Angle);
1105
            }
1106
        }
1107

    
1108
        public void DynamicThumbUpdate(AdornerMember item)
1109
        {
1110
            var AllControl = item.DrawingData as IPath;
1111
            List<Point> point = AllControl.PointSet;
1112

    
1113
            for (int i = 0; i < AllControl.PointSet.Count(); i++)
1114
            {
1115
                Canvas.SetLeft(item.ThumbList[i], AllControl.PointSet[i].X);
1116
                Canvas.SetTop(item.ThumbList[i], AllControl.PointSet[i].Y);
1117
            }
1118

    
1119

    
1120
            if (item.DrawingData as ArrowTextControl != null)
1121
            {
1122
                if (!(item.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
1123
                {
1124
                    List<Point> ps = new List<Point>();
1125

    
1126
                    var temp = item.DrawingData as ArrowTextControl;
1127
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1128
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1129
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1130
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1131

    
1132
                    if (temp.isFixed)
1133
                    {
1134
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1135
                        var testP = endP;
1136
                        if (ps[0] == endP) //상단
1137
                        {
1138
                            testP = new Point(endP.X, endP.Y - 50);
1139
                            //System.Diagnostics.Debug.WriteLine("상단");
1140
                        }
1141
                        else if (ps[1] == endP) //하단
1142
                        {
1143
                            testP = new Point(endP.X, endP.Y + 50);
1144
                            //System.Diagnostics.Debug.WriteLine("하단");
1145
                        }
1146
                        else if (ps[2] == endP) //좌단
1147
                        {
1148
                            testP = new Point(endP.X - 50, endP.Y);
1149
                            //System.Diagnostics.Debug.WriteLine("좌단");
1150
                        }
1151
                        else if (ps[3] == endP) //우단
1152
                        {
1153
                            testP = new Point(endP.X + 50, endP.Y);
1154
                            //System.Diagnostics.Debug.WriteLine("우단");
1155
                        }
1156
                        Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], testP.X);
1157
                        Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], testP.Y);
1158
                    }
1159
                    else
1160
                    {
1161
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1162
                        var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1163
                        Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1164
                        Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1165
                    }
1166
                }
1167
            }
1168
        }
1169

    
1170
        public void Set_Rotate()
1171
        {
1172
            double dDeltaAngle = 0;
1173
            List<Point> AllPointSet = new List<Point>();
1174
            Point CenterPoint = new Point();
1175

    
1176
            if (AngleValue >= 360)
1177
            {
1178
                AngleValue -= 360;
1179
            }
1180
            else if (AngleValue <= -360)
1181
            {
1182
                AngleValue += 360;
1183
            }
1184

    
1185
            #region 센터 포인트 구하기 (그룹핑)
1186
            foreach (var item in this.Members)
1187
            {
1188
                if (item.DrawingData.GetType().Name == "TextControl")
1189
                {
1190
                }
1191
                else
1192
                {
1193
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1194
                    {
1195
                        AllPointSet.Add(itemP);
1196
                    }
1197
                }
1198
            }
1199
            #endregion
1200

    
1201
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1202

    
1203
            Dispatcher.BeginInvoke((Action)(() =>
1204
            {
1205
                foreach (var item in this.Members)
1206
                {
1207
                    foreach (var thumb in item.ThumbList)
1208
                    {
1209
                        double x = Canvas.GetLeft(thumb);
1210
                        double y = Canvas.GetTop(thumb);
1211

    
1212
                        Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle);
1213
                        Canvas.SetLeft(thumb, value.X);
1214
                        Canvas.SetTop(thumb, value.Y);
1215

    
1216
                        if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last())
1217
                        {
1218

    
1219
                            Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox));
1220
                            Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox));
1221
                            if (!(item.DrawingData as ArrowTextControl).isTrans)
1222
                            {
1223
                                List<Point> ps = new List<Point>();
1224
                                var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1225
                                switch (Math.Abs(temp.Angle).ToString())
1226
                                {
1227
                                    case "90":
1228
                                        {
1229
                                            ps.Clear();
1230
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1231
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
1232
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
1233

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

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

    
1240
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
1241
                                        }
1242
                                        break;
1243
                                    case "270":
1244
                                        {
1245
                                            ps.Clear();
1246
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
1247
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
1248
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
1249

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

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

    
1256
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
1257
                                        }
1258
                                        break;
1259
                                    default:
1260
                                        {
1261
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
1262
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
1263
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
1264
                                            ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
1265
                                        }
1266
                                        break;
1267
                                }
1268

    
1269
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
1270
                                var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
1271
                                Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1272
                                Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1273
                            }
1274
                        }
1275
                    }
1276

    
1277
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1278
                    {
1279
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1280
                    }
1281
                }
1282
                #region 컨트롤 업데이트
1283
                foreach (var item in this.Members)
1284
                {
1285
                    switch (item.Drawingtype)
1286
                    {
1287
                        case ControlType.TextControl:
1288
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1289

    
1290
                            RectangleGeometry Data = new RectangleGeometry
1291
                            {
1292
                                Rect = new Rect()
1293
                                {
1294
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1295
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1296
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1297
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1298
                                }
1299
                            };
1300

    
1301
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1302
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);                                                      
1303

    
1304
                            DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
1305
                            DragThumb.RenderTransform = new RotateTransform()
1306
                            {
1307
                                Angle = (item.DrawingData as TextControl).Angle,
1308

    
1309
                            };
1310

    
1311
                            AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
1312
                            AdornerBorder.RenderTransform = new RotateTransform()
1313
                            {
1314
                                Angle = (item.DrawingData as TextControl).Angle,
1315

    
1316
                            };
1317

    
1318
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1319
                            {
1320
                                Angle = (item.DrawingData as TextControl).Angle,
1321
                            };
1322
                            BorderUpdate();
1323
                            break;
1324

    
1325
                        case ControlType.Date:
1326
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1327
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1328
                            BorderUpdate();
1329
                            break;
1330
                        case ControlType.ArrowMultiLine:
1331
                        case ControlType.ArcLine:
1332
                        case ControlType.ArcArrow:
1333
                        case ControlType.SingleLine:
1334
                        case ControlType.Triangle:
1335
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1336
                            BorderUpdate();
1337
                            break;
1338
                        case ControlType.ArrowTextControl:
1339
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1340
                            BorderUpdate();
1341
                            break;
1342
                        case ControlType.RectCloud:
1343
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1344
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1345
                            BorderUpdate();
1346
                            break;
1347
                        case ControlType.Rectangle:
1348
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1349
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1350
                            BorderUpdate();
1351
                            break;
1352
                        case ControlType.ImgControl:
1353
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1354
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1355
                            BorderUpdate();
1356
                            break;
1357
                        case ControlType.Sign:
1358
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1359
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1360
                            BorderUpdate();
1361
                            break;
1362
                        case ControlType.Symbol:
1363
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1364
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1365
                            BorderUpdate();
1366
                            break;
1367
                        case ControlType.Stamp:
1368
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1369
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1370
                            BorderUpdate();
1371
                            break;
1372
                        case ControlType.PolygonControl:
1373
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1374
                            BorderUpdate();
1375
                            break;
1376
                        case ControlType.PolygonCloud:
1377
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1378
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1379
                            BorderUpdate();
1380
                            break;
1381
                        case ControlType.Circle:
1382
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1383
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1384
                            ((CircleControl)item.DrawingData).SetCenterXY();
1385
                            BorderUpdate();
1386
                            break;
1387
                        case ControlType.Ink:
1388
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1389
                            BorderUpdate();
1390
                            break;
1391
                        case ControlType.InsideWhite:
1392
                            ((InsideWhiteControl)item.DrawingData).Angle = AngleValue;
1393
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1394
                            BorderUpdate();
1395
                            break;
1396
                        case ControlType.OverlapWhite:
1397
                            ((OverlapWhiteControl)item.DrawingData).Angle = AngleValue;
1398
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1399
                            BorderUpdate();
1400
                            break;
1401
                        case ControlType.ClipWhite:
1402
                            ((ClipWhiteControl)item.DrawingData).Angle = AngleValue;
1403
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1404
                            BorderUpdate();
1405
                            break;
1406
                        case ControlType.Coordinate:
1407
                            ((CoordinateControl)item.DrawingData).Angle = AngleValue;
1408
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1409
                            BorderUpdate();
1410
                            break;
1411
                        default:
1412
                            break;
1413
                    }
1414
                }
1415
                #endregion
1416
            }));
1417
        }
1418

    
1419
        private void resize_MouseMove(object sender, MouseEventArgs e)
1420
        {
1421
            reSizePoint = e.GetPosition(this);
1422
        }
1423

    
1424
        /// <summary>
1425
        /// 회전
1426
        /// </summary>
1427
        /// <param name="sender"></param>
1428
        /// <param name="e"></param>
1429
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1430
        {
1431
            MoveRotate(e);
1432
        }
1433

    
1434
        double LastRotateHorizontalValue = 0;
1435
        double LastRotateVerticalValue = 0;
1436
        //double LastWidthValue = 0;
1437
        //double SetWidth = 0;
1438
        bool RotateFlag = false;
1439

    
1440
        /// <summary>
1441
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1442
        /// </summary>
1443
        /// <param name="e"></param>
1444
        public void MoveRotate(DragDeltaEventArgs e)
1445
        {
1446
            double dDeltaAngle = 0;
1447

    
1448
            List<Point> AllPointSet = new List<Point>();
1449
            Point CenterPoint = new Point();
1450
            
1451
            #region 센터 포인트 구하기 (그룹핑)
1452
            foreach (var item in this.Members)
1453
            {
1454
                if (item.DrawingData.GetType().Name == "TextControl")
1455
                {                    
1456
                    if (AngleValue == 0)
1457
                    {
1458
                        AngleValue = (item.DrawingData as TextControl).Angle;
1459
                    }
1460
                    double X = Canvas.GetLeft((item.DrawingData as TextControl));
1461
                    double Y = Canvas.GetTop((item.DrawingData as TextControl));
1462
                    AllPointSet.Add(new Point(X, Y));
1463
                }
1464
                else
1465
                {
1466
                    foreach (Point itemP in (item.DrawingData as IPath).PointSet)
1467
                    {
1468
                        AllPointSet.Add(itemP);
1469
                    }
1470
                }
1471
            }
1472
            #endregion
1473
            CenterPoint = MathSet.FindCentroid(AllPointSet);
1474
            Point pt = Mouse.GetPosition(this);
1475

    
1476
            Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
1477
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1478
            dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1479

    
1480
            //System.Diagnostics.Debug.WriteLine("vec1 : " + vec1.X + "/" + vec1.Y);
1481
            //System.Diagnostics.Debug.WriteLine("vec2 : " + vec2.X + "/" + vec2.Y);
1482
            //System.Diagnostics.Debug.WriteLine("dDeltaAngle : " + dDeltaAngle);
1483

    
1484
            AngleValue += dDeltaAngle;
1485
            if (AngleValue > 360) AngleValue -= 360;
1486
            if (AngleValue < 0) AngleValue += 360;
1487
            this.rotatePoint = pt;  /// save rotatePoint
1488

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

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

    
1503
                    for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++)
1504
                    {
1505
                        (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle);
1506
                    }
1507
                }
1508
                #region 보더 업데이트
1509
                foreach (var item in this.Members)
1510
                {
1511
                    switch (item.Drawingtype)
1512
                    {
1513
                        case ControlType.TextControl:
1514
                            ((TextControl)item.DrawingData).Angle = AngleValue;
1515

    
1516
                            RectangleGeometry Data = new RectangleGeometry
1517
                            {
1518
                                Rect = new Rect()
1519
                                {
1520
                                    X = Canvas.GetLeft((item.DrawingData as TextControl)),
1521
                                    Y = Canvas.GetTop((item.DrawingData as TextControl)),
1522
                                    Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2,
1523
                                    Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2,
1524
                                }
1525
                            };
1526

    
1527
                            Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1528
                            Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV);
1529

    
1530
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1531
                            DragThumb.RenderTransform = new RotateTransform()
1532
                            {
1533
                                Angle = (item.DrawingData as TextControl).Angle,
1534
                                //CenterX = middle.X,
1535
                                //CenterY = middle.Y,
1536
                            };
1537

    
1538
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1539
                            AdornerBorder.RenderTransform = new RotateTransform()
1540
                            {
1541
                                Angle = (item.DrawingData as TextControl).Angle,
1542
                                //CenterX = middle.X,
1543
                                //CenterY = middle.Y,
1544
                            };
1545

    
1546
                            (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform()
1547
                            {
1548
                                Angle = (item.DrawingData as TextControl).Angle,
1549
                            };
1550

    
1551
                            BorderUpdate();
1552
                            break;
1553

    
1554
                        case ControlType.Date:
1555
                            ((DateControl)item.DrawingData).Angle = AngleValue;
1556
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1557
                            BorderUpdate();                          
1558
                            break;
1559
                        case ControlType.ArrowMultiLine:
1560
                        case ControlType.ArcLine:
1561
                        case ControlType.ArcArrow:
1562
                        case ControlType.SingleLine:
1563
                        case ControlType.Triangle:
1564
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1565
                            BorderUpdate();
1566
                            break;
1567
                        case ControlType.ArrowTextControl:
1568
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1569
                            BorderUpdate();
1570
                            break;
1571
                        case ControlType.RectCloud:
1572
                            ((RectCloudControl)item.DrawingData).Angle = AngleValue;
1573
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1574
                            BorderUpdate();
1575
                            break;
1576
                        case ControlType.Rectangle:
1577
                            ((RectangleControl)item.DrawingData).Angle = AngleValue;
1578
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1579
                            BorderUpdate();
1580
                            break;
1581
                        case ControlType.ImgControl:
1582
                            ((ImgControl)item.DrawingData).Angle = AngleValue;
1583
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1584
                            BorderUpdate();
1585
                            break;                        
1586
                        case ControlType.Sign:
1587
                            ((SignControl)item.DrawingData).Angle = AngleValue;
1588
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1589
                            BorderUpdate();
1590
                            break;                        
1591
                        case ControlType.Symbol:
1592
                            ((SymControl)item.DrawingData).Angle = AngleValue;
1593
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1594
                            BorderUpdate();
1595
                            break;
1596
                        case ControlType.Stamp:
1597
                            ((SymControlN)item.DrawingData).Angle = AngleValue;
1598
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1599
                            BorderUpdate();
1600
                            break;
1601
                        case ControlType.PolygonControl:
1602
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1603
                            BorderUpdate();
1604
                            break;
1605
                        case ControlType.PolygonCloud:
1606
                            ((ICloudControl)item.DrawingData).DrawingCloud();
1607
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1608
                            BorderUpdate();
1609
                            break;
1610
                        case ControlType.Circle:
1611
                            ((IShapeControl)item.DrawingData).Angle = AngleValue;
1612
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1613
                            ((CircleControl)item.DrawingData).SetCenterXY();
1614
                            BorderUpdate();
1615
                            break;
1616
                        case ControlType.Ink:
1617
                            for (int i = 0; i < (item.DrawingData as InkControl).PointC.Count(); i++)
1618
                            {
1619
                                for (int j = 0; j < (item.DrawingData as InkControl).PointC[i].pointSet.Count; j++)
1620
                                {
1621
                                    (item.DrawingData as InkControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as InkControl).PointC[i].pointSet[j], dDeltaAngle);
1622
                                }
1623
                            }
1624
                            (item.DrawingData as CommentUserInfo).UpdateControl();
1625
                            BorderUpdate();
1626
                            break;
1627
                        
1628
                        default:
1629
                            break;
1630
                    }
1631
                }
1632
                #endregion
1633
            }));
1634
            BorderUpdate();
1635
        }
1636

    
1637
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1638
        {            
1639

    
1640
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1641
            rotateTop.Cursor = Cursors.SizeAll;
1642

    
1643
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1644
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1645
            {
1646
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).Angle;
1647
            }
1648
            /// up to here
1649

    
1650

    
1651

    
1652
            if (ViewerDataModel.Instance.UndoDataList == null)
1653
            {
1654
                return;
1655
            }
1656

    
1657
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1658
            {
1659
                return;
1660
            }
1661

    
1662
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1663
            {
1664
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1665
                {
1666
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1667
                    {
1668
                        return;
1669
                    }
1670
                }
1671
            }
1672

    
1673
            var comments = (from drawing in this.Members
1674
                            select drawing.DrawingData as CommentUserInfo).ToList();
1675
            UndoCommand.Instance.Push(comments, this.AngleValue);
1676
        }
1677
        
1678
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1679
        {
1680
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1681

    
1682
            var comments = (from drawing in this.Members
1683
                            select drawing.DrawingData as CommentUserInfo).ToList();
1684
            UndoCommand.Instance.Push(comments, this.AngleValue);
1685
        }
1686

    
1687
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1688
        {
1689
            AdornerMember control = this.Members.FirstOrDefault();
1690

    
1691
            if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null)
1692
            {
1693
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1694
                {
1695
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1696
                }
1697
            }
1698

    
1699
        }
1700

    
1701
        public void TextControlChanger()
1702
        {
1703
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1704
            {
1705
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1706
                AllControl.Base_TextBox.Focus();
1707
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1708
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1709
                AllControl.Base_TextBox.Focus();
1710
                AllControl.SizeChanged += (sen, ea) =>
1711
                {
1712
                    if (AllControl.Base_TextBox != null)
1713
                    {
1714
                        RectangleGeometry Data = new RectangleGeometry
1715
                        {
1716
                            Rect = new Rect()
1717
                            {
1718
                                X = AllControl.StartPoint.X,
1719
                                Y = AllControl.StartPoint.Y,
1720
                                Width = AllControl.Base_TextBox.Width,
1721
                                Height = AllControl.Base_TextBox.Height,
1722
                            }
1723
                        };
1724

    
1725
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1726
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1727
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1728
                        {
1729
                            Angle = AllControl.Angle,
1730
                            CenterX = middle.X,
1731
                            CenterY = middle.Y,
1732
                        };
1733
                    }
1734
                    BorderUpdate();
1735
                };
1736
            }
1737
        }
1738

    
1739
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1740
        {
1741
            if (e.ClickCount == 2 && this.Members.Count == 1)
1742
            {
1743

    
1744
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1745
                {
1746
                    TextControlChanger();                    
1747
                }
1748

    
1749
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1750
                {
1751
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1752
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1753
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1754

    
1755
                    //ArrowControl TextBox Thumb없애기
1756
                    tm.Visibility = Visibility.Collapsed;
1757

    
1758
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1759
                    
1760
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1761

    
1762
                    {
1763
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1764
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1765

    
1766
                        List<Point> ps = new List<Point>();
1767
                        
1768
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1769
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1770
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1771
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1772

    
1773

    
1774

    
1775

    
1776
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1777
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1778
                        if (AllControl.isTrans)
1779
                        {
1780
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1781
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1782
                        }
1783
                        else
1784
                        {
1785
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1786
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1787
                        }
1788

    
1789

    
1790
                        BorderUpdate();
1791

    
1792
                    };
1793
                }
1794
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1795
                {
1796
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1797
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1798
                    //dropData.IsOpen = true;
1799
                    RadWindow rc = new RadWindow();
1800
                    rc.Width = 300;
1801
                    rc.Height = 300;
1802
                    rc.Header = "Change Date";
1803
                    rc.Content = instanceCal;
1804
                    rc.BorderThickness = new Thickness(3);
1805
                    rc.ResizeMode = ResizeMode.NoResize;
1806
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1807
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1808
                    rc.ModalBackground.Opacity = 0.6;
1809
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1810
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1811
                    {
1812
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1813
                        rc.Close();
1814
                    };
1815
                    rc.ShowDialog();
1816
                    //CalendarControl.xaml
1817
                }
1818
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1819
                {
1820
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1821
                    if (instance.isTransOn)
1822
                    {
1823
                        instance.isTransOn = false;
1824
                    }
1825
                    else
1826
                    {
1827
                        instance.isTransOn = true;
1828
                    }
1829
                    ///instance.SetArcPath();
1830
                    BorderUpdate();
1831
                }
1832
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1833
                {
1834
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1835
                    if (instance.isTransOn)
1836
                    {
1837
                        instance.isTransOn = false;
1838
                    }
1839
                    else
1840
                    {
1841
                        instance.isTransOn = true;
1842
                    }
1843
                    instance.SetArcPath();
1844
                    BorderUpdate();
1845
                }
1846

    
1847
            }
1848
            
1849
        }
1850
        #endregion
1851

    
1852
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1853
        {
1854
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1855
            {
1856
                DragThumb.Visibility = Visibility.Collapsed;
1857
            }
1858
        }
1859
    }
1860
}
클립보드 이미지 추가 (최대 크기: 500 MB)