프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (81 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
        /// <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_old(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

    
50
            Canvas.SetLeft(this, Canvas.GetLeft(this) + _dx);
51
            Canvas.SetTop(this, Canvas.GetTop(this) + _dy);
52
        }
53

    
54
        public void Translate(double dx, double dy, double angle)
55
        {
56
            var ratotePoint = MathHelper.RotatePoint(new Point(dx, dy), new Point(), angle);
57

    
58
            Canvas.SetLeft(this, Canvas.GetLeft(this) + ratotePoint.X);
59
            Canvas.SetTop(this, Canvas.GetTop(this) + ratotePoint.Y);
60
        }
61

    
62

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

    
72
        /// <summary>
73
        /// 
74
        /// </summary>
75
        /// <param name="sender"></param>
76
        /// <param name="e"></param>
77
        private void MyThumb_MouseEnter(object sender, MouseEventArgs e)
78
        {
79
            this.Opacity = 1.0;
80
        }
81
    }
82

    
83
    /// <summary>
84
    /// Interaction logic for AdornerFinal.xaml
85
    /// </summary>
86
    public class AdornerMember
87
    {
88
        public UIElement DrawingData { get; set; }
89
        public ControlType Drawingtype { get; set; }
90
        public double DrawingAngle { get; set; }
91
        public List<MyThumb> ThumbList { get; set; }
92
        public string Symbol_ID { get; set; }
93
        public long Group_ID { get; set; }
94

    
95
        /// <summary>
96
        /// update thumb
97
        /// </summary>
98
        public void UpdateThumb()
99
        {
100
            var path = this.DrawingData as IPath;
101
            for (int i = 0; i < path.PointSet.Count; ++i)
102
            {
103
                Canvas.SetLeft(this.ThumbList[i], path.PointSet[i].X);
104
                Canvas.SetTop(this.ThumbList[i], path.PointSet[i].Y);
105
            }
106

    
107
            if (this.DrawingData as ArrowTextControl != null)
108
            {
109
                if (!(this.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우
110
                {
111
                    List<Point> ps = new List<Point>();
112

    
113
                    var temp = this.DrawingData as ArrowTextControl;
114
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
115
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
116
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
117
                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
118

    
119
                    if (temp.isFixed)
120
                    {
121
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
122
                        var testP = endP;
123
                        if (ps[0] == endP) //상단
124
                        {
125
                            testP = new Point(endP.X, endP.Y - 50);
126
                        }
127
                        else if (ps[1] == endP) //하단
128
                        {
129
                            testP = new Point(endP.X, endP.Y + 50);
130
                        }
131
                        else if (ps[2] == endP) //좌단
132
                        {
133
                            testP = new Point(endP.X - 50, endP.Y);
134
                        }
135
                        else if (ps[3] == endP) //우단
136
                        {
137
                            testP = new Point(endP.X + 50, endP.Y);
138
                        }
139
                        Canvas.SetLeft(this.ThumbList[1], testP.X);
140
                        Canvas.SetTop(this.ThumbList[1], testP.Y);
141
                    }
142
                    else
143
                    {
144
                        var endP = MathSet.getNearPoint(ps, temp.MidPoint);
145
                        var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
146
                        Canvas.SetLeft(this.ThumbList[1], tempP.X);
147
                        Canvas.SetTop(this.ThumbList[1], tempP.Y);
148
                    }
149
                }
150
            }
151
        }
152

    
153
        /// <summary>
154
        /// rotate members about given position and angle
155
        /// </summary>
156
        /// <param name="at"></param>
157
        /// <param name="angle">in degree</param>
158
        public void RotateAbout(Point at, double angle)
159
        {
160
            for (int i = 0; i < (this.DrawingData as IPath).PointSet.Count; i++)
161
            {
162
                (this.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(at, (this.DrawingData as IPath).PointSet[i], angle);
163
            }
164
            (this.DrawingData as CommentUserInfo).UpdateControl();
165

    
166
            this.UpdateThumb();
167
        }
168
    }
169

    
170
    public partial class AdornerFinal : UserControl
171
    {
172
        public TextBox editTextBox { get; set; }
173
        #region 공용 인스턴스
174
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
175
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
176

    
177
        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 };
178

    
179
        private double angleValue;
180

    
181
        public double AngleValue { get => angleValue;
182
            set
183
            {
184
                if(angleValue != value)
185
                {
186
                    angleValue = value;
187
                }
188
            }
189
        }
190

    
191
        public bool IsTextAngle = false;
192
        public Rect BorderSize { get; set; }
193
        public bool TextCompensation = false;
194
        public bool isDragging { get; set; }
195
        public Thumb DraggerThumb { get; set; }
196
        public RadDropDownButton dropData;
197
        public RadCalendar dropCalendar;
198
        public Thumb mainDragThumb { get; set; }
199

    
200
        private bool disposed;
201

    
202
        public Point reSizePoint { get; set; }
203
        private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung
204
        private Point MouseDownPoint = new Point();
205
        private Point CurrentMousePoint = new Point();
206
        #endregion
207
        #region 생성자
208
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
209
        {
210
            dropData = sender as RadDropDownButton;
211
        }
212

    
213
        private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
214
        {
215
            dropCalendar = sender as RadCalendar;
216
            dropCalendar.SelectionChanged += (sen, ea) =>
217
            {
218
                dropData.IsOpen = false;
219
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
220
                {
221
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
222
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
223
                }
224
            };
225
        }
226

    
227
        public AdornerFinal()
228
        {
229
            InitializeComponent();
230
            BorderSize = new Rect();
231
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
232
        }
233

    
234
        ~AdornerFinal()
235
        {
236
            this.Dispose(false);
237
        }
238

    
239
        public void Dispose()
240
        {
241
            this.Dispose(true);
242
            GC.SuppressFinalize(this);
243
        }
244

    
245
        protected virtual void Dispose(bool disposing)
246
        {
247
            if (this.disposed) return;
248
            if (disposing)
249
            {
250
                foreach (var member in this.Members)
251
                {
252
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
253
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
254
                }
255
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
256
            }
257
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
258
            this.disposed = true;
259
        }
260

    
261
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
262
        {
263
            mainDragThumb = DragThumb;
264
        }
265

    
266
        public AdornerFinal(CommentUserInfo objectData) : this()
267
        {
268
            InitializeComponent();
269
            objectData.IsHitTestVisible = false;
270

    
271
            if ((objectData as ArrowTextControl) != null)
272
            {
273
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
274
            }
275

    
276
            Canvas.SetZIndex(objectData, 84);
277
            try
278
            {
279
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
280
                this.ContainerContent.Children.Add(objectData);
281
            }
282
            catch (Exception ex)
283
            {
284

    
285
            }
286
           
287
            SetAdornerMember(objectData as CommentUserInfo);
288
            this.Focus();
289
        }
290

    
291
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
292
        {
293
            InitializeComponent();
294
            foreach (var item in objectData)
295
            {
296
                //item.IsHitTestVisible = false;
297
                if ((item as ArrowTextControl) != null)
298
                {
299
                    (item as ArrowTextControl).Base_TextBox.Focusable = true;
300
                }
301
                try
302
                {
303
                    Canvas.SetZIndex(item, 80);
304
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
305
                    this.ContainerContent.Children.Add(item);
306
                }
307
                catch //(Exception ex)
308
                {
309
                }
310
                finally
311
                {
312
                    
313
                }
314
            }
315
            this.SetAdornerMember(objectData);
316
            this.Focus();
317
        }
318

    
319
        public Point Centeroid
320
        {
321
            get
322
            {
323
                List<Point> pts = new List<Point>();
324

    
325
                #region 센터 포인트 구하기 (그룹핑)
326
                foreach (var item in this.Members)
327
                {
328
                    if (item.DrawingData.GetType().Name == "TextControl")
329
                    {
330
                        if (AngleValue == 0)
331
                        {
332
                            AngleValue = (item.DrawingData as TextControl).CommentAngle;
333
                        }
334
                        double X = Canvas.GetLeft((item.DrawingData as TextControl));
335
                        double Y = Canvas.GetTop((item.DrawingData as TextControl));
336
                        pts.Add(new Point(X, Y));
337
                    }
338
                    else
339
                    {
340
                        pts.AddRange((item.DrawingData as IPath).PointSet);
341
                    }
342
                }
343
                #endregion
344

    
345
                return MathSet.FindCentroid(pts);
346
            }
347
        }
348

    
349
        #endregion
350
        #region 메서드
351
        public Rect getAdornerSize()
352
        {
353
            return BorderSize;
354
        }
355
        public void addMemberControl(UIElement objectData)
356
        {
357
            this.ContainerContent.Children.Add(objectData);
358
            SetAdornerMember(objectData as CommentUserInfo);
359
            this.Focus();
360
        }
361

    
362
        private void TextControlLostFocus(object sender,RoutedEventArgs e)
363
        {
364
            TextCompensation = false;
365
            BorderUpdate();
366

    
367
            if (sender is TextBox)
368
            {
369
                if ((sender as TextBox).Text == "") //보류
370
                {
371
                    this.ContainerContent.Children.Remove((sender as TextBox).Parent as MarkupToPDF.Common.CommentUserInfo);
372
                    this.Visibility = Visibility.Collapsed;
373
                }
374
            }
375
        }
376

    
377
        private void TextControlPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
378
        {
379
            if (sender is TextControl)
380
            {
381
                TextCompensation = true;
382
                BorderUpdate();
383
            }
384
        }
385

    
386
        private void TextControlSelectionChanged(object sender, RoutedEventArgs e)
387
        {
388
            BorderUpdate();
389
        }
390

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

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

    
480

    
481
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
482
                    DragThumb.RenderTransform = new RotateTransform()
483
                    {
484
                        Angle = (member as TextControl).CommentAngle,
485
                        //CenterX = middle.X,
486
                        //CenterY = middle.Y,
487
                    };
488

    
489
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
490
                    AdornerBorder.RenderTransform = new RotateTransform()
491
                    {
492
                        Angle = (member as TextControl).CommentAngle,
493
                        //CenterX = middle.X,
494
                        //CenterY = middle.Y,
495
                    };
496
                    //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
497
                    //{
498
                    //    TextCompensation = true;
499
                    //    BorderUpdate();
500
                    //    ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
501
                    //});
502

    
503
                    //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
504
                    //{
505
                    //    TextCompensation = true;
506
                    //    BorderUpdate();
507
                    //    ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine;
508
                    //});
509

    
510
                    ((TextControl)member).PropertyChanged += TextControlPropertyChanged;
511
                    ((TextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
512

    
513
                    //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a =>
514
                    //{
515
                    //    TextCompensation = false;
516
                    //    BorderUpdate();
517
                    //    if ((a.Sender as TextBox).Text == "") //보류
518
                    //    {
519
                    //        this.ContainerContent.Children.Remove(member);
520
                    //        this.Visibility = Visibility.Collapsed;
521
                    //    }
522

    
523
                    //    //((TextControl)member).UnEditingMode();
524
                    //    //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed;
525
                    //    //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed;
526
                    //    //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
527
                    //});
528
                    break;
529
                default:
530
                    break;
531
                    #endregion
532
            }
533

    
534
            if (member.GetType().Name == "TextControl")
535
            {
536
                TextControl content = ((TextControl)member);
537
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
538
                content.EndPoint = content.StartPoint;
539
            }
540
            else
541
            {
542
                RegistryPoint(member);
543
            }
544
            BorderUpdate();
545

    
546
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
547
                Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
548
        }
549

    
550
        private void ViewBoxRotate(UIElement member)
551
        {
552
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
553
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
554
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
555
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
556
        }
557

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

    
623
                        (member as TextControl).PropertyChanged += TextControlPropertyChanged;
624
                        (member as TextControl).Base_TextBox.SelectionChanged += TextControlSelectionChanged;
625

    
626
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
627
                        //{
628
                        //    BorderUpdate();
629
                        //});
630
                        //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
631
                        //{
632
                        //    BorderUpdate();
633
                        //    try
634
                        //    {
635
                        //        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
636
                        //    }
637
                        //    catch (Exception)
638
                        //    {
639

    
640
                        //    }
641

    
642
                        //});
643
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
644
                        //{
645
                        //    BorderUpdate();
646
                        //});
647
                        break;
648
                    case "InsideWhiteControl":
649
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
650
                        break;
651
                    case "OverlapWhiteControl":
652
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
653
                        break;
654
                    case "ClipWhiteControl":
655
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
656
                        break;
657
                    case "CoordinateControl":
658
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
659
                        break;
660
                    default:
661
                        break;
662
                        #endregion
663
                }
664
                if (member.GetType().Name == "TextControl")
665
                {
666
                    TextControl content = ((TextControl)member);
667
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
668
                    content.EndPoint = content.StartPoint;
669
                }
670
                else
671
                {
672
                    RegistryPoint(member, members.Count);
673
                }
674

    
675
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
676
                    Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
677
            }
678

    
679
            BorderUpdate();
680
        }
681

    
682

    
683
        /// <summary>
684
        /// Border 를 갱신
685
        /// </summary>
686
        public void BorderUpdate()
687
        {
688
            AdornerBorder.MinWidth = 10;
689
            AdornerBorder.MinHeight = 10;
690

    
691
            double minX = double.MaxValue;
692
            double minY = double.MaxValue;
693
            double maxX = double.MinValue;
694
            double maxY = double.MinValue;
695

    
696
            if (this.Members.Count == 1)
697
            {
698
                if (this.Members.First().DrawingData.GetType().Name == "TextControl")
699
                {
700
                    if ((this.Members.First().DrawingData as TextControl).CommentAngle != 0)
701
                    {
702
                        trRotate.Angle = (this.Members.First().DrawingData as TextControl).CommentAngle;
703
                        trRotateThumb.Angle = (this.Members.First().DrawingData as TextControl).CommentAngle;
704
                    }
705
                    else
706
                    {
707
                        trRotate.Angle = 0;
708
                        trRotateThumb.Angle = 0;
709
                    }
710
                }
711
            }
712
            foreach (var item in this.Members)
713
            {
714
                UIElement currentControl = (item as AdornerMember).DrawingData;
715

    
716
                Point startP = (currentControl as IPath).StartPoint;
717
                Point endP = (currentControl as IPath).EndPoint;
718

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

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

    
724
                if (item.DrawingData.GetType().Name == "TextControl")
725
                {
726
                    double textControlWidth;
727
                    double textControlHeight;
728

    
729
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
730
                    {
731
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
732
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
733
                    }
734
                    else
735
                    {
736
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
737
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
738
                    }
739
                    
740
                    if ((currentControl as TextControl).EndPoint.X < minX)
741
                    {
742
                        minX = (currentControl as TextControl).EndPoint.X;
743
                    }
744

    
745
                    if ((currentControl as TextControl).EndPoint.Y < minY)
746
                    {
747
                        minY = (currentControl as TextControl).EndPoint.Y;
748
                    }
749

    
750
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
751
                    {
752
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
753
                    }
754

    
755
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
756
                    {
757
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
758
                    }
759
                }
760
                else if ((currentControl as IViewBox) != null)
761
                {
762
                    IViewBox instance = currentControl as IViewBox;
763
                    List<Point> am = (currentControl as IPath).PointSet;
764
                    List<double> xSet = am.Select(p => p.X).ToList();
765
                    List<double> ySet = am.Select(p => p.Y).ToList();
766
                    if (xSet.Min() < minX) minX = xSet.Min();
767
                    if (ySet.Min() < minY) minY = ySet.Min();
768
                    if (xSet.Max() > maxX) maxX = xSet.Max();
769
                    if (ySet.Max() > maxY) maxY = ySet.Max();
770
                }
771
                else if ((currentControl as IPath).PathData == null)
772
                {
773
                    Rect rt = new Rect
774
                    {
775
                        X = (currentControl as IPath).StartPoint.X,
776
                        Y = (currentControl as IPath).StartPoint.Y,
777
                        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),
778
                        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),
779
                    };
780
                    if (rt.Left < minX) minX = rt.Left;
781
                    if (rt.Top < minY) minY = rt.Top;
782
                    if (rt.Right > maxX) maxX = rt.Right;
783
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
784
                }
785
                else if ((currentControl as IPath) == null)
786
                {
787
                    Rect rt = new Rect
788
                    {
789
                        X = (currentControl as IPath).StartPoint.X,
790
                        Y = (currentControl as IPath).StartPoint.Y,
791
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
792
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
793
                    };
794
                    if (rt.Left < minX) minX = rt.Left;
795
                    if (rt.Top < minY) minY = rt.Top;
796
                    if (rt.Right > maxX) maxX = rt.Right;
797
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
798
                }
799
                else if ((currentControl as CircleControl) != null)
800
                {                    
801
                    List<Point> am = (currentControl as IPath).PointSet;
802
                    List<double> xSet = am.Select(p => p.X).ToList();
803
                    List<double> ySet = am.Select(p => p.Y).ToList();
804
                    if (xSet.Min() < minX) minX = xSet.Min();
805
                    if (ySet.Min() < minY) minY = ySet.Min();
806
                    if (xSet.Max() > maxX) maxX = xSet.Max();
807
                    if (ySet.Max() > maxY) maxY = ySet.Max();
808
                }
809
                else
810
                {
811
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
812
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
813
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
814
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
815
                }
816
            }
817

    
818
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
819
            bool addWidthSize = false;
820
            bool addHeightSize = false;
821
            if (ac.Width <= 10)
822
            {
823
                ac.Width += 10;
824
                addWidthSize = true;
825
            }
826
            if (ac.Height <= 10)
827
            {
828
                ac.Height += 10;
829
                addHeightSize = true;
830
            }
831
            BorderSize = ac;
832
            AdornerBorder.MinWidth = 10;
833
            AdornerBorder.MinHeight = 10;
834
            AdornerBorder.Width = ac.Width;
835
            AdornerBorder.Height = ac.Height;
836
            Canvas.SetLeft(AdornerBorder, minX);
837
            Canvas.SetTop(AdornerBorder, minY);
838

    
839
            DragThumb.Width = ac.Width;
840
            DragThumb.Height = ac.Height;
841

    
842
            DragThumb.MinWidth = 10;
843
            DragThumb.MinHeight = 10;
844
            if (addWidthSize)
845
            {
846
                Canvas.SetLeft(DragThumb, minX - 5);
847
            }
848
            else
849
            {
850
                Canvas.SetLeft(DragThumb, minX);
851
            }
852

    
853
            if (addHeightSize)
854
            {
855
                Canvas.SetTop(DragThumb, minY - 5);
856
            }
857
            else
858
            {
859
                Canvas.SetTop(DragThumb, minY);
860
            }
861
        }
862
        /// <summary>
863
        /// UIElement 해제
864
        /// </summary>
865
        public void unRegister()
866
        {
867
            foreach (var item in this.ContainerContent.Children)
868
            {
869
                if (item is MarkupToPDF.Common.CommentUserInfo)
870
                {
871
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
872
                }
873
            }
874
            this.ContainerContent.Children.Clear();
875
        }
876

    
877
        /// <summary>
878
        /// 각 포인트들을 등록합니다.
879
        /// </summary>
880
        /// <param name="pointset">Drawing Point</param>
881
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
882
        {
883
            int count = 0;
884
            double Minx = 100000000;
885
            double Miny = 100000000;
886
            List<Point> list = (member as IPath).PointSet;
887
            if (member.GetType().Name == "InkControl")
888
            {
889
                list.Clear();
890
                list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
891
                list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
892
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
893
                list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
894
            }
895
            ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype;
896
            foreach (var ax in list)
897
            {
898
                Minx = (ax.X < Minx) ? ax.X : Minx;
899
                Miny = (ax.Y < Miny) ? ax.Y : Miny;
900
            }
901
            for (int i = 0; i < list.Count(); i++)
902
            {
903
                MyThumb tm = new MyThumb
904
                {
905
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
906
                };
907

    
908
                this.Members.Last().ThumbList.Add(tm);
909

    
910
                if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MiddlePoint))
911
                {
912
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
913
                }
914
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
915
                {
916
                    //if (this.Members.Count()<=1)
917
                    //{
918
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
919
                    List<Point> ps = new List<Point>();
920

    
921
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
922
                    {
923
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
924

    
925

    
926
                        switch (Math.Abs(temp.CommentAngle).ToString())
927
                        {
928
                            case "90":
929
                                {
930
                                    ps.Clear();
931
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
932
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
933
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
934

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

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

    
941
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
942
                                }
943
                                break;
944
                            case "270":
945
                                {
946
                                    ps.Clear();
947
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
948
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
949
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
950

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

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

    
957
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
958
                                }
959
                                break;
960
                            default:
961
                                {
962
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
963
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
964
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
965
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
966
                                }
967
                                break;
968
                        }
969

    
970
                        ArrowTextControl instance = (member as ArrowTextControl);
971
                        if (instance.isTrans)
972
                        {
973
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
974
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
975
                            //list[count] = tempP;
976
                            list[count] = temp.MidPoint;
977
                        }
978
                        else
979
                        {
980
                            if (temp.isFixed)
981
                            {
982
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
983
                                var testP = endP;
984
                                if (ps[0] == endP) //상단
985
                                {
986
                                    testP = new Point(endP.X, endP.Y - 50);
987
                                }
988
                                else if (ps[1] == endP) //하단
989
                                {
990
                                    testP = new Point(endP.X, endP.Y + 50);
991
                                }
992
                                else if (ps[2] == endP) //좌단
993
                                {
994
                                    testP = new Point(endP.X - 50, endP.Y);
995
                                }
996
                                else if (ps[3] == endP) //우단
997
                                {
998
                                    testP = new Point(endP.X + 50, endP.Y);
999
                                }
1000
                                list[count] = testP;
1001
                            }
1002
                            else
1003
                            {
1004
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
1005
                                list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
1006
                            }
1007
                        }
1008
                    }
1009
                }
1010

    
1011
                /// ArrowTextControl text box 화면 출력
1012
                if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last())
1013
                {
1014
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
1015
                    tm.Width = (member as ArrowTextControl).BoxWidth;
1016
                    tm.Height = (member as ArrowTextControl).BoxHeight;
1017
                    var angle = (member as ArrowTextControl).PageAngle;
1018
                    if (Math.Abs(angle).ToString() == "90")
1019
                    {
1020
                        tm.RenderTransformOrigin = new Point(0, 0);
1021
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
1022
                    }
1023
                    else if (Math.Abs(angle).ToString() == "270")
1024
                    {
1025
                        tm.RenderTransformOrigin = new Point(0, 0);
1026
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
1027
                    }
1028
                    else
1029
                    {
1030
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
1031
                        tm.RenderTransform = new RotateTransform()
1032
                        {
1033
                            Angle = angle
1034
                        };
1035
                    }
1036
                }
1037
                
1038
                if (member.GetType().Name == "CloudControl")
1039
                {
1040
                    if (i == list.Count() - 1)
1041
                    {
1042
                        tm.Visibility = System.Windows.Visibility.Collapsed;
1043
                    }
1044
                }
1045
                if (member.GetType().Name == "PolygonControl")
1046
                {
1047
                    if (i == list.Count() - 1)
1048
                    {
1049
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
1050
                        {
1051

    
1052
                        }
1053
                        else
1054
                        {
1055
                            tm.Visibility = System.Windows.Visibility.Collapsed;
1056
                        }
1057
                    }
1058
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
1059
                    {
1060
                        tm.Visibility = System.Windows.Visibility.Collapsed;
1061
                    }
1062
                }
1063
                
1064
                this.ContainerContent.Children.Add(tm);
1065
                Canvas.SetLeft(tm, list[count].X);
1066
                Canvas.SetTop(tm, list[count].Y);
1067
                if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint)
1068
                {
1069
                    Canvas.SetZIndex(tm, 95);
1070
                    //tm.Opacity = 0;
1071
                    tm.DragDelta += MidPoint_DragDelta;
1072
                }
1073
                else
1074
                {
1075
                    tm.DragDelta += ResizeTm_DragDelta;
1076
                    Canvas.SetZIndex(tm, 99);
1077
                }
1078

    
1079
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
1080
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
1081
                
1082
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
1083
                count++;
1084
            }
1085
        }
1086

    
1087
        private void MidPoint_DragDelta(object sender, DragDeltaEventArgs e)
1088
        {
1089
            MyThumb thumb = sender as MyThumb;
1090
            double newHorizontalChange = e.HorizontalChange;
1091
            double newVerticalChange = e.VerticalChange;
1092

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

    
1095
            var direction = VisualHelper.GetPointDirection(newpoint, ViewerDataModel.Instance.PageAngle);
1096

    
1097
            System.Diagnostics.Debug.WriteLine("뱡향 : " + direction.ToString());
1098

    
1099
            AdornerMember control = CurrentAdornerMember(thumb);
1100
            var commentInfo = (control.DrawingData) as CommentUserInfo;
1101

    
1102
            if (commentInfo is ArrowTextControl)
1103
            {
1104
                Point getThumbPoint = GetPosition(thumb);
1105

    
1106
                var arrowText = commentInfo as ArrowTextControl;
1107

    
1108
                //var midPoint = MathSet.getMiddlePoint(arrowText.StartPoint, arrowText.EndPoint);
1109
                //arrowText.MidPoint = newpoint;
1110
                thumb.Translate(newpoint.X, newpoint.Y, this.AngleValue);
1111
          
1112
                commentInfo.OnMoveCtrlPoint(getThumbPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1113

    
1114
                control.UpdateThumb();
1115

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

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

    
1121
        }
1122
        
1123

    
1124
        /// <summary>
1125
        /// 제어점을 조정하여 크기를 수정한다.
1126
        /// </summary>
1127
        /// <param name="sender"></param>
1128
        /// <param name="e"></param>
1129
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
1130
        {
1131
            if (sender.GetType() != typeof(MyThumb)) return;
1132

    
1133
            MyThumb thumb = sender as MyThumb;
1134

    
1135
            if (this.Members.Count > 1) return;
1136

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

    
1139
            double newHorizontalChange = e.HorizontalChange;
1140
            double newVerticalChange = e.VerticalChange;
1141

    
1142
            //if (reSizePoint != new Point(0, 0))
1143
            //{
1144
                //Point setPoint = Mouse.GetPosition(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanCanvas);
1145

    
1146
                Point setPoint = GetPosition(thumb);
1147

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

    
1150
                AdornerMember control = CurrentAdornerMember(thumb);
1151
                var commentInfo = (control.DrawingData) as CommentUserInfo;
1152

    
1153
                double ratatePointAngle = 0;
1154

    
1155
                if (commentInfo is ArrowTextControl)
1156
                {
1157
                    var textControl = (commentInfo as ArrowTextControl);
1158

    
1159
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1160

    
1161
                    {
1162
                        textControl.CommentAngle = 0;
1163
                        this.AngleValue = 0;
1164
                        ratatePointAngle = commentInfo.VisualPageAngle;
1165
                    }
1166
                    else
1167
                    {   
1168
                        //textControl.CommentAngle = commentInfo.VisualPageAngle + MathSet.returnAngle(textControl.StartPoint, ref tempPoint, ViewerDataModel.Instance.IsPressShift);
1169
                        textControl.OnCreatingMouseMove(textControl.EndPoint, ViewerDataModel.Instance.IsPressShift);
1170
                        this.AngleValue = textControl.CommentAngle;
1171
                        commentInfo.CommentAngle = this.AngleValue;
1172
                    }
1173
                        //CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1174
                }
1175
                System.Diagnostics.Debug.WriteLine("## Angle : " + this.AngleValue + " ##");
1176
                thumb.Translate(newHorizontalChange, newVerticalChange, this.AngleValue);
1177

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

    
1180
                var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1181
     
1182
                Point thumbPoint = MathHelper.RotatePoint(setPoint, new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1183

    
1184
                //thumbPoint.X = Math.Abs(thumbPoint.X);
1185
                //thumbPoint.Y = Math.Abs(thumbPoint.Y);
1186

    
1187
                //if ((setPoint.X + newpoint.X) < 0 || (Math.Abs(thumbPoint.X) + newpoint.X) - ViewerDataModel.Instance.ImageViewWidth > 0)
1188
                //{
1189
                //    newpoint.X = 0;
1190
                //}
1191

    
1192
                //if (setPoint.Y + newpoint.Y < 0 || (Math.Abs(thumbPoint.Y) + newpoint.Y) - ViewerDataModel.Instance.ImageViewHeight > 0)
1193
                //{
1194
                //    newpoint.Y = 0;
1195
                //}
1196

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

    
1199
                //System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1200
                control.UpdateThumb();
1201

    
1202
                //System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1203
                this.BorderUpdate();
1204

    
1205
               //System.Diagnostics.Debug.WriteLine($"5. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1206
            //}
1207
        }
1208

    
1209
        private AdornerMember CurrentAdornerMember(MyThumb thumb)
1210
        {
1211
            AdornerMember result = null;
1212

    
1213
            try
1214
            {
1215
                result = (from userThumb in this.Members
1216
                            where userThumb.ThumbList.Contains(thumb)
1217
                            select userThumb).FirstOrDefault();
1218
            }
1219
            catch (Exception ex)
1220
            {
1221
                App.FileLogger.Error(ex);
1222
            }
1223

    
1224
            return result;
1225
        }
1226

    
1227
        private Point GetPosition(Thumb thumb)
1228
        {
1229
            return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
1230
        }
1231

    
1232
        #endregion
1233
        #region 이벤트
1234

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

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

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

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

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

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

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

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

    
1306
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1307
        {
1308
            /// save mouse down and current mouse point
1309
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1310
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1311
            /// up to here
1312

    
1313
            if (ViewerDataModel.Instance.UndoDataList == null)
1314
            {
1315
                return;
1316
            }
1317
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1318
            {
1319
                return;
1320
            }
1321
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1322
            {
1323
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1324
                {
1325
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1326
                    {
1327
                        return;
1328
                    }
1329
                }
1330
            }
1331

    
1332
            var comments = (from drawing in this.Members
1333
                            select drawing.DrawingData as CommentUserInfo).ToList();
1334
            UndoCommand.Instance.Push(comments, this.AngleValue);
1335
        }
1336

    
1337
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1338
        {
1339
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1340

    
1341
            var comments = (from drawing in this.Members
1342
                            select drawing.DrawingData as CommentUserInfo).ToList();
1343
            UndoCommand.Instance.Push(comments, this.AngleValue);
1344
        }
1345

    
1346
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1347
        {
1348
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1349

    
1350
            var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1351
         
1352
            var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1353
            var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1354

    
1355
            try
1356
            {
1357
                DragThumb.Cursor = Cursors.SizeAll;
1358
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1359
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1360

    
1361

    
1362
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1363

    
1364
                //if (ViewerDataModel.Instance.PageAngle == 270 || ViewerDataModel.Instance.PageAngle == 90)
1365
                //{
1366
                //    mainRect = new Rect(0, 0, mainRect.Height, mainRect.Width);
1367
                //}
1368

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

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

    
1373
                var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1374
                
1375
                var moveDirection = mainRect.Movement(rotationRect);
1376

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

    
1380
                //if (Math.Abs(horzChange) > 0)
1381
                //{
1382
                //    if ((horzChange < 0 && !moveDirection.Left) || (horzChange > 0 && !moveDirection.Right))
1383
                //    {
1384
                //        //this.TranslateItems(horzChange * -1, 0);
1385
                //        //e.Handled = true;
1386
                //        horzChange = 0;
1387
                //        newMousePoint.X = this.CurrentMousePoint.X;
1388
                //    }
1389
                //}
1390

    
1391
                //if (Math.Abs(vertChange) > 0)
1392
                //{
1393
                //    if ((vertChange < 0 && !moveDirection.Up) || (vertChange > 0 && !moveDirection.Down))
1394
                //    {
1395
                //        //this.TranslateItems(0, vertChange * -1);
1396
                //        //e.Handled = true;
1397
                //        vertChange = 0;
1398
                //        newMousePoint.Y = this.CurrentMousePoint.Y;
1399
                //    }
1400
                //}
1401

    
1402
                this.TranslateItems(horzChange, vertChange);
1403
            }
1404
            finally
1405
            {
1406
                /// update CurrentMousePoint
1407
                this.CurrentMousePoint = newMousePoint;
1408
            }
1409
        }
1410

    
1411
        /// <summary>
1412
        /// translate all members
1413
        /// </summary>
1414
        /// <param name="e"></param>
1415
        public void TranslateItems(double dx, double dy)
1416
        {
1417
            Dispatcher.BeginInvoke((Action)(() =>
1418
            {
1419
                foreach (var item in this.Members)
1420
                {
1421
                    this.TranslateItem(dx, dy, item);
1422
                }
1423

    
1424
                this.BorderUpdate();
1425
            }));
1426
        }
1427

    
1428
        /// <summary>
1429
        /// translate a item
1430
        /// </summary>
1431
        /// <param name="e"></param>
1432
        /// <param name="item"></param>
1433
        private void TranslateItem(double dx, double dy, AdornerMember item)
1434
        {
1435
            /// rotate point with page rotation
1436
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1437
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1438
            /// up to here
1439
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1440

    
1441
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1442
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null);            
1443

    
1444
            item.UpdateThumb();
1445
        }
1446

    
1447
        private void resize_MouseMove(object sender, MouseEventArgs e)
1448
        {
1449
            //reSizePoint = e.GetPosition(this);
1450
        }
1451

    
1452
        /// <summary>
1453
        /// 회전
1454
        /// </summary>
1455
        /// <param name="sender"></param>
1456
        /// <param name="e"></param>
1457
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1458
        {
1459
            MoveRotate(e);
1460
        }
1461

    
1462
        double LastRotateHorizontalValue = 0;
1463
        double LastRotateVerticalValue = 0;
1464
        bool RotateFlag = false;
1465

    
1466
        /// <summary>
1467
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1468
        /// </summary>
1469
        /// <param name="e"></param>
1470
        public void MoveRotate(DragDeltaEventArgs e)
1471
        {
1472
            Point CenterPoint = this.Centeroid;
1473
            Point pt = Mouse.GetPosition(this);
1474

    
1475
            #region X축 기준으로 회전 각도를 구한다.
1476
            Point vec1 = new Point(1, 0);
1477
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1478
            double angle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1479
            if (angle > 360) angle -= 360;
1480
            if (angle < 0) angle += 360;
1481
            #endregion
1482

    
1483
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1484
            if (ViewerDataModel.Instance.IsAxisLock)
1485
            {
1486
                angle = AlignedAngles.OrderBy(x => Math.Abs(angle - x)).First();
1487
            }
1488
            #endregion
1489

    
1490
            double dDeltaAngle = angle - AngleValue;
1491
            AngleValue = angle;
1492

    
1493
            /// save rotatePoint
1494
            this.rotatePoint = pt;
1495

    
1496

    
1497
            Dispatcher.BeginInvoke((Action)(() =>
1498
            {
1499
                foreach (var member in this.Members)
1500
                {
1501
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1502
                    #region 보더 업데이트
1503
                    switch (member.Drawingtype)
1504
                    {
1505
                        case ControlType.TextControl:
1506
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1507

    
1508
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1509
                            DragThumb.RenderTransform = new RotateTransform()
1510
                            {
1511
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1512
                            };
1513

    
1514
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1515
                            AdornerBorder.RenderTransform = new RotateTransform()
1516
                            {
1517
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1518
                            };
1519

    
1520
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1521
                            BorderUpdate();
1522
                            break;
1523

    
1524
                        case ControlType.ArrowMultiLine:
1525
                        case ControlType.ArcLine:
1526
                        case ControlType.ArcArrow:
1527
                        case ControlType.SingleLine:
1528
                        case ControlType.Triangle:
1529
                        case ControlType.ArrowTextControl:
1530
                        case ControlType.PolygonControl:
1531
                        case ControlType.Ink:
1532
                            BorderUpdate();
1533
                            break;
1534
                        case ControlType.Date:
1535
                        case ControlType.RectCloud:
1536
                        case ControlType.Rectangle:
1537
                        case ControlType.ImgControl:
1538
                        case ControlType.Sign:
1539
                        case ControlType.Symbol:
1540
                        case ControlType.Stamp:
1541
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1542
                            BorderUpdate();
1543
                            break;
1544
                        case ControlType.PolygonCloud:
1545
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1546
                            BorderUpdate();
1547
                            break;
1548
                        case ControlType.Circle:
1549
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1550
                            ((CircleControl)member.DrawingData).SetCenterXY();
1551
                            BorderUpdate();
1552
                            break;
1553
                        default:
1554
                            break;
1555
                    }
1556
                }
1557
                #endregion
1558
            }));
1559
        }
1560

    
1561
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1562
        {            
1563
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1564
            rotateTop.Cursor = Cursors.SizeAll;
1565

    
1566
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1567
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1568
            {
1569
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).CommentAngle;
1570
            }
1571
            /// up to here
1572

    
1573
            if (ViewerDataModel.Instance.UndoDataList == null)
1574
            {
1575
                return;
1576
            }
1577

    
1578
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1579
            {
1580
                return;
1581
            }
1582

    
1583
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1584
            {
1585
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1586
                {
1587
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1588
                    {
1589
                        return;
1590
                    }
1591
                }
1592
            }
1593

    
1594
            var comments = (from drawing in this.Members
1595
                            select drawing.DrawingData as CommentUserInfo).ToList();
1596
            UndoCommand.Instance.Push(comments, this.AngleValue);
1597
        }
1598
        
1599
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1600
        {
1601
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1602

    
1603
            var comments = (from drawing in this.Members
1604
                            select drawing.DrawingData as CommentUserInfo).ToList();
1605
            UndoCommand.Instance.Push(comments, this.AngleValue);
1606
        }
1607

    
1608
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1609
        {
1610
            AdornerMember control = this.Members.FirstOrDefault();
1611

    
1612
            if ((control.DrawingData as ArrowTextControl) != null)
1613
            {
1614
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1615
                {
1616
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1617
                }
1618
            }
1619

    
1620
        }
1621

    
1622
        public void TextControlChanger()
1623
        {
1624
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1625
            {
1626
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1627
                AllControl.Base_TextBox.Focus();
1628
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1629
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1630
                AllControl.Base_TextBox.IsHitTestVisible = true;
1631
                AllControl.IsEditingMode = true;
1632
                AllControl.Base_TextBox.Focus();
1633

    
1634
                AllControl.SizeChanged += (sen, ea) =>
1635
                {
1636
                    if (AllControl.Base_TextBox != null)
1637
                    {
1638
                        RectangleGeometry Data = new RectangleGeometry
1639
                        {
1640
                            Rect = new Rect()
1641
                            {
1642
                                X = AllControl.StartPoint.X,
1643
                                Y = AllControl.StartPoint.Y,
1644
                                Width = AllControl.Base_TextBox.Width,
1645
                                Height = AllControl.Base_TextBox.Height,
1646
                            }
1647
                        };
1648

    
1649
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1650
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1651
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1652
                        {
1653
                            Angle = AllControl.CommentAngle,
1654
                            CenterX = middle.X,
1655
                            CenterY = middle.Y,
1656
                        };
1657
                    }
1658
                    BorderUpdate();
1659
                };
1660
            }
1661
        }
1662

    
1663
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1664
        {
1665
            if (e.ClickCount == 2 && this.Members.Count == 1)
1666
            {
1667

    
1668
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1669
                {
1670
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1671
                    TextControlChanger();                    
1672
                }
1673

    
1674
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1675
                {
1676
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1677
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1678
               
1679
                    //ArrowControl TextBox Thumb없애기
1680
                    tm.Visibility = Visibility.Collapsed;
1681

    
1682
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1683
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1684

    
1685
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1686
                    
1687

    
1688
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1689

    
1690
                    {
1691
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1692
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1693

    
1694
                        List<Point> ps = new List<Point>();
1695
                        
1696
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1697
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1698
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1699
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1700

    
1701

    
1702

    
1703

    
1704
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1705
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1706
                        if (AllControl.isTrans)
1707
                        {
1708
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1709
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1710
                        }
1711
                        else
1712
                        {
1713
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1714
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1715
                        }
1716

    
1717

    
1718
                        BorderUpdate();
1719

    
1720
                    };
1721
                }
1722
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1723
                {
1724
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1725
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1726
                    //dropData.IsOpen = true;
1727
                    RadWindow rc = new RadWindow();
1728
                    rc.Width = 300;
1729
                    rc.Height = 300;
1730
                    rc.Header = "Change Date";
1731
                    rc.Content = instanceCal;
1732
                    rc.BorderThickness = new Thickness(3);
1733
                    rc.ResizeMode = ResizeMode.NoResize;
1734
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1735
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1736
                    rc.ModalBackground.Opacity = 0.6;
1737
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1738
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1739
                    {
1740
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1741
                        rc.Close();
1742
                    };
1743
                    rc.ShowDialog();
1744
                    //CalendarControl.xaml
1745
                }
1746
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1747
                {
1748
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1749
                    if (instance.isTransOn)
1750
                    {
1751
                        instance.isTransOn = false;
1752
                    }
1753
                    else
1754
                    {
1755
                        instance.isTransOn = true;
1756
                    }
1757
                    ///instance.SetArcPath();
1758
                    BorderUpdate();
1759
                }
1760
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1761
                {
1762
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1763
                    if (instance.isTransOn)
1764
                    {
1765
                        instance.isTransOn = false;
1766
                    }
1767
                    else
1768
                    {
1769
                        instance.isTransOn = true;
1770
                    }
1771
                    instance.SetArcPath();
1772
                    BorderUpdate();
1773
                }
1774

    
1775
            }
1776
            
1777
        }
1778
        #endregion
1779

    
1780
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1781
        {
1782
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1783
            {
1784
                DragThumb.Visibility = Visibility.Collapsed;
1785
            }
1786
        }
1787

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