프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (69.1 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.Parsing;
9
using MarkupToPDF.Controls.Polygon;
10
using MarkupToPDF.Controls.Shape;
11
using MarkupToPDF.Controls.Text;
12
using System;
13
using System.Collections.Generic;
14
using System.Diagnostics;
15
using System.Linq;
16
using System.Reactive.Linq;
17
using System.Text;
18
using System.Windows;
19
using System.Windows.Controls;
20
using System.Windows.Controls.Primitives;
21
using System.Windows.Input;
22
using System.Windows.Media;
23
using Telerik.Windows.Controls;
24

    
25
namespace KCOM.Controls
26
{
27
    public class MyThumb : Thumb
28
    {
29
        public MyThumb()
30
        {
31
            this.Opacity = 0.6;
32
            this.MouseEnter += MyThumb_MouseEnter;
33
            this.MouseLeave += MyThumb_MouseLeave;
34
        }
35

    
36
        /// <summary>
37
        /// translate thumb with given delta and angle
38
        /// </summary>
39
        /// <param name="e"></param>
40
        /// <param name="angle"></param>
41
        public void Translate(double dx, double dy, double angle)
42
        {
43
            double radian = angle * Math.PI / 180;
44
            double cos = Math.Cos(radian);
45
            double sin = Math.Sin(radian);
46

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

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

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

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

    
85
        /// <summary>
86
        /// update thumb
87
        /// </summary>
88
        public void UpdateThumb()
89
        {
90
            var path = this.DrawingData as IPath;
91
            for (int i = 0; i < path.PointSet.Count; ++i)
92
            {
93
                Canvas.SetLeft(this.ThumbList[i], path.PointSet[i].X);
94
                Canvas.SetTop(this.ThumbList[i], path.PointSet[i].Y);
95
            }
96

    
97
            if (this.DrawingData as ArrowTextControl != null)
98
            {
99
                if (!(this.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
100
                {
101
                    List<Point> ps = new List<Point>();
102

    
103
                    var temp = this.DrawingData as ArrowTextControl;
104
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
105
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
106
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
107
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
108

    
109
                    if (temp.isFixed)
110
                    {
111
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
112
                        var testP = endP;
113
                        if (ps[0] == endP) //상단
114
                        {
115
                            testP = new Point(endP.X, endP.Y - 50);
116
                        }
117
                        else if (ps[1] == endP) //하단
118
                        {
119
                            testP = new Point(endP.X, endP.Y + 50);
120
                        }
121
                        else if (ps[2] == endP) //좌단
122
                        {
123
                            testP = new Point(endP.X - 50, endP.Y);
124
                        }
125
                        else if (ps[3] == endP) //우단
126
                        {
127
                            testP = new Point(endP.X + 50, endP.Y);
128
                        }
129
                        Canvas.SetLeft(this.ThumbList[1], testP.X);
130
                        Canvas.SetTop(this.ThumbList[1], testP.Y);
131
                    }
132
                    else
133
                    {
134
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
135
                        var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
136
                        Canvas.SetLeft(this.ThumbList[1], tempP.X);
137
                        Canvas.SetTop(this.ThumbList[1], tempP.Y);
138
                    }
139
                }
140
            }
141
        }
142

    
143
        /// <summary>
144
        /// rotate members about given position and angle
145
        /// </summary>
146
        /// <param name="at"></param>
147
        /// <param name="angle">in degree</param>
148
        public void RotateAbout(Point at, double angle)
149
        {
150
            for (int i = 0; i < (this.DrawingData as IPath).PointSet.Count; i++)
151
            {
152
                (this.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(at, (this.DrawingData as IPath).PointSet[i], angle);
153
            }
154
            (this.DrawingData as CommentUserInfo).UpdateControl();
155

    
156
            this.UpdateThumb();
157
        }
158
    }
159

    
160
    public partial class AdornerFinal : UserControl
161
    {
162
        public TextBox editTextBox { get; set; }
163
        #region 공용 인스턴스
164
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
165
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
166
        public double AngleValue = 0;
167
        public bool IsTextAngle = false;
168
        public Rect BorderSize { get; set; }
169
        public bool TextCompensation = false;
170
        public bool isDragging { get; set; }
171
        public Thumb DraggerThumb { get; set; }
172
        public RadDropDownButton dropData;
173
        public RadCalendar dropCalendar;
174
        public Thumb mainDragThumb { get; set; }
175

    
176
        private bool disposed;
177

    
178
        public Point reSizePoint { get; set; }
179
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
180
        private Point MouseDownPoint = new Point();
181
        private Point CurrentMousePoint = new Point();
182
        #endregion
183
        #region 생성자
184
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
185
        {
186
            dropData = sender as RadDropDownButton;
187
        }
188

    
189
        private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
190
        {
191
            dropCalendar = sender as RadCalendar;
192
            dropCalendar.SelectionChanged += (sen, ea) =>
193
            {
194
                dropData.IsOpen = false;
195
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
196
                {
197
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
198
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
199
                }
200
            };
201
        }
202

    
203
        public AdornerFinal()
204
        {
205
            InitializeComponent();
206
            BorderSize = new Rect();
207
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
208
        }
209

    
210
        ~AdornerFinal()
211
        {
212
            this.Dispose(false);
213
        }
214

    
215
        public void Dispose()
216
        {
217
            this.Dispose(true);
218
            GC.SuppressFinalize(this);
219
        }
220

    
221
        protected virtual void Dispose(bool disposing)
222
        {
223
            if (this.disposed) return;
224
            if (disposing)
225
            {
226
                foreach (var member in this.Members)
227
                {
228
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
229
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
230
                }
231
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
232
            }
233
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
234
            this.disposed = true;
235
        }
236

    
237
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
238
        {
239
            mainDragThumb = DragThumb;
240
        }
241

    
242
        public AdornerFinal(CommentUserInfo objectData) : this()
243
        {
244
            InitializeComponent();
245
            objectData.IsHitTestVisible = false;
246
            if ((objectData as ArrowTextControl) != null)
247
            {
248
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
249
            }
250
            Canvas.SetZIndex(objectData, 84);
251
            try
252
            {
253
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
254
                this.ContainerContent.Children.Add(objectData);
255
            }
256
            catch (Exception ex)
257
            {
258

    
259
            }
260
           
261
            SetAdornerMember(objectData as CommentUserInfo);
262
            this.Focus();
263
        }
264

    
265
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
266
        {
267
            InitializeComponent();
268
            foreach (var item in objectData)
269
            {
270
                //item.IsHitTestVisible = false;
271
                if ((item as ArrowTextControl) != null)
272
                {
273
                    (item as ArrowTextControl).Base_TextBox.Focusable = true;
274
                }
275
                try
276
                {
277
                    Canvas.SetZIndex(item, 80);
278
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
279
                    this.ContainerContent.Children.Add(item);
280
                }
281
                catch //(Exception ex)
282
                {
283
                }
284
                finally
285
                {
286
                    
287
                }
288
            }
289
            this.SetAdornerMember(objectData);
290
            this.Focus();
291
        }
292

    
293
        public Point Centeroid
294
        {
295
            get
296
            {
297
                List<Point> pts = new List<Point>();
298

    
299
                #region 센터 포인트 구하기 (그룹핑)
300
                foreach (var item in this.Members)
301
                {
302
                    if (item.DrawingData.GetType().Name == "TextControl")
303
                    {
304
                        if (AngleValue == 0)
305
                        {
306
                            AngleValue = (item.DrawingData as TextControl).CommentAngle;
307
                        }
308
                        double X = Canvas.GetLeft((item.DrawingData as TextControl));
309
                        double Y = Canvas.GetTop((item.DrawingData as TextControl));
310
                        pts.Add(new Point(X, Y));
311
                    }
312
                    else
313
                    {
314
                        pts.AddRange((item.DrawingData as IPath).PointSet);
315
                    }
316
                }
317
                #endregion
318

    
319
                return MathSet.FindCentroid(pts);
320
            }
321
        }
322

    
323
#endregion
324
#region 메서드
325
public Rect getAdornerSize()
326
        {
327
            return BorderSize;
328
        }
329
        public void addMemberControl(UIElement objectData)
330
        {
331
            this.ContainerContent.Children.Add(objectData);
332
            SetAdornerMember(objectData as CommentUserInfo);
333
            this.Focus();
334
        }
335
        /// <summary>
336
        /// UIElement를 종류에 맞게 등록시킴
337
        /// </summary>
338
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
339
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
340
        {
341
            switch (member.GetType().Name)
342
            {
343
                #region 컨트롤 조건
344
                case "LineControl":
345
                case "PolygonControl":
346
                case "ArrowControl":
347
                case "ArcControl":
348
                case "ArrowArcControl":
349
                case "ArrowControl_Multi":
350
                case "RectangleControl":
351
                case "TriControl":
352
                case "CircleControl":
353
                case "CloudControl":
354
                case "RectCloudControl":
355
                case "InkControl":
356
                case "InsideWhiteControl":
357
                case "OverlapWhiteControl":
358
                case "ClipWhiteControl":
359
                case "CoordinateControl":
360
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
361
                    break;
362
                case "ArrowTextControl":
363
                    this.Members.Add(new AdornerMember
364
                    {
365
                        DrawingData = member,
366
                        Drawingtype = ControlType.ArrowTextControl,
367
                        ThumbList = new List<MyThumb>(),
368
                        Symbol_ID = member.SymbolID,
369
                        Group_ID = member.GroupID,
370
                    });
371
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
372
                    AngleValue = (member as ArrowTextControl).CommentAngle;
373
                    Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
374
                    {
375
                        TextCompensation = false;
376
                        BorderUpdate();
377
                        if ((a.Sender as TextBox).Text == "") //보류
378
                        {
379
                            this.ContainerContent.Children.Remove(member);
380
                            this.Visibility = Visibility.Collapsed;
381
                        }
382
                    });
383
                    break;
384
                case "ImgControl":
385
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
386
                    AngleValue = (member as ImgControl).CommentAngle;
387
                    break;
388
                case "DateControl":
389
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
390
                    AngleValue = (member as DateControl).CommentAngle;
391
                    break;
392
                case "SignControl":
393
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
394
                    AngleValue = (member as SignControl).CommentAngle;
395
                    break;
396
                case "SymControl":
397
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
398
                    AngleValue = (member as SymControl).CommentAngle;
399
                    break;
400
                case "SymControlN":
401
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
402
                    AngleValue = (member as SymControlN).CommentAngle;
403
                    break;
404
                case "TextControl":
405
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
406
                    RectangleGeometry Data = new RectangleGeometry
407
                    {
408
                        Rect = new Rect()
409
                        {
410
                            X = Canvas.GetLeft((member as TextControl)),
411
                            Y = Canvas.GetTop((member as TextControl)),
412
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
413
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
414
                            //Width = (member as TextControl).BoxWidth / 2,
415
                            //Height = (member as TextControl).BoxHeight / 2,
416
                        }
417
                    };
418
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
419
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
420

    
421

    
422
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
423
                    DragThumb.RenderTransform = new RotateTransform()
424
                    {
425
                        Angle = (member as TextControl).CommentAngle,
426
                        //CenterX = middle.X,
427
                        //CenterY = middle.Y,
428
                    };
429

    
430
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
431
                    AdornerBorder.RenderTransform = new RotateTransform()
432
                    {
433
                        Angle = (member as TextControl).CommentAngle,
434
                        //CenterX = middle.X,
435
                        //CenterY = middle.Y,
436
                    };
437
                    Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
438
                    {
439
                        TextCompensation = true;
440
                        BorderUpdate();
441
                        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
442
                    });
443
                    Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
444
                    {
445
                        TextCompensation = false;
446
                        BorderUpdate();
447
                        if ((a.Sender as TextBox).Text == "") //보류
448
                        {
449
                            this.ContainerContent.Children.Remove(member);
450
                            this.Visibility = Visibility.Collapsed;
451
                        }
452

    
453
                        //((TextControl)member).UnEditingMode();
454
                        //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
455
                        //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
456
                        //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
457
                    });
458
                    break;
459
                default:
460
                    break;
461
                    #endregion
462
            }
463

    
464
            if (member.GetType().Name == "TextControl")
465
            {
466
                TextControl content = ((TextControl)member);
467
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
468
                content.EndPoint = content.StartPoint;
469
            }
470
            else
471
            {
472
                RegistryPoint(member);
473
            }
474
            BorderUpdate();
475

    
476
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
477
        }
478

    
479
        private void ViewBoxRotate(UIElement member)
480
        {
481
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
482
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
483
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
484
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
485
        }
486

    
487
        public void SetAdornerMember(List<CommentUserInfo> members)
488
        {
489
            foreach (var member in members)
490
            {
491
                switch (member.GetType().Name)
492
                {
493
                    #region 컨트롤 조건
494
                    case "LineControl":
495
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
496
                        break;
497
                    case "ImgControl":
498
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
499
                        break;
500
                    case "ArrowControl":
501
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
502
                        break;
503
                    case "PolygonControl":
504
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
505
                        break;
506
                    case "ArrowTextControl":
507
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
508
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
509
                        break;
510
                    case "ArcControl":
511
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
512
                        break;
513
                    case "ArrowArcControl":
514
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
515
                        break;
516
                    case "DateControl":
517
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
518
                        break;
519
                    case "ArrowControl_Multi":
520
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
521
                        break;
522
                    case "RectangleControl":
523
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
524
                        break;
525
                    case "TriControl":
526
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
527
                        break;
528
                    case "CircleControl":
529
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
530
                        break;
531
                    case "CloudControl":
532
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
533
                        break;
534
                    case "RectCloudControl":
535
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
536
                        break;
537
                    case "SignControl":
538
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
539
                        break;
540
                    case "SymControl":
541
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
542
                        break;
543
                    case "SymControlN":
544
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
545
                        break;
546
                    case "InkControl":
547
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
548
                        break;
549
                    case "TextControl":
550
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
551
                        Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
552
                        {
553
                            BorderUpdate();
554
                            try
555
                            {
556
                                ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
557
                            }
558
                            catch (Exception)
559
                            {
560

    
561
                            }
562

    
563
                        });
564
                        Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
565
                        {
566
                            BorderUpdate();
567
                        });
568
                        break;
569
                    case "InsideWhiteControl":
570
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
571
                        break;
572
                    case "OverlapWhiteControl":
573
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
574
                        break;
575
                    case "ClipWhiteControl":
576
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
577
                        break;
578
                    case "CoordinateControl":
579
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
580
                        break;
581
                    default:
582
                        break;
583
                        #endregion
584
                }
585
                if (member.GetType().Name == "TextControl")
586
                {
587
                    TextControl content = ((TextControl)member);
588
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
589
                    content.EndPoint = content.StartPoint;
590
                }
591
                else
592
                {
593
                    RegistryPoint(member, members.Count);
594
                }
595

    
596
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))  Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
597
            }
598

    
599
            BorderUpdate();
600
        }
601

    
602
        /// <summary>
603
        /// Border 를 갱신
604
        /// </summary>
605
        public void BorderUpdate()
606
        {
607
            AdornerBorder.MinWidth = 10;
608
            AdornerBorder.MinHeight = 10;
609

    
610
            double minX = double.MaxValue;
611
            double minY = double.MaxValue;
612
            double maxX = double.MinValue;
613
            double maxY = double.MinValue;
614

    
615
            if (this.Members.Count == 1)
616
            {
617
                if (this.Members.First().DrawingData.GetType().Name == "TextControl")
618
                {
619
                    if ((this.Members.First().DrawingData as TextControl).CommentAngle != 0)
620
                    {
621
                        trRotate.Angle = (this.Members.First().DrawingData as TextControl).CommentAngle;
622
                        trRotateThumb.Angle = (this.Members.First().DrawingData as TextControl).CommentAngle;
623
                    }
624
                    else
625
                    {
626
                        trRotate.Angle = 0;
627
                        trRotateThumb.Angle = 0;
628
                    }
629
                }
630
            }
631
            foreach (var item in this.Members)
632
            {
633
                UIElement currentControl = (item as AdornerMember).DrawingData;
634
                if (item.DrawingData.GetType().Name == "TextControl")
635
                {
636
                    double textControlWidth;
637
                    double textControlHeight;
638

    
639
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
640
                    {
641
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
642
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
643
                    }
644
                    else
645
                    {
646
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
647
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
648
                    }
649
                    
650
                    if ((currentControl as TextControl).EndPoint.X < minX)
651
                    {
652
                        minX = (currentControl as TextControl).EndPoint.X;
653
                    }
654

    
655
                    if ((currentControl as TextControl).EndPoint.Y < minY)
656
                    {
657
                        minY = (currentControl as TextControl).EndPoint.Y;
658
                    }
659

    
660
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
661
                    {
662
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
663
                    }
664

    
665
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
666
                    {
667
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
668
                    }
669
                }
670
                else if ((currentControl as IViewBox) != null)
671
                {
672
                    IViewBox instance = currentControl as IViewBox;
673
                    List<Point> am = (currentControl as IPath).PointSet;
674
                    List<double> xSet = am.Select(p => p.X).ToList();
675
                    List<double> ySet = am.Select(p => p.Y).ToList();
676
                    if (xSet.Min() < minX) minX = xSet.Min();
677
                    if (ySet.Min() < minY) minY = ySet.Min();
678
                    if (xSet.Max() > maxX) maxX = xSet.Max();
679
                    if (ySet.Max() > maxY) maxY = ySet.Max();
680
                }
681
                else if ((currentControl as IPath).PathData == null)
682
                {
683
                    Rect rt = new Rect
684
                    {
685
                        X = (currentControl as IPath).StartPoint.X,
686
                        Y = (currentControl as IPath).StartPoint.Y,
687
                        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),
688
                        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),
689
                    };
690
                    if (rt.Left < minX) minX = rt.Left;
691
                    if (rt.Top < minY) minY = rt.Top;
692
                    if (rt.Right > maxX) maxX = rt.Right;
693
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
694
                }
695
                else if ((currentControl as IPath) == null)
696
                {
697
                    Rect rt = new Rect
698
                    {
699
                        X = (currentControl as IPath).StartPoint.X,
700
                        Y = (currentControl as IPath).StartPoint.Y,
701
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
702
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
703
                    };
704
                    if (rt.Left < minX) minX = rt.Left;
705
                    if (rt.Top < minY) minY = rt.Top;
706
                    if (rt.Right > maxX) maxX = rt.Right;
707
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
708
                }
709
                else if ((currentControl as CircleControl) != null)
710
                {                    
711
                    List<Point> am = (currentControl as IPath).PointSet;
712
                    List<double> xSet = am.Select(p => p.X).ToList();
713
                    List<double> ySet = am.Select(p => p.Y).ToList();
714
                    if (xSet.Min() < minX) minX = xSet.Min();
715
                    if (ySet.Min() < minY) minY = ySet.Min();
716
                    if (xSet.Max() > maxX) maxX = xSet.Max();
717
                    if (ySet.Max() > maxY) maxY = ySet.Max();
718
                }
719
                else
720
                {
721
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
722
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
723
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
724
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
725
                }
726
            }
727

    
728
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
729
            bool addWidthSize = false;
730
            bool addHeightSize = false;
731
            if (ac.Width <= 10)
732
            {
733
                ac.Width += 10;
734
                addWidthSize = true;
735
            }
736
            if (ac.Height <= 10)
737
            {
738
                ac.Height += 10;
739
                addHeightSize = true;
740
            }
741
            BorderSize = ac;
742
            AdornerBorder.MinWidth = 10;
743
            AdornerBorder.MinHeight = 10;
744
            AdornerBorder.Width = ac.Width;
745
            AdornerBorder.Height = ac.Height;
746
            Canvas.SetLeft(AdornerBorder, minX);
747
            Canvas.SetTop(AdornerBorder, minY);
748

    
749
            DragThumb.Width = ac.Width;
750
            DragThumb.Height = ac.Height;
751

    
752
            DragThumb.MinWidth = 10;
753
            DragThumb.MinHeight = 10;
754
            if (addWidthSize)
755
            {
756
                Canvas.SetLeft(DragThumb, minX - 5);
757
            }
758
            else
759
            {
760
                Canvas.SetLeft(DragThumb, minX);
761
            }
762

    
763
            if (addHeightSize)
764
            {
765
                Canvas.SetTop(DragThumb, minY - 5);
766
            }
767
            else
768
            {
769
                Canvas.SetTop(DragThumb, minY);
770
            }
771
        }
772
        /// <summary>
773
        /// UIElement 해제
774
        /// </summary>
775
        public void unRegister()
776
        {
777
            foreach (var item in this.ContainerContent.Children)
778
            {
779
                if (item is MarkupToPDF.Common.CommentUserInfo)
780
                {
781
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
782
                }
783
            }
784
            this.ContainerContent.Children.Clear();
785
        }
786

    
787
        /// <summary>
788
        /// 각 포인트들을 등록합니다.
789
        /// </summary>
790
        /// <param name="pointset">Drawing Point</param>
791
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
792
        {
793
            int count = 0;
794
            double Minx = 100000000;
795
            double Miny = 100000000;
796
            List<Point> list = (member as IPath).PointSet;
797
            if (member.GetType().Name == "InkControl")
798
            {
799
                list.Clear();
800
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
801
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
802
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
803
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
804
            }
805
            ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype;
806
            foreach (var ax in list)
807
            {
808
                Minx = (ax.X < Minx) ? ax.X : Minx;
809
                Miny = (ax.Y < Miny) ? ax.Y : Miny;
810
            }
811
            for (int i = 0; i < list.Count(); i++)
812
            {
813
                MyThumb tm = new MyThumb
814
                {
815
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
816
                };
817

    
818
                this.Members.Last().ThumbList.Add(tm);
819

    
820
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MidPoint))
821
                {
822
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
823
                }
824
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
825
                {
826
                    //if (this.Members.Count()<=1)
827
                    //{
828
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
829
                    List<Point> ps = new List<Point>();
830

    
831
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
832
                    {
833
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
834

    
835

    
836
                        switch (Math.Abs(temp.CommentAngle).ToString())
837
                        {
838
                            case "90":
839
                                {
840
                                    ps.Clear();
841
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
842
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
843
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
844

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

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

    
851
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
852
                                }
853
                                break;
854
                            case "270":
855
                                {
856
                                    ps.Clear();
857
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
858
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
859
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
860

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

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

    
867
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
868
                                }
869
                                break;
870
                            default:
871
                                {
872
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
873
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
874
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
875
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
876
                                }
877
                                break;
878
                        }
879

    
880
                        ArrowTextControl instance = (member as ArrowTextControl);
881
                        if (instance.isTrans)
882
                        {
883
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
884
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
885
                            //list[count] = tempP;
886
                            list[count] = temp.MidPoint;
887
                        }
888
                        else
889
                        {
890
                            if (temp.isFixed)
891
                            {
892
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
893
                                var testP = endP;
894
                                if (ps[0] == endP) //상단
895
                                {
896
                                    testP = new Point(endP.X, endP.Y - 50);
897
                                }
898
                                else if (ps[1] == endP) //하단
899
                                {
900
                                    testP = new Point(endP.X, endP.Y + 50);
901
                                }
902
                                else if (ps[2] == endP) //좌단
903
                                {
904
                                    testP = new Point(endP.X - 50, endP.Y);
905
                                }
906
                                else if (ps[3] == endP) //우단
907
                                {
908
                                    testP = new Point(endP.X + 50, endP.Y);
909
                                }
910
                                list[count] = testP;
911
                            }
912
                            else
913
                            {
914
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
915
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
916
                            }
917
                        }
918
                    }
919
                }
920
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
921
                {
922
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
923
                    tm.Width = (member as ArrowTextControl).BoxWidth;
924
                    tm.Height = (member as ArrowTextControl).BoxHeight;
925
                    var angle = (member as ArrowTextControl).PageAngle;
926
                    if (Math.Abs(angle).ToString() == "90")
927
                    {
928
                        tm.RenderTransformOrigin = new Point(0, 0);
929
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
930
                    }
931
                    else if (Math.Abs(angle).ToString() == "270")
932
                    {
933
                        tm.RenderTransformOrigin = new Point(0, 0);
934
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
935
                    }
936
                    else
937
                    {
938
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
939
                        tm.RenderTransform = new RotateTransform()
940
                        {
941
                            Angle = angle
942
                        };
943
                    }
944
                }
945
                
946
                if (member.GetType().Name == "CloudControl")
947
                {
948
                    if (i == list.Count() - 1)
949
                    {
950
                        tm.Visibility = System.Windows.Visibility.Collapsed;
951
                    }
952
                }
953
                if (member.GetType().Name == "PolygonControl")
954
                {
955
                    if (i == list.Count() - 1)
956
                    {
957
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
958
                        {
959

    
960
                        }
961
                        else
962
                        {
963
                            tm.Visibility = System.Windows.Visibility.Collapsed;
964
                        }
965
                    }
966
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
967
                    {
968
                        tm.Visibility = System.Windows.Visibility.Collapsed;
969
                    }
970
                }
971
                
972
                this.ContainerContent.Children.Add(tm);
973
                Canvas.SetLeft(tm, list[count].X);
974
                Canvas.SetTop(tm, list[count].Y);
975
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
976
                {
977
                    Canvas.SetZIndex(tm, 95);
978
                }
979
                else
980
                {
981
                    Canvas.SetZIndex(tm, 99);
982
                }
983

    
984
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
985
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
986
                tm.DragDelta += ResizeTm_DragDelta;
987
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
988
                count++;
989
            }
990
        }
991

    
992
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
993
        {
994
            if (this.Members.Count > 1) return;
995
            if (reSizePoint != new Point(0, 0))
996
            {
997
                MyThumb thumb = sender as MyThumb;
998
                Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
999
                thumb.Translate(e.HorizontalChange, e.VerticalChange, this.AngleValue);
1000
                
1001
                AdornerMember control = (from userThumb in this.Members
1002
                                         where userThumb.ThumbList.Contains(thumb)
1003
                                         select userThumb).FirstOrDefault();
1004

    
1005
                IPath AllControl = control.DrawingData as IPath;
1006
                ((control.DrawingData) as CommentUserInfo).OnMoveCtrlPoint(setPoint, e.HorizontalChange, e.VerticalChange);
1007
                control.UpdateThumb();
1008
                this.BorderUpdate();
1009
            }
1010
        }
1011

    
1012
        #endregion
1013
        #region 이벤트
1014

    
1015
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1016
        {
1017
            this.isDragging = false;
1018
            DraggerThumb = null;
1019

    
1020
            var comments = (from drawing in this.Members
1021
                            select drawing.DrawingData as CommentUserInfo).ToList();
1022
            UndoCommand.Instance.Push(comments, this.AngleValue);
1023
        }
1024

    
1025
        /// <summary>
1026
        /// start drag
1027
        /// </summary>
1028
        /// <param name="sender"></param>
1029
        /// <param name="e"></param>
1030
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1031
        {
1032
            this.DraggerThumb = sender as Thumb;
1033
            this.isDragging = true;
1034

    
1035
            if (ViewerDataModel.Instance.UndoDataList == null)
1036
            {
1037
                return;
1038
            }
1039

    
1040
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1041
            {
1042
                return;
1043
            }
1044

    
1045
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1046
            {
1047
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1048
                {
1049
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1050
                    {
1051
                        return;
1052
                    }
1053
                }
1054
            }
1055

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

    
1061
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1062
        {
1063
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1064
            {
1065
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1066
                    IsTextAngle = true;
1067
                else
1068
                    IsTextAngle = false;
1069
                LastRotateVerticalValue = e.GetPosition(this).X;
1070
            }
1071
            else
1072
            {
1073
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1074
                {
1075
                    RotateFlag = true;
1076
                }
1077
                else
1078
                {
1079
                    RotateFlag = false;
1080
                }
1081
                LastRotateHorizontalValue = e.GetPosition(this).X;
1082
            }
1083
        }
1084

    
1085
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1086
        {
1087
            /// save mouse down and current mouse point
1088
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1089
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1090
            /// up to here
1091

    
1092
            if (ViewerDataModel.Instance.UndoDataList == null)
1093
            {
1094
                return;
1095
            }
1096
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1097
            {
1098
                return;
1099
            }
1100
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1101
            {
1102
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1103
                {
1104
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1105
                    {
1106
                        return;
1107
                    }
1108
                }
1109
            }
1110

    
1111
            var comments = (from drawing in this.Members
1112
                            select drawing.DrawingData as CommentUserInfo).ToList();
1113
            UndoCommand.Instance.Push(comments, this.AngleValue);
1114
        }
1115

    
1116
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1117
        {
1118
            DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1119

    
1120
            var comments = (from drawing in this.Members
1121
                            select drawing.DrawingData as CommentUserInfo).ToList();
1122
            UndoCommand.Instance.Push(comments, this.AngleValue);
1123
        }
1124

    
1125
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1126
        {
1127
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1128
            var tmp = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1129

    
1130
            var horzChange = (tmp.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1131
            var vertChange = (tmp.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1132
            try
1133
            {
1134
                DragThumb.Cursor = Cursors.SizeAll;
1135
                this.TranslateItems(horzChange, vertChange);
1136
            }
1137
            finally
1138
            {
1139
                /// update CurrentMousePoint
1140
                this.CurrentMousePoint = tmp;
1141
            }
1142
        }
1143

    
1144
        /// <summary>
1145
        /// translate all members
1146
        /// </summary>
1147
        /// <param name="e"></param>
1148
        public void TranslateItems(double dx, double dy)
1149
        {
1150
            Dispatcher.BeginInvoke((Action)(() =>
1151
            {
1152
                foreach (var item in this.Members)
1153
                {
1154
                    this.TranslateItem(dx, dy, item);
1155
                }
1156
            }));
1157
            this.BorderUpdate();
1158
        }
1159

    
1160
        /// <summary>
1161
        /// translate a item
1162
        /// </summary>
1163
        /// <param name="e"></param>
1164
        /// <param name="item"></param>
1165
        private void TranslateItem(double dx, double dy, AdornerMember item)
1166
        {
1167
            /// rotate point with page rotation
1168
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1169
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1170
            /// up to here
1171
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1172

    
1173
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1174
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null);            
1175

    
1176
            item.UpdateThumb();
1177
        }
1178

    
1179
        private void resize_MouseMove(object sender, MouseEventArgs e)
1180
        {
1181
            reSizePoint = e.GetPosition(this);
1182
        }
1183

    
1184
        /// <summary>
1185
        /// 회전
1186
        /// </summary>
1187
        /// <param name="sender"></param>
1188
        /// <param name="e"></param>
1189
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1190
        {
1191
            MoveRotate(e);
1192
        }
1193

    
1194
        double LastRotateHorizontalValue = 0;
1195
        double LastRotateVerticalValue = 0;
1196
        bool RotateFlag = false;
1197

    
1198
        /// <summary>
1199
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1200
        /// </summary>
1201
        /// <param name="e"></param>
1202
        public void MoveRotate(DragDeltaEventArgs e)
1203
        {
1204
            Point CenterPoint = this.Centeroid;
1205
            Point pt = Mouse.GetPosition(this);
1206

    
1207
            Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
1208
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1209
            double dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1210

    
1211
            AngleValue += dDeltaAngle;
1212
            if (AngleValue > 360) AngleValue -= 360;
1213
            if (AngleValue < 0) AngleValue += 360;
1214
            this.rotatePoint = pt;  /// save rotatePoint
1215

    
1216
            Dispatcher.BeginInvoke((Action)(() =>
1217
            {
1218
                foreach (var member in this.Members)
1219
                {
1220
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1221
                    #region 보더 업데이트
1222
                    switch (member.Drawingtype)
1223
                    {
1224
                        case ControlType.TextControl:
1225
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1226

    
1227
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1228
                            DragThumb.RenderTransform = new RotateTransform()
1229
                            {
1230

    
1231
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1232
                            };
1233

    
1234
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1235
                            AdornerBorder.RenderTransform = new RotateTransform()
1236
                            {
1237
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1238
                            };
1239

    
1240
                            //(member.DrawingData as TextControl).Angle = AngleValue;
1241

    
1242
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1243
                            BorderUpdate();
1244
                            break;
1245

    
1246
                        case ControlType.ArrowMultiLine:
1247
                        case ControlType.ArcLine:
1248
                        case ControlType.ArcArrow:
1249
                        case ControlType.SingleLine:
1250
                        case ControlType.Triangle:
1251
                        case ControlType.ArrowTextControl:
1252
                        case ControlType.PolygonControl:
1253
                        case ControlType.Ink:
1254
                            BorderUpdate();
1255
                            break;
1256
                        case ControlType.Date:
1257
                        case ControlType.RectCloud:
1258
                        case ControlType.Rectangle:
1259
                        case ControlType.ImgControl:
1260
                        case ControlType.Sign:
1261
                        case ControlType.Symbol:
1262
                        case ControlType.Stamp:
1263
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1264
                            BorderUpdate();
1265
                            break;
1266
                        case ControlType.PolygonCloud:
1267
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1268
                            BorderUpdate();
1269
                            break;
1270
                        case ControlType.Circle:
1271
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1272
                            ((CircleControl)member.DrawingData).SetCenterXY();
1273
                            BorderUpdate();
1274
                            break;
1275
                        default:
1276
                            break;
1277
                    }
1278
                }
1279
                #endregion
1280
            }));
1281
        }
1282

    
1283
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1284
        {            
1285
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1286
            rotateTop.Cursor = Cursors.SizeAll;
1287

    
1288
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1289
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1290
            {
1291
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).CommentAngle;
1292
            }
1293
            /// up to here
1294

    
1295
            if (ViewerDataModel.Instance.UndoDataList == null)
1296
            {
1297
                return;
1298
            }
1299

    
1300
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1301
            {
1302
                return;
1303
            }
1304

    
1305
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1306
            {
1307
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1308
                {
1309
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1310
                    {
1311
                        return;
1312
                    }
1313
                }
1314
            }
1315

    
1316
            var comments = (from drawing in this.Members
1317
                            select drawing.DrawingData as CommentUserInfo).ToList();
1318
            UndoCommand.Instance.Push(comments, this.AngleValue);
1319
        }
1320
        
1321
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1322
        {
1323
            rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource);
1324

    
1325
            var comments = (from drawing in this.Members
1326
                            select drawing.DrawingData as CommentUserInfo).ToList();
1327
            UndoCommand.Instance.Push(comments, this.AngleValue);
1328
        }
1329

    
1330
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1331
        {
1332
            AdornerMember control = this.Members.FirstOrDefault();
1333

    
1334
            if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null)
1335
            {
1336
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1337
                {
1338
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1339
                }
1340
            }
1341

    
1342
        }
1343

    
1344
        public void TextControlChanger()
1345
        {
1346
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1347
            {
1348
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1349
                AllControl.Base_TextBox.Focus();
1350
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1351
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1352
                AllControl.Base_TextBox.IsHitTestVisible = true;
1353
                AllControl.Base_TextBox.Focus();
1354

    
1355
                AllControl.SizeChanged += (sen, ea) =>
1356
                {
1357
                    if (AllControl.Base_TextBox != null)
1358
                    {
1359
                        RectangleGeometry Data = new RectangleGeometry
1360
                        {
1361
                            Rect = new Rect()
1362
                            {
1363
                                X = AllControl.StartPoint.X,
1364
                                Y = AllControl.StartPoint.Y,
1365
                                Width = AllControl.Base_TextBox.Width,
1366
                                Height = AllControl.Base_TextBox.Height,
1367
                            }
1368
                        };
1369

    
1370
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1371
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1372
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1373
                        {
1374
                            Angle = AllControl.CommentAngle,
1375
                            CenterX = middle.X,
1376
                            CenterY = middle.Y,
1377
                        };
1378
                    }
1379
                    BorderUpdate();
1380
                };
1381
            }
1382
        }
1383

    
1384
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1385
        {
1386
            if (e.ClickCount == 2 && this.Members.Count == 1)
1387
            {
1388

    
1389
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1390
                {
1391
                    TextControlChanger();                    
1392
                }
1393

    
1394
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1395
                {
1396
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1397
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1398
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1399

    
1400
                    //ArrowControl TextBox Thumb없애기
1401
                    tm.Visibility = Visibility.Collapsed;
1402

    
1403
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1404
                    
1405
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1406

    
1407
                    {
1408
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1409
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1410

    
1411
                        List<Point> ps = new List<Point>();
1412
                        
1413
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1414
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1415
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1416
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1417

    
1418

    
1419

    
1420

    
1421
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1422
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1423
                        if (AllControl.isTrans)
1424
                        {
1425
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1426
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1427
                        }
1428
                        else
1429
                        {
1430
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1431
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1432
                        }
1433

    
1434

    
1435
                        BorderUpdate();
1436

    
1437
                    };
1438
                }
1439
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1440
                {
1441
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1442
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1443
                    //dropData.IsOpen = true;
1444
                    RadWindow rc = new RadWindow();
1445
                    rc.Width = 300;
1446
                    rc.Height = 300;
1447
                    rc.Header = "Change Date";
1448
                    rc.Content = instanceCal;
1449
                    rc.BorderThickness = new Thickness(3);
1450
                    rc.ResizeMode = ResizeMode.NoResize;
1451
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1452
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1453
                    rc.ModalBackground.Opacity = 0.6;
1454
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1455
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1456
                    {
1457
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1458
                        rc.Close();
1459
                    };
1460
                    rc.ShowDialog();
1461
                    //CalendarControl.xaml
1462
                }
1463
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1464
                {
1465
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1466
                    if (instance.isTransOn)
1467
                    {
1468
                        instance.isTransOn = false;
1469
                    }
1470
                    else
1471
                    {
1472
                        instance.isTransOn = true;
1473
                    }
1474
                    ///instance.SetArcPath();
1475
                    BorderUpdate();
1476
                }
1477
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1478
                {
1479
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1480
                    if (instance.isTransOn)
1481
                    {
1482
                        instance.isTransOn = false;
1483
                    }
1484
                    else
1485
                    {
1486
                        instance.isTransOn = true;
1487
                    }
1488
                    instance.SetArcPath();
1489
                    BorderUpdate();
1490
                }
1491

    
1492
            }
1493
            
1494
        }
1495
        #endregion
1496

    
1497
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1498
        {
1499
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1500
            {
1501
                DragThumb.Visibility = Visibility.Collapsed;
1502
            }
1503
        }
1504
    }
1505
}
클립보드 이미지 추가 (최대 크기: 500 MB)