프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 3b797b23

이력 | 보기 | 이력해설 | 다운로드 (79.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.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.Text;
17
using System.Threading.Tasks;
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
        public void Translate(double dx, double dy, double angle)
37
        {
38
            var ratotePoint = MathHelper.RotatePoint(new Point(dx, dy), new Point(), angle);
39

    
40
            Canvas.SetLeft(this, Canvas.GetLeft(this) + ratotePoint.X);
41
            Canvas.SetTop(this, Canvas.GetTop(this) + ratotePoint.Y);
42
        }
43

    
44

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

    
54
        /// <summary>
55
        /// 
56
        /// </summary>
57
        /// <param name="sender"></param>
58
        /// <param name="e"></param>
59
        private void MyThumb_MouseEnter(object sender, MouseEventArgs e)
60
        {
61
            this.Opacity = 1.0;
62
        }
63
    }
64

    
65
    /// <summary>
66
    /// Interaction logic for AdornerFinal.xaml
67
    /// </summary>
68
    public class AdornerMember
69
    {
70
        public UIElement DrawingData { get; set; }
71
        public ControlType Drawingtype { get; set; }
72
        public double DrawingAngle { get; set; }
73
        public List<MyThumb> ThumbList { get; set; }
74
        public string Symbol_ID { get; set; }
75
        public long Group_ID { get; set; }
76

    
77
        /// <summary>
78
        /// update thumb
79
        /// </summary>
80
        public void UpdateThumb()
81
        {
82
            var path = this.DrawingData as IPath;
83
            for (int i = 0; i < path.PointSet.Count; ++i)
84
            {
85
                Canvas.SetLeft(this.ThumbList[i], path.PointSet[i].X);
86
                Canvas.SetTop(this.ThumbList[i], path.PointSet[i].Y);
87
            }
88

    
89
            if (this.DrawingData is ArrowTextControl ArrowTextCtrl)
90
            {
91
                if (!ArrowTextCtrl.isTrans) //trans가 True인경우
92
                {
93
                    List<Point> ps = new List<Point>();
94

    
95
                    var temp = this.DrawingData as ArrowTextControl;
96
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
97
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
98
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
99
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
100

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

    
135
        /// <summary>
136
        /// rotate members about given position and angle
137
        /// </summary>
138
        /// <param name="at"></param>
139
        /// <param name="angle">in degree</param>
140
        public void RotateAbout(Point at, double angle)
141
        {
142
            for (int i = 0; i < (this.DrawingData as IPath).PointSet.Count; i++)
143
            {
144
                (this.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(at, (this.DrawingData as IPath).PointSet[i], angle);
145
            }
146
            (this.DrawingData as CommentUserInfo).UpdateControl();
147

    
148
            this.UpdateThumb();
149
        }
150
    }
151

    
152
    public partial class AdornerFinal : UserControl
153
    {
154
        public TextBox editTextBox { get; set; }
155
        #region 공용 인스턴스
156
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
157
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
158

    
159
        private List<double> AlignedAngles {get;} = new List<double>() { 0, 30, 45, 60, 90, 120, 135, 150, 180, 210, 225, 240, 270, 300, 315, 330, 360 };
160

    
161
        private double angleValue;
162

    
163
        public double AngleValue { get => angleValue;
164
            set
165
            {
166
                if(angleValue != value)
167
                {
168
                    angleValue = value;
169
                }
170
            }
171
        }
172

    
173
        public bool IsTextAngle = false;
174
        public Rect BorderSize { get; set; }
175
        public bool TextCompensation = false;
176
        public bool isDragging { get; set; }
177
        public Thumb DraggerThumb { get; set; }
178
        public RadDropDownButton dropData;
179
        public RadCalendar dropCalendar;
180
        public Thumb mainDragThumb { get; set; }
181

    
182
        private bool disposed;
183

    
184
        public Point reSizePoint { get; set; }
185
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
186
        private Point MouseDownPoint = new Point();
187
        private Point CurrentMousePoint = new Point();
188
        #endregion
189
        #region 생성자
190
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
191
        {
192
            dropData = sender as RadDropDownButton;
193
        }
194

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

    
209
        public AdornerFinal()
210
        {
211
            InitializeComponent();
212
            BorderSize = new Rect();
213
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
214
        }
215

    
216
        ~AdornerFinal()
217
        {
218
            this.Dispose(false);
219
        }
220

    
221
        public void Dispose()
222
        {
223
            this.Dispose(true);
224
            GC.SuppressFinalize(this);
225
        }
226

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

    
243
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
244
        {
245
            mainDragThumb = DragThumb;
246
        }
247

    
248
        public AdornerFinal(CommentUserInfo objectData) : this()
249
        {
250
            InitializeComponent();
251
            objectData.IsHitTestVisible = false;
252

    
253
            if ((objectData as ArrowTextControl) != null)
254
            {
255
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
256
            }
257

    
258
            Canvas.SetZIndex(objectData, 84);
259
            try
260
            {
261
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
262
                this.ContainerContent.Children.Add(objectData);
263
            }
264
            catch (Exception ex)
265
            {
266

    
267
            }
268
           
269
            SetAdornerMember(objectData as CommentUserInfo);
270
            this.Focus();
271
        }
272

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

    
301
        public Point Centeroid
302
        {
303
            get
304
            {
305
                List<Point> pts = new List<Point>();
306

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

    
327
                return MathSet.FindCentroid(pts);
328
            }
329
        }
330

    
331
        #endregion
332
        #region 메서드
333
        public Rect getAdornerSize()
334
        {
335
            return BorderSize;
336
        }
337
        public void addMemberControl(UIElement objectData)
338
        {
339
            this.ContainerContent.Children.Add(objectData);
340
            SetAdornerMember(objectData as CommentUserInfo);
341
            this.Focus();
342
        }
343

    
344
        private void TextControlLostFocus(object sender,RoutedEventArgs e)
345
        {
346
            TextCompensation = false;
347
            BorderUpdate();
348

    
349
            if (sender is TextBox)
350
            {
351
                if ((sender as TextBox).Text == "") //보류
352
                {
353
                    this.ContainerContent.Children.Remove((sender as TextBox).Parent as MarkupToPDF.Common.CommentUserInfo);
354
                    this.Visibility = Visibility.Collapsed;
355
                }
356
            }
357
        }
358

    
359
        private void TextControlPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
360
        {
361
            if (sender is TextControl)
362
            {
363
                TextCompensation = true;
364
                BorderUpdate();
365
            }
366
        }
367

    
368
        private void TextControlSelectionChanged(object sender, RoutedEventArgs e)
369
        {
370
            BorderUpdate();
371
        }
372

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

    
382
        /// <summary>
383
        /// UIElement를 종류에 맞게 등록시킴
384
        /// </summary>
385
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
386
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
387
        {
388
            switch (member.GetType().Name)
389
            {
390
                #region 컨트롤 조건
391
                case "LineControl":
392
                case "PolygonControl":
393
                case "ArrowControl":
394
                case "ArcControl":
395
                case "ArrowArcControl":
396
                case "ArrowControl_Multi":
397
                case "RectangleControl":
398
                case "TriControl":
399
                case "CircleControl":
400
                case "CloudControl":
401
                case "RectCloudControl":
402
                case "InkControl":
403
                case "InsideWhiteControl":
404
                case "OverlapWhiteControl":
405
                case "ClipWhiteControl":
406
                case "CoordinateControl":
407
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
408
                    break;
409
                case "ArrowTextControl":
410
                    this.Members.Add(new AdornerMember
411
                    {
412
                        DrawingData = member,
413
                        Drawingtype = ControlType.ArrowTextControl,
414
                        ThumbList = new List<MyThumb>(),
415
                        Symbol_ID = member.SymbolID,
416
                        Group_ID = member.GroupID,
417
                    });
418
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
419
                    AngleValue = (member as ArrowTextControl).CommentAngle;
420

    
421
                    ((ArrowTextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
422

    
423
                    //Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
424
                    //{
425
                    //    TextCompensation = false;
426
                    //    BorderUpdate();
427
                    //    if ((a.Sender as TextBox).Text == "") //보류
428
                    //    {
429
                    //        this.ContainerContent.Children.Remove(member);
430
                    //        this.Visibility = Visibility.Collapsed;
431
                    //    }
432
                    //});
433
                    break;
434
                case "ImgControl":
435
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
436
                    AngleValue = (member as ImgControl).CommentAngle;
437
                    break;
438
                case "DateControl":
439
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
440
                    AngleValue = (member as DateControl).CommentAngle;
441
                    break;
442
                case "SignControl":
443
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
444
                    AngleValue = (member as SignControl).CommentAngle;
445
                    break;
446
                case "SymControl":
447
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
448
                    AngleValue = (member as SymControl).CommentAngle;
449
                    break;
450
                case "SymControlN":
451
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
452
                    AngleValue = (member as SymControlN).CommentAngle;
453
                    break;
454
                case "TextControl":
455
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
456
                    RectangleGeometry Data = new RectangleGeometry
457
                    {
458
                        Rect = new Rect()
459
                        {
460
                            X = Canvas.GetLeft((member as TextControl)),
461
                            Y = Canvas.GetTop((member as TextControl)),
462
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
463
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
464
                            //Width = (member as TextControl).BoxWidth / 2,
465
                            //Height = (member as TextControl).BoxHeight / 2,
466
                        }
467
                    };
468
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
469
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
470

    
471

    
472
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
473
                    DragThumb.RenderTransform = new RotateTransform()
474
                    {
475
                        Angle = (member as TextControl).CommentAngle,
476
                        //CenterX = middle.X,
477
                        //CenterY = middle.Y,
478
                    };
479

    
480
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
481
                    AdornerBorder.RenderTransform = new RotateTransform()
482
                    {
483
                        Angle = (member as TextControl).CommentAngle,
484
                        //CenterX = middle.X,
485
                        //CenterY = middle.Y,
486
                    };
487
                    //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
488
                    //{
489
                    //    TextCompensation = true;
490
                    //    BorderUpdate();
491
                    //    ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
492
                    //});
493

    
494
                    //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
495
                    //{
496
                    //    TextCompensation = true;
497
                    //    BorderUpdate();
498
                    //    ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
499
                    //});
500

    
501
                    ((TextControl)member).PropertyChanged += TextControlPropertyChanged;
502
                    ((TextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
503

    
504
                    //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
505
                    //{
506
                    //    TextCompensation = false;
507
                    //    BorderUpdate();
508
                    //    if ((a.Sender as TextBox).Text == "") //보류
509
                    //    {
510
                    //        this.ContainerContent.Children.Remove(member);
511
                    //        this.Visibility = Visibility.Collapsed;
512
                    //    }
513

    
514
                    //    //((TextControl)member).UnEditingMode();
515
                    //    //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
516
                    //    //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
517
                    //    //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
518
                    //});
519
                    break;
520
                default:
521
                    break;
522
                    #endregion
523
            }
524

    
525
            if (member.GetType().Name == "TextControl")
526
            {
527
                TextControl content = ((TextControl)member);
528
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
529
                content.EndPoint = content.StartPoint;
530
            }
531
            else
532
            {
533
                RegistryPoint(member);
534
            }
535
            BorderUpdate();
536

    
537
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
538
                Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
539
        }
540

    
541

    
542
        public void SetAdornerMember(List<CommentUserInfo> members)
543
        {
544
            foreach (var member in members)
545
            {
546
                switch (member.GetType().Name)
547
                {
548
                    #region 컨트롤 조건
549
                    case "LineControl":
550
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
551
                        break;
552
                    case "ImgControl":
553
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
554
                        break;
555
                    case "ArrowControl":
556
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
557
                        break;
558
                    case "PolygonControl":
559
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
560
                        break;
561
                    case "ArrowTextControl":
562
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
563
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
564
                        break;
565
                    case "ArcControl":
566
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
567
                        break;
568
                    case "ArrowArcControl":
569
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
570
                        break;
571
                    case "DateControl":
572
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
573
                        break;
574
                    case "ArrowControl_Multi":
575
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
576
                        break;
577
                    case "RectangleControl":
578
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
579
                        break;
580
                    case "TriControl":
581
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
582
                        break;
583
                    case "CircleControl":
584
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
585
                        break;
586
                    case "CloudControl":
587
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
588
                        break;
589
                    case "RectCloudControl":
590
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
591
                        break;
592
                    case "SignControl":
593
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
594
                        break;
595
                    case "SymControl":
596
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
597
                        break;
598
                    case "SymControlN":
599
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
600
                        break;
601
                    case "InkControl":
602
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
603
                        break;
604
                    case "TextControl":
605
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
606

    
607
                        (member as TextControl).PropertyChanged += TextControlPropertyChanged;
608
                        (member as TextControl).Base_TextBox.SelectionChanged += TextControlSelectionChanged;
609

    
610
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
611
                        //{
612
                        //    BorderUpdate();
613
                        //});
614
                        //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
615
                        //{
616
                        //    BorderUpdate();
617
                        //    try
618
                        //    {
619
                        //        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
620
                        //    }
621
                        //    catch (Exception)
622
                        //    {
623

    
624
                        //    }
625

    
626
                        //});
627
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
628
                        //{
629
                        //    BorderUpdate();
630
                        //});
631
                        break;
632
                    case "InsideWhiteControl":
633
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
634
                        break;
635
                    case "OverlapWhiteControl":
636
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
637
                        break;
638
                    case "ClipWhiteControl":
639
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
640
                        break;
641
                    case "CoordinateControl":
642
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
643
                        break;
644
                    default:
645
                        break;
646
                        #endregion
647
                }
648
                if (member.GetType().Name == "TextControl")
649
                {
650
                    TextControl content = ((TextControl)member);
651
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
652
                    content.EndPoint = content.StartPoint;
653
                }
654
                else
655
                {
656
                    RegistryPoint(member, members.Count);
657
                }
658

    
659
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
660
                    Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
661
            }
662

    
663
            BorderUpdate();
664
        }
665

    
666

    
667
        /// <summary>
668
        /// Border 를 갱신
669
        /// </summary>
670
        public void BorderUpdate()
671
        {
672
            AdornerBorder.MinWidth = 10;
673
            AdornerBorder.MinHeight = 10;
674

    
675
            double minX = double.MaxValue;
676
            double minY = double.MaxValue;
677
            double maxX = double.MinValue;
678
            double maxY = double.MinValue;
679

    
680
            if (this.Members.Count == 1)
681
            {
682
                if (this.Members[0].DrawingData.GetType().Name == "TextControl")
683
                {
684
                    if ((this.Members[0].DrawingData as TextControl).CommentAngle != 0)
685
                    {
686
                        trRotate.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
687
                        trRotateThumb.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
688
                    }
689
                    else
690
                    {
691
                        trRotate.Angle = 0;
692
                        trRotateThumb.Angle = 0;
693
                    }
694
                }
695
            }
696

    
697
            foreach (var item in this.Members)
698
            {
699
                UIElement currentControl = (item as AdornerMember).DrawingData;
700

    
701
                Point startP = (currentControl as IPath).StartPoint;
702
                Point endP = (currentControl as IPath).EndPoint;
703

    
704
                // ViewerDataModel.Instance.Angle = MathSet.returnAngle(startP, ref endP, ViewerDataModel.Instance.IsPressShift);
705

    
706
                // 컨트롤의 angle변환시 상단 anglecontrol에 출력
707
                ViewerDataModel.Instance.MarkupAngle = (currentControl as CommentUserInfo).CommentAngle;
708

    
709
                if (item.DrawingData.GetType().Name == "TextControl")
710
                {
711
                    double textControlWidth;
712
                    double textControlHeight;
713

    
714
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
715
                    {
716
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
717
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
718
                    }
719
                    else
720
                    {
721
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
722
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
723
                    }
724
                    
725
                    if ((currentControl as TextControl).EndPoint.X < minX)
726
                    {
727
                        minX = (currentControl as TextControl).EndPoint.X;
728
                    }
729

    
730
                    if ((currentControl as TextControl).EndPoint.Y < minY)
731
                    {
732
                        minY = (currentControl as TextControl).EndPoint.Y;
733
                    }
734

    
735
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
736
                    {
737
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
738
                    }
739

    
740
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
741
                    {
742
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
743
                    }
744
                }
745
                else if ((currentControl as IViewBox) != null)
746
                {
747
                    IViewBox instance = currentControl as IViewBox;
748
                    List<Point> am = (currentControl as IPath).PointSet;
749
                    List<double> xSet = am.Select(p => p.X).ToList();
750
                    List<double> ySet = am.Select(p => p.Y).ToList();
751
                    if (xSet.Min() < minX) minX = xSet.Min();
752
                    if (ySet.Min() < minY) minY = ySet.Min();
753
                    if (xSet.Max() > maxX) maxX = xSet.Max();
754
                    if (ySet.Max() > maxY) maxY = ySet.Max();
755
                }
756
                else if ((currentControl as IPath).PathData == null)
757
                {
758
                    Rect rt = new Rect
759
                    {
760
                        X = (currentControl as IPath).StartPoint.X,
761
                        Y = (currentControl as IPath).StartPoint.Y,
762
                        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),
763
                        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),
764
                    };
765
                    if (rt.Left < minX) minX = rt.Left;
766
                    if (rt.Top < minY) minY = rt.Top;
767
                    if (rt.Right > maxX) maxX = rt.Right;
768
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
769
                }
770
                else if ((currentControl as IPath) == null)
771
                {
772
                    Rect rt = new Rect
773
                    {
774
                        X = (currentControl as IPath).StartPoint.X,
775
                        Y = (currentControl as IPath).StartPoint.Y,
776
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
777
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
778
                    };
779
                    if (rt.Left < minX) minX = rt.Left;
780
                    if (rt.Top < minY) minY = rt.Top;
781
                    if (rt.Right > maxX) maxX = rt.Right;
782
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
783
                }
784
                else if (currentControl is CircleControl CircleCtrl)
785
                {
786
                    List<Point> am = CircleCtrl.PointSet;
787
                    minX = am.Min(x => x.X);
788
                    minY = am.Min(x => x.Y);
789
                    maxX = am.Max(x => x.X);
790
                    maxY = am.Max(x => x.Y);
791
                }
792
                else
793
                {
794
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
795
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
796
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
797
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
798
                }
799
            }
800

    
801
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
802
            bool addWidthSize = false;
803
            bool addHeightSize = false;
804
            if (ac.Width <= 10)
805
            {
806
                ac.Width += 10;
807
                addWidthSize = true;
808
            }
809
            if (ac.Height <= 10)
810
            {
811
                ac.Height += 10;
812
                addHeightSize = true;
813
            }
814
            BorderSize = ac;
815
            AdornerBorder.MinWidth = 10;
816
            AdornerBorder.MinHeight = 10;
817
            AdornerBorder.Width = ac.Width;
818
            AdornerBorder.Height = ac.Height;
819
            Canvas.SetLeft(AdornerBorder, minX);
820
            Canvas.SetTop(AdornerBorder, minY);
821

    
822
            DragThumb.Width = ac.Width;
823
            DragThumb.Height = ac.Height;
824

    
825
            DragThumb.MinWidth = 10;
826
            DragThumb.MinHeight = 10;
827
            if (addWidthSize)
828
            {
829
                Canvas.SetLeft(DragThumb, minX - 5);
830
            }
831
            else
832
            {
833
                Canvas.SetLeft(DragThumb, minX);
834
            }
835

    
836
            if (addHeightSize)
837
            {
838
                Canvas.SetTop(DragThumb, minY - 5);
839
            }
840
            else
841
            {
842
                Canvas.SetTop(DragThumb, minY);
843
            }
844
        }
845

    
846
        /// <summary>
847
        /// UIElement 해제
848
        /// </summary>
849
        public void unRegister()
850
        {
851
            foreach (var item in this.ContainerContent.Children)
852
            {
853
                if (item is MarkupToPDF.Common.CommentUserInfo)
854
                {
855
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
856
                }
857
            }
858
            this.ContainerContent.Children.Clear();
859
        }
860

    
861
        /// <summary>
862
        /// 각 포인트들을 등록합니다.
863
        /// </summary>
864
        /// <param name="pointset">Drawing Point</param>
865
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
866
        {
867
            int count = 0;
868
            List<Point> list = (member as IPath).PointSet;
869
            if (member.GetType().Name == "InkControl")
870
            {
871
                list.Clear();
872
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
873
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
874
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
875
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
876
            }
877
            ControlType markT = this.Members.First(p => p.DrawingData == member).Drawingtype;
878
            double Minx = list.Min(x => x.X);
879
            double Miny = list.Min(x => x.Y);
880

    
881
            for (int i = 0; i < list.Count; i++)
882
            {
883
                MyThumb tm = new MyThumb
884
                {
885
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
886
                };
887

    
888
                this.Members.Last().ThumbList.Add(tm);
889

    
890
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MiddlePoint))
891
                {
892
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
893
                }
894
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
895
                {
896
                    //if (this.Members.Count()<=1)
897
                    //{
898
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
899
                    List<Point> ps = new List<Point>();
900

    
901
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
902
                    {
903
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
904

    
905
                        switch (Math.Abs(temp.CommentAngle).ToString())
906
                        {
907
                            case "90":
908
                                {
909
                                    ps.Clear();
910
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
911
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
912
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
913

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

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

    
920
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
921
                                }
922
                                break;
923
                            case "270":
924
                                {
925
                                    ps.Clear();
926
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
927
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
928
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
929

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

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

    
936
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
937
                                }
938
                                break;
939
                            default:
940
                                {
941
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
942
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
943
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
944
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
945
                                }
946
                                break;
947
                        }
948

    
949
                        ArrowTextControl instance = (member as ArrowTextControl);
950
                        if (instance.isTrans)
951
                        {
952
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
953
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
954
                            //list[count] = tempP;
955
                            list[count] = temp.MidPoint;
956
                        }
957
                        else
958
                        {
959
                            if (temp.isFixed)
960
                            {
961
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
962
                                var testP = endP;
963
                                if (ps[0] == endP) //상단
964
                                {
965
                                    testP = new Point(endP.X, endP.Y - 50);
966
                                }
967
                                else if (ps[1] == endP) //하단
968
                                {
969
                                    testP = new Point(endP.X, endP.Y + 50);
970
                                }
971
                                else if (ps[2] == endP) //좌단
972
                                {
973
                                    testP = new Point(endP.X - 50, endP.Y);
974
                                }
975
                                else if (ps[3] == endP) //우단
976
                                {
977
                                    testP = new Point(endP.X + 50, endP.Y);
978
                                }
979
                                list[count] = testP;
980
                            }
981
                            else
982
                            {
983
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
984
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
985
                            }
986
                        }
987
                    }
988
                }
989

    
990
                /// ArrowTextControl text box 화면 출력
991
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
992
                {
993
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
994
                    tm.Width = (member as ArrowTextControl).BoxWidth;
995
                    tm.Height = (member as ArrowTextControl).BoxHeight;
996
                    var angle = (member as ArrowTextControl).PageAngle;
997
                    if (Math.Abs(angle).ToString() == "90")
998
                    {
999
                        tm.RenderTransformOrigin = new Point(0, 0);
1000
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
1001
                    }
1002
                    else if (Math.Abs(angle).ToString() == "270")
1003
                    {
1004
                        tm.RenderTransformOrigin = new Point(0, 0);
1005
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
1006
                    }
1007
                    else
1008
                    {
1009
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
1010
                        tm.RenderTransform = new RotateTransform()
1011
                        {
1012
                            Angle = angle
1013
                        };
1014
                    }
1015
                }
1016
                
1017
                if (member.GetType().Name == "CloudControl")
1018
                {
1019
                    if (i == list.Count() - 1)
1020
                    {
1021
                        tm.Visibility = System.Windows.Visibility.Collapsed;
1022
                    }
1023
                }
1024
                if (member.GetType().Name == "PolygonControl")
1025
                {
1026
                    if (i == list.Count() - 1)
1027
                    {
1028
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
1029
                        {
1030

    
1031
                        }
1032
                        else
1033
                        {
1034
                            tm.Visibility = System.Windows.Visibility.Collapsed;
1035
                        }
1036
                    }
1037
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
1038
                    {
1039
                        tm.Visibility = System.Windows.Visibility.Collapsed;
1040
                    }
1041
                }
1042
                
1043
                this.ContainerContent.Children.Add(tm);
1044
                Canvas.SetLeft(tm, list[count].X);
1045
                Canvas.SetTop(tm, list[count].Y);
1046
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
1047
                {
1048
                    Canvas.SetZIndex(tm, 95);
1049
                    //tm.Opacity = 0;
1050
                    tm.DragDelta += MidPoint_DragDelta;
1051
                }
1052
                else
1053
                {
1054
                    tm.DragDelta += ResizeTm_DragDelta;
1055
                    Canvas.SetZIndex(tm, 99);
1056
                }
1057

    
1058
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
1059
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
1060
                
1061
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
1062
                count++;
1063
            }
1064
        }
1065

    
1066
        private void MidPoint_DragDelta(object sender, DragDeltaEventArgs e)
1067
        {
1068
            MyThumb thumb = sender as MyThumb;
1069
            double newHorizontalChange = e.HorizontalChange;
1070
            double newVerticalChange = e.VerticalChange;
1071

    
1072
            var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), 0);// commentInfo.VisualPageAngle);
1073

    
1074
            var direction = VisualHelper.GetPointDirection(newpoint, ViewerDataModel.Instance.PageAngle);
1075

    
1076
            System.Diagnostics.Debug.WriteLine("뱡향 : " + direction.ToString());
1077

    
1078
            AdornerMember control = CurrentAdornerMember(thumb);
1079
            var commentInfo = (control.DrawingData) as CommentUserInfo;
1080

    
1081
            if (commentInfo is ArrowTextControl)
1082
            {
1083
                Point getThumbPoint = GetPosition(thumb);
1084

    
1085
                var arrowText = commentInfo as ArrowTextControl;
1086

    
1087
                //var midPoint = MathSet.getMiddlePoint(arrowText.StartPoint, arrowText.EndPoint);
1088
                //arrowText.MidPoint = newpoint;
1089
                thumb.Translate(newpoint.X, newpoint.Y, this.AngleValue);
1090
          
1091
                commentInfo.OnMoveCtrlPoint(getThumbPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1092

    
1093
                control.UpdateThumb();
1094

    
1095
                System.Diagnostics.Debug.WriteLine($"text {Canvas.GetLeft(arrowText.Base_TextBox)},{Canvas.GetTop(arrowText.Base_TextBox)}");
1096

    
1097
                System.Diagnostics.Debug.WriteLine($"Page Angle : {ViewerDataModel.Instance.PageAngle} GetPoint : {getThumbPoint.X},{getThumbPoint.Y}  Change Value : {newpoint.X},{newpoint.Y}");
1098
            }
1099

    
1100
        }
1101
        
1102

    
1103
        /// <summary>
1104
        /// 제어점을 조정하여 크기를 수정한다.
1105
        /// </summary>
1106
        /// <param name="sender"></param>
1107
        /// <param name="e"></param>
1108
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
1109
        {
1110
            if (sender.GetType() != typeof(MyThumb)) return;
1111

    
1112
            MyThumb thumb = sender as MyThumb;
1113

    
1114
            if (this.Members.Count > 1) return;
1115

    
1116
            System.Diagnostics.Debug.WriteLine($"Value {e.HorizontalChange},{e.VerticalChange}");
1117

    
1118
            double newHorizontalChange = e.HorizontalChange;
1119
            double newVerticalChange = e.VerticalChange;
1120

    
1121
            //if (reSizePoint != new Point(0, 0))
1122
            //{
1123
                //Point setPoint = Mouse.GetPosition(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanCanvas);
1124

    
1125
                Point setPoint = GetPosition(thumb);
1126

    
1127
                //System.Diagnostics.Debug.WriteLine($"1. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}  Change Value : {newHorizontalChange},{newVerticalChange}");
1128

    
1129
                AdornerMember control = CurrentAdornerMember(thumb);
1130
                var commentInfo = (control.DrawingData) as CommentUserInfo;
1131

    
1132
                double ratatePointAngle = 0;
1133

    
1134
                if (commentInfo is ArrowTextControl)
1135
                {
1136
                    var textControl = (commentInfo as ArrowTextControl);
1137

    
1138
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1139

    
1140
                    {
1141
                        textControl.CommentAngle = 0;
1142
                        this.AngleValue = 0;
1143
                        ratatePointAngle = commentInfo.VisualPageAngle;
1144
                    }
1145
                    else
1146
                    {   
1147
                        //textControl.CommentAngle = commentInfo.VisualPageAngle + MathSet.returnAngle(textControl.StartPoint, ref tempPoint, ViewerDataModel.Instance.IsPressShift);
1148
                        textControl.OnCreatingMouseMove(textControl.EndPoint, ViewerDataModel.Instance.IsPressShift);
1149
                        this.AngleValue = textControl.CommentAngle;
1150
                        commentInfo.CommentAngle = this.AngleValue;
1151
                    }
1152
                        //CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1153
                }
1154
                System.Diagnostics.Debug.WriteLine("## Angle : " + this.AngleValue + " ##");
1155
                thumb.Translate(newHorizontalChange, newVerticalChange, this.AngleValue);
1156

    
1157
                // 페이지회전에 따른 화살표텍스트 박스의 이동 수정
1158

    
1159
                var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1160
     
1161
                Point thumbPoint = MathHelper.RotatePoint(setPoint, new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1162

    
1163
                //thumbPoint.X = Math.Abs(thumbPoint.X);
1164
                //thumbPoint.Y = Math.Abs(thumbPoint.Y);
1165

    
1166
                //if ((setPoint.X + newpoint.X) < 0 || (Math.Abs(thumbPoint.X) + newpoint.X) - ViewerDataModel.Instance.ImageViewWidth > 0)
1167
                //{
1168
                //    newpoint.X = 0;
1169
                //}
1170

    
1171
                //if (setPoint.Y + newpoint.Y < 0 || (Math.Abs(thumbPoint.Y) + newpoint.Y) - ViewerDataModel.Instance.ImageViewHeight > 0)
1172
                //{
1173
                //    newpoint.Y = 0;
1174
                //}
1175

    
1176
                commentInfo.OnMoveCtrlPoint(setPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1177

    
1178
                //System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1179
                control.UpdateThumb();
1180

    
1181
                //System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1182
                this.BorderUpdate();
1183

    
1184
               //System.Diagnostics.Debug.WriteLine($"5. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1185
            //}
1186
        }
1187

    
1188
        private AdornerMember CurrentAdornerMember(MyThumb thumb)
1189
        {
1190
            AdornerMember result = null;
1191

    
1192
            try
1193
            {
1194
                result = (from userThumb in this.Members
1195
                            where userThumb.ThumbList.Contains(thumb)
1196
                            select userThumb).FirstOrDefault();
1197
            }
1198
            catch (Exception ex)
1199
            {
1200
                App.FileLogger.Error(ex);
1201
            }
1202

    
1203
            return result;
1204
        }
1205

    
1206
        private Point GetPosition(Thumb thumb)
1207
        {
1208
            return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
1209
        }
1210

    
1211
        #endregion
1212
        #region 이벤트
1213

    
1214
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1215
        {
1216
            this.isDragging = false;
1217
            DraggerThumb = null;
1218

    
1219
            var comments = (from drawing in this.Members
1220
                            select drawing.DrawingData as CommentUserInfo).ToList();
1221
            UndoCommand.Instance.Push(comments, this.AngleValue);
1222
            ViewerDataModel.Instance.IsMarkupUpdate = true;
1223
        }
1224

    
1225
        /// <summary>
1226
        /// start drag
1227
        /// </summary>
1228
        /// <param name="sender"></param>
1229
        /// <param name="e"></param>
1230
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1231
        {
1232
            this.DraggerThumb = sender as Thumb;
1233
            this.isDragging = true;
1234

    
1235
            if (ViewerDataModel.Instance.UndoDataList == null)
1236
            {
1237
                return;
1238
            }
1239

    
1240
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1241
            {
1242
                return;
1243
            }
1244

    
1245
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1246
            {
1247
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1248
                {
1249
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1250
                    {
1251
                        return;
1252
                    }
1253
                }
1254
            }
1255

    
1256
            var comments = (from drawing in this.Members
1257
                            select drawing.DrawingData as CommentUserInfo).ToList();
1258
            UndoCommand.Instance.Push(comments, this.AngleValue);
1259
        }
1260

    
1261
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1262
        {
1263
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1264
            {
1265
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1266
                    IsTextAngle = true;
1267
                else
1268
                    IsTextAngle = false;
1269
                LastRotateVerticalValue = e.GetPosition(this).X;
1270
            }
1271
            else
1272
            {
1273
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1274
                {
1275
                    RotateFlag = true;
1276
                }
1277
                else
1278
                {
1279
                    RotateFlag = false;
1280
                }
1281
                LastRotateHorizontalValue = e.GetPosition(this).X;
1282
            }
1283
        }
1284

    
1285
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1286
        {
1287
            /// save mouse down and current mouse point
1288
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1289
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1290
            /// up to here
1291

    
1292
            if (ViewerDataModel.Instance.UndoDataList == null)
1293
            {
1294
                return;
1295
            }
1296
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1297
            {
1298
                return;
1299
            }
1300
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1301
            {
1302
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1303
                {
1304
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1305
                    {
1306
                        return;
1307
                    }
1308
                }
1309
            }
1310

    
1311
            var comments = (from drawing in this.Members
1312
                            select drawing.DrawingData as CommentUserInfo).ToList();
1313
            UndoCommand.Instance.Push(comments, this.AngleValue);
1314
        }
1315

    
1316
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1317
        {
1318
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1319

    
1320
            var comments = (from drawing in this.Members
1321
                            select drawing.DrawingData as CommentUserInfo).ToList();
1322
            UndoCommand.Instance.Push(comments, this.AngleValue);
1323
        }
1324

    
1325
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1326
        {
1327
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1328

    
1329
            var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1330
         
1331
            var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1332
            var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1333

    
1334
            try
1335
            {
1336
                DragThumb.Cursor = Cursors.SizeAll;
1337
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1338
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1339

    
1340

    
1341
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1342

    
1343
                //if (ViewerDataModel.Instance.PageAngle == 270 || ViewerDataModel.Instance.PageAngle == 90)
1344
                //{
1345
                //    mainRect = new Rect(0, 0, mainRect.Height, mainRect.Width);
1346
                //}
1347

    
1348
                mainRect = MathHelper.RotateRect(ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect(), new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1349

    
1350
                var rect = (this.ContainerContent.FindChildByType<CommentUserInfo>() as CommentUserInfo).ItemRect; //this.AdornerBorder.Bounds(ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel);
1351

    
1352
                var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1353
                
1354
                var moveDirection = mainRect.Movement(rotationRect);
1355

    
1356
                System.Diagnostics.Debug.WriteLine($"horzChange: {horzChange} , vertChange:{vertChange}");
1357
                //System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : Top:{rect.Top}, Left:{rect.Left}, Right:{rect.Right}, Bottom:{rect.Bottom} ,BottomLeft : {rect.BottomLeft} BottomRight : {rect.BottomRight}");
1358

    
1359
                //if (Math.Abs(horzChange) > 0)
1360
                //{
1361
                //    if ((horzChange < 0 && !moveDirection.Left) || (horzChange > 0 && !moveDirection.Right))
1362
                //    {
1363
                //        //this.TranslateItems(horzChange * -1, 0);
1364
                //        //e.Handled = true;
1365
                //        horzChange = 0;
1366
                //        newMousePoint.X = this.CurrentMousePoint.X;
1367
                //    }
1368
                //}
1369

    
1370
                //if (Math.Abs(vertChange) > 0)
1371
                //{
1372
                //    if ((vertChange < 0 && !moveDirection.Up) || (vertChange > 0 && !moveDirection.Down))
1373
                //    {
1374
                //        //this.TranslateItems(0, vertChange * -1);
1375
                //        //e.Handled = true;
1376
                //        vertChange = 0;
1377
                //        newMousePoint.Y = this.CurrentMousePoint.Y;
1378
                //    }
1379
                //}
1380

    
1381
                this.TranslateItems(horzChange, vertChange);
1382
            }
1383
            finally
1384
            {
1385
                /// update CurrentMousePoint
1386
                this.CurrentMousePoint = newMousePoint;
1387
            }
1388
        }
1389

    
1390
        /// <summary>
1391
        /// translate all members
1392
        /// </summary>
1393
        /// <param name="e"></param>
1394
        public void TranslateItems(double dx, double dy)
1395
        {
1396
            Dispatcher.BeginInvoke((Action)(() =>
1397
            {
1398
                foreach (var item in this.Members)
1399
                {
1400
                    this.TranslateItem(dx, dy, item);
1401
                }
1402

    
1403
                this.BorderUpdate();
1404
            }));
1405
        }
1406

    
1407
        /// <summary>
1408
        /// translate a item
1409
        /// </summary>
1410
        /// <param name="e"></param>
1411
        /// <param name="item"></param>
1412
        private void TranslateItem(double dx, double dy, AdornerMember item)
1413
        {
1414
            /// rotate point with page rotation
1415
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1416
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1417
            /// up to here
1418
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1419

    
1420
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1421
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null);            
1422

    
1423
            item.UpdateThumb();
1424
        }
1425

    
1426
        private void resize_MouseMove(object sender, MouseEventArgs e)
1427
        {
1428
            //reSizePoint = e.GetPosition(this);
1429
        }
1430

    
1431
        /// <summary>
1432
        /// 회전
1433
        /// </summary>
1434
        /// <param name="sender"></param>
1435
        /// <param name="e"></param>
1436
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1437
        {
1438
            MoveRotate(e);
1439
        }
1440

    
1441
        double LastRotateHorizontalValue = 0;
1442
        double LastRotateVerticalValue = 0;
1443
        bool RotateFlag = false;
1444

    
1445
        /// <summary>
1446
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1447
        /// </summary>
1448
        /// <param name="e"></param>
1449
        public void MoveRotate(DragDeltaEventArgs e)
1450
        {
1451
            Point CenterPoint = this.Centeroid;
1452
            Point pt = Mouse.GetPosition(this);
1453

    
1454
            #region X축 기준으로 회전 각도를 구한다.
1455
            Vector AxisY = new Vector(0, 1);
1456
            Vector vec2 = new Vector(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1457
            vec2.Normalize();
1458
            double angle = Vector.AngleBetween(AxisY, vec2);
1459
            if (angle > 360) angle -= 360;
1460
            if (angle < 0) angle += 360;
1461
            #endregion
1462

    
1463
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1464
            if (ViewerDataModel.Instance.IsAxisLock)
1465
            {
1466
                angle = AlignedAngles.OrderBy(x => Math.Abs(angle - x)).First();
1467
            }
1468
            #endregion
1469

    
1470
            double dDeltaAngle = angle - AngleValue;
1471
            AngleValue = angle;
1472

    
1473
            /// save rotatePoint
1474
            this.rotatePoint = pt;
1475

    
1476
            Dispatcher.BeginInvoke((Action)(() =>
1477
            {
1478
                foreach (var member in this.Members)
1479
                {
1480
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1481
                    #region 보더 업데이트
1482
                    switch (member.Drawingtype)
1483
                    {
1484
                        case ControlType.TextControl:
1485
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1486

    
1487
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1488
                            DragThumb.RenderTransform = new RotateTransform()
1489
                            {
1490
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1491
                            };
1492

    
1493
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1494
                            AdornerBorder.RenderTransform = new RotateTransform()
1495
                            {
1496
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1497
                            };
1498

    
1499
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1500
                            BorderUpdate();
1501
                            break;
1502

    
1503
                        case ControlType.ArrowMultiLine:
1504
                        case ControlType.ArcLine:
1505
                        case ControlType.ArcArrow:
1506
                        case ControlType.SingleLine:
1507
                        case ControlType.Triangle:
1508
                        case ControlType.ArrowTextControl:
1509
                        case ControlType.PolygonControl:
1510
                        case ControlType.Ink:
1511
                            BorderUpdate();
1512
                            break;
1513
                        case ControlType.Date:
1514
                        case ControlType.RectCloud:
1515
                        case ControlType.Rectangle:
1516
                        case ControlType.ImgControl:
1517
                        case ControlType.Sign:
1518
                        case ControlType.Symbol:
1519
                        case ControlType.Stamp:
1520
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1521
                            BorderUpdate();
1522
                            break;
1523
                        case ControlType.PolygonCloud:
1524
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1525
                            BorderUpdate();
1526
                            break;
1527
                        case ControlType.Circle:
1528
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1529
                            ((CircleControl)member.DrawingData).SetCenterXY();
1530
                            BorderUpdate();
1531
                            break;
1532
                        default:
1533
                            break;
1534
                    }
1535
                }
1536
                #endregion
1537
            }));
1538
        }
1539

    
1540
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1541
        {            
1542
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1543
            rotateTop.Cursor = Cursors.SizeAll;
1544

    
1545
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1546
            if ((1 == this.Members.Count) && (this.Members[0]).DrawingData.GetType().Name == "TextControl")
1547
            {
1548
                this.AngleValue = ((this.Members[0]).DrawingData as TextControl).CommentAngle;
1549
            }
1550
            /// up to here
1551

    
1552
            if (ViewerDataModel.Instance.UndoDataList == null)
1553
            {
1554
                return;
1555
            }
1556

    
1557
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1558
            {
1559
                return;
1560
            }
1561

    
1562
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1563
            {
1564
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1565
                {
1566
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1567
                    {
1568
                        return;
1569
                    }
1570
                }
1571
            }
1572

    
1573
            var comments = (from drawing in this.Members
1574
                            select drawing.DrawingData as CommentUserInfo).ToList();
1575
            UndoCommand.Instance.Push(comments, this.AngleValue);
1576
        }
1577
        
1578
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1579
        {
1580
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1581

    
1582
            var comments = (from drawing in this.Members
1583
                            select drawing.DrawingData as CommentUserInfo).ToList();
1584
            UndoCommand.Instance.Push(comments, this.AngleValue);
1585
        }
1586

    
1587
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1588
        {
1589
            AdornerMember control = this.Members.FirstOrDefault();
1590

    
1591
            if ((control.DrawingData as ArrowTextControl) != null)
1592
            {
1593
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1594
                {
1595
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1596
                }
1597
            }
1598

    
1599
        }
1600

    
1601
        public void TextControlChanger()
1602
        {
1603
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1604
            {
1605
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1606
                AllControl.Base_TextBox.Focus();
1607
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1608
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1609
                AllControl.Base_TextBox.IsHitTestVisible = true;
1610
                AllControl.IsEditingMode = true;
1611
                AllControl.Base_TextBox.Focus();
1612

    
1613
                AllControl.SizeChanged += (sen, ea) =>
1614
                {
1615
                    if (AllControl.Base_TextBox != null)
1616
                    {
1617
                        RectangleGeometry Data = new RectangleGeometry
1618
                        {
1619
                            Rect = new Rect()
1620
                            {
1621
                                X = AllControl.StartPoint.X,
1622
                                Y = AllControl.StartPoint.Y,
1623
                                Width = AllControl.Base_TextBox.Width,
1624
                                Height = AllControl.Base_TextBox.Height,
1625
                            }
1626
                        };
1627

    
1628
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1629
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1630
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1631
                        {
1632
                            Angle = AllControl.CommentAngle,
1633
                            CenterX = middle.X,
1634
                            CenterY = middle.Y,
1635
                        };
1636
                    }
1637
                    BorderUpdate();
1638
                };
1639
            }
1640
        }
1641

    
1642
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1643
        {
1644
            if (e.ClickCount == 2 && this.Members.Count == 1)
1645
            {
1646
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1647
                {
1648
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1649
                    TextControlChanger();                    
1650
                }
1651

    
1652
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1653
                {
1654
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1655
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1656
               
1657
                    //ArrowControl TextBox Thumb없애기
1658
                    tm.Visibility = Visibility.Collapsed;
1659

    
1660
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1661
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1662

    
1663
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1664
                    
1665

    
1666
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1667

    
1668
                    {
1669
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1670
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1671

    
1672
                        List<Point> ps = new List<Point>();
1673
                        
1674
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1675
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1676
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1677
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1678

    
1679

    
1680

    
1681

    
1682
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1683
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1684
                        if (AllControl.isTrans)
1685
                        {
1686
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1687
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1688
                        }
1689
                        else
1690
                        {
1691
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1692
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1693
                        }
1694

    
1695

    
1696
                        BorderUpdate();
1697

    
1698
                    };
1699
                }
1700
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1701
                {
1702
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1703
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1704
                    //dropData.IsOpen = true;
1705
                    RadWindow rc = new RadWindow();
1706
                    rc.Width = 300;
1707
                    rc.Height = 300;
1708
                    rc.Header = "Change Date";
1709
                    rc.Content = instanceCal;
1710
                    rc.BorderThickness = new Thickness(3);
1711
                    rc.ResizeMode = ResizeMode.NoResize;
1712
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1713
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1714
                    rc.ModalBackground.Opacity = 0.6;
1715
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1716
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1717
                    {
1718
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1719
                        rc.Close();
1720
                    };
1721
                    rc.ShowDialog();
1722
                    //CalendarControl.xaml
1723
                }
1724
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1725
                {
1726
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1727
                    if (instance.isTransOn)
1728
                    {
1729
                        instance.isTransOn = false;
1730
                    }
1731
                    else
1732
                    {
1733
                        instance.isTransOn = true;
1734
                    }
1735
                    ///instance.SetArcPath();
1736
                    BorderUpdate();
1737
                }
1738
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1739
                {
1740
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1741
                    if (instance.isTransOn)
1742
                    {
1743
                        instance.isTransOn = false;
1744
                    }
1745
                    else
1746
                    {
1747
                        instance.isTransOn = true;
1748
                    }
1749
                    instance.SetArcPath();
1750
                    BorderUpdate();
1751
                }
1752

    
1753
            }
1754
            
1755
        }
1756
        #endregion
1757

    
1758
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1759
        {
1760
            if ((this.Members[0] as AdornerMember).DrawingData.GetType().Name == "TextControl" 
1761
                || (this.Members[0] as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1762
            {
1763
                DragThumb.Visibility = Visibility.Collapsed;
1764
            }
1765
        }
1766
    }
1767
}
클립보드 이미지 추가 (최대 크기: 500 MB)