프로젝트

일반

사용자정보

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

markus / KCOM / Controls / AdornerFinal.xaml.cs @ 122914ba

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

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