프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 8118ba81

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