프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 8771edc4

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