프로젝트

일반

사용자정보

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

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

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

1 787a4489 KangIngu
using KCOM.Common;
2 d128ceb2 humkyung
using KCOM.Events;
3 787a4489 KangIngu
using MarkupToPDF.Common;
4 684ef11c ljiyeon
using MarkupToPDF.Controls.Cad;
5 787a4489 KangIngu
using MarkupToPDF.Controls.Common;
6
using MarkupToPDF.Controls.Etc;
7
using MarkupToPDF.Controls.Line;
8 105359ce ljiyeon
using MarkupToPDF.Controls.Parsing;
9 787a4489 KangIngu
using MarkupToPDF.Controls.Polygon;
10
using MarkupToPDF.Controls.Shape;
11
using MarkupToPDF.Controls.Text;
12
using System;
13
using System.Collections.Generic;
14 53880c83 ljiyeon
using System.Diagnostics;
15 787a4489 KangIngu
using System.Linq;
16
using System.Text;
17 8e5a4a6a taeseongkim
using System.Threading.Tasks;
18 787a4489 KangIngu
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 f513c215 humkyung
    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 3dbace4e taeseongkim
        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 d2114d3b humkyung
        /// <summary>
46 f513c215 humkyung
        /// </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 787a4489 KangIngu
    /// <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 f513c215 humkyung
        public List<MyThumb> ThumbList { get; set; }
74 c8e9b3e4 ljiyeon
        public string Symbol_ID { get; set; }
75 53880c83 ljiyeon
        public long Group_ID { get; set; }
76 508c3ac5 humkyung
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 3b797b23 humkyung
            if (this.DrawingData is ArrowTextControl ArrowTextCtrl)
90 508c3ac5 humkyung
            {
91 3b797b23 humkyung
                if (!ArrowTextCtrl.isTrans) //trans가 True인경우
92 508c3ac5 humkyung
                {
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 554aae3b humkyung
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 787a4489 KangIngu
    }
151 4913851c humkyung
152 787a4489 KangIngu
    public partial class AdornerFinal : UserControl
153
    {
154
        public TextBox editTextBox { get; set; }
155
        #region 공용 인스턴스
156 4913851c humkyung
        public List<AdornerMember> Members { get; } = new List<AdornerMember>();
157 787a4489 KangIngu
        public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>();
158 b643fcca taeseongkim
159 edef7af2 humkyung
        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 e65e8c5c humkyung
        /// <summary>
162
        /// 회전 시작할때의 각도
163
        /// </summary>
164 fd452a01 swate0609
        public double dBeforeAngle { get; set; }
165 b643fcca taeseongkim
166 e65e8c5c humkyung
        private double angleValue;
167 b643fcca taeseongkim
        public double AngleValue { get => angleValue;
168
            set
169
            {
170
                if(angleValue != value)
171
                {
172
                    angleValue = value;
173
                }
174
            }
175
        }
176
177 e65e8c5c humkyung
        /// <summary>
178
        /// Axis Lock을 적용하지 않는 실제 회전 각도
179
        /// </summary>
180
        private double _ActualAngle { get; set; }
181
182 fd452a01 swate0609
        public List<Point> lstBeforePointSet { get; set; }
183
184 787a4489 KangIngu
        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 4913851c humkyung
        private bool disposed;
194
195 787a4489 KangIngu
        public Point reSizePoint { get; set; }
196 e65e8c5c humkyung
        private Point RotatedPoint { get; set; } /// 2018.05.09 added by humkyung
197 0d00f9c8 humkyung
        private Point MouseDownPoint = new Point();
198
        private Point CurrentMousePoint = new Point();
199 787a4489 KangIngu
        #endregion
200
        #region 생성자
201
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
202
        {
203
            dropData = sender as RadDropDownButton;
204
        }
205 4913851c humkyung
206 787a4489 KangIngu
        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 4913851c humkyung
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
213 787a4489 KangIngu
                {
214 4913851c humkyung
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
215 787a4489 KangIngu
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
216
                }
217
            };
218
        }
219 4913851c humkyung
220 787a4489 KangIngu
        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 4913851c humkyung
        }
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 787a4489 KangIngu
        }
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 1305c420 taeseongkim
264 787a4489 KangIngu
            if ((objectData as ArrowTextControl) != null)
265
            {
266
                (objectData as ArrowTextControl).Base_TextBox.Focusable = true;
267
            }
268 1305c420 taeseongkim
269 787a4489 KangIngu
            Canvas.SetZIndex(objectData, 84);
270
            try
271
            {
272 05009a0e ljiyeon
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
273 787a4489 KangIngu
                this.ContainerContent.Children.Add(objectData);
274
            }
275 1066bae3 ljiyeon
            catch (Exception ex)
276 787a4489 KangIngu
            {
277
278
            }
279 1066bae3 ljiyeon
           
280 787a4489 KangIngu
            SetAdornerMember(objectData as CommentUserInfo);
281
            this.Focus();
282
        }
283 4913851c humkyung
284 9b7cda70 KangIngu
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
285 787a4489 KangIngu
        {
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 a0bab669 KangIngu
                    Canvas.SetZIndex(item, 80);
297 05009a0e ljiyeon
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
298 787a4489 KangIngu
                    this.ContainerContent.Children.Add(item);
299
                }
300 53880c83 ljiyeon
                catch //(Exception ex)
301 787a4489 KangIngu
                {
302
                }
303 1066bae3 ljiyeon
                finally
304
                {
305
                    
306
                }
307 787a4489 KangIngu
            }
308 4913851c humkyung
            this.SetAdornerMember(objectData);
309 787a4489 KangIngu
            this.Focus();
310
        }
311
312 62b6bcde humkyung
        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 fa48eb85 taeseongkim
                            AngleValue = (item.DrawingData as TextControl).CommentAngle;
326 62b6bcde humkyung
                        }
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 b643fcca taeseongkim
        #endregion
343
        #region 메서드
344
        public Rect getAdornerSize()
345 787a4489 KangIngu
        {
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 902faaea taeseongkim
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 24c5e56c taeseongkim
            if (sender is TextControl)
373 902faaea taeseongkim
            {
374
                TextCompensation = true;
375
                BorderUpdate();
376
            }
377
        }
378
379
        private void TextControlSelectionChanged(object sender, RoutedEventArgs e)
380
        {
381
            BorderUpdate();
382
        }
383
384 3b797b23 humkyung
        
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 787a4489 KangIngu
        /// <summary>
394
        /// UIElement를 종류에 맞게 등록시킴
395
        /// </summary>
396
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
397
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
398 53880c83 ljiyeon
        {
399 787a4489 KangIngu
            switch (member.GetType().Name)
400
            {
401
                #region 컨트롤 조건
402 554aae3b humkyung
                case "LineControl":
403
                case "PolygonControl":
404 787a4489 KangIngu
                case "ArrowControl":
405 554aae3b humkyung
                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 e65e8c5c humkyung
                    _ActualAngle = AngleValue = member.CommentAngle;
420 787a4489 KangIngu
                    break;
421
                case "ArrowTextControl":
422 4913851c humkyung
                    this.Members.Add(new AdornerMember
423 53880c83 ljiyeon
                    {
424
                        DrawingData = member,
425
                        Drawingtype = ControlType.ArrowTextControl,
426 f513c215 humkyung
                        ThumbList = new List<MyThumb>(),
427 53880c83 ljiyeon
                        Symbol_ID = member.SymbolID,
428
                        Group_ID = member.GroupID,
429
                    });
430 787a4489 KangIngu
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
431 e65e8c5c humkyung
                    _ActualAngle = AngleValue = (member as ArrowTextControl).CommentAngle;
432 902faaea taeseongkim
433
                    ((ArrowTextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
434 787a4489 KangIngu
                    break;
435 554aae3b humkyung
                case "ImgControl":
436 2d2252ba ljiyeon
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
437 e65e8c5c humkyung
                    _ActualAngle = AngleValue = (member as ImgControl).CommentAngle;
438 2d2252ba ljiyeon
                    break;
439 787a4489 KangIngu
                case "DateControl":
440 2d2252ba ljiyeon
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
441 e65e8c5c humkyung
                    _ActualAngle = AngleValue = (member as DateControl).CommentAngle;
442 2d2252ba ljiyeon
                    break;
443 787a4489 KangIngu
                case "SignControl":
444 2d2252ba ljiyeon
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
445 e65e8c5c humkyung
                    _ActualAngle = AngleValue = (member as SignControl).CommentAngle;
446 2d2252ba ljiyeon
                    break;
447 787a4489 KangIngu
                case "SymControl":
448 2d2252ba ljiyeon
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
449 e65e8c5c humkyung
                    _ActualAngle = AngleValue = (member as SymControl).CommentAngle;
450 2d2252ba ljiyeon
                    break;
451 787a4489 KangIngu
                case "SymControlN":
452 554aae3b humkyung
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
453 e65e8c5c humkyung
                    _ActualAngle = AngleValue = (member as SymControlN).CommentAngle;
454 787a4489 KangIngu
                    break;
455
                case "TextControl":
456 f513c215 humkyung
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
457 787a4489 KangIngu
                    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 fa48eb85 taeseongkim
                        Angle = (member as TextControl).CommentAngle,
475 787a4489 KangIngu
                    };
476
477
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
478
                    AdornerBorder.RenderTransform = new RotateTransform()
479
                    {
480 fa48eb85 taeseongkim
                        Angle = (member as TextControl).CommentAngle,
481 787a4489 KangIngu
                    };
482 902faaea taeseongkim
483
                    ((TextControl)member).PropertyChanged += TextControlPropertyChanged;
484
                    ((TextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
485 787a4489 KangIngu
                    break;
486
                default:
487
                    break;
488
                    #endregion
489
            }
490 554aae3b humkyung
491 787a4489 KangIngu
            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 4913851c humkyung
503 ab7fe8c0 humkyung
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
504
                Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
505 787a4489 KangIngu
        }
506
507 4913851c humkyung
508 787a4489 KangIngu
        public void SetAdornerMember(List<CommentUserInfo> members)
509
        {
510
            foreach (var member in members)
511
            {
512
                switch (member.GetType().Name)
513
                {
514
                    #region 컨트롤 조건
515 53880c83 ljiyeon
                    case "LineControl":
516 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
517 53880c83 ljiyeon
                        break;
518
                    case "ImgControl":
519 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
520 787a4489 KangIngu
                        break;
521
                    case "ArrowControl":
522 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
523 787a4489 KangIngu
                        break;
524 53880c83 ljiyeon
                    case "PolygonControl":
525 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
526 787a4489 KangIngu
                        break;
527
                    case "ArrowTextControl":
528 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
529 787a4489 KangIngu
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
530
                        break;
531
                    case "ArcControl":
532 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
533 787a4489 KangIngu
                        break;
534 40b3ce25 ljiyeon
                    case "ArrowArcControl":
535 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
536 40b3ce25 ljiyeon
                        break;
537 787a4489 KangIngu
                    case "DateControl":
538 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
539 787a4489 KangIngu
                        break;
540
                    case "ArrowControl_Multi":
541 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
542 787a4489 KangIngu
                        break;
543
                    case "RectangleControl":
544 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
545 787a4489 KangIngu
                        break;
546
                    case "TriControl":
547 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
548 787a4489 KangIngu
                        break;
549
                    case "CircleControl":
550 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
551 787a4489 KangIngu
                        break;
552
                    case "CloudControl":
553 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
554 787a4489 KangIngu
                        break;
555
                    case "RectCloudControl":
556 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
557 787a4489 KangIngu
                        break;
558
                    case "SignControl":
559 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
560 787a4489 KangIngu
                        break;
561
                    case "SymControl":
562 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
563 787a4489 KangIngu
                        break;
564
                    case "SymControlN":
565 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
566 787a4489 KangIngu
                        break;
567 53880c83 ljiyeon
                    case "InkControl":
568 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
569 787a4489 KangIngu
                        break;
570
                    case "TextControl":
571 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
572 787a4489 KangIngu
573 902faaea taeseongkim
                        (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 787a4489 KangIngu
                        break;
598 684ef11c ljiyeon
                    case "InsideWhiteControl":
599 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
600 684ef11c ljiyeon
                        break;
601
                    case "OverlapWhiteControl":
602 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
603 684ef11c ljiyeon
                        break;
604
                    case "ClipWhiteControl":
605 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
606 684ef11c ljiyeon
                        break;
607
                    case "CoordinateControl":
608 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
609 684ef11c ljiyeon
                        break;
610 787a4489 KangIngu
                    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 4913851c humkyung
625 ab7fe8c0 humkyung
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
626
                    Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
627 787a4489 KangIngu
            }
628
629
            BorderUpdate();
630
        }
631
632 902faaea taeseongkim
633 787a4489 KangIngu
        /// <summary>
634
        /// Border 를 갱신
635
        /// </summary>
636
        public void BorderUpdate()
637
        {
638
            AdornerBorder.MinWidth = 10;
639
            AdornerBorder.MinHeight = 10;
640
641 992a98b4 KangIngu
            double minX = double.MaxValue;
642
            double minY = double.MaxValue;
643
            double maxX = double.MinValue;
644
            double maxY = double.MinValue;
645 787a4489 KangIngu
646 4913851c humkyung
            if (this.Members.Count == 1)
647 787a4489 KangIngu
            {
648 3b797b23 humkyung
                if (this.Members[0].DrawingData.GetType().Name == "TextControl")
649 787a4489 KangIngu
                {
650 3b797b23 humkyung
                    if ((this.Members[0].DrawingData as TextControl).CommentAngle != 0)
651 787a4489 KangIngu
                    {
652 3b797b23 humkyung
                        trRotate.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
653
                        trRotateThumb.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
654 787a4489 KangIngu
                    }
655
                    else
656
                    {
657
                        trRotate.Angle = 0;
658
                        trRotateThumb.Angle = 0;
659
                    }
660
                }
661
            }
662 3b797b23 humkyung
663 4913851c humkyung
            foreach (var item in this.Members)
664 787a4489 KangIngu
            {
665
                UIElement currentControl = (item as AdornerMember).DrawingData;
666 b643fcca taeseongkim
667
                Point startP = (currentControl as IPath).StartPoint;
668
                Point endP = (currentControl as IPath).EndPoint;
669
670 902faaea taeseongkim
                // ViewerDataModel.Instance.Angle = MathSet.returnAngle(startP, ref endP, ViewerDataModel.Instance.IsPressShift);
671
672
                // 컨트롤의 angle변환시 상단 anglecontrol에 출력
673 4f017ed3 taeseongkim
                ViewerDataModel.Instance.MarkupAngle = (currentControl as CommentUserInfo).CommentAngle;
674 b643fcca taeseongkim
675 787a4489 KangIngu
                if (item.DrawingData.GetType().Name == "TextControl")
676
                {
677
                    double textControlWidth;
678
                    double textControlHeight;
679 fa48eb85 taeseongkim
680 787a4489 KangIngu
                    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 29010418 ljiyeon
                    
691 787a4489 KangIngu
                    if ((currentControl as TextControl).EndPoint.X < minX)
692
                    {
693
                        minX = (currentControl as TextControl).EndPoint.X;
694
                    }
695 fa48eb85 taeseongkim
696 787a4489 KangIngu
                    if ((currentControl as TextControl).EndPoint.Y < minY)
697
                    {
698
                        minY = (currentControl as TextControl).EndPoint.Y;
699
                    }
700 fa48eb85 taeseongkim
701 787a4489 KangIngu
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
702
                    {
703
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
704
                    }
705 fa48eb85 taeseongkim
706 787a4489 KangIngu
                    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 3b797b23 humkyung
                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 787a4489 KangIngu
                }
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 3b797b23 humkyung
812 787a4489 KangIngu
        /// <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 f513c215 humkyung
827 787a4489 KangIngu
        /// <summary>
828
        /// 각 포인트들을 등록합니다.
829
        /// </summary>
830
        /// <param name="pointset">Drawing Point</param>
831
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
832 53880c83 ljiyeon
        {
833 787a4489 KangIngu
            int count = 0;
834 e65e8c5c humkyung
            List<Point> pts = (member as IPath).PointSet;
835 787a4489 KangIngu
            if (member.GetType().Name == "InkControl")
836
            {
837 e65e8c5c humkyung
                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 787a4489 KangIngu
            }
843 3b797b23 humkyung
            ControlType markT = this.Members.First(p => p.DrawingData == member).Drawingtype;
844 e65e8c5c humkyung
            double Minx = pts.Min(x => x.X);
845
            double Miny = pts.Min(x => x.Y);
846 3b797b23 humkyung
847 e65e8c5c humkyung
            for (int i = 0; i < pts.Count; i++)
848 787a4489 KangIngu
            {
849 f513c215 humkyung
                MyThumb tm = new MyThumb
850 787a4489 KangIngu
                {
851
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
852
                };
853
854 4913851c humkyung
                this.Members.Last().ThumbList.Add(tm);
855 29010418 ljiyeon
856 e65e8c5c humkyung
                if ((markT == ControlType.ArcLine && pts[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && pts[i] == (member as ArrowArcControl).MiddlePoint))
857 787a4489 KangIngu
                {
858
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
859
                }
860
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
861
                {
862 4913851c humkyung
                    //if (this.Members.Count()<=1)
863 787a4489 KangIngu
                    //{
864
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
865
                    List<Point> ps = new List<Point>();
866
867 4913851c humkyung
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
868 787a4489 KangIngu
                    {
869 4913851c humkyung
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
870 787a4489 KangIngu
871 fa48eb85 taeseongkim
                        switch (Math.Abs(temp.CommentAngle).ToString())
872 787a4489 KangIngu
                        {
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 e65e8c5c humkyung
                            pts[count] = temp.MidPoint;
922 787a4489 KangIngu
                        }
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 e65e8c5c humkyung
                                pts[count] = testP;
946 787a4489 KangIngu
                            }
947
                            else
948
                            {
949
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
950 e65e8c5c humkyung
                                pts[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
951 787a4489 KangIngu
                            }
952
                        }
953
                    }
954
                }
955 39f208de taeseongkim
956
                /// ArrowTextControl text box 화면 출력
957 e65e8c5c humkyung
                if (member.GetType().Name == "ArrowTextControl" && pts[i] == pts.Last())
958 787a4489 KangIngu
                {
959
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
960
                    tm.Width = (member as ArrowTextControl).BoxWidth;
961
                    tm.Height = (member as ArrowTextControl).BoxHeight;
962 fa48eb85 taeseongkim
                    var angle = (member as ArrowTextControl).PageAngle;
963 787a4489 KangIngu
                    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 fa48eb85 taeseongkim
                            Angle = angle
979 787a4489 KangIngu
                        };
980
                    }
981
                }
982 29010418 ljiyeon
                
983 787a4489 KangIngu
                if (member.GetType().Name == "CloudControl")
984
                {
985 e65e8c5c humkyung
                    if (i == pts.Count() - 1)
986 787a4489 KangIngu
                    {
987
                        tm.Visibility = System.Windows.Visibility.Collapsed;
988
                    }
989
                }
990
                if (member.GetType().Name == "PolygonControl")
991
                {
992 e65e8c5c humkyung
                    if (i == pts.Count() - 1)
993 787a4489 KangIngu
                    {
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 29010418 ljiyeon
                
1009 787a4489 KangIngu
                this.ContainerContent.Children.Add(tm);
1010 e65e8c5c humkyung
                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 787a4489 KangIngu
                {
1014
                    Canvas.SetZIndex(tm, 95);
1015 1b2cf911 taeseongkim
                    //tm.Opacity = 0;
1016 3dbace4e taeseongkim
                    tm.DragDelta += MidPoint_DragDelta;
1017 787a4489 KangIngu
                }
1018
                else
1019
                {
1020 3dbace4e taeseongkim
                    tm.DragDelta += ResizeTm_DragDelta;
1021 787a4489 KangIngu
                    Canvas.SetZIndex(tm, 99);
1022
                }
1023
1024
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
1025
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
1026 3dbace4e taeseongkim
                
1027 787a4489 KangIngu
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
1028
                count++;
1029
            }
1030
        }
1031
1032 3dbace4e taeseongkim
        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 41c4405e taeseongkim
            var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), 0);// commentInfo.VisualPageAngle);
1039 3dbace4e taeseongkim
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 41c4405e taeseongkim
          
1057 3dbace4e taeseongkim
                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 ab7fe8c0 humkyung
        /// <summary>
1070
        /// 제어점을 조정하여 크기를 수정한다.
1071
        /// </summary>
1072
        /// <param name="sender"></param>
1073
        /// <param name="e"></param>
1074 787a4489 KangIngu
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
1075
        {
1076 7bb40d38 taeseongkim
            if (sender.GetType() != typeof(MyThumb)) return;
1077
1078
            MyThumb thumb = sender as MyThumb;
1079
1080 d2114d3b humkyung
            if (this.Members.Count > 1) return;
1081 7bb40d38 taeseongkim
1082
            System.Diagnostics.Debug.WriteLine($"Value {e.HorizontalChange},{e.VerticalChange}");
1083
1084
            double newHorizontalChange = e.HorizontalChange;
1085
            double newVerticalChange = e.VerticalChange;
1086
1087 39f208de taeseongkim
            //if (reSizePoint != new Point(0, 0))
1088
            //{
1089 15bbef90 taeseongkim
                //Point setPoint = Mouse.GetPosition(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanCanvas);
1090
1091 39f208de taeseongkim
                Point setPoint = GetPosition(thumb);
1092 8de55603 taeseongkim
1093
                //System.Diagnostics.Debug.WriteLine($"1. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}  Change Value : {newHorizontalChange},{newVerticalChange}");
1094 15bbef90 taeseongkim
1095 8de55603 taeseongkim
                AdornerMember control = CurrentAdornerMember(thumb);
1096
                var commentInfo = (control.DrawingData) as CommentUserInfo;
1097 15bbef90 taeseongkim
1098 39f208de taeseongkim
                double ratatePointAngle = 0;
1099 233ef333 taeseongkim
1100 39f208de taeseongkim
                if (commentInfo is ArrowTextControl)
1101 8de55603 taeseongkim
                {
1102 39f208de taeseongkim
                    var textControl = (commentInfo as ArrowTextControl);
1103 233ef333 taeseongkim
1104 39f208de taeseongkim
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1105
1106
                    {
1107 3dbace4e taeseongkim
                        textControl.CommentAngle = 0;
1108
                        this.AngleValue = 0;
1109
                        ratatePointAngle = commentInfo.VisualPageAngle;
1110 39f208de taeseongkim
                    }
1111
                    else
1112 41c4405e taeseongkim
                    {   
1113 39f208de taeseongkim
                        //textControl.CommentAngle = commentInfo.VisualPageAngle + MathSet.returnAngle(textControl.StartPoint, ref tempPoint, ViewerDataModel.Instance.IsPressShift);
1114 41c4405e taeseongkim
                        textControl.OnCreatingMouseMove(textControl.EndPoint, ViewerDataModel.Instance.IsPressShift);
1115 39f208de taeseongkim
                        this.AngleValue = textControl.CommentAngle;
1116
                        commentInfo.CommentAngle = this.AngleValue;
1117
                    }
1118
                        //CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1119 8de55603 taeseongkim
                }
1120 39f208de taeseongkim
                System.Diagnostics.Debug.WriteLine("## Angle : " + this.AngleValue + " ##");
1121
                thumb.Translate(newHorizontalChange, newVerticalChange, this.AngleValue);
1122
1123
                // 페이지회전에 따른 화살표텍스트 박스의 이동 수정
1124 43e1d368 taeseongkim
1125 39f208de taeseongkim
                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 8de55603 taeseongkim
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 508c3ac5 humkyung
                control.UpdateThumb();
1146 15bbef90 taeseongkim
1147 8de55603 taeseongkim
                //System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1148 508c3ac5 humkyung
                this.BorderUpdate();
1149 15bbef90 taeseongkim
1150 8de55603 taeseongkim
               //System.Diagnostics.Debug.WriteLine($"5. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1151 39f208de taeseongkim
            //}
1152 8de55603 taeseongkim
        }
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 787a4489 KangIngu
            }
1168 8de55603 taeseongkim
1169
            return result;
1170 787a4489 KangIngu
        }
1171
1172 15bbef90 taeseongkim
        private Point GetPosition(Thumb thumb)
1173
        {
1174
            return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
1175
        }
1176
1177 787a4489 KangIngu
        #endregion
1178
        #region 이벤트
1179
1180
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1181
        {
1182
            this.isDragging = false;
1183
            DraggerThumb = null;
1184
1185 fd452a01 swate0609
            List<Point> lstPointTemp = new List<Point>();
1186
            foreach(var vPoint in this.lstBeforePointSet)
1187
            {
1188
                lstPointTemp.Add(vPoint);
1189
            }
1190
1191 4913851c humkyung
            var comments = (from drawing in this.Members
1192 d128ceb2 humkyung
                            select drawing.DrawingData as CommentUserInfo).ToList();
1193 fd452a01 swate0609
            UndoCommand.Instance.Push(comments, this.AngleValue, 0, lstPointTemp);
1194 26ec6226 taeseongkim
            ViewerDataModel.Instance.IsMarkupUpdate = true;
1195 787a4489 KangIngu
        }
1196
1197 ec052e41 humkyung
        /// <summary>
1198
        /// start drag
1199
        /// </summary>
1200
        /// <param name="sender"></param>
1201
        /// <param name="e"></param>
1202 787a4489 KangIngu
        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 fd452a01 swate0609
            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 ec052e41 humkyung
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb))
1224 787a4489 KangIngu
            {
1225
                return;
1226
            }
1227
1228 ec052e41 humkyung
            if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null))
1229 787a4489 KangIngu
            {
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 4913851c humkyung
            var comments = (from drawing in this.Members
1240 d128ceb2 humkyung
                            select drawing.DrawingData as CommentUserInfo).ToList();
1241 fd452a01 swate0609
            UndoCommand.Instance.Push(comments, this.AngleValue, 0, lstBeforePointSet);
1242 787a4489 KangIngu
        }
1243
1244
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1245
        {
1246 4913851c humkyung
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1247 787a4489 KangIngu
            {
1248
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1249
                    IsTextAngle = true;
1250
                else
1251
                    IsTextAngle = false;
1252
                LastRotateVerticalValue = e.GetPosition(this).X;
1253
            }
1254 9f473fb7 KangIngu
            else
1255 53880c83 ljiyeon
            {
1256 9f473fb7 KangIngu
                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 787a4489 KangIngu
        }
1267
1268 8771edc4 humkyung
        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 902faaea taeseongkim
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1302 8771edc4 humkyung
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 6b6e937c taeseongkim
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1309 787a4489 KangIngu
        {
1310 508c3ac5 humkyung
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1311 025ebf74 humkyung
1312 f3ab410f taeseongkim
            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 0d00f9c8 humkyung
            try
1318
            {
1319
                DragThumb.Cursor = Cursors.SizeAll;
1320 39f208de taeseongkim
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1321
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1322 8e5a4a6a taeseongkim
1323
1324 39f208de taeseongkim
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1325 f3ab410f taeseongkim
1326 39f208de taeseongkim
                //if (ViewerDataModel.Instance.PageAngle == 270 || ViewerDataModel.Instance.PageAngle == 90)
1327 f3ab410f taeseongkim
                //{
1328 39f208de taeseongkim
                //    mainRect = new Rect(0, 0, mainRect.Height, mainRect.Width);
1329 f3ab410f taeseongkim
                //}
1330
1331 39f208de taeseongkim
                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 f3ab410f taeseongkim
1339 39f208de taeseongkim
                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 f3ab410f taeseongkim
1342 39f208de taeseongkim
                //if (Math.Abs(horzChange) > 0)
1343 f3ab410f taeseongkim
                //{
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 39f208de taeseongkim
                //if (Math.Abs(vertChange) > 0)
1354 f3ab410f taeseongkim
                //{
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 8de55603 taeseongkim
1364
                this.TranslateItems(horzChange, vertChange);
1365 0d00f9c8 humkyung
            }
1366
            finally
1367
            {
1368
                /// update CurrentMousePoint
1369 f3ab410f taeseongkim
                this.CurrentMousePoint = newMousePoint;
1370 0d00f9c8 humkyung
            }
1371 787a4489 KangIngu
        }
1372 eb2b9248 KangIngu
1373 0d00f9c8 humkyung
        /// <summary>
1374
        /// translate all members
1375
        /// </summary>
1376
        /// <param name="e"></param>
1377
        public void TranslateItems(double dx, double dy)
1378 787a4489 KangIngu
        {
1379
            Dispatcher.BeginInvoke((Action)(() =>
1380
            {
1381 4913851c humkyung
                foreach (var item in this.Members)
1382 787a4489 KangIngu
                {
1383 0d00f9c8 humkyung
                    this.TranslateItem(dx, dy, item);
1384 787a4489 KangIngu
                }
1385 c7fde400 taeseongkim
1386
                this.BorderUpdate();
1387 787a4489 KangIngu
            }));
1388
        }
1389 eb2b9248 KangIngu
1390 0d00f9c8 humkyung
        /// <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 787a4489 KangIngu
        {
1397 554aae3b humkyung
            /// 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 0d00f9c8 humkyung
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1402 105359ce ljiyeon
1403
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1404
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), Event_Type.Thumb, null, null);            
1405
1406 508c3ac5 humkyung
            item.UpdateThumb();
1407 787a4489 KangIngu
        }
1408
1409
        private void resize_MouseMove(object sender, MouseEventArgs e)
1410
        {
1411 39f208de taeseongkim
            //reSizePoint = e.GetPosition(this);
1412 787a4489 KangIngu
        }
1413 0d00f9c8 humkyung
1414 787a4489 KangIngu
        /// <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 9f473fb7 KangIngu
        bool RotateFlag = false;
1427
1428 992a98b4 KangIngu
        /// <summary>
1429
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1430
        /// </summary>
1431
        /// <param name="e"></param>
1432 787a4489 KangIngu
        public void MoveRotate(DragDeltaEventArgs e)
1433
        {
1434 62b6bcde humkyung
            Point CenterPoint = this.Centeroid;
1435 992a98b4 KangIngu
            Point pt = Mouse.GetPosition(this);
1436
1437 edef7af2 humkyung
            #region X축 기준으로 회전 각도를 구한다.
1438 e65e8c5c humkyung
            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 edef7af2 humkyung
            #endregion
1444
1445 e65e8c5c humkyung
            _ActualAngle += dDeltaAngle;
1446
            if (_ActualAngle > 360) _ActualAngle -= 360;
1447
            if (_ActualAngle < 0) _ActualAngle += 360;
1448 edef7af2 humkyung
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1449
            if (ViewerDataModel.Instance.IsAxisLock)
1450
            {
1451 e65e8c5c humkyung
                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 edef7af2 humkyung
            }
1459
            #endregion
1460
1461
            /// save rotatePoint
1462 e65e8c5c humkyung
            this.RotatedPoint = pt;
1463 787a4489 KangIngu
1464
            Dispatcher.BeginInvoke((Action)(() =>
1465
            {
1466 554aae3b humkyung
                foreach (var member in this.Members)
1467 787a4489 KangIngu
                {
1468 554aae3b humkyung
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1469
                    #region 보더 업데이트
1470
                    switch (member.Drawingtype)
1471 787a4489 KangIngu
                    {
1472
                        case ControlType.TextControl:
1473 fa48eb85 taeseongkim
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1474 53880c83 ljiyeon
1475 9b7cda70 KangIngu
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1476 787a4489 KangIngu
                            DragThumb.RenderTransform = new RotateTransform()
1477
                            {
1478 fa48eb85 taeseongkim
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1479 787a4489 KangIngu
                            };
1480
1481 9b7cda70 KangIngu
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1482 787a4489 KangIngu
                            AdornerBorder.RenderTransform = new RotateTransform()
1483
                            {
1484 fa48eb85 taeseongkim
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1485 54e35b39 송근호
                            };
1486 6e035f10 송근호
1487 62b6bcde humkyung
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1488 787a4489 KangIngu
                            BorderUpdate();
1489
                            break;
1490 53880c83 ljiyeon
1491 787a4489 KangIngu
                        case ControlType.ArrowMultiLine:
1492
                        case ControlType.ArcLine:
1493 40b3ce25 ljiyeon
                        case ControlType.ArcArrow:
1494 787a4489 KangIngu
                        case ControlType.SingleLine:
1495
                        case ControlType.Triangle:
1496
                        case ControlType.ArrowTextControl:
1497 554aae3b humkyung
                        case ControlType.PolygonControl:
1498
                        case ControlType.Ink:
1499 787a4489 KangIngu
                            BorderUpdate();
1500
                            break;
1501 554aae3b humkyung
                        case ControlType.Date:
1502 787a4489 KangIngu
                        case ControlType.RectCloud:
1503
                        case ControlType.Rectangle:
1504
                        case ControlType.ImgControl:
1505
                        case ControlType.Sign:
1506
                        case ControlType.Symbol:
1507
                        case ControlType.Stamp:
1508 fa48eb85 taeseongkim
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1509 787a4489 KangIngu
                            BorderUpdate();
1510
                            break;
1511
                        case ControlType.PolygonCloud:
1512 554aae3b humkyung
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1513 787a4489 KangIngu
                            BorderUpdate();
1514
                            break;
1515
                        case ControlType.Circle:
1516 fa48eb85 taeseongkim
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1517 554aae3b humkyung
                            ((CircleControl)member.DrawingData).SetCenterXY();
1518 787a4489 KangIngu
                            BorderUpdate();
1519
                            break;
1520
                        default:
1521
                            break;
1522
                    }
1523
                }
1524
                #endregion
1525
            }));
1526
        }
1527 eb2b9248 KangIngu
1528 787a4489 KangIngu
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1529 29010418 ljiyeon
        {            
1530 e65e8c5c humkyung
            this.RotatedPoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1531 eb2b9248 KangIngu
            rotateTop.Cursor = Cursors.SizeAll;
1532
1533 992a98b4 KangIngu
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1534 3b797b23 humkyung
            if ((1 == this.Members.Count) && (this.Members[0]).DrawingData.GetType().Name == "TextControl")
1535 992a98b4 KangIngu
            {
1536 3b797b23 humkyung
                this.AngleValue = ((this.Members[0]).DrawingData as TextControl).CommentAngle;
1537 992a98b4 KangIngu
            }
1538
            /// up to here
1539
1540 fd452a01 swate0609
            dBeforeAngle = this.angleValue;
1541
1542 01cbc243 KangIngu
            if (ViewerDataModel.Instance.UndoDataList == null)
1543 787a4489 KangIngu
            {
1544
                return;
1545
            }
1546
1547 d128ceb2 humkyung
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)
1548 787a4489 KangIngu
            {
1549
                return;
1550
            }
1551 d128ceb2 humkyung
1552
            if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)
1553 787a4489 KangIngu
            {
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 4913851c humkyung
            var comments = (from drawing in this.Members
1564 d128ceb2 humkyung
                            select drawing.DrawingData as CommentUserInfo).ToList();
1565 fd452a01 swate0609
            UndoCommand.Instance.Push(comments, this.AngleValue, this.angleValue);
1566 787a4489 KangIngu
        }
1567 29010418 ljiyeon
        
1568 787a4489 KangIngu
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1569
        {
1570 902faaea taeseongkim
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1571 d128ceb2 humkyung
1572 4913851c humkyung
            var comments = (from drawing in this.Members
1573 d128ceb2 humkyung
                            select drawing.DrawingData as CommentUserInfo).ToList();
1574 fd452a01 swate0609
            UndoCommand.Instance.Push(comments, this.AngleValue, dBeforeAngle);
1575 787a4489 KangIngu
        }
1576
1577
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1578
        {
1579 4913851c humkyung
            AdornerMember control = this.Members.FirstOrDefault();
1580 787a4489 KangIngu
1581 3dbace4e taeseongkim
            if ((control.DrawingData as ArrowTextControl) != null)
1582 787a4489 KangIngu
            {
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 eb2b9248 KangIngu
1591 787a4489 KangIngu
        public void TextControlChanger()
1592
        {
1593 4913851c humkyung
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1594 787a4489 KangIngu
            {
1595 4913851c humkyung
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1596 787a4489 KangIngu
                AllControl.Base_TextBox.Focus();
1597
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1598
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1599 fa48eb85 taeseongkim
                AllControl.Base_TextBox.IsHitTestVisible = true;
1600 1305c420 taeseongkim
                AllControl.IsEditingMode = true;
1601 787a4489 KangIngu
                AllControl.Base_TextBox.Focus();
1602 fa48eb85 taeseongkim
1603 787a4489 KangIngu
                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 fa48eb85 taeseongkim
                            Angle = AllControl.CommentAngle,
1623 787a4489 KangIngu
                            CenterX = middle.X,
1624
                            CenterY = middle.Y,
1625
                        };
1626
                    }
1627
                    BorderUpdate();
1628
                };
1629
            }
1630
        }
1631 eb2b9248 KangIngu
1632 787a4489 KangIngu
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1633
        {
1634 4913851c humkyung
            if (e.ClickCount == 2 && this.Members.Count == 1)
1635 787a4489 KangIngu
            {
1636 4913851c humkyung
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1637 787a4489 KangIngu
                {
1638 1305c420 taeseongkim
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1639 29010418 ljiyeon
                    TextControlChanger();                    
1640 787a4489 KangIngu
                }
1641
1642 4913851c humkyung
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1643 787a4489 KangIngu
                {
1644 4913851c humkyung
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1645
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1646 1305c420 taeseongkim
               
1647 3797ff05 djkim
                    //ArrowControl TextBox Thumb없애기
1648 787a4489 KangIngu
                    tm.Visibility = Visibility.Collapsed;
1649
1650 4913851c humkyung
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1651 1305c420 taeseongkim
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1652
1653
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1654 29010418 ljiyeon
                    
1655 1305c420 taeseongkim
1656 787a4489 KangIngu
                    ((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 29010418 ljiyeon
                        
1664 787a4489 KangIngu
                        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 4913851c humkyung
                            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 787a4489 KangIngu
                        }
1679
                        else
1680
                        {
1681 4913851c humkyung
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1682
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1683 787a4489 KangIngu
                        }
1684
1685 9b7cda70 KangIngu
1686 787a4489 KangIngu
                        BorderUpdate();
1687 9b7cda70 KangIngu
1688 787a4489 KangIngu
                    };
1689
                }
1690 4913851c humkyung
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1691 787a4489 KangIngu
                {
1692 4913851c humkyung
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1693 787a4489 KangIngu
                    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 4913851c humkyung
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1715 787a4489 KangIngu
                {
1716 4913851c humkyung
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1717 787a4489 KangIngu
                    if (instance.isTransOn)
1718
                    {
1719
                        instance.isTransOn = false;
1720
                    }
1721
                    else
1722
                    {
1723
                        instance.isTransOn = true;
1724
                    }
1725 661b7416 humkyung
                    ///instance.SetArcPath();
1726 787a4489 KangIngu
                    BorderUpdate();
1727
                }
1728 4913851c humkyung
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1729 40b3ce25 ljiyeon
                {
1730 4913851c humkyung
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1731 40b3ce25 ljiyeon
                    if (instance.isTransOn)
1732
                    {
1733
                        instance.isTransOn = false;
1734
                    }
1735
                    else
1736
                    {
1737
                        instance.isTransOn = true;
1738
                    }
1739
                    instance.SetArcPath();
1740
                    BorderUpdate();
1741
                }
1742 787a4489 KangIngu
1743
            }
1744 29010418 ljiyeon
            
1745 787a4489 KangIngu
        }
1746
        #endregion
1747
1748
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1749
        {
1750 3b797b23 humkyung
            if ((this.Members[0] as AdornerMember).DrawingData.GetType().Name == "TextControl" 
1751
                || (this.Members[0] as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1752 787a4489 KangIngu
            {
1753
                DragThumb.Visibility = Visibility.Collapsed;
1754 9b7cda70 KangIngu
            }
1755 787a4489 KangIngu
        }
1756
    }
1757
}
클립보드 이미지 추가 (최대 크기: 500 MB)