프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (78.9 KB)

1
using KCOM.Common;
2
using KCOM.Events;
3
using MarkupToPDF.Common;
4
using MarkupToPDF.Controls.Cad;
5
using MarkupToPDF.Controls.Common;
6
using MarkupToPDF.Controls.Etc;
7
using MarkupToPDF.Controls.Line;
8
using MarkupToPDF.Controls.Parsing;
9
using MarkupToPDF.Controls.Polygon;
10
using MarkupToPDF.Controls.Shape;
11
using MarkupToPDF.Controls.Text;
12
using System;
13
using System.Collections.Generic;
14
using System.Diagnostics;
15
using System.Linq;
16
using System.Text;
17
using System.Threading.Tasks;
18
using System.Windows;
19
using System.Windows.Controls;
20
using System.Windows.Controls.Primitives;
21
using System.Windows.Input;
22
using System.Windows.Media;
23
using Telerik.Windows.Controls;
24

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

    
36
        public void Translate(double dx, double dy, double angle)
37
        {
38
            var ratotePoint = MathHelper.RotatePoint(new Point(dx, dy), new Point(), angle);
39

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

    
44

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

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

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

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

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

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

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

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

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

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

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

    
161
        /// <summary>
162
        /// 회전 시작할때의 각도
163
        /// </summary>
164
        public double dBeforeAngle { get; set; }
165

    
166
        private double angleValue;
167
        public double AngleValue { get => angleValue;
168
            set
169
            {
170
                if(angleValue != value)
171
                {
172
                    angleValue = value;
173
                }
174
            }
175
        }
176

    
177
        /// <summary>
178
        /// Axis Lock을 적용하지 않는 실제 회전 각도
179
        /// </summary>
180
        private double _ActualAngle { get; set; }
181

    
182
        public List<Point> lstBeforePointSet { get; set; }
183

    
184
        public bool IsTextAngle = false;
185
        public Rect BorderSize { get; set; }
186
        public bool TextCompensation = false;
187
        public bool isDragging { get; set; }
188
        public Thumb DraggerThumb { get; set; }
189
        public RadDropDownButton dropData;
190
        public RadCalendar dropCalendar;
191
        public Thumb mainDragThumb { get; set; }
192

    
193
        private bool disposed;
194

    
195
        public Point reSizePoint { get; set; }
196
        private Point RotatedPoint { get; set; } /// 2018.05.09 added by humkyung
197
        private Point MouseDownPoint = new Point();
198
        private Point CurrentMousePoint = new Point();
199
        #endregion
200
        #region 생성자
201
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
202
        {
203
            dropData = sender as RadDropDownButton;
204
        }
205

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

    
220
        public AdornerFinal()
221
        {
222
            InitializeComponent();
223
            BorderSize = new Rect();
224
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
225
        }
226

    
227
        ~AdornerFinal()
228
        {
229
            this.Dispose(false);
230
        }
231

    
232
        public void Dispose()
233
        {
234
            this.Dispose(true);
235
            GC.SuppressFinalize(this);
236
        }
237

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

    
254
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
255
        {
256
            mainDragThumb = DragThumb;
257
        }
258

    
259
        public AdornerFinal(CommentUserInfo objectData) : this()
260
        {
261
            InitializeComponent();
262
            objectData.IsHitTestVisible = false;
263

    
264
            if ((objectData as ArrowTextControl) != null)
265
            {
266
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
267
            }
268

    
269
            Canvas.SetZIndex(objectData, 84);
270
            try
271
            {
272
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
273
                this.ContainerContent.Children.Add(objectData);
274
            }
275
            catch (Exception ex)
276
            {
277

    
278
            }
279
           
280
            SetAdornerMember(objectData as CommentUserInfo);
281
            this.Focus();
282
        }
283

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

    
312
        public Point Centeroid
313
        {
314
            get
315
            {
316
                List<Point> pts = new List<Point>();
317

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

    
338
                return MathSet.FindCentroid(pts);
339
            }
340
        }
341

    
342
        #endregion
343
        #region 메서드
344
        public Rect getAdornerSize()
345
        {
346
            return BorderSize;
347
        }
348
        public void addMemberControl(UIElement objectData)
349
        {
350
            this.ContainerContent.Children.Add(objectData);
351
            SetAdornerMember(objectData as CommentUserInfo);
352
            this.Focus();
353
        }
354

    
355
        private void TextControlLostFocus(object sender,RoutedEventArgs e)
356
        {
357
            TextCompensation = false;
358
            BorderUpdate();
359

    
360
            if (sender is TextBox)
361
            {
362
                if ((sender as TextBox).Text == "") //보류
363
                {
364
                    this.ContainerContent.Children.Remove((sender as TextBox).Parent as MarkupToPDF.Common.CommentUserInfo);
365
                    this.Visibility = Visibility.Collapsed;
366
                }
367
            }
368
        }
369

    
370
        private void TextControlPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
371
        {
372
            if (sender is TextControl)
373
            {
374
                TextCompensation = true;
375
                BorderUpdate();
376
            }
377
        }
378

    
379
        private void TextControlSelectionChanged(object sender, RoutedEventArgs e)
380
        {
381
            BorderUpdate();
382
        }
383

    
384
        
385
        private void ViewBoxRotate(UIElement member)
386
        {
387
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
388
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
389
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
390
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
391
        }
392

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

    
433
                    ((ArrowTextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
434
                    break;
435
                case "ImgControl":
436
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
437
                    _ActualAngle = AngleValue = (member as ImgControl).CommentAngle;
438
                    break;
439
                case "DateControl":
440
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
441
                    _ActualAngle = AngleValue = (member as DateControl).CommentAngle;
442
                    break;
443
                case "SignControl":
444
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
445
                    _ActualAngle = AngleValue = (member as SignControl).CommentAngle;
446
                    break;
447
                case "SymControl":
448
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
449
                    _ActualAngle = AngleValue = (member as SymControl).CommentAngle;
450
                    break;
451
                case "SymControlN":
452
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
453
                    _ActualAngle = AngleValue = (member as SymControlN).CommentAngle;
454
                    break;
455
                case "TextControl":
456
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
457
                    RectangleGeometry Data = new RectangleGeometry
458
                    {
459
                        Rect = new Rect()
460
                        {
461
                            X = Canvas.GetLeft((member as TextControl)),
462
                            Y = Canvas.GetTop((member as TextControl)),
463
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
464
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
465
                        }
466
                    };
467
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
468
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
469

    
470

    
471
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
472
                    DragThumb.RenderTransform = new RotateTransform()
473
                    {
474
                        Angle = (member as TextControl).CommentAngle,
475
                    };
476

    
477
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
478
                    AdornerBorder.RenderTransform = new RotateTransform()
479
                    {
480
                        Angle = (member as TextControl).CommentAngle,
481
                    };
482

    
483
                    ((TextControl)member).PropertyChanged += TextControlPropertyChanged;
484
                    ((TextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
485
                    break;
486
                default:
487
                    break;
488
                    #endregion
489
            }
490

    
491
            if (member.GetType().Name == "TextControl")
492
            {
493
                TextControl content = ((TextControl)member);
494
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
495
                content.EndPoint = content.StartPoint;
496
            }
497
            else
498
            {
499
                RegistryPoint(member);
500
            }
501
            BorderUpdate();
502

    
503
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
504
                Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
505
        }
506

    
507

    
508
        public void SetAdornerMember(List<CommentUserInfo> members)
509
        {
510
            foreach (var member in members)
511
            {
512
                switch (member.GetType().Name)
513
                {
514
                    #region 컨트롤 조건
515
                    case "LineControl":
516
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
517
                        break;
518
                    case "ImgControl":
519
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
520
                        break;
521
                    case "ArrowControl":
522
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
523
                        break;
524
                    case "PolygonControl":
525
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
526
                        break;
527
                    case "ArrowTextControl":
528
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
529
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
530
                        break;
531
                    case "ArcControl":
532
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
533
                        break;
534
                    case "ArrowArcControl":
535
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
536
                        break;
537
                    case "DateControl":
538
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
539
                        break;
540
                    case "ArrowControl_Multi":
541
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
542
                        break;
543
                    case "RectangleControl":
544
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
545
                        break;
546
                    case "TriControl":
547
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
548
                        break;
549
                    case "CircleControl":
550
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
551
                        break;
552
                    case "CloudControl":
553
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
554
                        break;
555
                    case "RectCloudControl":
556
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
557
                        break;
558
                    case "SignControl":
559
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
560
                        break;
561
                    case "SymControl":
562
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
563
                        break;
564
                    case "SymControlN":
565
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
566
                        break;
567
                    case "InkControl":
568
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
569
                        break;
570
                    case "TextControl":
571
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
572

    
573
                        (member as TextControl).PropertyChanged += TextControlPropertyChanged;
574
                        (member as TextControl).Base_TextBox.SelectionChanged += TextControlSelectionChanged;
575

    
576
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
577
                        //{
578
                        //    BorderUpdate();
579
                        //});
580
                        //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
581
                        //{
582
                        //    BorderUpdate();
583
                        //    try
584
                        //    {
585
                        //        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
586
                        //    }
587
                        //    catch (Exception)
588
                        //    {
589

    
590
                        //    }
591

    
592
                        //});
593
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
594
                        //{
595
                        //    BorderUpdate();
596
                        //});
597
                        break;
598
                    case "InsideWhiteControl":
599
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
600
                        break;
601
                    case "OverlapWhiteControl":
602
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
603
                        break;
604
                    case "ClipWhiteControl":
605
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
606
                        break;
607
                    case "CoordinateControl":
608
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
609
                        break;
610
                    default:
611
                        break;
612
                        #endregion
613
                }
614
                if (member.GetType().Name == "TextControl")
615
                {
616
                    TextControl content = ((TextControl)member);
617
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
618
                    content.EndPoint = content.StartPoint;
619
                }
620
                else
621
                {
622
                    RegistryPoint(member, members.Count);
623
                }
624

    
625
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
626
                    Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
627
            }
628

    
629
            BorderUpdate();
630
        }
631

    
632

    
633
        /// <summary>
634
        /// Border 를 갱신
635
        /// </summary>
636
        public void BorderUpdate()
637
        {
638
            AdornerBorder.MinWidth = 10;
639
            AdornerBorder.MinHeight = 10;
640

    
641
            double minX = double.MaxValue;
642
            double minY = double.MaxValue;
643
            double maxX = double.MinValue;
644
            double maxY = double.MinValue;
645

    
646
            if (this.Members.Count == 1)
647
            {
648
                if (this.Members[0].DrawingData.GetType().Name == "TextControl")
649
                {
650
                    if ((this.Members[0].DrawingData as TextControl).CommentAngle != 0)
651
                    {
652
                        trRotate.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
653
                        trRotateThumb.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
654
                    }
655
                    else
656
                    {
657
                        trRotate.Angle = 0;
658
                        trRotateThumb.Angle = 0;
659
                    }
660
                }
661
            }
662

    
663
            foreach (var item in this.Members)
664
            {
665
                UIElement currentControl = (item as AdornerMember).DrawingData;
666

    
667
                Point startP = (currentControl as IPath).StartPoint;
668
                Point endP = (currentControl as IPath).EndPoint;
669

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

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

    
675
                if (item.DrawingData.GetType().Name == "TextControl")
676
                {
677
                    double textControlWidth;
678
                    double textControlHeight;
679

    
680
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
681
                    {
682
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
683
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
684
                    }
685
                    else
686
                    {
687
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
688
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
689
                    }
690
                    
691
                    if ((currentControl as TextControl).EndPoint.X < minX)
692
                    {
693
                        minX = (currentControl as TextControl).EndPoint.X;
694
                    }
695

    
696
                    if ((currentControl as TextControl).EndPoint.Y < minY)
697
                    {
698
                        minY = (currentControl as TextControl).EndPoint.Y;
699
                    }
700

    
701
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
702
                    {
703
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
704
                    }
705

    
706
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
707
                    {
708
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
709
                    }
710
                }
711
                else if ((currentControl as IViewBox) != null)
712
                {
713
                    IViewBox instance = currentControl as IViewBox;
714
                    List<Point> am = (currentControl as IPath).PointSet;
715
                    List<double> xSet = am.Select(p => p.X).ToList();
716
                    List<double> ySet = am.Select(p => p.Y).ToList();
717
                    if (xSet.Min() < minX) minX = xSet.Min();
718
                    if (ySet.Min() < minY) minY = ySet.Min();
719
                    if (xSet.Max() > maxX) maxX = xSet.Max();
720
                    if (ySet.Max() > maxY) maxY = ySet.Max();
721
                }
722
                else if ((currentControl as IPath).PathData == null)
723
                {
724
                    Rect rt = new Rect
725
                    {
726
                        X = (currentControl as IPath).StartPoint.X,
727
                        Y = (currentControl as IPath).StartPoint.Y,
728
                        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),
729
                        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),
730
                    };
731
                    if (rt.Left < minX) minX = rt.Left;
732
                    if (rt.Top < minY) minY = rt.Top;
733
                    if (rt.Right > maxX) maxX = rt.Right;
734
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
735
                }
736
                else if ((currentControl as IPath) == null)
737
                {
738
                    Rect rt = new Rect
739
                    {
740
                        X = (currentControl as IPath).StartPoint.X,
741
                        Y = (currentControl as IPath).StartPoint.Y,
742
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
743
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
744
                    };
745
                    if (rt.Left < minX) minX = rt.Left;
746
                    if (rt.Top < minY) minY = rt.Top;
747
                    if (rt.Right > maxX) maxX = rt.Right;
748
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
749
                }
750
                else if (currentControl is CircleControl CircleCtrl)
751
                {
752
                    List<Point> am = CircleCtrl.PointSet;
753
                    minX = am.Min(x => x.X);
754
                    minY = am.Min(x => x.Y);
755
                    maxX = am.Max(x => x.X);
756
                    maxY = am.Max(x => x.Y);
757
                }
758
                else
759
                {
760
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
761
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
762
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
763
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
764
                }
765
            }
766

    
767
            Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY);
768
            bool addWidthSize = false;
769
            bool addHeightSize = false;
770
            if (ac.Width <= 10)
771
            {
772
                ac.Width += 10;
773
                addWidthSize = true;
774
            }
775
            if (ac.Height <= 10)
776
            {
777
                ac.Height += 10;
778
                addHeightSize = true;
779
            }
780
            BorderSize = ac;
781
            AdornerBorder.MinWidth = 10;
782
            AdornerBorder.MinHeight = 10;
783
            AdornerBorder.Width = ac.Width;
784
            AdornerBorder.Height = ac.Height;
785
            Canvas.SetLeft(AdornerBorder, minX);
786
            Canvas.SetTop(AdornerBorder, minY);
787

    
788
            DragThumb.Width = ac.Width;
789
            DragThumb.Height = ac.Height;
790

    
791
            DragThumb.MinWidth = 10;
792
            DragThumb.MinHeight = 10;
793
            if (addWidthSize)
794
            {
795
                Canvas.SetLeft(DragThumb, minX - 5);
796
            }
797
            else
798
            {
799
                Canvas.SetLeft(DragThumb, minX);
800
            }
801

    
802
            if (addHeightSize)
803
            {
804
                Canvas.SetTop(DragThumb, minY - 5);
805
            }
806
            else
807
            {
808
                Canvas.SetTop(DragThumb, minY);
809
            }
810
        }
811

    
812
        /// <summary>
813
        /// UIElement 해제
814
        /// </summary>
815
        public void unRegister()
816
        {
817
            foreach (var item in this.ContainerContent.Children)
818
            {
819
                if (item is MarkupToPDF.Common.CommentUserInfo)
820
                {
821
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
822
                }
823
            }
824
            this.ContainerContent.Children.Clear();
825
        }
826

    
827
        /// <summary>
828
        /// 각 포인트들을 등록합니다.
829
        /// </summary>
830
        /// <param name="pointset">Drawing Point</param>
831
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
832
        {
833
            int count = 0;
834
            List<Point> pts = (member as IPath).PointSet;
835
            if (member.GetType().Name == "InkControl")
836
            {
837
                pts.Clear();
838
                pts.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
839
                pts.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
840
                pts.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
841
                pts.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
842
            }
843
            ControlType markT = this.Members.First(p => p.DrawingData == member).Drawingtype;
844
            double Minx = pts.Min(x => x.X);
845
            double Miny = pts.Min(x => x.Y);
846

    
847
            for (int i = 0; i < pts.Count; i++)
848
            {
849
                MyThumb tm = new MyThumb
850
                {
851
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
852
                };
853

    
854
                this.Members.Last().ThumbList.Add(tm);
855

    
856
                if ((markT == ControlType.ArcLine && pts[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && pts[i] == (member as ArrowArcControl).MiddlePoint))
857
                {
858
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
859
                }
860
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
861
                {
862
                    //if (this.Members.Count()<=1)
863
                    //{
864
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
865
                    List<Point> ps = new List<Point>();
866

    
867
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
868
                    {
869
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
870

    
871
                        switch (Math.Abs(temp.CommentAngle).ToString())
872
                        {
873
                            case "90":
874
                                {
875
                                    ps.Clear();
876
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
877
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
878
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
879

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

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

    
886
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
887
                                }
888
                                break;
889
                            case "270":
890
                                {
891
                                    ps.Clear();
892
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
893
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
894
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
895

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

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

    
902
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
903
                                }
904
                                break;
905
                            default:
906
                                {
907
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
908
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
909
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
910
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
911
                                }
912
                                break;
913
                        }
914

    
915
                        ArrowTextControl instance = (member as ArrowTextControl);
916
                        if (instance.isTrans)
917
                        {
918
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
919
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
920
                            //list[count] = tempP;
921
                            pts[count] = temp.MidPoint;
922
                        }
923
                        else
924
                        {
925
                            if (temp.isFixed)
926
                            {
927
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
928
                                var testP = endP;
929
                                if (ps[0] == endP) //상단
930
                                {
931
                                    testP = new Point(endP.X, endP.Y - 50);
932
                                }
933
                                else if (ps[1] == endP) //하단
934
                                {
935
                                    testP = new Point(endP.X, endP.Y + 50);
936
                                }
937
                                else if (ps[2] == endP) //좌단
938
                                {
939
                                    testP = new Point(endP.X - 50, endP.Y);
940
                                }
941
                                else if (ps[3] == endP) //우단
942
                                {
943
                                    testP = new Point(endP.X + 50, endP.Y);
944
                                }
945
                                pts[count] = testP;
946
                            }
947
                            else
948
                            {
949
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
950
                                pts[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
951
                            }
952
                        }
953
                    }
954
                }
955

    
956
                /// ArrowTextControl text box 화면 출력
957
                if (member.GetType().Name == "ArrowTextControl" && pts[i] == pts.Last())
958
                {
959
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
960
                    tm.Width = (member as ArrowTextControl).BoxWidth;
961
                    tm.Height = (member as ArrowTextControl).BoxHeight;
962
                    var angle = (member as ArrowTextControl).PageAngle;
963
                    if (Math.Abs(angle).ToString() == "90")
964
                    {
965
                        tm.RenderTransformOrigin = new Point(0, 0);
966
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
967
                    }
968
                    else if (Math.Abs(angle).ToString() == "270")
969
                    {
970
                        tm.RenderTransformOrigin = new Point(0, 0);
971
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
972
                    }
973
                    else
974
                    {
975
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
976
                        tm.RenderTransform = new RotateTransform()
977
                        {
978
                            Angle = angle
979
                        };
980
                    }
981
                }
982
                
983
                if (member.GetType().Name == "CloudControl")
984
                {
985
                    if (i == pts.Count() - 1)
986
                    {
987
                        tm.Visibility = System.Windows.Visibility.Collapsed;
988
                    }
989
                }
990
                if (member.GetType().Name == "PolygonControl")
991
                {
992
                    if (i == pts.Count() - 1)
993
                    {
994
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
995
                        {
996

    
997
                        }
998
                        else
999
                        {
1000
                            tm.Visibility = System.Windows.Visibility.Collapsed;
1001
                        }
1002
                    }
1003
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
1004
                    {
1005
                        tm.Visibility = System.Windows.Visibility.Collapsed;
1006
                    }
1007
                }
1008
                
1009
                this.ContainerContent.Children.Add(tm);
1010
                Canvas.SetLeft(tm, pts[count].X);
1011
                Canvas.SetTop(tm, pts[count].Y);
1012
                if (member.GetType().Name == "ArrowTextControl" && pts[i] == (member as ArrowTextControl).MidPoint)
1013
                {
1014
                    Canvas.SetZIndex(tm, 95);
1015
                    //tm.Opacity = 0;
1016
                    tm.DragDelta += MidPoint_DragDelta;
1017
                }
1018
                else
1019
                {
1020
                    tm.DragDelta += ResizeTm_DragDelta;
1021
                    Canvas.SetZIndex(tm, 99);
1022
                }
1023

    
1024
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
1025
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
1026
                
1027
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
1028
                count++;
1029
            }
1030
        }
1031

    
1032
        private void MidPoint_DragDelta(object sender, DragDeltaEventArgs e)
1033
        {
1034
            MyThumb thumb = sender as MyThumb;
1035
            double newHorizontalChange = e.HorizontalChange;
1036
            double newVerticalChange = e.VerticalChange;
1037

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

    
1040
            var direction = VisualHelper.GetPointDirection(newpoint, ViewerDataModel.Instance.PageAngle);
1041

    
1042
            System.Diagnostics.Debug.WriteLine("뱡향 : " + direction.ToString());
1043

    
1044
            AdornerMember control = CurrentAdornerMember(thumb);
1045
            var commentInfo = (control.DrawingData) as CommentUserInfo;
1046

    
1047
            if (commentInfo is ArrowTextControl)
1048
            {
1049
                Point getThumbPoint = GetPosition(thumb);
1050

    
1051
                var arrowText = commentInfo as ArrowTextControl;
1052

    
1053
                //var midPoint = MathSet.getMiddlePoint(arrowText.StartPoint, arrowText.EndPoint);
1054
                //arrowText.MidPoint = newpoint;
1055
                thumb.Translate(newpoint.X, newpoint.Y, this.AngleValue);
1056
          
1057
                commentInfo.OnMoveCtrlPoint(getThumbPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1058

    
1059
                control.UpdateThumb();
1060

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

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

    
1066
        }
1067
        
1068

    
1069
        /// <summary>
1070
        /// 제어점을 조정하여 크기를 수정한다.
1071
        /// </summary>
1072
        /// <param name="sender"></param>
1073
        /// <param name="e"></param>
1074
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
1075
        {
1076
            if (sender.GetType() != typeof(MyThumb)) return;
1077

    
1078
            MyThumb thumb = sender as MyThumb;
1079

    
1080
            if (this.Members.Count > 1) return;
1081

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

    
1084
            double newHorizontalChange = e.HorizontalChange;
1085
            double newVerticalChange = e.VerticalChange;
1086

    
1087
            //if (reSizePoint != new Point(0, 0))
1088
            //{
1089
                //Point setPoint = Mouse.GetPosition(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanCanvas);
1090

    
1091
                Point setPoint = GetPosition(thumb);
1092

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

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

    
1098
                double ratatePointAngle = 0;
1099

    
1100
                if (commentInfo is ArrowTextControl)
1101
                {
1102
                    var textControl = (commentInfo as ArrowTextControl);
1103

    
1104
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1105

    
1106
                    {
1107
                        textControl.CommentAngle = 0;
1108
                        this.AngleValue = 0;
1109
                        ratatePointAngle = commentInfo.VisualPageAngle;
1110
                    }
1111
                    else
1112
                    {   
1113
                        //textControl.CommentAngle = commentInfo.VisualPageAngle + MathSet.returnAngle(textControl.StartPoint, ref tempPoint, ViewerDataModel.Instance.IsPressShift);
1114
                        textControl.OnCreatingMouseMove(textControl.EndPoint, ViewerDataModel.Instance.IsPressShift);
1115
                        this.AngleValue = textControl.CommentAngle;
1116
                        commentInfo.CommentAngle = this.AngleValue;
1117
                    }
1118
                        //CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1119
                }
1120
                System.Diagnostics.Debug.WriteLine("## Angle : " + this.AngleValue + " ##");
1121
                thumb.Translate(newHorizontalChange, newVerticalChange, this.AngleValue);
1122

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

    
1125
                var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1126
     
1127
                Point thumbPoint = MathHelper.RotatePoint(setPoint, new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1128

    
1129
                //thumbPoint.X = Math.Abs(thumbPoint.X);
1130
                //thumbPoint.Y = Math.Abs(thumbPoint.Y);
1131

    
1132
                //if ((setPoint.X + newpoint.X) < 0 || (Math.Abs(thumbPoint.X) + newpoint.X) - ViewerDataModel.Instance.ImageViewWidth > 0)
1133
                //{
1134
                //    newpoint.X = 0;
1135
                //}
1136

    
1137
                //if (setPoint.Y + newpoint.Y < 0 || (Math.Abs(thumbPoint.Y) + newpoint.Y) - ViewerDataModel.Instance.ImageViewHeight > 0)
1138
                //{
1139
                //    newpoint.Y = 0;
1140
                //}
1141

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

    
1144
                //System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1145
                control.UpdateThumb();
1146

    
1147
                //System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1148
                this.BorderUpdate();
1149

    
1150
               //System.Diagnostics.Debug.WriteLine($"5. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1151
            //}
1152
        }
1153

    
1154
        private AdornerMember CurrentAdornerMember(MyThumb thumb)
1155
        {
1156
            AdornerMember result = null;
1157

    
1158
            try
1159
            {
1160
                result = (from userThumb in this.Members
1161
                            where userThumb.ThumbList.Contains(thumb)
1162
                            select userThumb).FirstOrDefault();
1163
            }
1164
            catch (Exception ex)
1165
            {
1166
                App.FileLogger.Error(ex);
1167
            }
1168

    
1169
            return result;
1170
        }
1171

    
1172
        private Point GetPosition(Thumb thumb)
1173
        {
1174
            return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
1175
        }
1176

    
1177
        #endregion
1178
        #region 이벤트
1179

    
1180
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1181
        {
1182
            this.isDragging = false;
1183
            DraggerThumb = null;
1184

    
1185
            List<Point> lstPointTemp = new List<Point>();
1186
            foreach(var vPoint in this.lstBeforePointSet)
1187
            {
1188
                lstPointTemp.Add(vPoint);
1189
            }
1190

    
1191
            var comments = (from drawing in this.Members
1192
                            select drawing.DrawingData as CommentUserInfo).ToList();
1193
            UndoCommand.Instance.Push(comments, this.AngleValue, 0, lstPointTemp);
1194
            ViewerDataModel.Instance.IsMarkupUpdate = true;
1195
        }
1196

    
1197
        /// <summary>
1198
        /// start drag
1199
        /// </summary>
1200
        /// <param name="sender"></param>
1201
        /// <param name="e"></param>
1202
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1203
        {
1204
            this.DraggerThumb = sender as Thumb;
1205
            this.isDragging = true;
1206

    
1207
            if (ViewerDataModel.Instance.UndoDataList == null)
1208
            {
1209
                return;
1210
            }
1211

    
1212
            if (lstBeforePointSet == null)
1213
                lstBeforePointSet = new List<Point>();
1214

    
1215
            lstBeforePointSet.Clear();
1216
            foreach(var vPoint in ((dynamic)this.Members.FirstOrDefault().DrawingData).PointSet)
1217
            {
1218
                lstBeforePointSet.Add(vPoint);
1219
            }
1220

    
1221
            //lstBeforePointSet = ((dynamic)this.Members.FirstOrDefault().DrawingData).PointSet;
1222

    
1223
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1224
            {
1225
                return;
1226
            }
1227

    
1228
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1229
            {
1230
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1231
                {
1232
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1233
                    {
1234
                        return;
1235
                    }
1236
                }
1237
            }
1238

    
1239
            var comments = (from drawing in this.Members
1240
                            select drawing.DrawingData as CommentUserInfo).ToList();
1241
            UndoCommand.Instance.Push(comments, this.AngleValue, 0, lstBeforePointSet);
1242
        }
1243

    
1244
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1245
        {
1246
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1247
            {
1248
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1249
                    IsTextAngle = true;
1250
                else
1251
                    IsTextAngle = false;
1252
                LastRotateVerticalValue = e.GetPosition(this).X;
1253
            }
1254
            else
1255
            {
1256
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1257
                {
1258
                    RotateFlag = true;
1259
                }
1260
                else
1261
                {
1262
                    RotateFlag = false;
1263
                }
1264
                LastRotateHorizontalValue = e.GetPosition(this).X;
1265
            }
1266
        }
1267

    
1268
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1269
        {
1270
            /// save mouse down and current mouse point
1271
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1272
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1273
            /// up to here
1274

    
1275
            if (ViewerDataModel.Instance.UndoDataList == null)
1276
            {
1277
                return;
1278
            }
1279
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1280
            {
1281
                return;
1282
            }
1283
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1284
            {
1285
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1286
                {
1287
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1288
                    {
1289
                        return;
1290
                    }
1291
                }
1292
            }
1293

    
1294
            var comments = (from drawing in this.Members
1295
                            select drawing.DrawingData as CommentUserInfo).ToList();
1296
            UndoCommand.Instance.Push(comments, this.AngleValue);
1297
        }
1298

    
1299
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1300
        {
1301
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1302

    
1303
            var comments = (from drawing in this.Members
1304
                            select drawing.DrawingData as CommentUserInfo).ToList();
1305
            UndoCommand.Instance.Push(comments, this.AngleValue);
1306
        }
1307

    
1308
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1309
        {
1310
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1311

    
1312
            var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1313
         
1314
            var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1315
            var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1316

    
1317
            try
1318
            {
1319
                DragThumb.Cursor = Cursors.SizeAll;
1320
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1321
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1322

    
1323

    
1324
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1325

    
1326
                //if (ViewerDataModel.Instance.PageAngle == 270 || ViewerDataModel.Instance.PageAngle == 90)
1327
                //{
1328
                //    mainRect = new Rect(0, 0, mainRect.Height, mainRect.Width);
1329
                //}
1330

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

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

    
1335
                var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1336
                
1337
                var moveDirection = mainRect.Movement(rotationRect);
1338

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

    
1342
                //if (Math.Abs(horzChange) > 0)
1343
                //{
1344
                //    if ((horzChange < 0 && !moveDirection.Left) || (horzChange > 0 && !moveDirection.Right))
1345
                //    {
1346
                //        //this.TranslateItems(horzChange * -1, 0);
1347
                //        //e.Handled = true;
1348
                //        horzChange = 0;
1349
                //        newMousePoint.X = this.CurrentMousePoint.X;
1350
                //    }
1351
                //}
1352

    
1353
                //if (Math.Abs(vertChange) > 0)
1354
                //{
1355
                //    if ((vertChange < 0 && !moveDirection.Up) || (vertChange > 0 && !moveDirection.Down))
1356
                //    {
1357
                //        //this.TranslateItems(0, vertChange * -1);
1358
                //        //e.Handled = true;
1359
                //        vertChange = 0;
1360
                //        newMousePoint.Y = this.CurrentMousePoint.Y;
1361
                //    }
1362
                //}
1363

    
1364
                this.TranslateItems(horzChange, vertChange);
1365
            }
1366
            finally
1367
            {
1368
                /// update CurrentMousePoint
1369
                this.CurrentMousePoint = newMousePoint;
1370
            }
1371
        }
1372

    
1373
        /// <summary>
1374
        /// translate all members
1375
        /// </summary>
1376
        /// <param name="e"></param>
1377
        public void TranslateItems(double dx, double dy)
1378
        {
1379
            Dispatcher.BeginInvoke((Action)(() =>
1380
            {
1381
                foreach (var item in this.Members)
1382
                {
1383
                    this.TranslateItem(dx, dy, item);
1384
                }
1385

    
1386
                this.BorderUpdate();
1387
            }));
1388
        }
1389

    
1390
        /// <summary>
1391
        /// translate a item
1392
        /// </summary>
1393
        /// <param name="e"></param>
1394
        /// <param name="item"></param>
1395
        private void TranslateItem(double dx, double dy, AdornerMember item)
1396
        {
1397
            /// rotate point with page rotation
1398
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1399
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1400
            /// up to here
1401
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1402

    
1403
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1404
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null);            
1405

    
1406
            item.UpdateThumb();
1407
        }
1408

    
1409
        private void resize_MouseMove(object sender, MouseEventArgs e)
1410
        {
1411
            //reSizePoint = e.GetPosition(this);
1412
        }
1413

    
1414
        /// <summary>
1415
        /// 회전
1416
        /// </summary>
1417
        /// <param name="sender"></param>
1418
        /// <param name="e"></param>
1419
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1420
        {
1421
            MoveRotate(e);
1422
        }
1423

    
1424
        double LastRotateHorizontalValue = 0;
1425
        double LastRotateVerticalValue = 0;
1426
        bool RotateFlag = false;
1427

    
1428
        /// <summary>
1429
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1430
        /// </summary>
1431
        /// <param name="e"></param>
1432
        public void MoveRotate(DragDeltaEventArgs e)
1433
        {
1434
            Point CenterPoint = this.Centeroid;
1435
            Point pt = Mouse.GetPosition(this);
1436

    
1437
            #region X축 기준으로 회전 각도를 구한다.
1438
            Vector AxisX = new Vector(RotatedPoint.X - CenterPoint.X, RotatedPoint.Y - CenterPoint.Y);
1439
            AxisX.Normalize();
1440
            Vector AxisY = new Vector(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1441
            AxisY.Normalize();
1442
            double dDeltaAngle = Vector.AngleBetween(AxisX, AxisY);
1443
            #endregion
1444

    
1445
            _ActualAngle += dDeltaAngle;
1446
            if (_ActualAngle > 360) _ActualAngle -= 360;
1447
            if (_ActualAngle < 0) _ActualAngle += 360;
1448
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1449
            if (ViewerDataModel.Instance.IsAxisLock)
1450
            {
1451
                double tmp = AlignedAngles.OrderBy(x => Math.Abs(_ActualAngle - x)).First();
1452
                dDeltaAngle = tmp - AngleValue;
1453
                AngleValue = tmp;
1454
            }
1455
            else
1456
            {
1457
                AngleValue = _ActualAngle;
1458
            }
1459
            #endregion
1460

    
1461
            /// save rotatePoint
1462
            this.RotatedPoint = pt;
1463

    
1464
            Dispatcher.BeginInvoke((Action)(() =>
1465
            {
1466
                foreach (var member in this.Members)
1467
                {
1468
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1469
                    #region 보더 업데이트
1470
                    switch (member.Drawingtype)
1471
                    {
1472
                        case ControlType.TextControl:
1473
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1474

    
1475
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1476
                            DragThumb.RenderTransform = new RotateTransform()
1477
                            {
1478
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1479
                            };
1480

    
1481
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1482
                            AdornerBorder.RenderTransform = new RotateTransform()
1483
                            {
1484
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1485
                            };
1486

    
1487
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1488
                            BorderUpdate();
1489
                            break;
1490

    
1491
                        case ControlType.ArrowMultiLine:
1492
                        case ControlType.ArcLine:
1493
                        case ControlType.ArcArrow:
1494
                        case ControlType.SingleLine:
1495
                        case ControlType.Triangle:
1496
                        case ControlType.ArrowTextControl:
1497
                        case ControlType.PolygonControl:
1498
                        case ControlType.Ink:
1499
                            BorderUpdate();
1500
                            break;
1501
                        case ControlType.Date:
1502
                        case ControlType.RectCloud:
1503
                        case ControlType.Rectangle:
1504
                        case ControlType.ImgControl:
1505
                        case ControlType.Sign:
1506
                        case ControlType.Symbol:
1507
                        case ControlType.Stamp:
1508
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1509
                            BorderUpdate();
1510
                            break;
1511
                        case ControlType.PolygonCloud:
1512
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1513
                            BorderUpdate();
1514
                            break;
1515
                        case ControlType.Circle:
1516
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1517
                            ((CircleControl)member.DrawingData).SetCenterXY();
1518
                            BorderUpdate();
1519
                            break;
1520
                        default:
1521
                            break;
1522
                    }
1523
                }
1524
                #endregion
1525
            }));
1526
        }
1527

    
1528
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1529
        {            
1530
            this.RotatedPoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1531
            rotateTop.Cursor = Cursors.SizeAll;
1532

    
1533
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1534
            if ((1 == this.Members.Count) && (this.Members[0]).DrawingData.GetType().Name == "TextControl")
1535
            {
1536
                this.AngleValue = ((this.Members[0]).DrawingData as TextControl).CommentAngle;
1537
            }
1538
            /// up to here
1539

    
1540
            dBeforeAngle = this.angleValue;
1541

    
1542
            if (ViewerDataModel.Instance.UndoDataList == null)
1543
            {
1544
                return;
1545
            }
1546

    
1547
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1548
            {
1549
                return;
1550
            }
1551

    
1552
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1553
            {
1554
                if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0)
1555
                {
1556
                    if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null)
1557
                    {
1558
                        return;
1559
                    }
1560
                }
1561
            }
1562

    
1563
            var comments = (from drawing in this.Members
1564
                            select drawing.DrawingData as CommentUserInfo).ToList();
1565
            UndoCommand.Instance.Push(comments, this.AngleValue, this.angleValue);
1566
        }
1567
        
1568
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1569
        {
1570
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1571

    
1572
            var comments = (from drawing in this.Members
1573
                            select drawing.DrawingData as CommentUserInfo).ToList();
1574
            UndoCommand.Instance.Push(comments, this.AngleValue, dBeforeAngle);
1575
        }
1576

    
1577
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1578
        {
1579
            AdornerMember control = this.Members.FirstOrDefault();
1580

    
1581
            if ((control.DrawingData as ArrowTextControl) != null)
1582
            {
1583
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1584
                {
1585
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1586
                }
1587
            }
1588

    
1589
        }
1590

    
1591
        public void TextControlChanger()
1592
        {
1593
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1594
            {
1595
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1596
                AllControl.Base_TextBox.Focus();
1597
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1598
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1599
                AllControl.Base_TextBox.IsHitTestVisible = true;
1600
                AllControl.IsEditingMode = true;
1601
                AllControl.Base_TextBox.Focus();
1602

    
1603
                AllControl.SizeChanged += (sen, ea) =>
1604
                {
1605
                    if (AllControl.Base_TextBox != null)
1606
                    {
1607
                        RectangleGeometry Data = new RectangleGeometry
1608
                        {
1609
                            Rect = new Rect()
1610
                            {
1611
                                X = AllControl.StartPoint.X,
1612
                                Y = AllControl.StartPoint.Y,
1613
                                Width = AllControl.Base_TextBox.Width,
1614
                                Height = AllControl.Base_TextBox.Height,
1615
                            }
1616
                        };
1617

    
1618
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1619
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1620
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1621
                        {
1622
                            Angle = AllControl.CommentAngle,
1623
                            CenterX = middle.X,
1624
                            CenterY = middle.Y,
1625
                        };
1626
                    }
1627
                    BorderUpdate();
1628
                };
1629
            }
1630
        }
1631

    
1632
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1633
        {
1634
            if (e.ClickCount == 2 && this.Members.Count == 1)
1635
            {
1636
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1637
                {
1638
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1639
                    TextControlChanger();                    
1640
                }
1641

    
1642
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1643
                {
1644
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1645
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1646
               
1647
                    //ArrowControl TextBox Thumb없애기
1648
                    tm.Visibility = Visibility.Collapsed;
1649

    
1650
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1651
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1652

    
1653
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1654
                    
1655

    
1656
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1657

    
1658
                    {
1659
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1660
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1661

    
1662
                        List<Point> ps = new List<Point>();
1663
                        
1664
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1665
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1666
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1667
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1668

    
1669

    
1670

    
1671

    
1672
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1673
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1674
                        if (AllControl.isTrans)
1675
                        {
1676
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1677
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1678
                        }
1679
                        else
1680
                        {
1681
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1682
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1683
                        }
1684

    
1685

    
1686
                        BorderUpdate();
1687

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

    
1743
            }
1744
            
1745
        }
1746
        #endregion
1747

    
1748
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1749
        {
1750
            if ((this.Members[0] as AdornerMember).DrawingData.GetType().Name == "TextControl" 
1751
                || (this.Members[0] as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1752
            {
1753
                DragThumb.Visibility = Visibility.Collapsed;
1754
            }
1755
        }
1756
    }
1757
}
클립보드 이미지 추가 (최대 크기: 500 MB)