프로젝트

일반

사용자정보

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

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

이력 | 보기 | 이력해설 | 다운로드 (75.3 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 b643fcca taeseongkim
165 e65e8c5c humkyung
        private double angleValue;
166 b643fcca taeseongkim
        public double AngleValue { get => angleValue;
167
            set
168
            {
169
                if(angleValue != value)
170
                {
171
                    angleValue = value;
172
                }
173
            }
174
        }
175
176 e65e8c5c humkyung
        /// <summary>
177
        /// Axis Lock을 적용하지 않는 실제 회전 각도
178
        /// </summary>
179
        private double _ActualAngle { get; set; }
180
181 787a4489 KangIngu
        public bool IsTextAngle = false;
182
        public Rect BorderSize { get; set; }
183
        public bool TextCompensation = false;
184
        public bool isDragging { get; set; }
185
        public Thumb DraggerThumb { get; set; }
186
        public RadDropDownButton dropData;
187
        public RadCalendar dropCalendar;
188
        public Thumb mainDragThumb { get; set; }
189
190 4913851c humkyung
        private bool disposed;
191
192 787a4489 KangIngu
        public Point reSizePoint { get; set; }
193 e65e8c5c humkyung
        private Point RotatedPoint { get; set; } /// 2018.05.09 added by humkyung
194 0d00f9c8 humkyung
        private Point MouseDownPoint = new Point();
195
        private Point CurrentMousePoint = new Point();
196 787a4489 KangIngu
        #endregion
197
        #region 생성자
198
        private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e)
199
        {
200
            dropData = sender as RadDropDownButton;
201
        }
202 4913851c humkyung
203 787a4489 KangIngu
        private void Date_Calendar_Loaded(object sender, RoutedEventArgs e)
204
        {
205
            dropCalendar = sender as RadCalendar;
206
            dropCalendar.SelectionChanged += (sen, ea) =>
207
            {
208
                dropData.IsOpen = false;
209 4913851c humkyung
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
210 787a4489 KangIngu
                {
211 4913851c humkyung
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
212 787a4489 KangIngu
                    data.Text = dropCalendar.SelectedDate.Value.ToShortDateString();
213
                }
214
            };
215
        }
216 4913851c humkyung
217 787a4489 KangIngu
        public AdornerFinal()
218
        {
219
            InitializeComponent();
220
            BorderSize = new Rect();
221
            _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true });
222 4913851c humkyung
        }
223
224
        ~AdornerFinal()
225
        {
226
            this.Dispose(false);
227
        }
228
229
        public void Dispose()
230
        {
231
            this.Dispose(true);
232
            GC.SuppressFinalize(this);
233
        }
234
235
        protected virtual void Dispose(bool disposing)
236
        {
237
            if (this.disposed) return;
238
            if (disposing)
239
            {
240
                foreach (var member in this.Members)
241
                {
242
                    if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData))
243
                        Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo);
244
                }
245
                // IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다.
246
            }
247
            // .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다.
248
            this.disposed = true;
249 787a4489 KangIngu
        }
250
251
        void DragThumb_Loaded(object sender, RoutedEventArgs e)
252
        {
253
            mainDragThumb = DragThumb;
254
        }
255
256
        public AdornerFinal(CommentUserInfo objectData) : this()
257
        {
258
            InitializeComponent();
259
            objectData.IsHitTestVisible = false;
260 1305c420 taeseongkim
261 b2d0f316 humkyung
            if (objectData is ArrowTextControl ArrTextCtrl)
262 787a4489 KangIngu
            {
263 b2d0f316 humkyung
                ArrTextCtrl.Base_TextBox.Focusable = true;
264 787a4489 KangIngu
            }
265 1305c420 taeseongkim
266 b2d0f316 humkyung
            ///Canvas.SetZIndex(objectData, 84);
267 787a4489 KangIngu
            try
268
            {
269 05009a0e ljiyeon
                ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData);
270 787a4489 KangIngu
                this.ContainerContent.Children.Add(objectData);
271
            }
272 1066bae3 ljiyeon
            catch (Exception ex)
273 787a4489 KangIngu
            {
274
275
            }
276 1066bae3 ljiyeon
           
277 b2d0f316 humkyung
            SetAdornerMember(objectData);
278 787a4489 KangIngu
            this.Focus();
279
        }
280 4913851c humkyung
281 9b7cda70 KangIngu
        public AdornerFinal(List<CommentUserInfo> objectData) : this()
282 787a4489 KangIngu
        {
283
            InitializeComponent();
284
            foreach (var item in objectData)
285
            {
286
                //item.IsHitTestVisible = false;
287 b2d0f316 humkyung
                if (item is ArrowTextControl ArrTextCtrl)
288 787a4489 KangIngu
                {
289 b2d0f316 humkyung
                    ArrTextCtrl.Base_TextBox.Focusable = true;
290 787a4489 KangIngu
                }
291
                try
292
                {
293 b2d0f316 humkyung
                    ///Canvas.SetZIndex(item, 80);
294
295 05009a0e ljiyeon
                    ViewerDataModel.Instance.MarkupControls_USER.Remove(item);
296 787a4489 KangIngu
                    this.ContainerContent.Children.Add(item);
297
                }
298 53880c83 ljiyeon
                catch //(Exception ex)
299 787a4489 KangIngu
                {
300
                }
301 1066bae3 ljiyeon
                finally
302
                {
303
                    
304
                }
305 787a4489 KangIngu
            }
306 4913851c humkyung
            this.SetAdornerMember(objectData);
307 787a4489 KangIngu
            this.Focus();
308
        }
309
310 62b6bcde humkyung
        public Point Centeroid
311
        {
312
            get
313
            {
314
                List<Point> pts = new List<Point>();
315
316
                #region 센터 포인트 구하기 (그룹핑)
317
                foreach (var item in this.Members)
318
                {
319
                    if (item.DrawingData.GetType().Name == "TextControl")
320
                    {
321
                        if (AngleValue == 0)
322
                        {
323 fa48eb85 taeseongkim
                            AngleValue = (item.DrawingData as TextControl).CommentAngle;
324 62b6bcde humkyung
                        }
325
                        double X = Canvas.GetLeft((item.DrawingData as TextControl));
326
                        double Y = Canvas.GetTop((item.DrawingData as TextControl));
327
                        pts.Add(new Point(X, Y));
328
                    }
329
                    else
330
                    {
331
                        pts.AddRange((item.DrawingData as IPath).PointSet);
332
                    }
333
                }
334
                #endregion
335
336
                return MathSet.FindCentroid(pts);
337
            }
338
        }
339
340 b643fcca taeseongkim
        #endregion
341
        #region 메서드
342
        public Rect getAdornerSize()
343 787a4489 KangIngu
        {
344
            return BorderSize;
345
        }
346 902faaea taeseongkim
347
        private void TextControlLostFocus(object sender,RoutedEventArgs e)
348
        {
349
            TextCompensation = false;
350
            BorderUpdate();
351
352 b2d0f316 humkyung
            if (sender is TextBox TextBox)
353 902faaea taeseongkim
            {
354 b2d0f316 humkyung
                if (TextBox.Text == "") //보류
355 902faaea taeseongkim
                {
356
                    this.ContainerContent.Children.Remove((sender as TextBox).Parent as MarkupToPDF.Common.CommentUserInfo);
357
                    this.Visibility = Visibility.Collapsed;
358
                }
359
            }
360
        }
361
362
        private void TextControlPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
363
        {
364 24c5e56c taeseongkim
            if (sender is TextControl)
365 902faaea taeseongkim
            {
366
                TextCompensation = true;
367
                BorderUpdate();
368
            }
369
        }
370
371
        private void TextControlSelectionChanged(object sender, RoutedEventArgs e)
372
        {
373
            BorderUpdate();
374
        }
375
376 3b797b23 humkyung
        
377
        private void ViewBoxRotate(UIElement member)
378
        {
379
            AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5);
380
            DragThumb.RenderTransformOrigin = new Point(0.5, 0.5);
381
            AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
382
            DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).CommentAngle };
383
        }
384
385 787a4489 KangIngu
        /// <summary>
386
        /// UIElement를 종류에 맞게 등록시킴
387
        /// </summary>
388
        /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param>
389
        public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member)
390 53880c83 ljiyeon
        {
391 787a4489 KangIngu
            switch (member.GetType().Name)
392
            {
393
                #region 컨트롤 조건
394 554aae3b humkyung
                case "LineControl":
395
                case "PolygonControl":
396 787a4489 KangIngu
                case "ArrowControl":
397 554aae3b humkyung
                case "ArcControl":
398
                case "ArrowArcControl":
399
                case "ArrowControl_Multi":
400
                case "RectangleControl":
401
                case "TriControl":
402
                case "CircleControl":
403
                case "CloudControl":
404
                case "RectCloudControl":
405
                case "InkControl":
406
                case "InsideWhiteControl":
407
                case "OverlapWhiteControl":
408
                case "ClipWhiteControl":
409
                case "CoordinateControl":
410
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
411 e65e8c5c humkyung
                    _ActualAngle = AngleValue = member.CommentAngle;
412 787a4489 KangIngu
                    break;
413
                case "ArrowTextControl":
414 4913851c humkyung
                    this.Members.Add(new AdornerMember
415 53880c83 ljiyeon
                    {
416
                        DrawingData = member,
417
                        Drawingtype = ControlType.ArrowTextControl,
418 f513c215 humkyung
                        ThumbList = new List<MyThumb>(),
419 53880c83 ljiyeon
                        Symbol_ID = member.SymbolID,
420
                        Group_ID = member.GroupID,
421
                    });
422 787a4489 KangIngu
                    (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
423 e65e8c5c humkyung
                    _ActualAngle = AngleValue = (member as ArrowTextControl).CommentAngle;
424 902faaea taeseongkim
425
                    ((ArrowTextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
426 787a4489 KangIngu
                    break;
427 554aae3b humkyung
                case "ImgControl":
428 2d2252ba ljiyeon
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
429 e65e8c5c humkyung
                    _ActualAngle = AngleValue = (member as ImgControl).CommentAngle;
430 2d2252ba ljiyeon
                    break;
431 787a4489 KangIngu
                case "DateControl":
432 2d2252ba ljiyeon
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
433 e65e8c5c humkyung
                    _ActualAngle = AngleValue = (member as DateControl).CommentAngle;
434 2d2252ba ljiyeon
                    break;
435 787a4489 KangIngu
                case "SignControl":
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 SignControl).CommentAngle;
438 2d2252ba ljiyeon
                    break;
439 787a4489 KangIngu
                case "SymControl":
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 SymControl).CommentAngle;
442 2d2252ba ljiyeon
                    break;
443 787a4489 KangIngu
                case "SymControlN":
444 554aae3b humkyung
                    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 SymControlN).CommentAngle;
446 787a4489 KangIngu
                    break;
447
                case "TextControl":
448 f513c215 humkyung
                    this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
449 787a4489 KangIngu
                    RectangleGeometry Data = new RectangleGeometry
450
                    {
451
                        Rect = new Rect()
452
                        {
453
                            X = Canvas.GetLeft((member as TextControl)),
454
                            Y = Canvas.GetTop((member as TextControl)),
455
                            Width = (member as TextControl).Base_TextBlock.ActualWidth / 2,
456
                            Height = (member as TextControl).Base_TextBlock.ActualHeight / 2,
457
                        }
458
                    };
459
                    Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
460
                    Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV);
461
462
463
                    DragThumb.RenderTransformOrigin = new Point(0.0, 0.0);
464
                    DragThumb.RenderTransform = new RotateTransform()
465
                    {
466 fa48eb85 taeseongkim
                        Angle = (member as TextControl).CommentAngle,
467 787a4489 KangIngu
                    };
468
469
                    AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0);
470
                    AdornerBorder.RenderTransform = new RotateTransform()
471
                    {
472 fa48eb85 taeseongkim
                        Angle = (member as TextControl).CommentAngle,
473 787a4489 KangIngu
                    };
474 902faaea taeseongkim
475
                    ((TextControl)member).PropertyChanged += TextControlPropertyChanged;
476
                    ((TextControl)member).Base_TextBox.LostFocus += TextControlLostFocus;
477 787a4489 KangIngu
                    break;
478
                default:
479
                    break;
480
                    #endregion
481
            }
482 554aae3b humkyung
483 787a4489 KangIngu
            if (member.GetType().Name == "TextControl")
484
            {
485
                TextControl content = ((TextControl)member);
486
                content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
487
                content.EndPoint = content.StartPoint;
488
            }
489
            else
490
            {
491
                RegistryPoint(member);
492
            }
493
            BorderUpdate();
494 4913851c humkyung
495 ab7fe8c0 humkyung
            if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
496
                Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member);
497 787a4489 KangIngu
        }
498
499 4913851c humkyung
500 787a4489 KangIngu
        public void SetAdornerMember(List<CommentUserInfo> members)
501
        {
502
            foreach (var member in members)
503
            {
504
                switch (member.GetType().Name)
505
                {
506
                    #region 컨트롤 조건
507 53880c83 ljiyeon
                    case "LineControl":
508 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
509 53880c83 ljiyeon
                        break;
510
                    case "ImgControl":
511 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
512 787a4489 KangIngu
                        break;
513
                    case "ArrowControl":
514 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
515 787a4489 KangIngu
                        break;
516 53880c83 ljiyeon
                    case "PolygonControl":
517 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
518 787a4489 KangIngu
                        break;
519
                    case "ArrowTextControl":
520 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
521 787a4489 KangIngu
                        (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false;
522
                        break;
523
                    case "ArcControl":
524 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
525 787a4489 KangIngu
                        break;
526 40b3ce25 ljiyeon
                    case "ArrowArcControl":
527 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
528 40b3ce25 ljiyeon
                        break;
529 787a4489 KangIngu
                    case "DateControl":
530 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
531 787a4489 KangIngu
                        break;
532
                    case "ArrowControl_Multi":
533 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
534 787a4489 KangIngu
                        break;
535
                    case "RectangleControl":
536 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
537 787a4489 KangIngu
                        break;
538
                    case "TriControl":
539 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
540 787a4489 KangIngu
                        break;
541
                    case "CircleControl":
542 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
543 787a4489 KangIngu
                        break;
544
                    case "CloudControl":
545 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
546 787a4489 KangIngu
                        break;
547
                    case "RectCloudControl":
548 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
549 787a4489 KangIngu
                        break;
550
                    case "SignControl":
551 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
552 787a4489 KangIngu
                        break;
553
                    case "SymControl":
554 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
555 787a4489 KangIngu
                        break;
556
                    case "SymControlN":
557 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
558 787a4489 KangIngu
                        break;
559 53880c83 ljiyeon
                    case "InkControl":
560 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
561 787a4489 KangIngu
                        break;
562
                    case "TextControl":
563 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
564 787a4489 KangIngu
565 902faaea taeseongkim
                        (member as TextControl).PropertyChanged += TextControlPropertyChanged;
566
                        (member as TextControl).Base_TextBox.SelectionChanged += TextControlSelectionChanged;
567
568
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
569
                        //{
570
                        //    BorderUpdate();
571
                        //});
572
                        //Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a =>
573
                        //{
574
                        //    BorderUpdate();
575
                        //    try
576
                        //    {
577
                        //        ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; 
578
                        //    }
579
                        //    catch (Exception)
580
                        //    {
581
582
                        //    }
583
584
                        //});
585
                        //Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a =>
586
                        //{
587
                        //    BorderUpdate();
588
                        //});
589 787a4489 KangIngu
                        break;
590 684ef11c ljiyeon
                    case "InsideWhiteControl":
591 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
592 684ef11c ljiyeon
                        break;
593
                    case "OverlapWhiteControl":
594 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
595 684ef11c ljiyeon
                        break;
596
                    case "ClipWhiteControl":
597 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
598 684ef11c ljiyeon
                        break;
599
                    case "CoordinateControl":
600 f513c215 humkyung
                        this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
601 684ef11c ljiyeon
                        break;
602 787a4489 KangIngu
                    default:
603
                        break;
604
                        #endregion
605
                }
606
                if (member.GetType().Name == "TextControl")
607
                {
608
                    TextControl content = ((TextControl)member);
609
                    content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content));
610
                    content.EndPoint = content.StartPoint;
611
                }
612
                else
613
                {
614
                    RegistryPoint(member, members.Count);
615
                }
616 4913851c humkyung
617 ab7fe8c0 humkyung
                if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member))
618
                    Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols
619 787a4489 KangIngu
            }
620
621
            BorderUpdate();
622
        }
623
624 902faaea taeseongkim
625 787a4489 KangIngu
        /// <summary>
626
        /// Border 를 갱신
627
        /// </summary>
628
        public void BorderUpdate()
629
        {
630
            AdornerBorder.MinWidth = 10;
631
            AdornerBorder.MinHeight = 10;
632
633 992a98b4 KangIngu
            double minX = double.MaxValue;
634
            double minY = double.MaxValue;
635
            double maxX = double.MinValue;
636 a7bd032b 이지연
            double maxY = double.MinValue; 
637 e59e6c8e 이지연
            double lineSize = 0;
638
            double marginSize = 0;
639 4913851c humkyung
            if (this.Members.Count == 1)
640 787a4489 KangIngu
            {
641 3b797b23 humkyung
                if (this.Members[0].DrawingData.GetType().Name == "TextControl")
642 787a4489 KangIngu
                {
643 3b797b23 humkyung
                    if ((this.Members[0].DrawingData as TextControl).CommentAngle != 0)
644 787a4489 KangIngu
                    {
645 3b797b23 humkyung
                        trRotate.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
646
                        trRotateThumb.Angle = (this.Members[0].DrawingData as TextControl).CommentAngle;
647 787a4489 KangIngu
                    }
648
                    else
649
                    {
650
                        trRotate.Angle = 0;
651
                        trRotateThumb.Angle = 0;
652
                    }
653
                }
654
            }
655 3b797b23 humkyung
656 4913851c humkyung
            foreach (var item in this.Members)
657 787a4489 KangIngu
            {
658
                UIElement currentControl = (item as AdornerMember).DrawingData;
659 a7bd032b 이지연
                
660 b643fcca taeseongkim
                Point startP = (currentControl as IPath).StartPoint;
661
                Point endP = (currentControl as IPath).EndPoint;
662
663 902faaea taeseongkim
                // ViewerDataModel.Instance.Angle = MathSet.returnAngle(startP, ref endP, ViewerDataModel.Instance.IsPressShift);
664
665
                // 컨트롤의 angle변환시 상단 anglecontrol에 출력
666 4f017ed3 taeseongkim
                ViewerDataModel.Instance.MarkupAngle = (currentControl as CommentUserInfo).CommentAngle;
667 b643fcca taeseongkim
668 787a4489 KangIngu
                if (item.DrawingData.GetType().Name == "TextControl")
669
                {
670
                    double textControlWidth;
671
                    double textControlHeight;
672 e59e6c8e 이지연
                             
673 787a4489 KangIngu
                    if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0)
674
                    {
675
                        textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth);
676
                        textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight);
677
                    }
678
                    else
679
                    {
680
                        textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth);
681
                        textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight);
682
                    }
683 29010418 ljiyeon
                    
684 787a4489 KangIngu
                    if ((currentControl as TextControl).EndPoint.X < minX)
685
                    {
686
                        minX = (currentControl as TextControl).EndPoint.X;
687
                    }
688 fa48eb85 taeseongkim
689 787a4489 KangIngu
                    if ((currentControl as TextControl).EndPoint.Y < minY)
690
                    {
691
                        minY = (currentControl as TextControl).EndPoint.Y;
692
                    }
693 fa48eb85 taeseongkim
694 787a4489 KangIngu
                    if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX)
695
                    {
696
                        maxX = textControlWidth + (currentControl as TextControl).EndPoint.X;
697
                    }
698 fa48eb85 taeseongkim
699 787a4489 KangIngu
                    if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY)
700
                    {
701
                        maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y;
702
                    }
703 d3b658ee 이지연
                    if ((currentControl as TextControl).ControlType_No == 2)
704 3c4acae8 이지연
                        marginSize = (((currentControl as TextControl).Base_TextPath).ActualHeight - ((currentControl as TextControl).Base_Border).ActualHeight) / 2 + (((dynamic)currentControl).LineSize.Left / 2) + (currentControl as TextControl).ArcLength - 30;
705
                    if ((currentControl as TextControl).ControlType_No == 1)
706
                        marginSize = ((dynamic)currentControl).LineSize.Left;
707 787a4489 KangIngu
                }
708
                else if ((currentControl as IViewBox) != null)
709
                {
710
                    IViewBox instance = currentControl as IViewBox;
711
                    List<Point> am = (currentControl as IPath).PointSet;
712
                    List<double> xSet = am.Select(p => p.X).ToList();
713
                    List<double> ySet = am.Select(p => p.Y).ToList();
714
                    if (xSet.Min() < minX) minX = xSet.Min();
715
                    if (ySet.Min() < minY) minY = ySet.Min();
716
                    if (xSet.Max() > maxX) maxX = xSet.Max();
717
                    if (ySet.Max() > maxY) maxY = ySet.Max();
718
                }
719
                else if ((currentControl as IPath).PathData == null)
720
                {
721
                    Rect rt = new Rect
722
                    {
723
                        X = (currentControl as IPath).StartPoint.X,
724
                        Y = (currentControl as IPath).StartPoint.Y,
725
                        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),
726
                        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),
727
                    };
728
                    if (rt.Left < minX) minX = rt.Left;
729
                    if (rt.Top < minY) minY = rt.Top;
730
                    if (rt.Right > maxX) maxX = rt.Right;
731
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
732
                }
733
                else if ((currentControl as IPath) == null)
734
                {
735
                    Rect rt = new Rect
736
                    {
737
                        X = (currentControl as IPath).StartPoint.X,
738
                        Y = (currentControl as IPath).StartPoint.Y,
739
                        Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X,
740
                        Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y
741
                    };
742
                    if (rt.Left < minX) minX = rt.Left;
743
                    if (rt.Top < minY) minY = rt.Top;
744
                    if (rt.Right > maxX) maxX = rt.Right;
745
                    if (rt.Bottom > maxY) maxY = rt.Bottom;
746
                }
747 3b797b23 humkyung
                else if (currentControl is CircleControl CircleCtrl)
748
                {
749
                    List<Point> am = CircleCtrl.PointSet;
750 e59e6c8e 이지연
                    lineSize = CircleCtrl.LineSize;
751 3b797b23 humkyung
                    minX = am.Min(x => x.X);
752
                    minY = am.Min(x => x.Y);
753
                    maxX = am.Max(x => x.X);
754
                    maxY = am.Max(x => x.Y);
755 787a4489 KangIngu
                }
756 a7bd032b 이지연
                else 
757 787a4489 KangIngu
                {
758 e59e6c8e 이지연
                    lineSize = ((dynamic)currentControl).LineSize;
759 787a4489 KangIngu
                    if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left;
760
                    if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top;
761
                    if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right;
762
                    if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom;
763
                }
764
            }
765
766 e59e6c8e 이지연
            Rect ac = new Rect(minX , minY, maxX - minX, maxY - minY);
767 787a4489 KangIngu
            bool addWidthSize = false;
768
            bool addHeightSize = false;
769
            if (ac.Width <= 10)
770
            {
771
                ac.Width += 10;
772
                addWidthSize = true;
773
            }
774
            if (ac.Height <= 10)
775
            {
776
                ac.Height += 10;
777
                addHeightSize = true;
778
            }
779
            BorderSize = ac;
780 e59e6c8e 이지연
            //lineSize : Thickness 굵기에 따라서 adoner 수정 
781
            ac.Width += lineSize;
782
            ac.Height += lineSize;
783 787a4489 KangIngu
            AdornerBorder.MinWidth = 10;
784
            AdornerBorder.MinHeight = 10;
785
            AdornerBorder.Width = ac.Width;
786
            AdornerBorder.Height = ac.Height;
787 e59e6c8e 이지연
            minX -= lineSize / 2;
788
            minY -= lineSize / 2;
789 787a4489 KangIngu
            Canvas.SetLeft(AdornerBorder, minX);
790
            Canvas.SetTop(AdornerBorder, minY);
791
792
            DragThumb.Width = ac.Width;
793
            DragThumb.Height = ac.Height;
794 3c4acae8 이지연
            rotateTop.Margin = new Thickness(rotateTop.Margin.Left, -30 - marginSize, rotateTop.Margin.Right, rotateTop.Margin.Bottom);
795 787a4489 KangIngu
            DragThumb.MinWidth = 10;
796
            DragThumb.MinHeight = 10;
797
            if (addWidthSize)
798
            {
799
                Canvas.SetLeft(DragThumb, minX - 5);
800
            }
801
            else
802
            {
803
                Canvas.SetLeft(DragThumb, minX);
804
            }
805
806
            if (addHeightSize)
807
            {
808
                Canvas.SetTop(DragThumb, minY - 5);
809
            }
810
            else
811
            {
812
                Canvas.SetTop(DragThumb, minY);
813
            }
814
        }
815 3b797b23 humkyung
816 787a4489 KangIngu
        /// <summary>
817
        /// UIElement 해제
818
        /// </summary>
819 b2d0f316 humkyung
        public void UnRegister()
820 787a4489 KangIngu
        {
821
            foreach (var item in this.ContainerContent.Children)
822
            {
823
                if (item is MarkupToPDF.Common.CommentUserInfo)
824
                {
825
                    (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true;
826
                }
827
            }
828
            this.ContainerContent.Children.Clear();
829
        }
830 f513c215 humkyung
831 787a4489 KangIngu
        /// <summary>
832
        /// 각 포인트들을 등록합니다.
833
        /// </summary>
834
        /// <param name="pointset">Drawing Point</param>
835
        public void RegistryPoint(CommentUserInfo member, int cnt = 1)
836 53880c83 ljiyeon
        {
837 787a4489 KangIngu
            int count = 0;
838 e65e8c5c humkyung
            List<Point> pts = (member as IPath).PointSet;
839 787a4489 KangIngu
            if (member.GetType().Name == "InkControl")
840
            {
841 e65e8c5c humkyung
                pts.Clear();
842
                pts.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y));
843
                pts.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom));
844
                pts.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom));
845
                pts.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top));
846 787a4489 KangIngu
            }
847 3b797b23 humkyung
            ControlType markT = this.Members.First(p => p.DrawingData == member).Drawingtype;
848 e65e8c5c humkyung
            double Minx = pts.Min(x => x.X);
849
            double Miny = pts.Min(x => x.Y);
850 3b797b23 humkyung
851 e65e8c5c humkyung
            for (int i = 0; i < pts.Count; i++)
852 787a4489 KangIngu
            {
853 f513c215 humkyung
                MyThumb tm = new MyThumb
854 787a4489 KangIngu
                {
855
                    Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"],
856
                };
857
858 4913851c humkyung
                this.Members.Last().ThumbList.Add(tm);
859 29010418 ljiyeon
860 e65e8c5c humkyung
                if ((markT == ControlType.ArcLine && pts[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && pts[i] == (member as ArrowArcControl).MiddlePoint))
861 787a4489 KangIngu
                {
862
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
863
                }
864
                if (member.GetType().Name == "ArrowTextControl" && i == 1)
865
                {
866 4913851c humkyung
                    //if (this.Members.Count()<=1)
867 787a4489 KangIngu
                    //{
868
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"];
869
                    List<Point> ps = new List<Point>();
870
871 4913851c humkyung
                    if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null)
872 787a4489 KangIngu
                    {
873 4913851c humkyung
                        var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
874 787a4489 KangIngu
875 fa48eb85 taeseongkim
                        switch (Math.Abs(temp.CommentAngle).ToString())
876 787a4489 KangIngu
                        {
877
                            case "90":
878
                                {
879
                                    ps.Clear();
880
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
881
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간
882
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽
883
884
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간
885
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단
886
887
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); //중간 하단
888
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 하단
889
890
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간
891
                                }
892
                                break;
893
                            case "270":
894
                                {
895
                                    ps.Clear();
896
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽
897
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간
898
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽
899
900
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간
901
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단
902
903
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); //중간 하단
904
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 하단
905
906
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간
907
                                }
908
                                break;
909
                            default:
910
                                {
911
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단
912
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단
913
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단
914
                                    ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2));  //우단
915
                                }
916
                                break;
917
                        }
918
919
                        ArrowTextControl instance = (member as ArrowTextControl);
920
                        if (instance.isTrans)
921
                        {
922
                            //var endP = MathSet.getNearPoint(ps, temp.MidPoint);
923
                            //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP);
924
                            //list[count] = tempP;
925 e65e8c5c humkyung
                            pts[count] = temp.MidPoint;
926 787a4489 KangIngu
                        }
927
                        else
928
                        {
929
                            if (temp.isFixed)
930
                            {
931
                                var endP = MathSet.getNearPoint(ps, temp.MidPoint);
932
                                var testP = endP;
933
                                if (ps[0] == endP) //상단
934
                                {
935
                                    testP = new Point(endP.X, endP.Y - 50);
936
                                }
937
                                else if (ps[1] == endP) //하단
938
                                {
939
                                    testP = new Point(endP.X, endP.Y + 50);
940
                                }
941
                                else if (ps[2] == endP) //좌단
942
                                {
943
                                    testP = new Point(endP.X - 50, endP.Y);
944
                                }
945
                                else if (ps[3] == endP) //우단
946
                                {
947
                                    testP = new Point(endP.X + 50, endP.Y);
948
                                }
949 e65e8c5c humkyung
                                pts[count] = testP;
950 787a4489 KangIngu
                            }
951
                            else
952
                            {
953
                                var endP = MathSet.getNearPoint(ps, instance.MidPoint);
954 e65e8c5c humkyung
                                pts[count] = MathSet.getMiddlePoint(instance.StartPoint, endP);
955 787a4489 KangIngu
                            }
956
                        }
957
                    }
958
                }
959 39f208de taeseongkim
960
                /// ArrowTextControl text box 화면 출력
961 e65e8c5c humkyung
                if (member.GetType().Name == "ArrowTextControl" && pts[i] == pts.Last())
962 787a4489 KangIngu
                {
963
                    tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"];
964
                    tm.Width = (member as ArrowTextControl).BoxWidth;
965
                    tm.Height = (member as ArrowTextControl).BoxHeight;
966 fa48eb85 taeseongkim
                    var angle = (member as ArrowTextControl).PageAngle;
967 787a4489 KangIngu
                    if (Math.Abs(angle).ToString() == "90")
968
                    {
969
                        tm.RenderTransformOrigin = new Point(0, 0);
970
                        tm.RenderTransform = new RotateTransform { Angle = 270 };
971
                    }
972
                    else if (Math.Abs(angle).ToString() == "270")
973
                    {
974
                        tm.RenderTransformOrigin = new Point(0, 0);
975
                        tm.RenderTransform = new RotateTransform { Angle = 90 };
976
                    }
977
                    else
978
                    {
979
                        tm.RenderTransformOrigin = new Point(0.5, 0.5);
980
                        tm.RenderTransform = new RotateTransform()
981
                        {
982 fa48eb85 taeseongkim
                            Angle = angle
983 787a4489 KangIngu
                        };
984
                    }
985
                }
986 29010418 ljiyeon
                
987 787a4489 KangIngu
                if (member.GetType().Name == "CloudControl")
988
                {
989 e65e8c5c humkyung
                    if (i == pts.Count() - 1)
990 787a4489 KangIngu
                    {
991
                        tm.Visibility = System.Windows.Visibility.Collapsed;
992
                    }
993
                }
994
                if (member.GetType().Name == "PolygonControl")
995
                {
996 e65e8c5c humkyung
                    if (i == pts.Count() - 1)
997 787a4489 KangIngu
                    {
998
                        if ((member as PolygonControl).ControlType == ControlType.ChainLine)
999
                        {
1000
1001
                        }
1002
                        else
1003
                        {
1004
                            tm.Visibility = System.Windows.Visibility.Collapsed;
1005
                        }
1006
                    }
1007
                    if ((member as PolygonControl).ControlType == ControlType.Ink)
1008
                    {
1009
                        tm.Visibility = System.Windows.Visibility.Collapsed;
1010
                    }
1011
                }
1012 29010418 ljiyeon
                
1013 787a4489 KangIngu
                this.ContainerContent.Children.Add(tm);
1014 e65e8c5c humkyung
                Canvas.SetLeft(tm, pts[count].X);
1015
                Canvas.SetTop(tm, pts[count].Y);
1016
                if (member.GetType().Name == "ArrowTextControl" && pts[i] == (member as ArrowTextControl).MidPoint)
1017 787a4489 KangIngu
                {
1018
                    Canvas.SetZIndex(tm, 95);
1019 1b2cf911 taeseongkim
                    //tm.Opacity = 0;
1020 3dbace4e taeseongkim
                    tm.DragDelta += MidPoint_DragDelta;
1021 787a4489 KangIngu
                }
1022
                else
1023
                {
1024 3dbace4e taeseongkim
                    tm.DragDelta += ResizeTm_DragDelta;
1025 787a4489 KangIngu
                    Canvas.SetZIndex(tm, 99);
1026
                }
1027
1028
                tm.DragStarted += new DragStartedEventHandler(tm_DragStarted);
1029
                tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted);
1030 3dbace4e taeseongkim
                
1031 787a4489 KangIngu
                tm.MouseMove += new MouseEventHandler(resize_MouseMove);
1032
                count++;
1033
            }
1034
        }
1035
1036 3dbace4e taeseongkim
        private void MidPoint_DragDelta(object sender, DragDeltaEventArgs e)
1037
        {
1038
            MyThumb thumb = sender as MyThumb;
1039
            double newHorizontalChange = e.HorizontalChange;
1040
            double newVerticalChange = e.VerticalChange;
1041
1042 41c4405e taeseongkim
            var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), 0);// commentInfo.VisualPageAngle);
1043 3dbace4e taeseongkim
1044
            var direction = VisualHelper.GetPointDirection(newpoint, ViewerDataModel.Instance.PageAngle);
1045
1046
            System.Diagnostics.Debug.WriteLine("뱡향 : " + direction.ToString());
1047
1048
            AdornerMember control = CurrentAdornerMember(thumb);
1049
            var commentInfo = (control.DrawingData) as CommentUserInfo;
1050
1051
            if (commentInfo is ArrowTextControl)
1052
            {
1053
                Point getThumbPoint = GetPosition(thumb);
1054
1055
                var arrowText = commentInfo as ArrowTextControl;
1056
1057
                //var midPoint = MathSet.getMiddlePoint(arrowText.StartPoint, arrowText.EndPoint);
1058
                //arrowText.MidPoint = newpoint;
1059
                thumb.Translate(newpoint.X, newpoint.Y, this.AngleValue);
1060 41c4405e taeseongkim
          
1061 3dbace4e taeseongkim
                commentInfo.OnMoveCtrlPoint(getThumbPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1062
1063
                control.UpdateThumb();
1064
1065
                System.Diagnostics.Debug.WriteLine($"text {Canvas.GetLeft(arrowText.Base_TextBox)},{Canvas.GetTop(arrowText.Base_TextBox)}");
1066
1067
                System.Diagnostics.Debug.WriteLine($"Page Angle : {ViewerDataModel.Instance.PageAngle} GetPoint : {getThumbPoint.X},{getThumbPoint.Y}  Change Value : {newpoint.X},{newpoint.Y}");
1068
            }
1069
1070
        }
1071
        
1072
1073 ab7fe8c0 humkyung
        /// <summary>
1074
        /// 제어점을 조정하여 크기를 수정한다.
1075
        /// </summary>
1076
        /// <param name="sender"></param>
1077
        /// <param name="e"></param>
1078 787a4489 KangIngu
        private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e)
1079
        {
1080 7bb40d38 taeseongkim
            if (sender.GetType() != typeof(MyThumb)) return;
1081
1082
            MyThumb thumb = sender as MyThumb;
1083
1084 d2114d3b humkyung
            if (this.Members.Count > 1) return;
1085 7bb40d38 taeseongkim
1086
            System.Diagnostics.Debug.WriteLine($"Value {e.HorizontalChange},{e.VerticalChange}");
1087
1088
            double newHorizontalChange = e.HorizontalChange;
1089
            double newVerticalChange = e.VerticalChange;
1090
1091 39f208de taeseongkim
            //if (reSizePoint != new Point(0, 0))
1092
            //{
1093 15bbef90 taeseongkim
                //Point setPoint = Mouse.GetPosition(Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanCanvas);
1094
1095 39f208de taeseongkim
                Point setPoint = GetPosition(thumb);
1096 8de55603 taeseongkim
1097
                //System.Diagnostics.Debug.WriteLine($"1. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}  Change Value : {newHorizontalChange},{newVerticalChange}");
1098 15bbef90 taeseongkim
1099 8de55603 taeseongkim
                AdornerMember control = CurrentAdornerMember(thumb);
1100
                var commentInfo = (control.DrawingData) as CommentUserInfo;
1101 15bbef90 taeseongkim
1102 39f208de taeseongkim
                double ratatePointAngle = 0;
1103 233ef333 taeseongkim
1104 39f208de taeseongkim
                if (commentInfo is ArrowTextControl)
1105 8de55603 taeseongkim
                {
1106 39f208de taeseongkim
                    var textControl = (commentInfo as ArrowTextControl);
1107 233ef333 taeseongkim
1108 39f208de taeseongkim
                    if (textControl.EndPoint == MathSet.getNearPoint(textControl.PointSet, setPoint)) //(textControl.MidPoint == MathSet.getNearPoint(textControl.PointSet,setPoint) ||
1109
1110
                    {
1111 3dbace4e taeseongkim
                        textControl.CommentAngle = 0;
1112
                        this.AngleValue = 0;
1113
                        ratatePointAngle = commentInfo.VisualPageAngle;
1114 39f208de taeseongkim
                    }
1115
                    else
1116 41c4405e taeseongkim
                    {   
1117 39f208de taeseongkim
                        //textControl.CommentAngle = commentInfo.VisualPageAngle + MathSet.returnAngle(textControl.StartPoint, ref tempPoint, ViewerDataModel.Instance.IsPressShift);
1118 41c4405e taeseongkim
                        textControl.OnCreatingMouseMove(textControl.EndPoint, ViewerDataModel.Instance.IsPressShift);
1119 39f208de taeseongkim
                        this.AngleValue = textControl.CommentAngle;
1120
                        commentInfo.CommentAngle = this.AngleValue;
1121
                    }
1122
                        //CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked);
1123 8de55603 taeseongkim
                }
1124 39f208de taeseongkim
                System.Diagnostics.Debug.WriteLine("## Angle : " + this.AngleValue + " ##");
1125
                thumb.Translate(newHorizontalChange, newVerticalChange, this.AngleValue);
1126
1127
                // 페이지회전에 따른 화살표텍스트 박스의 이동 수정
1128 43e1d368 taeseongkim
1129 39f208de taeseongkim
                var newpoint = MathHelper.RotatePoint(new Point(newHorizontalChange, newVerticalChange), new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1130
     
1131
                Point thumbPoint = MathHelper.RotatePoint(setPoint, new Point(), ratatePointAngle);// commentInfo.VisualPageAngle);
1132
1133
                //thumbPoint.X = Math.Abs(thumbPoint.X);
1134
                //thumbPoint.Y = Math.Abs(thumbPoint.Y);
1135
1136
                //if ((setPoint.X + newpoint.X) < 0 || (Math.Abs(thumbPoint.X) + newpoint.X) - ViewerDataModel.Instance.ImageViewWidth > 0)
1137
                //{
1138
                //    newpoint.X = 0;
1139
                //}
1140
1141
                //if (setPoint.Y + newpoint.Y < 0 || (Math.Abs(thumbPoint.Y) + newpoint.Y) - ViewerDataModel.Instance.ImageViewHeight > 0)
1142
                //{
1143
                //    newpoint.Y = 0;
1144
                //}
1145 8de55603 taeseongkim
1146
                commentInfo.OnMoveCtrlPoint(setPoint, newpoint.X, newpoint.Y, ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift);
1147
1148
                //System.Diagnostics.Debug.WriteLine($"3. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1149 508c3ac5 humkyung
                control.UpdateThumb();
1150 15bbef90 taeseongkim
1151 8de55603 taeseongkim
                //System.Diagnostics.Debug.WriteLine($"4. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1152 508c3ac5 humkyung
                this.BorderUpdate();
1153 15bbef90 taeseongkim
1154 8de55603 taeseongkim
               //System.Diagnostics.Debug.WriteLine($"5. GetPoint : {GetPosition(thumb).X},{GetPosition(thumb).Y}");
1155 39f208de taeseongkim
            //}
1156 8de55603 taeseongkim
        }
1157
1158
        private AdornerMember CurrentAdornerMember(MyThumb thumb)
1159
        {
1160
            AdornerMember result = null;
1161
1162
            try
1163
            {
1164
                result = (from userThumb in this.Members
1165
                            where userThumb.ThumbList.Contains(thumb)
1166
                            select userThumb).FirstOrDefault();
1167
            }
1168
            catch (Exception ex)
1169
            {
1170
                App.FileLogger.Error(ex);
1171 787a4489 KangIngu
            }
1172 8de55603 taeseongkim
1173
            return result;
1174 787a4489 KangIngu
        }
1175
1176 15bbef90 taeseongkim
        private Point GetPosition(Thumb thumb)
1177
        {
1178
            return new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb));
1179
        }
1180
1181 787a4489 KangIngu
        #endregion
1182
        #region 이벤트
1183
1184
        void tm_DragCompleted(object sender, DragCompletedEventArgs e)
1185
        {
1186
            this.isDragging = false;
1187
            DraggerThumb = null;
1188
1189 fd452a01 swate0609
1190 4913851c humkyung
            var comments = (from drawing in this.Members
1191 d128ceb2 humkyung
                            select drawing.DrawingData as CommentUserInfo).ToList();
1192 26ec6226 taeseongkim
            ViewerDataModel.Instance.IsMarkupUpdate = true;
1193 787a4489 KangIngu
        }
1194
1195 ec052e41 humkyung
        /// <summary>
1196
        /// start drag
1197
        /// </summary>
1198
        /// <param name="sender"></param>
1199
        /// <param name="e"></param>
1200 787a4489 KangIngu
        void tm_DragStarted(object sender, DragStartedEventArgs e)
1201
        {
1202
            this.DraggerThumb = sender as Thumb;
1203
            this.isDragging = true;
1204
1205
            if (ViewerDataModel.Instance.UndoDataList == null)
1206
            {
1207
                return;
1208
            }
1209
1210 4913851c humkyung
            var comments = (from drawing in this.Members
1211 d128ceb2 humkyung
                            select drawing.DrawingData as CommentUserInfo).ToList();
1212 34ac8db7 humkyung
1213
            UndoCommand.Instance.Push(EventType.Operation, comments);
1214 787a4489 KangIngu
        }
1215
1216
        private void rotate_MouseMove(object sender, MouseEventArgs e)
1217
        {
1218 4913851c humkyung
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1219 787a4489 KangIngu
            {
1220
                if (LastRotateVerticalValue < e.GetPosition(this).X)
1221
                    IsTextAngle = true;
1222
                else
1223
                    IsTextAngle = false;
1224
                LastRotateVerticalValue = e.GetPosition(this).X;
1225
            }
1226 9f473fb7 KangIngu
            else
1227 53880c83 ljiyeon
            {
1228 9f473fb7 KangIngu
                if (e.GetPosition(this).X > LastRotateHorizontalValue)
1229
                {
1230
                    RotateFlag = true;
1231
                }
1232
                else
1233
                {
1234
                    RotateFlag = false;
1235
                }
1236
                LastRotateHorizontalValue = e.GetPosition(this).X;
1237
            }
1238 787a4489 KangIngu
        }
1239
1240 8771edc4 humkyung
        private void drag_DragStarted(object sender, DragStartedEventArgs e)
1241
        {
1242
            /// save mouse down and current mouse point
1243
            this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1244
            this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1245
            /// up to here
1246
1247
            if (ViewerDataModel.Instance.UndoDataList == null)
1248
            {
1249
                return;
1250
            }
1251
1252
            var comments = (from drawing in this.Members
1253
                            select drawing.DrawingData as CommentUserInfo).ToList();
1254 34ac8db7 humkyung
1255
            UndoCommand.Instance.Push(EventType.Operation, comments);
1256 8771edc4 humkyung
        }
1257
1258
        private void drag_DragCompleted(object sender, DragCompletedEventArgs e)
1259
        {
1260 902faaea taeseongkim
            DragThumb.Cursor = new Cursor(App.DefaultArrowCursorStream);
1261 8771edc4 humkyung
1262
            var comments = (from drawing in this.Members
1263
                            select drawing.DrawingData as CommentUserInfo).ToList();
1264
        }
1265
1266 6b6e937c taeseongkim
        private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e)
1267 787a4489 KangIngu
        {
1268 508c3ac5 humkyung
            double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale;
1269 025ebf74 humkyung
1270 f3ab410f taeseongkim
            var newMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender));
1271
         
1272
            var horzChange = (newMousePoint.X - this.CurrentMousePoint.X) / scale;/// Math.Round(tmp.X - this.CurrentMousePoint.X) / scale;
1273
            var vertChange = (newMousePoint.Y - this.CurrentMousePoint.Y) / scale;///Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale;
1274
1275 0d00f9c8 humkyung
            try
1276
            {
1277
                DragThumb.Cursor = Cursors.SizeAll;
1278 39f208de taeseongkim
                System.Diagnostics.Debug.WriteLine($"TransItem : {horzChange}, {vertChange}");
1279
                System.Diagnostics.Debug.WriteLine($"DragDeltaEventArgs : {e.HorizontalChange}, {e.VerticalChange}");
1280 8e5a4a6a taeseongkim
1281
1282 39f208de taeseongkim
                var mainRect = ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect();
1283 f3ab410f taeseongkim
1284 39f208de taeseongkim
                mainRect = MathHelper.RotateRect(ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel.Rect(), new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1285
1286
                var rect = (this.ContainerContent.FindChildByType<CommentUserInfo>() as CommentUserInfo).ItemRect; //this.AdornerBorder.Bounds(ViewerDataModel.Instance.SystemMain.dzMainMenu.mainPanel);
1287
1288
                var rotationRect = MathHelper.RotateRect(rect, new Point(mainRect.Width / 2, mainRect.Height / 2), ViewerDataModel.Instance.PageAngle);
1289
                
1290
                var moveDirection = mainRect.Movement(rotationRect);
1291 f3ab410f taeseongkim
1292 39f208de taeseongkim
                System.Diagnostics.Debug.WriteLine($"horzChange: {horzChange} , vertChange:{vertChange}");
1293 8de55603 taeseongkim
1294
                this.TranslateItems(horzChange, vertChange);
1295 0d00f9c8 humkyung
            }
1296
            finally
1297
            {
1298
                /// update CurrentMousePoint
1299 f3ab410f taeseongkim
                this.CurrentMousePoint = newMousePoint;
1300 0d00f9c8 humkyung
            }
1301 787a4489 KangIngu
        }
1302 eb2b9248 KangIngu
1303 0d00f9c8 humkyung
        /// <summary>
1304
        /// translate all members
1305
        /// </summary>
1306
        /// <param name="e"></param>
1307
        public void TranslateItems(double dx, double dy)
1308 787a4489 KangIngu
        {
1309
            Dispatcher.BeginInvoke((Action)(() =>
1310
            {
1311 4913851c humkyung
                foreach (var item in this.Members)
1312 787a4489 KangIngu
                {
1313 0d00f9c8 humkyung
                    this.TranslateItem(dx, dy, item);
1314 787a4489 KangIngu
                }
1315 c7fde400 taeseongkim
1316
                this.BorderUpdate();
1317 787a4489 KangIngu
            }));
1318
        }
1319 eb2b9248 KangIngu
1320 0d00f9c8 humkyung
        /// <summary>
1321
        /// translate a item
1322
        /// </summary>
1323
        /// <param name="e"></param>
1324
        /// <param name="item"></param>
1325
        private void TranslateItem(double dx, double dy, AdornerMember item)
1326 787a4489 KangIngu
        {
1327 554aae3b humkyung
            /// rotate point with page rotation
1328
            var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle;
1329
            Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation);
1330
            /// up to here
1331 0d00f9c8 humkyung
            (item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y);
1332 105359ce ljiyeon
1333
                ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.MarkupListUpdate(
1334 873011c4 humkyung
                        MarkupParser.MarkupToString((item.DrawingData as CommentUserInfo), App.ViewInfo.UserID), EventType.Operation, null, null);            
1335 105359ce ljiyeon
1336 508c3ac5 humkyung
            item.UpdateThumb();
1337 787a4489 KangIngu
        }
1338
1339
        private void resize_MouseMove(object sender, MouseEventArgs e)
1340
        {
1341 39f208de taeseongkim
            //reSizePoint = e.GetPosition(this);
1342 787a4489 KangIngu
        }
1343 0d00f9c8 humkyung
1344 787a4489 KangIngu
        /// <summary>
1345
        /// 회전
1346
        /// </summary>
1347
        /// <param name="sender"></param>
1348
        /// <param name="e"></param>
1349
        public void rotate_DragDelta(object sender, DragDeltaEventArgs e)
1350
        {
1351
            MoveRotate(e);
1352
        }
1353
1354
        double LastRotateHorizontalValue = 0;
1355
        double LastRotateVerticalValue = 0;
1356 9f473fb7 KangIngu
        bool RotateFlag = false;
1357
1358 992a98b4 KangIngu
        /// <summary>
1359
        /// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history>
1360
        /// </summary>
1361
        /// <param name="e"></param>
1362 787a4489 KangIngu
        public void MoveRotate(DragDeltaEventArgs e)
1363
        {
1364 62b6bcde humkyung
            Point CenterPoint = this.Centeroid;
1365 992a98b4 KangIngu
            Point pt = Mouse.GetPosition(this);
1366
1367 edef7af2 humkyung
            #region X축 기준으로 회전 각도를 구한다.
1368 e65e8c5c humkyung
            Vector AxisX = new Vector(RotatedPoint.X - CenterPoint.X, RotatedPoint.Y - CenterPoint.Y);
1369
            AxisX.Normalize();
1370
            Vector AxisY = new Vector(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y);
1371
            AxisY.Normalize();
1372
            double dDeltaAngle = Vector.AngleBetween(AxisX, AxisY);
1373 edef7af2 humkyung
            #endregion
1374
1375 e65e8c5c humkyung
            _ActualAngle += dDeltaAngle;
1376
            if (_ActualAngle > 360) _ActualAngle -= 360;
1377
            if (_ActualAngle < 0) _ActualAngle += 360;
1378 edef7af2 humkyung
            #region AxisLock이 설정되어 있는 경우 Angle을 특정 값으로 정렬한다.
1379 b79d6e7f humkyung
            if (ViewerDataModel.Instance.IsAxisLock || ViewerDataModel.Instance.IsPressShift)
1380 edef7af2 humkyung
            {
1381 e65e8c5c humkyung
                double tmp = AlignedAngles.OrderBy(x => Math.Abs(_ActualAngle - x)).First();
1382
                dDeltaAngle = tmp - AngleValue;
1383
                AngleValue = tmp;
1384
            }
1385
            else
1386
            {
1387
                AngleValue = _ActualAngle;
1388 edef7af2 humkyung
            }
1389
            #endregion
1390
1391
            /// save rotatePoint
1392 e65e8c5c humkyung
            this.RotatedPoint = pt;
1393 787a4489 KangIngu
1394
            Dispatcher.BeginInvoke((Action)(() =>
1395
            {
1396 554aae3b humkyung
                foreach (var member in this.Members)
1397 787a4489 KangIngu
                {
1398 554aae3b humkyung
                    member.RotateAbout(CenterPoint, dDeltaAngle); 
1399
                    #region 보더 업데이트
1400
                    switch (member.Drawingtype)
1401 787a4489 KangIngu
                    {
1402
                        case ControlType.TextControl:
1403 fa48eb85 taeseongkim
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1404 53880c83 ljiyeon
1405 9b7cda70 KangIngu
                            DragThumb.RenderTransformOrigin = new Point(0, 0);
1406 787a4489 KangIngu
                            DragThumb.RenderTransform = new RotateTransform()
1407
                            {
1408 fa48eb85 taeseongkim
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1409 787a4489 KangIngu
                            };
1410
1411 9b7cda70 KangIngu
                            AdornerBorder.RenderTransformOrigin = new Point(0, 0);
1412 787a4489 KangIngu
                            AdornerBorder.RenderTransform = new RotateTransform()
1413
                            {
1414 fa48eb85 taeseongkim
                                Angle = (member.DrawingData as CommentUserInfo).CommentAngle
1415 54e35b39 송근호
                            };
1416 6e035f10 송근호
1417 62b6bcde humkyung
                            (member.DrawingData as CommentUserInfo).UpdateControl();
1418 787a4489 KangIngu
                            BorderUpdate();
1419
                            break;
1420 53880c83 ljiyeon
1421 787a4489 KangIngu
                        case ControlType.ArrowMultiLine:
1422
                        case ControlType.ArcLine:
1423 40b3ce25 ljiyeon
                        case ControlType.ArcArrow:
1424 787a4489 KangIngu
                        case ControlType.SingleLine:
1425
                        case ControlType.Triangle:
1426
                        case ControlType.ArrowTextControl:
1427 554aae3b humkyung
                        case ControlType.PolygonControl:
1428
                        case ControlType.Ink:
1429 787a4489 KangIngu
                            BorderUpdate();
1430
                            break;
1431 554aae3b humkyung
                        case ControlType.Date:
1432 787a4489 KangIngu
                        case ControlType.RectCloud:
1433
                        case ControlType.Rectangle:
1434
                        case ControlType.ImgControl:
1435
                        case ControlType.Sign:
1436
                        case ControlType.Symbol:
1437
                        case ControlType.Stamp:
1438 fa48eb85 taeseongkim
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1439 787a4489 KangIngu
                            BorderUpdate();
1440
                            break;
1441
                        case ControlType.PolygonCloud:
1442 554aae3b humkyung
                            ((ICloudControl)member.DrawingData).DrawingCloud();
1443 787a4489 KangIngu
                            BorderUpdate();
1444
                            break;
1445
                        case ControlType.Circle:
1446 fa48eb85 taeseongkim
                            (member.DrawingData as CommentUserInfo).CommentAngle = AngleValue;
1447 554aae3b humkyung
                            ((CircleControl)member.DrawingData).SetCenterXY();
1448 787a4489 KangIngu
                            BorderUpdate();
1449
                            break;
1450
                        default:
1451
                            break;
1452
                    }
1453
                }
1454
                #endregion
1455
            }));
1456
        }
1457 eb2b9248 KangIngu
1458 873011c4 humkyung
        /// <summary>
1459
        /// 객체 회전 시작
1460
        /// </summary>
1461
        /// <param name="sender"></param>
1462
        /// <param name="e"></param>
1463 787a4489 KangIngu
        private void rotate_DragStarted(object sender, DragStartedEventArgs e)
1464 29010418 ljiyeon
        {            
1465 e65e8c5c humkyung
            this.RotatedPoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung
1466 eb2b9248 KangIngu
            rotateTop.Cursor = Cursors.SizeAll;
1467
1468 992a98b4 KangIngu
            /// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung
1469 3b797b23 humkyung
            if ((1 == this.Members.Count) && (this.Members[0]).DrawingData.GetType().Name == "TextControl")
1470 992a98b4 KangIngu
            {
1471 3b797b23 humkyung
                this.AngleValue = ((this.Members[0]).DrawingData as TextControl).CommentAngle;
1472 992a98b4 KangIngu
            }
1473
            /// up to here
1474
1475 01cbc243 KangIngu
            if (ViewerDataModel.Instance.UndoDataList == null)
1476 787a4489 KangIngu
            {
1477
                return;
1478
            }
1479
1480 4913851c humkyung
            var comments = (from drawing in this.Members
1481 d128ceb2 humkyung
                            select drawing.DrawingData as CommentUserInfo).ToList();
1482 34ac8db7 humkyung
            UndoCommand.Instance.Push(EventType.Operation, comments);
1483 787a4489 KangIngu
        }
1484 29010418 ljiyeon
        
1485 787a4489 KangIngu
        private void rotate_DragCompleted(object sender, DragCompletedEventArgs e)
1486
        {
1487 902faaea taeseongkim
            rotateTop.Cursor = new Cursor(App.DefaultArrowCursorStream);
1488 d128ceb2 humkyung
1489 4913851c humkyung
            var comments = (from drawing in this.Members
1490 d128ceb2 humkyung
                            select drawing.DrawingData as CommentUserInfo).ToList();
1491 787a4489 KangIngu
        }
1492
1493
        public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
1494
        {
1495 4913851c humkyung
            AdornerMember control = this.Members.FirstOrDefault();
1496 787a4489 KangIngu
1497 3dbace4e taeseongkim
            if ((control.DrawingData as ArrowTextControl) != null)
1498 787a4489 KangIngu
            {
1499
                if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false)
1500
                {
1501
                    (control.DrawingData as ArrowTextControl).isTrans = true;
1502
                }
1503
            }
1504
1505
        }
1506 eb2b9248 KangIngu
1507 787a4489 KangIngu
        public void TextControlChanger()
1508
        {
1509 4913851c humkyung
            if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1510 787a4489 KangIngu
            {
1511 4913851c humkyung
                TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl;
1512 787a4489 KangIngu
                AllControl.Base_TextBox.Focus();
1513
                AllControl.Base_TextBox.Visibility = Visibility.Visible;
1514
                AllControl.Base_TextBlock.Visibility = Visibility.Collapsed;
1515 fa48eb85 taeseongkim
                AllControl.Base_TextBox.IsHitTestVisible = true;
1516 1305c420 taeseongkim
                AllControl.IsEditingMode = true;
1517 787a4489 KangIngu
                AllControl.Base_TextBox.Focus();
1518 fa48eb85 taeseongkim
1519 787a4489 KangIngu
                AllControl.SizeChanged += (sen, ea) =>
1520
                {
1521
                    if (AllControl.Base_TextBox != null)
1522
                    {
1523
                        RectangleGeometry Data = new RectangleGeometry
1524
                        {
1525
                            Rect = new Rect()
1526
                            {
1527
                                X = AllControl.StartPoint.X,
1528
                                Y = AllControl.StartPoint.Y,
1529
                                Width = AllControl.Base_TextBox.Width,
1530
                                Height = AllControl.Base_TextBox.Height,
1531
                            }
1532
                        };
1533
1534
                        Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom);
1535
                        Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV);
1536
                        AllControl.Base_Grid.RenderTransform = new RotateTransform()
1537
                        {
1538 fa48eb85 taeseongkim
                            Angle = AllControl.CommentAngle,
1539 787a4489 KangIngu
                            CenterX = middle.X,
1540
                            CenterY = middle.Y,
1541
                        };
1542
                    }
1543
                    BorderUpdate();
1544
                };
1545
            }
1546
        }
1547 eb2b9248 KangIngu
1548 787a4489 KangIngu
        private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭
1549
        {
1550 4913851c humkyung
            if (e.ClickCount == 2 && this.Members.Count == 1)
1551 787a4489 KangIngu
            {
1552 4913851c humkyung
                if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl")
1553 787a4489 KangIngu
                {
1554 1305c420 taeseongkim
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1555 29010418 ljiyeon
                    TextControlChanger();                    
1556 787a4489 KangIngu
                }
1557
1558 4913851c humkyung
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl")
1559 787a4489 KangIngu
                {
1560 4913851c humkyung
                    ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl;
1561
                    Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last();
1562 1305c420 taeseongkim
               
1563 3797ff05 djkim
                    //ArrowControl TextBox Thumb없애기
1564 787a4489 KangIngu
                    tm.Visibility = Visibility.Collapsed;
1565
1566 4913851c humkyung
                    ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true;
1567 1305c420 taeseongkim
                    SelectionSet.Instance.UnSelect(ViewerDataModel.Instance.SystemMain.dzMainMenu);
1568
1569
                    ((ArrowTextControl)AllControl).Base_TextBox.Focus();
1570 29010418 ljiyeon
                    
1571 1305c420 taeseongkim
1572 787a4489 KangIngu
                    ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) =>
1573
1574
                    {
1575
                        tm.Width = (AllControl as ArrowTextControl).BoxWidth;
1576
                        tm.Height = (AllControl as ArrowTextControl).BoxHeight;
1577
1578
                        List<Point> ps = new List<Point>();
1579 29010418 ljiyeon
                        
1580 787a4489 KangIngu
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단
1581
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단
1582
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단
1583
                        ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2));  //우단
1584
1585
1586
1587
1588
                        var endP = MathSet.getNearPoint(ps, AllControl.MidPoint);
1589
                        var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP);
1590
                        if (AllControl.isTrans)
1591
                        {
1592 4913851c humkyung
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X);
1593
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y);
1594 787a4489 KangIngu
                        }
1595
                        else
1596
                        {
1597 4913851c humkyung
                            Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X);
1598
                            Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y);
1599 787a4489 KangIngu
                        }
1600
1601 9b7cda70 KangIngu
1602 787a4489 KangIngu
                        BorderUpdate();
1603 9b7cda70 KangIngu
1604 787a4489 KangIngu
                    };
1605
                }
1606 4913851c humkyung
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl")
1607 787a4489 KangIngu
                {
1608 4913851c humkyung
                    DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl;
1609 787a4489 KangIngu
                    CalendarControl instanceCal = new CalendarControl(data.Text);
1610
                    //dropData.IsOpen = true;
1611
                    RadWindow rc = new RadWindow();
1612
                    rc.Width = 300;
1613
                    rc.Height = 300;
1614
                    rc.Header = "Change Date";
1615
                    rc.Content = instanceCal;
1616
                    rc.BorderThickness = new Thickness(3);
1617
                    rc.ResizeMode = ResizeMode.NoResize;
1618
                    rc.WindowStartupLocation = WindowStartupLocation.CenterScreen;
1619
                    rc.ModalBackground = new SolidColorBrush(Colors.Black);
1620
                    rc.ModalBackground.Opacity = 0.6;
1621
                    Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme());
1622
                    instanceCal.changeDateCal.SelectionChanged += (sen, ea) =>
1623
                    {
1624
                        data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString();
1625
                        rc.Close();
1626
                    };
1627
                    rc.ShowDialog();
1628
                    //CalendarControl.xaml
1629
                }
1630 4913851c humkyung
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl")
1631 787a4489 KangIngu
                {
1632 4913851c humkyung
                    ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl);
1633 787a4489 KangIngu
                    if (instance.isTransOn)
1634
                    {
1635
                        instance.isTransOn = false;
1636
                    }
1637
                    else
1638
                    {
1639
                        instance.isTransOn = true;
1640
                    }
1641 661b7416 humkyung
                    ///instance.SetArcPath();
1642 787a4489 KangIngu
                    BorderUpdate();
1643
                }
1644 4913851c humkyung
                else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl")
1645 40b3ce25 ljiyeon
                {
1646 4913851c humkyung
                    ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl);
1647 40b3ce25 ljiyeon
                    if (instance.isTransOn)
1648
                    {
1649
                        instance.isTransOn = false;
1650
                    }
1651
                    else
1652
                    {
1653
                        instance.isTransOn = true;
1654
                    }
1655
                    instance.SetArcPath();
1656
                    BorderUpdate();
1657
                }
1658 787a4489 KangIngu
1659
            }
1660 29010418 ljiyeon
            
1661 787a4489 KangIngu
        }
1662
        #endregion
1663
1664
        private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e)
1665
        {
1666 b2d0f316 humkyung
            if (this.Members[0].DrawingData.GetType().Name == "TextControl" 
1667
                || this.Members[0].DrawingData.GetType().Name == "ArrowTextControl")
1668 787a4489 KangIngu
            {
1669
                DragThumb.Visibility = Visibility.Collapsed;
1670 9b7cda70 KangIngu
            }
1671 787a4489 KangIngu
        }
1672
    }
1673
}
클립보드 이미지 추가 (최대 크기: 500 MB)