프로젝트

일반

사용자정보

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

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

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

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

    
201
        private bool disposed;
202

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
481

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

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

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

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

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

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

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

    
547
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) 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))  Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
676
            }
677

    
678
            BorderUpdate();
679
        }
680

    
681

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
924

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1105
                var arrowText = commentInfo as ArrowTextControl;
1106

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

    
1113
                control.UpdateThumb();
1114

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

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

    
1120
        }
1121
        
1122

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

    
1127
            MyThumb thumb = sender as MyThumb;
1128

    
1129
            if (this.Members.Count > 1) return;
1130

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

    
1133
            double newHorizontalChange = e.HorizontalChange;
1134
            double newVerticalChange = e.VerticalChange;
1135

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

    
1140
                Point setPoint = GetPosition(thumb);
1141

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

    
1144
                AdornerMember control = CurrentAdornerMember(thumb);
1145
                var commentInfo = (control.DrawingData) as CommentUserInfo;
1146

    
1147
                double ratatePointAngle = 0;
1148

    
1149
                if (commentInfo is ArrowTextControl)
1150
                {
1151
                    var textControl = (commentInfo as ArrowTextControl);
1152

    
1153
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1154

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

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

    
1174
                var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1175
     
1176
                Point thumbPoint = MathHelper.RotatePoint(setPoint, new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1177

    
1178
                //thumbPoint.X = Math.Abs(thumbPoint.X);
1179
                //thumbPoint.Y = Math.Abs(thumbPoint.Y);
1180

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

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

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

    
1193
                //System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1194
                control.UpdateThumb();
1195

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

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

    
1203
        private AdornerMember CurrentAdornerMember(MyThumb thumb)
1204
        {
1205
            AdornerMember result = null;
1206

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

    
1218
            return result;
1219
        }
1220

    
1221
        private Point GetPosition(Thumb thumb)
1222
        {
1223
            return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
1224
        }
1225

    
1226
        #endregion
1227
        #region 이벤트
1228

    
1229
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1230
        {
1231
            this.isDragging = false;
1232
            DraggerThumb = null;
1233

    
1234
            var comments = (from drawing in this.Members
1235
                            select drawing.DrawingData as CommentUserInfo).ToList();
1236
            UndoCommand.Instance.Push(comments, this.AngleValue);
1237
            ViewerDataModel.Instance.IsMarkupUpdate = true;
1238
        }
1239

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

    
1250
            if (ViewerDataModel.Instance.UndoDataList == null)
1251
            {
1252
                return;
1253
            }
1254

    
1255
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1256
            {
1257
                return;
1258
            }
1259

    
1260
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1261
            {
1262
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1263
                {
1264
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1265
                    {
1266
                        return;
1267
                    }
1268
                }
1269
            }
1270

    
1271
            var comments = (from drawing in this.Members
1272
                            select drawing.DrawingData as CommentUserInfo).ToList();
1273
            UndoCommand.Instance.Push(comments, this.AngleValue);
1274
        }
1275

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

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

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

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

    
1331
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1332
        {
1333
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1334

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

    
1340
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1341
        {
1342
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1343

    
1344
            var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1345
         
1346
            var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1347
            var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1348

    
1349
            try
1350
            {
1351
                DragThumb.Cursor = Cursors.SizeAll;
1352
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1353
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1354

    
1355

    
1356
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1357

    
1358
                //if (ViewerDataModel.Instance.PageAngle == 270 || ViewerDataModel.Instance.PageAngle == 90)
1359
                //{
1360
                //    mainRect = new Rect(0, 0, mainRect.Height, mainRect.Width);
1361
                //}
1362

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

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

    
1367
                var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1368
                
1369
                var moveDirection = mainRect.Movement(rotationRect);
1370

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

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

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

    
1396
                this.TranslateItems(horzChange, vertChange);
1397
            }
1398
            finally
1399
            {
1400
                /// update CurrentMousePoint
1401
                this.CurrentMousePoint = newMousePoint;
1402
            }
1403
        }
1404

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

    
1418
                this.BorderUpdate();
1419
            }));
1420
        }
1421

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

    
1435
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1436
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null);            
1437

    
1438
            item.UpdateThumb();
1439
        }
1440

    
1441
        private void resize_MouseMove(object sender, MouseEventArgs e)
1442
        {
1443
            //reSizePoint = e.GetPosition(this);
1444
        }
1445

    
1446
        /// <summary>
1447
        /// 회전
1448
        /// </summary>
1449
        /// <param name="sender"></param>
1450
        /// <param name="e"></param>
1451
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1452
        {
1453
            MoveRotate(e);
1454
        }
1455

    
1456
        double LastRotateHorizontalValue = 0;
1457
        double LastRotateVerticalValue = 0;
1458
        bool RotateFlag = false;
1459

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

    
1469
            #region X축 기준으로 회전 각도를 구한다.
1470
            Point vec1 = new Point(1, 0);
1471
            Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1472
            double angle = (MathSet.getAngleBetweenVectors(vec1, vec2));
1473
            if (angle > 360) angle -= 360;
1474
            if (angle < 0) angle += 360;
1475
            #endregion
1476

    
1477
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1478
            if (ViewerDataModel.Instance.IsAxisLock)
1479
            {
1480
                angle = AlignedAngles.OrderBy(x => Math.Abs(angle - x)).First();
1481
            }
1482
            #endregion
1483

    
1484
            double dDeltaAngle = angle - AngleValue;
1485
            AngleValue = angle;
1486

    
1487
            /// save rotatePoint
1488
            this.rotatePoint = pt;
1489

    
1490
            Dispatcher.BeginInvoke((Action)(() =>
1491
            {
1492
                foreach (var member in this.Members)
1493
                {
1494
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1495
                    #region 보더 업데이트
1496
                    switch (member.Drawingtype)
1497
                    {
1498
                        case ControlType.TextControl:
1499
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1500

    
1501
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1502
                            DragThumb.RenderTransform = new RotateTransform()
1503
                            {
1504

    
1505
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1506
                            };
1507

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

    
1514
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1515
                            BorderUpdate();
1516
                            break;
1517

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

    
1555
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1556
        {            
1557
            this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1558
            rotateTop.Cursor = Cursors.SizeAll;
1559

    
1560
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1561
            if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1562
            {
1563
                this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).CommentAngle;
1564
            }
1565
            /// up to here
1566

    
1567
            if (ViewerDataModel.Instance.UndoDataList == null)
1568
            {
1569
                return;
1570
            }
1571

    
1572
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1573
            {
1574
                return;
1575
            }
1576

    
1577
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1578
            {
1579
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1580
                {
1581
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1582
                    {
1583
                        return;
1584
                    }
1585
                }
1586
            }
1587

    
1588
            var comments = (from drawing in this.Members
1589
                            select drawing.DrawingData as CommentUserInfo).ToList();
1590
            UndoCommand.Instance.Push(comments, this.AngleValue);
1591
        }
1592
        
1593
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1594
        {
1595
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1596

    
1597
            var comments = (from drawing in this.Members
1598
                            select drawing.DrawingData as CommentUserInfo).ToList();
1599
            UndoCommand.Instance.Push(comments, this.AngleValue);
1600
        }
1601

    
1602
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1603
        {
1604
            AdornerMember control = this.Members.FirstOrDefault();
1605

    
1606
            if ((control.DrawingData as ArrowTextControl) != null)
1607
            {
1608
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1609
                {
1610
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1611
                }
1612
            }
1613

    
1614
        }
1615

    
1616
        public void TextControlChanger()
1617
        {
1618
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1619
            {
1620
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1621
                AllControl.Base_TextBox.Focus();
1622
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1623
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1624
                AllControl.Base_TextBox.IsHitTestVisible = true;
1625
                AllControl.IsEditingMode = true;
1626
                AllControl.Base_TextBox.Focus();
1627

    
1628
                AllControl.SizeChanged += (sen, ea) =>
1629
                {
1630
                    if (AllControl.Base_TextBox != null)
1631
                    {
1632
                        RectangleGeometry Data = new RectangleGeometry
1633
                        {
1634
                            Rect = new Rect()
1635
                            {
1636
                                X = AllControl.StartPoint.X,
1637
                                Y = AllControl.StartPoint.Y,
1638
                                Width = AllControl.Base_TextBox.Width,
1639
                                Height = AllControl.Base_TextBox.Height,
1640
                            }
1641
                        };
1642

    
1643
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1644
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1645
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1646
                        {
1647
                            Angle = AllControl.CommentAngle,
1648
                            CenterX = middle.X,
1649
                            CenterY = middle.Y,
1650
                        };
1651
                    }
1652
                    BorderUpdate();
1653
                };
1654
            }
1655
        }
1656

    
1657
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1658
        {
1659
            if (e.ClickCount == 2 && this.Members.Count == 1)
1660
            {
1661

    
1662
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1663
                {
1664
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1665
                    TextControlChanger();                    
1666
                }
1667

    
1668
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1669
                {
1670
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1671
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1672
               
1673
                    //ArrowControl TextBox Thumb없애기
1674
                    tm.Visibility = Visibility.Collapsed;
1675

    
1676
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1677
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1678

    
1679
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1680
                    
1681

    
1682
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1683

    
1684
                    {
1685
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1686
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1687

    
1688
                        List<Point> ps = new List<Point>();
1689
                        
1690
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1691
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1692
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1693
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1694

    
1695

    
1696

    
1697

    
1698
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1699
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1700
                        if (AllControl.isTrans)
1701
                        {
1702
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1703
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1704
                        }
1705
                        else
1706
                        {
1707
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1708
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1709
                        }
1710

    
1711

    
1712
                        BorderUpdate();
1713

    
1714
                    };
1715
                }
1716
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1717
                {
1718
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1719
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1720
                    //dropData.IsOpen = true;
1721
                    RadWindow rc = new RadWindow();
1722
                    rc.Width = 300;
1723
                    rc.Height = 300;
1724
                    rc.Header = "Change Date";
1725
                    rc.Content = instanceCal;
1726
                    rc.BorderThickness = new Thickness(3);
1727
                    rc.ResizeMode = ResizeMode.NoResize;
1728
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1729
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1730
                    rc.ModalBackground.Opacity = 0.6;
1731
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1732
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1733
                    {
1734
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1735
                        rc.Close();
1736
                    };
1737
                    rc.ShowDialog();
1738
                    //CalendarControl.xaml
1739
                }
1740
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1741
                {
1742
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
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
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1755
                {
1756
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1757
                    if (instance.isTransOn)
1758
                    {
1759
                        instance.isTransOn = false;
1760
                    }
1761
                    else
1762
                    {
1763
                        instance.isTransOn = true;
1764
                    }
1765
                    instance.SetArcPath();
1766
                    BorderUpdate();
1767
                }
1768

    
1769
            }
1770
            
1771
        }
1772
        #endregion
1773

    
1774
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1775
        {
1776
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1777
            {
1778
                DragThumb.Visibility = Visibility.Collapsed;
1779
            }
1780
        }
1781

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