프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 1305c420

이력 | 보기 | 이력해설 | 다운로드 (80.3 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 double angleValue;
178

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

    
189

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

    
199
        private bool disposed;
200

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
479

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

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

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

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

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

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

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

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

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

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

    
621
                        (member as TextControl).PropertyChanged += TextControlPropertyChanged;
622
                        (member as TextControl).Base_TextBox.SelectionChanged += TextControlSelectionChanged;
623

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

    
638
                        //    }
639

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

    
673
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))  Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
674
            }
675

    
676
            BorderUpdate();
677
        }
678

    
679

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

    
688
            double minX = double.MaxValue;
689
            double minY = double.MaxValue;
690
            double maxX = double.MinValue;
691
            double maxY = double.MinValue;
692

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

    
713
                Point startP = (currentControl as IPath).StartPoint;
714
                Point endP = (currentControl as IPath).EndPoint;
715

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

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

    
721
                if (item.DrawingData.GetType().Name == "TextControl")
722
                {
723
                    double textControlWidth;
724
                    double textControlHeight;
725

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

    
742
                    if ((currentControl as TextControl).EndPoint.Y < minY)
743
                    {
744
                        minY = (currentControl as TextControl).EndPoint.Y;
745
                    }
746

    
747
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
748
                    {
749
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
750
                    }
751

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

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

    
836
            DragThumb.Width = ac.Width;
837
            DragThumb.Height = ac.Height;
838

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

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

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

    
905
                this.Members.Last().ThumbList.Add(tm);
906

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

    
918
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
919
                    {
920
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
921

    
922

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1092
            var direction = VisualHelper.GetPointDirection(newpoint, ViewerDataModel.Instance.PageAngle);
1093

    
1094
            System.Diagnostics.Debug.WriteLine("뱡향 : " + direction.ToString());
1095

    
1096
            AdornerMember control = CurrentAdornerMember(thumb);
1097
            var commentInfo = (control.DrawingData) as CommentUserInfo;
1098

    
1099
            if (commentInfo is ArrowTextControl)
1100
            {
1101
                Point getThumbPoint = GetPosition(thumb);
1102

    
1103
                var arrowText = commentInfo as ArrowTextControl;
1104

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

    
1111
                control.UpdateThumb();
1112

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

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

    
1118
        }
1119
        
1120

    
1121
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
1122
        {
1123
            if (sender.GetType() != typeof(MyThumb)) return;
1124

    
1125
            MyThumb thumb = sender as MyThumb;
1126

    
1127
            if (this.Members.Count > 1) return;
1128

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

    
1131
            double newHorizontalChange = e.HorizontalChange;
1132
            double newVerticalChange = e.VerticalChange;
1133

    
1134
            //if (reSizePoint != new Point(0, 0))
1135
            //{
1136
                //Point setPoint = Mouse.GetPosition(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanCanvas);
1137

    
1138
                Point setPoint = GetPosition(thumb);
1139

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

    
1142
                AdornerMember control = CurrentAdornerMember(thumb);
1143
                var commentInfo = (control.DrawingData) as CommentUserInfo;
1144

    
1145
                double ratatePointAngle = 0;
1146

    
1147
                if (commentInfo is ArrowTextControl)
1148
                {
1149
                    var textControl = (commentInfo as ArrowTextControl);
1150

    
1151
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1152

    
1153
                    {
1154
                        textControl.CommentAngle = 0;
1155
                        this.AngleValue = 0;
1156
                        ratatePointAngle = commentInfo.VisualPageAngle;
1157
                    }
1158
                    else
1159
                    {   
1160
                        //textControl.CommentAngle = commentInfo.VisualPageAngle + MathSet.returnAngle(textControl.StartPoint, ref tempPoint, ViewerDataModel.Instance.IsPressShift);
1161
                        textControl.OnCreatingMouseMove(textControl.EndPoint, ViewerDataModel.Instance.IsPressShift);
1162
                        this.AngleValue = textControl.CommentAngle;
1163
                        commentInfo.CommentAngle = this.AngleValue;
1164
                    }
1165
                        //CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1166
                }
1167
                System.Diagnostics.Debug.WriteLine("## Angle : " + this.AngleValue + " ##");
1168
                thumb.Translate(newHorizontalChange, newVerticalChange, this.AngleValue);
1169

    
1170
                // 페이지회전에 따른 화살표텍스트 박스의 이동 수정
1171
                var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1172
     
1173
                Point thumbPoint = MathHelper.RotatePoint(setPoint, new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1174

    
1175
                //thumbPoint.X = Math.Abs(thumbPoint.X);
1176
                //thumbPoint.Y = Math.Abs(thumbPoint.Y);
1177

    
1178
                //if ((setPoint.X + newpoint.X) < 0 || (Math.Abs(thumbPoint.X) + newpoint.X) - ViewerDataModel.Instance.ImageViewWidth > 0)
1179
                //{
1180
                //    newpoint.X = 0;
1181
                //}
1182

    
1183
                //if (setPoint.Y + newpoint.Y < 0 || (Math.Abs(thumbPoint.Y) + newpoint.Y) - ViewerDataModel.Instance.ImageViewHeight > 0)
1184
                //{
1185
                //    newpoint.Y = 0;
1186
                //}
1187

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

    
1190
                //System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1191
                control.UpdateThumb();
1192

    
1193
                //System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1194
                this.BorderUpdate();
1195

    
1196
               //System.Diagnostics.Debug.WriteLine($"5. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1197
            //}
1198
        }
1199

    
1200
        private AdornerMember CurrentAdornerMember(MyThumb thumb)
1201
        {
1202
            AdornerMember result = null;
1203

    
1204
            try
1205
            {
1206
                result = (from userThumb in this.Members
1207
                            where userThumb.ThumbList.Contains(thumb)
1208
                            select userThumb).FirstOrDefault();
1209
            }
1210
            catch (Exception ex)
1211
            {
1212
                App.FileLogger.Error(ex);
1213
            }
1214

    
1215
            return result;
1216
        }
1217

    
1218
        private Point GetPosition(Thumb thumb)
1219
        {
1220
            return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
1221
        }
1222

    
1223
        #endregion
1224
        #region 이벤트
1225

    
1226
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1227
        {
1228
            this.isDragging = false;
1229
            DraggerThumb = null;
1230

    
1231
            var comments = (from drawing in this.Members
1232
                            select drawing.DrawingData as CommentUserInfo).ToList();
1233
            UndoCommand.Instance.Push(comments, this.AngleValue);
1234
        }
1235

    
1236
        /// <summary>
1237
        /// start drag
1238
        /// </summary>
1239
        /// <param name="sender"></param>
1240
        /// <param name="e"></param>
1241
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1242
        {
1243
            this.DraggerThumb = sender as Thumb;
1244
            this.isDragging = true;
1245

    
1246
            if (ViewerDataModel.Instance.UndoDataList == null)
1247
            {
1248
                return;
1249
            }
1250

    
1251
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1252
            {
1253
                return;
1254
            }
1255

    
1256
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1257
            {
1258
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1259
                {
1260
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1261
                    {
1262
                        return;
1263
                    }
1264
                }
1265
            }
1266

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

    
1272
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1273
        {
1274
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1275
            {
1276
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1277
                    IsTextAngle = true;
1278
                else
1279
                    IsTextAngle = false;
1280
                LastRotateVerticalValue = e.GetPosition(this).X;
1281
            }
1282
            else
1283
            {
1284
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1285
                {
1286
                    RotateFlag = true;
1287
                }
1288
                else
1289
                {
1290
                    RotateFlag = false;
1291
                }
1292
                LastRotateHorizontalValue = e.GetPosition(this).X;
1293
            }
1294
        }
1295

    
1296
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1297
        {
1298
            /// save mouse down and current mouse point
1299
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1300
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1301
            /// up to here
1302

    
1303
            if (ViewerDataModel.Instance.UndoDataList == null)
1304
            {
1305
                return;
1306
            }
1307
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1308
            {
1309
                return;
1310
            }
1311
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1312
            {
1313
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1314
                {
1315
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1316
                    {
1317
                        return;
1318
                    }
1319
                }
1320
            }
1321

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

    
1327
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1328
        {
1329
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1330

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

    
1336
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1337
        {
1338
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1339

    
1340
            var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1341
         
1342
            var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1343
            var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1344

    
1345
            try
1346
            {
1347
                DragThumb.Cursor = Cursors.SizeAll;
1348
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1349
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1350

    
1351

    
1352
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1353

    
1354
                //if (ViewerDataModel.Instance.PageAngle == 270 || ViewerDataModel.Instance.PageAngle == 90)
1355
                //{
1356
                //    mainRect = new Rect(0, 0, mainRect.Height, mainRect.Width);
1357
                //}
1358

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

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

    
1363
                var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1364
                
1365
                var moveDirection = mainRect.Movement(rotationRect);
1366

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

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

    
1381
                //if (Math.Abs(vertChange) > 0)
1382
                //{
1383
                //    if ((vertChange < 0 && !moveDirection.Up) || (vertChange > 0 && !moveDirection.Down))
1384
                //    {
1385
                //        //this.TranslateItems(0, vertChange * -1);
1386
                //        //e.Handled = true;
1387
                //        vertChange = 0;
1388
                //        newMousePoint.Y = this.CurrentMousePoint.Y;
1389
                //    }
1390
                //}
1391

    
1392
                this.TranslateItems(horzChange, vertChange);
1393
            }
1394
            finally
1395
            {
1396
                /// update CurrentMousePoint
1397
                this.CurrentMousePoint = newMousePoint;
1398
            }
1399
        }
1400

    
1401
        /// <summary>
1402
        /// translate all members
1403
        /// </summary>
1404
        /// <param name="e"></param>
1405
        public void TranslateItems(double dx, double dy)
1406
        {
1407
            Dispatcher.BeginInvoke((Action)(() =>
1408
            {
1409
                foreach (var item in this.Members)
1410
                {
1411
                    this.TranslateItem(dx, dy, item);
1412
                }
1413

    
1414
                this.BorderUpdate();
1415
            }));
1416
        }
1417

    
1418
        /// <summary>
1419
        /// translate a item
1420
        /// </summary>
1421
        /// <param name="e"></param>
1422
        /// <param name="item"></param>
1423
        private void TranslateItem(double dx, double dy, AdornerMember item)
1424
        {
1425
            /// rotate point with page rotation
1426
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1427
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1428
            /// up to here
1429
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1430

    
1431
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1432
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null);            
1433

    
1434
            item.UpdateThumb();
1435
        }
1436

    
1437
        private void resize_MouseMove(object sender, MouseEventArgs e)
1438
        {
1439
            //reSizePoint = e.GetPosition(this);
1440
        }
1441

    
1442
        /// <summary>
1443
        /// 회전
1444
        /// </summary>
1445
        /// <param name="sender"></param>
1446
        /// <param name="e"></param>
1447
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1448
        {
1449
            MoveRotate(e);
1450
        }
1451

    
1452
        double LastRotateHorizontalValue = 0;
1453
        double LastRotateVerticalValue = 0;
1454
        bool RotateFlag = false;
1455

    
1456
        /// <summary>
1457
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1458
        /// </summary>
1459
        /// <param name="e"></param>
1460
        public void MoveRotate(DragDeltaEventArgs e)
1461
        {
1462
            Point CenterPoint = this.Centeroid;
1463
            Point pt = Mouse.GetPosition(this);
1464

    
1465
            Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y);
1466
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1467
            double dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1468

    
1469
            AngleValue += dDeltaAngle;
1470
            if (AngleValue > 360) AngleValue -= 360;
1471
            if (AngleValue < 0) AngleValue += 360;
1472
            this.rotatePoint = pt;  /// save rotatePoint
1473

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

    
1485
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1486
                            DragThumb.RenderTransform = new RotateTransform()
1487
                            {
1488

    
1489
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1490
                            };
1491

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

    
1498
                            //(member.DrawingData as TextControl).Angle = AngleValue;
1499

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

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

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

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

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

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

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

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

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

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

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

    
1600
        }
1601

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

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

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

    
1643
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1644
        {
1645
            if (e.ClickCount == 2 && this.Members.Count == 1)
1646
            {
1647

    
1648
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1649
                {
1650
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1651
                    TextControlChanger();                    
1652
                }
1653

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

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

    
1665
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1666
                    
1667

    
1668
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1669

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

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

    
1681

    
1682

    
1683

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

    
1697

    
1698
                        BorderUpdate();
1699

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

    
1755
            }
1756
            
1757
        }
1758
        #endregion
1759

    
1760
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1761
        {
1762
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1763
            {
1764
                DragThumb.Visibility = Visibility.Collapsed;
1765
            }
1766
        }
1767

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