프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 99b9f32a

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

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