프로젝트

일반

사용자정보

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

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

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