프로젝트

일반

사용자정보

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

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

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

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

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

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

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

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

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

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

    
157
        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 };
158

    
159
        /// <summary>
160
        /// 회전 시작할때의 각도
161
        /// </summary>
162

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

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

    
179
        public bool IsTextAngle = false;
180
        public Rect BorderSize { get; set; }
181
        public bool TextCompensation = false;
182
        public bool isDragging { get; set; }
183
        public Thumb DraggerThumb { get; set; }
184
        public RadDropDownButton dropData;
185
        public RadCalendar dropCalendar;
186
        public Thumb mainDragThumb { get; set; }
187

    
188
        private bool disposed;
189

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

    
201
        private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
202
        {
203
            dropCalendar = sender as RadCalendar;
204
            dropCalendar.SelectionChanged += (sen, ea) =>
205
            {
206
                dropData.IsOpen = false;
207
                if ((this.Members[0]).DrawingData.GetType().Name == "DateControl")
208
                {
209
                    DateControl data = (this.Members[0]).DrawingData as DateControl;
210
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
211
                }
212
            };
213
        }
214

    
215
        public AdornerFinal()
216
        {
217
            InitializeComponent();
218
            BorderSize = new Rect();
219
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
220
        }
221

    
222
        public AdornerFinal(CommentUserInfo objectData) : this()
223
        {
224
            InitializeComponent();
225
            objectData.IsHitTestVisible = false;
226

    
227
            if (objectData is ArrowTextControl ArrTextCtrl)
228
            {
229
                ArrTextCtrl.Base_TextBox.Focusable = true;
230
            }
231

    
232
            ///Canvas.SetZIndex(objectData, 84);
233
            try
234
            {
235
                objectData.Index = ViewerDataModel.Instance.MarkupControls_USER.IndexOf(objectData);
236
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
237
                this.ContainerContent.Children.Add(objectData);
238
            }
239
            catch (Exception ex)
240
            {
241
                throw new InvalidOperationException(ex.Message);
242
            }
243

    
244
            SetAdornerMember(objectData);
245
            this.Focus();
246
        }
247

    
248
        public AdornerFinal(List<CommentUserInfo> comments) : this()
249
        {
250
            InitializeComponent();
251

    
252
            comments.ForEach(x => x.Index = ViewerDataModel.Instance.MarkupControls_USER.IndexOf(x)); 
253
            foreach (var item in comments)
254
            {
255
                if (item is ArrowTextControl ArrTextCtrl)
256
                {
257
                    ArrTextCtrl.Base_TextBox.Focusable = true;
258
                }
259
                try
260
                {
261
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
262
                    this.ContainerContent.Children.Add(item);
263
                }
264
                catch (Exception ex)
265
                {
266
                    throw new InvalidOperationException(ex.Message);
267
                }
268
                finally
269
                {
270
                }
271
            }
272

    
273
            this.SetAdornerMember(comments);
274
            this.Focus();
275
        }
276

    
277
        ~AdornerFinal()
278
        {
279
            this.Dispose(false);
280
        }
281

    
282
        public void Dispose()
283
        {
284
            this.Dispose(true);
285
            GC.SuppressFinalize(this);
286
        }
287

    
288
        protected virtual void Dispose(bool disposing)
289
        {
290
            if (this.disposed) return;
291
            if (disposing)
292
            {
293
                foreach (var member in this.Members)
294
                {
295
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
296
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
297
                }
298
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
299
            }
300
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
301
            this.disposed = true;
302
        }
303

    
304
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
305
        {
306
            mainDragThumb = DragThumb;
307
        }
308

    
309
        public Point Centeroid
310
        {
311
            get
312
            {
313
                List<Point> pts = new List<Point>();
314

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

    
335
                return MathSet.FindCentroid(pts);
336
            }
337
        }
338

    
339
        #endregion
340
        #region 메서드
341
        public Rect getAdornerSize()
342
        {
343
            return BorderSize;
344
        }
345

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

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

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

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

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

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

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

    
460

    
461
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
462
                    DragThumb.RenderTransform = new RotateTransform()
463
                    {
464
                        Angle = (member as TextControl).CommentAngle,
465
                    };
466

    
467
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
468
                    AdornerBorder.RenderTransform = new RotateTransform()
469
                    {
470
                        Angle = (member as TextControl).CommentAngle,
471
                    };
472

    
473
                    ((TextControl)member).PropertyChanged += TextControlPropertyChanged;
474
                    ((TextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
475
                    break;
476
                default:
477
                    break;
478
                    #endregion
479
            }
480

    
481
            if (member.GetType().Name == "TextControl")
482
            {
483
                TextControl content = ((TextControl)member);
484
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
485
                content.EndPoint = content.StartPoint;
486
            }
487
            else
488
            {
489
                RegistryPoint(member);
490
            }
491
            BorderUpdate();
492

    
493
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
494
                Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
495
        }
496

    
497

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

    
563
                        (member as TextControl).PropertyChanged += TextControlPropertyChanged;
564
                        (member as TextControl).Base_TextBox.SelectionChanged += TextControlSelectionChanged;
565

    
566
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
567
                        //{
568
                        //    BorderUpdate();
569
                        //});
570
                        //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
571
                        //{
572
                        //    BorderUpdate();
573
                        //    try
574
                        //    {
575
                        //        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
576
                        //    }
577
                        //    catch (Exception)
578
                        //    {
579

    
580
                        //    }
581

    
582
                        //});
583
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
584
                        //{
585
                        //    BorderUpdate();
586
                        //});
587
                        break;
588
                    case "InsideWhiteControl":
589
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
590
                        break;
591
                    case "OverlapWhiteControl":
592
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
593
                        break;
594
                    case "ClipWhiteControl":
595
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
596
                        break;
597
                    case "CoordinateControl":
598
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID });
599
                        break;
600
                    default:
601
                        break;
602
                        #endregion
603
                }
604
                if (member.GetType().Name == "TextControl")
605
                {
606
                    TextControl content = ((TextControl)member);
607
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
608
                    content.EndPoint = content.StartPoint;
609
                }
610
                else
611
                {
612
                    RegistryPoint(member, members.Count);
613
                }
614

    
615
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
616
                    Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
617
            }
618

    
619
            BorderUpdate();
620
        }
621

    
622

    
623
        /// <summary>
624
        /// Border 를 갱신
625
        /// </summary>
626
        public void BorderUpdate()
627
        {
628
            AdornerBorder.MinWidth = 10;
629
            AdornerBorder.MinHeight = 10;
630

    
631
            double minX = double.MaxValue;
632
            double minY = double.MaxValue;
633
            double maxX = double.MinValue;
634
            double maxY = double.MinValue; 
635
            double lineSize = 0;
636
            double marginSize = 0;
637
            if (this.Members.Count == 1)
638
            {
639
                if (this.Members[0].DrawingData.GetType().Name == "TextControl")
640
                {
641
                    if ((this.Members[0].DrawingData as TextControl).CommentAngle != 0)
642
                    {
643
                        trRotate.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
644
                        trRotateThumb.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
645
                    }
646
                    else
647
                    {
648
                        trRotate.Angle = 0;
649
                        trRotateThumb.Angle = 0;
650
                    }
651
                }
652
            }
653

    
654
            foreach (var item in this.Members)
655
            {
656
                UIElement currentControl = item.DrawingData;
657
                
658
                Point startP = (currentControl as IPath).StartPoint;
659
                Point endP = (currentControl as IPath).EndPoint;
660

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

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

    
666
                if (item.DrawingData.GetType().Name == "TextControl")
667
                {
668
                    double textControlWidth;
669
                    double textControlHeight;
670
                             
671
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
672
                    {
673
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
674
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
675
                    }
676
                    else
677
                    {
678
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
679
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
680
                    }
681
                    
682
                    if ((currentControl as TextControl).EndPoint.X < minX)
683
                    {
684
                        minX = (currentControl as TextControl).EndPoint.X;
685
                    }
686

    
687
                    if ((currentControl as TextControl).EndPoint.Y < minY)
688
                    {
689
                        minY = (currentControl as TextControl).EndPoint.Y;
690
                    }
691

    
692
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
693
                    {
694
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
695
                    }
696

    
697
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
698
                    {
699
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
700
                    }
701
                    if ((currentControl as TextControl).ControlType_No == 2)
702
                        marginSize = (((currentControl as TextControl).Base_TextPath).ActualHeight - ((currentControl as TextControl).Base_Border).ActualHeight) / 2 + (((dynamic)currentControl).LineSize.Left / 2) + (currentControl as TextControl).ArcLength - 30;
703
                    if ((currentControl as TextControl).ControlType_No == 1)
704
                        marginSize = ((dynamic)currentControl).LineSize.Left;
705
                }
706
                else if ((currentControl as IViewBox) != null)
707
                {
708
                    IViewBox instance = currentControl as IViewBox;
709
                    List<Point> am = (currentControl as IPath).PointSet;
710
                    List<double> xSet = am.Select(p => p.X).ToList();
711
                    List<double> ySet = am.Select(p => p.Y).ToList();
712
                    if (xSet.Min() < minX) minX = xSet.Min();
713
                    if (ySet.Min() < minY) minY = ySet.Min();
714
                    if (xSet.Max() > maxX) maxX = xSet.Max();
715
                    if (ySet.Max() > maxY) maxY = ySet.Max();
716
                }
717
                else if ((currentControl as IPath).PathData == null)
718
                {
719
                    Rect rt = new Rect
720
                    {
721
                        X = (currentControl as IPath).StartPoint.X,
722
                        Y = (currentControl as IPath).StartPoint.Y,
723
                        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),
724
                        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),
725
                    };
726
                    if (rt.Left < minX) minX = rt.Left;
727
                    if (rt.Top < minY) minY = rt.Top;
728
                    if (rt.Right > maxX) maxX = rt.Right;
729
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
730
                }
731
                else if ((currentControl as IPath) == null)
732
                {
733
                    Rect rt = new Rect
734
                    {
735
                        X = (currentControl as IPath).StartPoint.X,
736
                        Y = (currentControl as IPath).StartPoint.Y,
737
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
738
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
739
                    };
740
                    if (rt.Left < minX) minX = rt.Left;
741
                    if (rt.Top < minY) minY = rt.Top;
742
                    if (rt.Right > maxX) maxX = rt.Right;
743
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
744
                }
745
                else if (currentControl is CircleControl CircleCtrl)
746
                {
747
                    List<Point> am = CircleCtrl.PointSet;
748
                    lineSize = CircleCtrl.LineSize;
749

    
750
                    List<double> xSet = am.Select(p => p.X).ToList();
751
                    List<double> ySet = am.Select(p => p.Y).ToList();
752
                    if (xSet.Min() < minX) minX = xSet.Min();
753
                    if (ySet.Min() < minY) minY = ySet.Min();
754
                    if (xSet.Max() > maxX) maxX = xSet.Max();
755
                    if (ySet.Max() > maxY) maxY = ySet.Max();
756
                }
757
                else 
758
                {
759
                    lineSize = ((dynamic)currentControl).LineSize;
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
            //lineSize : Thickness 굵기에 따라서 adoner 수정 
782
            ac.Width += lineSize;
783
            ac.Height += lineSize;
784
            AdornerBorder.MinWidth = 10;
785
            AdornerBorder.MinHeight = 10;
786
            AdornerBorder.Width = ac.Width;
787
            AdornerBorder.Height = ac.Height;
788
            minX -= lineSize / 2;
789
            minY -= lineSize / 2;
790
            Canvas.SetLeft(AdornerBorder, minX);
791
            Canvas.SetTop(AdornerBorder, minY);
792

    
793
            DragThumb.Width = ac.Width;
794
            DragThumb.Height = ac.Height;
795
            rotateTop.Margin = new Thickness(rotateTop.Margin.Left, -30 - marginSize, rotateTop.Margin.Right, rotateTop.Margin.Bottom);
796
            DragThumb.MinWidth = 10;
797
            DragThumb.MinHeight = 10;
798
            if (addWidthSize)
799
            {
800
                Canvas.SetLeft(DragThumb, minX - 5);
801
            }
802
            else
803
            {
804
                Canvas.SetLeft(DragThumb, minX);
805
            }
806

    
807
            if (addHeightSize)
808
            {
809
                Canvas.SetTop(DragThumb, minY - 5);
810
            }
811
            else
812
            {
813
                Canvas.SetTop(DragThumb, minY);
814
            }
815
        }
816

    
817
        /// <summary>
818
        /// UIElement 해제
819
        /// </summary>
820
        public void UnRegister()
821
        {
822
            foreach (var item in this.ContainerContent.Children)
823
            {
824
                if (item is MarkupToPDF.Common.CommentUserInfo)
825
                {
826
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
827
                }
828
            }
829
            this.ContainerContent.Children.Clear();
830
        }
831

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

    
852
            for (int i = 0; i < pts.Count; i++)
853
            {
854
                MyThumb tm = new MyThumb
855
                {
856
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
857
                };
858

    
859
                this.Members.Last().ThumbList.Add(tm);
860

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

    
872
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
873
                    {
874
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
875

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

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

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

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

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

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

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

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

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

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

    
1029
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
1030
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
1031
                
1032
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
1033
                count++;
1034
            }
1035
        }
1036

    
1037
        private void MidPoint_DragDelta(object sender, DragDeltaEventArgs e)
1038
        {
1039
            MyThumb thumb = sender as MyThumb;
1040
            double newHorizontalChange = e.HorizontalChange;
1041
            double newVerticalChange = e.VerticalChange;
1042

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

    
1045
            var direction = VisualHelper.GetPointDirection(newpoint, ViewerDataModel.Instance.PageAngle);
1046

    
1047
            System.Diagnostics.Debug.WriteLine("뱡향 : " + direction.ToString());
1048

    
1049
            AdornerMember control = CurrentAdornerMember(thumb);
1050
            var commentInfo = (control.DrawingData) as CommentUserInfo;
1051

    
1052
            if (commentInfo is ArrowTextControl)
1053
            {
1054
                Point getThumbPoint = GetPosition(thumb);
1055

    
1056
                var arrowText = commentInfo as ArrowTextControl;
1057

    
1058
                //var midPoint = MathSet.getMiddlePoint(arrowText.StartPoint, arrowText.EndPoint);
1059
                //arrowText.MidPoint = newpoint;
1060
                thumb.Translate(newpoint.X, newpoint.Y, this.AngleValue);
1061
          
1062
                commentInfo.OnMoveCtrlPoint(getThumbPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1063

    
1064
                control.UpdateThumb();
1065

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

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

    
1071
        }
1072
        
1073

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

    
1083
            MyThumb thumb = sender as MyThumb;
1084

    
1085
            if (this.Members.Count > 1) return;
1086

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

    
1089
            double newHorizontalChange = e.HorizontalChange;
1090
            double newVerticalChange = e.VerticalChange;
1091

    
1092
            //if (reSizePoint != new Point(0, 0))
1093
            //{
1094
                //Point setPoint = Mouse.GetPosition(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanCanvas);
1095

    
1096
                Point setPoint = GetPosition(thumb);
1097

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

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

    
1103
                double ratatePointAngle = 0;
1104

    
1105
                if (commentInfo is ArrowTextControl)
1106
                {
1107
                    var textControl = (commentInfo as ArrowTextControl);
1108

    
1109
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1110

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

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

    
1130
                var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1131
     
1132
                Point thumbPoint = MathHelper.RotatePoint(setPoint, new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1133

    
1134
                //thumbPoint.X = Math.Abs(thumbPoint.X);
1135
                //thumbPoint.Y = Math.Abs(thumbPoint.Y);
1136

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

    
1142
                //if (setPoint.Y + newpoint.Y < 0 || (Math.Abs(thumbPoint.Y) + newpoint.Y) - ViewerDataModel.Instance.ImageViewHeight > 0)
1143
                //{
1144
                //    newpoint.Y = 0;
1145
                //}
1146

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

    
1149
                //System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1150
                control.UpdateThumb();
1151

    
1152
                //System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1153
                this.BorderUpdate();
1154

    
1155
               //System.Diagnostics.Debug.WriteLine($"5. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1156
            //}
1157
        }
1158

    
1159
        private AdornerMember CurrentAdornerMember(MyThumb thumb)
1160
        {
1161
            AdornerMember result = null;
1162

    
1163
            try
1164
            {
1165
                result = (from userThumb in this.Members
1166
                            where userThumb.ThumbList.Contains(thumb)
1167
                            select userThumb).FirstOrDefault();
1168
            }
1169
            catch (Exception ex)
1170
            {
1171
                App.FileLogger.Error(ex);
1172
            }
1173

    
1174
            return result;
1175
        }
1176

    
1177
        private Point GetPosition(Thumb thumb)
1178
        {
1179
            return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
1180
        }
1181

    
1182
        #endregion
1183
        #region 이벤트
1184

    
1185
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1186
        {
1187
            this.isDragging = false;
1188
            DraggerThumb = null;
1189

    
1190

    
1191
            var comments = (from drawing in this.Members
1192
                            select drawing.DrawingData as CommentUserInfo).ToList();
1193
            ViewerDataModel.Instance.IsMarkupUpdate = true;
1194
        }
1195

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

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

    
1211
            var comments = (from drawing in this.Members
1212
                            select drawing.DrawingData as CommentUserInfo).ToList();
1213

    
1214
            UndoCommand.Instance.Push(EventType.Operation, comments);
1215
        }
1216

    
1217
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1218
        {
1219
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1220
            {
1221
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1222
                    IsTextAngle = true;
1223
                else
1224
                    IsTextAngle = false;
1225
                LastRotateVerticalValue = e.GetPosition(this).X;
1226
            }
1227
            else
1228
            {
1229
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1230
                {
1231
                    RotateFlag = true;
1232
                }
1233
                else
1234
                {
1235
                    RotateFlag = false;
1236
                }
1237
                LastRotateHorizontalValue = e.GetPosition(this).X;
1238
            }
1239
        }
1240

    
1241
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1242
        {
1243
            /// save mouse down and current mouse point
1244
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1245
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1246
            /// up to here
1247

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

    
1253
            var comments = (from drawing in this.Members
1254
                            select drawing.DrawingData as CommentUserInfo).ToList();
1255

    
1256
            UndoCommand.Instance.Push(EventType.Operation, comments);
1257
        }
1258

    
1259
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1260
        {
1261
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1262

    
1263
            var comments = (from drawing in this.Members
1264
                            select drawing.DrawingData as CommentUserInfo).ToList();
1265
        }
1266

    
1267
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1268
        {
1269
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1270

    
1271
            var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1272
         
1273
            var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1274
            var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1275

    
1276
            try
1277
            {
1278
                DragThumb.Cursor = Cursors.SizeAll;
1279
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1280
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1281

    
1282

    
1283
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1284

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

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

    
1289
                var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1290
                
1291
                var moveDirection = mainRect.Movement(rotationRect);
1292

    
1293
                System.Diagnostics.Debug.WriteLine($"horzChange: {horzChange} , vertChange:{vertChange}");
1294

    
1295
                this.TranslateItems(horzChange, vertChange);
1296
            }
1297
            finally
1298
            {
1299
                /// update CurrentMousePoint
1300
                this.CurrentMousePoint = newMousePoint;
1301
            }
1302
        }
1303

    
1304
        /// <summary>
1305
        /// translate all members
1306
        /// </summary>
1307
        /// <param name="e"></param>
1308
        public void TranslateItems(double dx, double dy)
1309
        {
1310
            Dispatcher.BeginInvoke((Action)(() =>
1311
            {
1312
                foreach (var item in this.Members)
1313
                {
1314
                    this.TranslateItem(dx, dy, item);
1315
                }
1316

    
1317
                this.BorderUpdate();
1318
            }));
1319
        }
1320

    
1321
        /// <summary>
1322
        /// translate a item
1323
        /// </summary>
1324
        /// <param name="e"></param>
1325
        /// <param name="item"></param>
1326
        private void TranslateItem(double dx, double dy, AdornerMember item)
1327
        {
1328
            /// rotate point with page rotation
1329
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1330
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1331
            /// up to here
1332
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1333

    
1334
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1335
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), EventType.Operation, null, null);            
1336

    
1337
            item.UpdateThumb();
1338
        }
1339

    
1340
        private void resize_MouseMove(object sender, MouseEventArgs e)
1341
        {
1342
            //reSizePoint = e.GetPosition(this);
1343
        }
1344

    
1345
        /// <summary>
1346
        /// 회전
1347
        /// </summary>
1348
        /// <param name="sender"></param>
1349
        /// <param name="e"></param>
1350
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1351
        {
1352
            MoveRotate(e);
1353
        }
1354

    
1355
        double LastRotateHorizontalValue = 0;
1356
        double LastRotateVerticalValue = 0;
1357
        bool RotateFlag = false;
1358

    
1359
        /// <summary>
1360
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1361
        /// </summary>
1362
        /// <param name="e"></param>
1363
        public void MoveRotate(DragDeltaEventArgs e)
1364
        {
1365
            Point CenterPoint = this.Centeroid;
1366
            Point pt = Mouse.GetPosition(this);
1367

    
1368
            #region X축 기준으로 회전 각도를 구한다.
1369
            Vector AxisX = new Vector(RotatedPoint.X - CenterPoint.X, RotatedPoint.Y - CenterPoint.Y);
1370
            AxisX.Normalize();
1371
            Vector AxisY = new Vector(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1372
            AxisY.Normalize();
1373
            double dDeltaAngle = Vector.AngleBetween(AxisX, AxisY);
1374
            #endregion
1375

    
1376
            _ActualAngle += dDeltaAngle;
1377
            if (_ActualAngle > 360) _ActualAngle -= 360;
1378
            if (_ActualAngle < 0) _ActualAngle += 360;
1379
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1380
            if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
1381
            {
1382
                double tmp = AlignedAngles.OrderBy(x => Math.Abs(_ActualAngle - x)).First();
1383
                dDeltaAngle = tmp - AngleValue;
1384
                AngleValue = tmp;
1385
            }
1386
            else
1387
            {
1388
                AngleValue = _ActualAngle;
1389
            }
1390
            #endregion
1391

    
1392
            /// save rotatePoint
1393
            this.RotatedPoint = pt;
1394

    
1395
            Dispatcher.BeginInvoke((Action)(() =>
1396
            {
1397
                foreach (var member in this.Members)
1398
                {
1399
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1400
                    #region 보더 업데이트
1401
                    switch (member.Drawingtype)
1402
                    {
1403
                        case ControlType.TextControl:
1404
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1405

    
1406
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1407
                            DragThumb.RenderTransform = new RotateTransform()
1408
                            {
1409
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1410
                            };
1411

    
1412
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1413
                            AdornerBorder.RenderTransform = new RotateTransform()
1414
                            {
1415
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1416
                            };
1417

    
1418
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1419
                            BorderUpdate();
1420
                            break;
1421

    
1422
                        case ControlType.ArrowMultiLine:
1423
                        case ControlType.ArcLine:
1424
                        case ControlType.ArcArrow:
1425
                        case ControlType.SingleLine:
1426
                        case ControlType.Triangle:
1427
                        case ControlType.ArrowTextControl:
1428
                        case ControlType.PolygonControl:
1429
                        case ControlType.Ink:
1430
                            BorderUpdate();
1431
                            break;
1432
                        case ControlType.Date:
1433
                        case ControlType.RectCloud:
1434
                        case ControlType.Rectangle:
1435
                        case ControlType.ImgControl:
1436
                        case ControlType.Sign:
1437
                        case ControlType.Symbol:
1438
                        case ControlType.Stamp:
1439
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1440
                            BorderUpdate();
1441
                            break;
1442
                        case ControlType.PolygonCloud:
1443
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1444
                            BorderUpdate();
1445
                            break;
1446
                        case ControlType.Circle:
1447
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1448
                            ((CircleControl)member.DrawingData).SetCenterXY();
1449
                            BorderUpdate();
1450
                            break;
1451
                        default:
1452
                            break;
1453
                    }
1454
                }
1455
                #endregion
1456
            }));
1457
        }
1458

    
1459
        /// <summary>
1460
        /// 객체 회전 시작
1461
        /// </summary>
1462
        /// <param name="sender"></param>
1463
        /// <param name="e"></param>
1464
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1465
        {            
1466
            this.RotatedPoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1467
            rotateTop.Cursor = Cursors.SizeAll;
1468

    
1469
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1470
            if ((1 == this.Members.Count) && (this.Members[0]).DrawingData.GetType().Name == "TextControl")
1471
            {
1472
                this.AngleValue = ((this.Members[0]).DrawingData as TextControl).CommentAngle;
1473
            }
1474
            /// up to here
1475

    
1476
            if (ViewerDataModel.Instance.UndoDataList == null)
1477
            {
1478
                return;
1479
            }
1480

    
1481
            var comments = (from drawing in this.Members
1482
                            select drawing.DrawingData as CommentUserInfo).ToList();
1483
            UndoCommand.Instance.Push(EventType.Operation, comments);
1484
        }
1485
        
1486
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1487
        {
1488
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1489

    
1490
            var comments = (from drawing in this.Members
1491
                            select drawing.DrawingData as CommentUserInfo).ToList();
1492
        }
1493

    
1494
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1495
        {
1496
            AdornerMember control = this.Members.FirstOrDefault();
1497

    
1498
            if ((control.DrawingData as ArrowTextControl) != null)
1499
            {
1500
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1501
                {
1502
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1503
                }
1504
            }
1505

    
1506
        }
1507

    
1508
        public void TextControlChanger()
1509
        {
1510
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1511
            {
1512
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1513
                AllControl.Base_TextBox.Focus();
1514
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1515
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1516
                AllControl.Base_TextBox.IsHitTestVisible = true;
1517
                AllControl.IsEditingMode = true;
1518
                AllControl.Base_TextBox.Focus();
1519

    
1520
                AllControl.SizeChanged += (sen, ea) =>
1521
                {
1522
                    if (AllControl.Base_TextBox != null)
1523
                    {
1524
                        RectangleGeometry Data = new RectangleGeometry
1525
                        {
1526
                            Rect = new Rect()
1527
                            {
1528
                                X = AllControl.StartPoint.X,
1529
                                Y = AllControl.StartPoint.Y,
1530
                                Width = AllControl.Base_TextBox.Width,
1531
                                Height = AllControl.Base_TextBox.Height,
1532
                            }
1533
                        };
1534

    
1535
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1536
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1537
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1538
                        {
1539
                            Angle = AllControl.CommentAngle,
1540
                            CenterX = middle.X,
1541
                            CenterY = middle.Y,
1542
                        };
1543
                    }
1544
                    BorderUpdate();
1545
                };
1546
            }
1547
        }
1548

    
1549
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1550
        {
1551
            if (e.ClickCount == 2 && this.Members.Count == 1)
1552
            {
1553
                if (this.Members[0].DrawingData.GetType().Name == "TextControl")
1554
                {
1555
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1556
                    TextControlChanger();                    
1557
                }
1558

    
1559
                else if (this.Members[0].DrawingData.GetType().Name == "ArrowTextControl")
1560
                {
1561
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1562
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1563
               
1564
                    //ArrowControl TextBox Thumb없애기
1565
                    tm.Visibility = Visibility.Collapsed;
1566

    
1567
                    (this.Members[0].DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1568
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1569

    
1570
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1571
                    
1572

    
1573
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1574

    
1575
                    {
1576
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1577
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1578

    
1579
                        List<Point> ps = new List<Point>();
1580
                        
1581
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1582
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1583
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1584
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1585

    
1586
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1587
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1588
                        if (AllControl.isTrans)
1589
                        {
1590
                            Canvas.SetLeft((this.Members[0]).ThumbList[1], AllControl.MidPoint.X);
1591
                            Canvas.SetTop((this.Members[0]).ThumbList[1], AllControl.MidPoint.Y);
1592
                        }
1593
                        else
1594
                        {
1595
                            Canvas.SetLeft((this.Members[0]).ThumbList[1], tempP.X);
1596
                            Canvas.SetTop((this.Members[0]).ThumbList[1], tempP.Y);
1597
                        }
1598

    
1599

    
1600
                        BorderUpdate();
1601

    
1602
                    };
1603
                }
1604
                else if ((this.Members[0]).DrawingData.GetType().Name == "DateControl")
1605
                {
1606
                    DateControl data = (this.Members[0]).DrawingData as DateControl;
1607
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1608
                    //dropData.IsOpen = true;
1609
                    RadWindow rc = new RadWindow();
1610
                    rc.Width = 300;
1611
                    rc.Height = 300;
1612
                    rc.Header = "Change Date";
1613
                    rc.Content = instanceCal;
1614
                    rc.BorderThickness = new Thickness(3);
1615
                    rc.ResizeMode = ResizeMode.NoResize;
1616
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1617
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1618
                    rc.ModalBackground.Opacity = 0.6;
1619
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1620
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1621
                    {
1622
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1623
                        rc.Close();
1624
                    };
1625
                    rc.ShowDialog();
1626
                    //CalendarControl.xaml
1627
                }
1628
                else if ((this.Members[0]).DrawingData.GetType().Name == "ArcControl")
1629
                {
1630
                    ArcControl instance = ((this.Members[0]).DrawingData as ArcControl);
1631
                    if (instance.isTransOn)
1632
                    {
1633
                        instance.isTransOn = false;
1634
                    }
1635
                    else
1636
                    {
1637
                        instance.isTransOn = true;
1638
                    }
1639
                    ///instance.SetArcPath();
1640
                    BorderUpdate();
1641
                }
1642
                else if ((this.Members[0]).DrawingData.GetType().Name == "ArrowArcControl")
1643
                {
1644
                    ArrowArcControl instance = ((this.Members[0]).DrawingData as ArrowArcControl);
1645
                    if (instance.isTransOn)
1646
                    {
1647
                        instance.isTransOn = false;
1648
                    }
1649
                    else
1650
                    {
1651
                        instance.isTransOn = true;
1652
                    }
1653
                    instance.SetArcPath();
1654
                    BorderUpdate();
1655
                }
1656
            }
1657
        }
1658
        #endregion
1659

    
1660
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1661
        {
1662
            if (this.Members[0].DrawingData.GetType().Name == "TextControl" 
1663
                || this.Members[0].DrawingData.GetType().Name == "ArrowTextControl")
1664
            {
1665
                DragThumb.Visibility = Visibility.Collapsed;
1666
            }
1667
        }
1668
    }
1669
}
클립보드 이미지 추가 (최대 크기: 500 MB)