프로젝트

일반

사용자정보

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

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

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