프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 76dc223b

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