markus / KCOM / Controls / AdornerFinal.xaml.cs @ a0bab669
이력 | 보기 | 이력해설 | 다운로드 (152 KB)
1 | 787a4489 | KangIngu | using KCOM.Common; |
---|---|---|---|
2 | using MarkupToPDF.Common; |
||
3 | using MarkupToPDF.Controls.Common; |
||
4 | using MarkupToPDF.Controls.Etc; |
||
5 | using MarkupToPDF.Controls.Line; |
||
6 | using MarkupToPDF.Controls.Polygon; |
||
7 | using MarkupToPDF.Controls.Shape; |
||
8 | using MarkupToPDF.Controls.Text; |
||
9 | using System; |
||
10 | using System.Collections.Generic; |
||
11 | using System.Linq; |
||
12 | using System.Reactive.Linq; |
||
13 | using System.Text; |
||
14 | using System.Windows; |
||
15 | using System.Windows.Controls; |
||
16 | using System.Windows.Controls.Primitives; |
||
17 | using System.Windows.Input; |
||
18 | using System.Windows.Media; |
||
19 | using Telerik.Windows.Controls; |
||
20 | |||
21 | namespace KCOM.Controls |
||
22 | { |
||
23 | /// <summary> |
||
24 | /// Interaction logic for AdornerFinal.xaml |
||
25 | /// </summary> |
||
26 | public class AdornerMember |
||
27 | { |
||
28 | public UIElement DrawingData { get; set; } |
||
29 | public ControlType Drawingtype { get; set; } |
||
30 | public double DrawingAngle { get; set; } |
||
31 | public List<Thumb> ThumbList { get; set; } |
||
32 | |||
33 | } |
||
34 | public partial class AdornerFinal : UserControl |
||
35 | { |
||
36 | public TextBox editTextBox { get; set; } |
||
37 | #region 공용 인스턴스 |
||
38 | public List<AdornerMember> MemberSet { get; set; } |
||
39 | public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>(); |
||
40 | public double AngleValue = 0; |
||
41 | public bool IsTextAngle = false; |
||
42 | public Rect BorderSize { get; set; } |
||
43 | public bool TextCompensation = false; |
||
44 | public bool isDragging { get; set; } |
||
45 | public Thumb DraggerThumb { get; set; } |
||
46 | public RadDropDownButton dropData; |
||
47 | public RadCalendar dropCalendar; |
||
48 | public Thumb mainDragThumb { get; set; } |
||
49 | |||
50 | public Point reSizePoint { get; set; } |
||
51 | #endregion |
||
52 | #region 생성자 |
||
53 | private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e) |
||
54 | { |
||
55 | dropData = sender as RadDropDownButton; |
||
56 | } |
||
57 | private void Date_Calendar_Loaded(object sender, RoutedEventArgs e) |
||
58 | { |
||
59 | dropCalendar = sender as RadCalendar; |
||
60 | dropCalendar.SelectionChanged += (sen, ea) => |
||
61 | { |
||
62 | dropData.IsOpen = false; |
||
63 | if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "DateControl") |
||
64 | { |
||
65 | DateControl data = (MemberSet.First() as AdornerMember).DrawingData as DateControl; |
||
66 | data.Text = dropCalendar.SelectedDate.Value.ToShortDateString(); |
||
67 | } |
||
68 | }; |
||
69 | } |
||
70 | public AdornerFinal() |
||
71 | { |
||
72 | InitializeComponent(); |
||
73 | MemberSet = new List<AdornerMember>(); |
||
74 | BorderSize = new Rect(); |
||
75 | _dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true }); |
||
76 | //_dragData.Add(rotateCenter, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true }); |
||
77 | } |
||
78 | |||
79 | void DragThumb_Loaded(object sender, RoutedEventArgs e) |
||
80 | { |
||
81 | mainDragThumb = DragThumb; |
||
82 | } |
||
83 | |||
84 | public AdornerFinal(CommentUserInfo objectData) : this() |
||
85 | { |
||
86 | InitializeComponent(); |
||
87 | objectData.IsHitTestVisible = false; |
||
88 | if ((objectData as ArrowTextControl) != null) |
||
89 | { |
||
90 | (objectData as ArrowTextControl).Base_TextBox.Focusable = true; |
||
91 | } |
||
92 | Canvas.SetZIndex(objectData, 84); |
||
93 | try |
||
94 | { |
||
95 | this.ContainerContent.Children.Add(objectData); |
||
96 | } |
||
97 | catch (Exception ex) |
||
98 | { |
||
99 | |||
100 | } |
||
101 | SetAdornerMember(objectData as CommentUserInfo); |
||
102 | this.Focus(); |
||
103 | } |
||
104 | public AdornerFinal(List<CommentUserInfo> objectData) : this() |
||
105 | { |
||
106 | InitializeComponent(); |
||
107 | foreach (var item in objectData) |
||
108 | { |
||
109 | //item.IsHitTestVisible = false; |
||
110 | if ((item as ArrowTextControl) != null) |
||
111 | { |
||
112 | (item as ArrowTextControl).Base_TextBox.Focusable = true; |
||
113 | } |
||
114 | try |
||
115 | { |
||
116 | a0bab669 | KangIngu | Canvas.SetZIndex(item, 80); |
117 | 787a4489 | KangIngu | this.ContainerContent.Children.Add(item); |
118 | } |
||
119 | catch (Exception ex) |
||
120 | { |
||
121 | |||
122 | } |
||
123 | } |
||
124 | SetAdornerMember(objectData); |
||
125 | this.Focus(); |
||
126 | } |
||
127 | |||
128 | #endregion |
||
129 | #region 메서드 |
||
130 | public Rect getAdornerSize() |
||
131 | { |
||
132 | return BorderSize; |
||
133 | } |
||
134 | public void addMemberControl(UIElement objectData) |
||
135 | { |
||
136 | this.ContainerContent.Children.Add(objectData); |
||
137 | SetAdornerMember(objectData as CommentUserInfo); |
||
138 | this.Focus(); |
||
139 | } |
||
140 | /// <summary> |
||
141 | /// UIElement를 종류에 맞게 등록시킴 |
||
142 | /// </summary> |
||
143 | /// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param> |
||
144 | public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member) |
||
145 | { |
||
146 | |||
147 | switch (member.GetType().Name) |
||
148 | { |
||
149 | #region 컨트롤 조건 |
||
150 | case "LineControl": //Angle추가 안했음 |
||
151 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<Thumb>() }); |
||
152 | break; |
||
153 | case "ImgControl": //Angle추가 안했음 |
||
154 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<Thumb>() }); |
||
155 | //AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5); |
||
156 | //DragThumb.RenderTransformOrigin = new Point(0.5, 0.5); |
||
157 | AngleValue = (member as ImgControl).Angle; |
||
158 | break; |
||
159 | //case "SymControl": //Angle추가 안했음 |
||
160 | // MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() }); |
||
161 | // AngleValue = (member as SymControl).Angle; |
||
162 | // //ViewBoxRotate(member); |
||
163 | // break; |
||
164 | //case "SymControlN": //Angle추가 안했음 |
||
165 | // MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() }); |
||
166 | // AngleValue = (member as SymControlN).Angle; |
||
167 | // //ViewBoxRotate(member); |
||
168 | // break; |
||
169 | case "PolygonControl": //Angle추가 안했음 |
||
170 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<Thumb>() }); |
||
171 | break; |
||
172 | case "ArrowControl": |
||
173 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<Thumb>() }); |
||
174 | break; |
||
175 | case "ArrowTextControl": |
||
176 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<Thumb>() }); |
||
177 | (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false; |
||
178 | |||
179 | 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 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<Thumb>() }); |
||
192 | break; |
||
193 | case "ArrowControl_Multi": |
||
194 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<Thumb>() }); |
||
195 | break; |
||
196 | case "RectangleControl": |
||
197 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<Thumb>() }); |
||
198 | break; |
||
199 | case "DateControl": |
||
200 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<Thumb>() }); |
||
201 | AngleValue = (member as DateControl).Angle; |
||
202 | break; |
||
203 | case "TriControl": |
||
204 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<Thumb>() }); |
||
205 | break; |
||
206 | case "CircleControl": |
||
207 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<Thumb>() }); |
||
208 | break; |
||
209 | case "CloudControl": |
||
210 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<Thumb>() }); |
||
211 | break; |
||
212 | case "RectCloudControl": |
||
213 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<Thumb>() }); |
||
214 | break; |
||
215 | //강인구 추가 |
||
216 | case "SignControl": |
||
217 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<Thumb>() }); |
||
218 | AngleValue = (member as SignControl).Angle; |
||
219 | break; |
||
220 | //강인구 추가 |
||
221 | case "SymControl": |
||
222 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<Thumb>() }); |
||
223 | AngleValue = (member as SymControl).Angle; |
||
224 | break; |
||
225 | //강인구 추가 |
||
226 | case "SymControlN": |
||
227 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<Thumb>() }); |
||
228 | AngleValue = (member as SymControlN).Angle; |
||
229 | break; |
||
230 | case "InkControl": //Angle추가 안했음 |
||
231 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<Thumb>() }); |
||
232 | break; |
||
233 | case "TextControl": |
||
234 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<Thumb>() }); |
||
235 | RectangleGeometry Data = new RectangleGeometry |
||
236 | { |
||
237 | Rect = new Rect() |
||
238 | { |
||
239 | X = Canvas.GetLeft((member as TextControl)), |
||
240 | Y = Canvas.GetTop((member as TextControl)), |
||
241 | Width = (member as TextControl).Base_TextBlock.ActualWidth / 2, |
||
242 | Height = (member as TextControl).Base_TextBlock.ActualHeight / 2, |
||
243 | //Width = (member as TextControl).BoxWidth / 2, |
||
244 | //Height = (member as TextControl).BoxHeight / 2, |
||
245 | } |
||
246 | }; |
||
247 | Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom); |
||
248 | Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV); |
||
249 | |||
250 | |||
251 | DragThumb.RenderTransformOrigin = new Point(0.0, 0.0); |
||
252 | DragThumb.RenderTransform = new RotateTransform() |
||
253 | { |
||
254 | Angle = (member as TextControl).Angle, |
||
255 | //CenterX = middle.X, |
||
256 | //CenterY = middle.Y, |
||
257 | }; |
||
258 | |||
259 | AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0); |
||
260 | AdornerBorder.RenderTransform = new RotateTransform() |
||
261 | { |
||
262 | Angle = (member as TextControl).Angle, |
||
263 | //CenterX = middle.X, |
||
264 | //CenterY = middle.Y, |
||
265 | }; |
||
266 | Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a => |
||
267 | { |
||
268 | TextCompensation = true; |
||
269 | BorderUpdate(); |
||
270 | ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; |
||
271 | }); |
||
272 | Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a => |
||
273 | { |
||
274 | TextCompensation = false; |
||
275 | BorderUpdate(); |
||
276 | if ((a.Sender as TextBox).Text == "") //보류 |
||
277 | { |
||
278 | this.ContainerContent.Children.Remove(member); |
||
279 | this.Visibility = Visibility.Collapsed; |
||
280 | } |
||
281 | |||
282 | //((TextControl)member).UnEditingMode(); |
||
283 | //((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed; |
||
284 | //((TextControl)member).Base_Border.Visibility = Visibility.Collapsed; |
||
285 | //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed; |
||
286 | }); |
||
287 | break; |
||
288 | default: |
||
289 | break; |
||
290 | #endregion |
||
291 | } |
||
292 | if (member.GetType().Name == "TextControl") |
||
293 | { |
||
294 | TextControl content = ((TextControl)member); |
||
295 | content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content)); |
||
296 | content.EndPoint = content.StartPoint; |
||
297 | |||
298 | //RegistryPoint(AllControl.PointSet); |
||
299 | } |
||
300 | else |
||
301 | { |
||
302 | RegistryPoint(member); |
||
303 | } |
||
304 | BorderUpdate(); |
||
305 | } |
||
306 | |||
307 | private void ViewBoxRotate(UIElement member) |
||
308 | { |
||
309 | AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5); |
||
310 | DragThumb.RenderTransformOrigin = new Point(0.5, 0.5); |
||
311 | AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle }; |
||
312 | DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle }; |
||
313 | } |
||
314 | public void SetAdornerMember(List<CommentUserInfo> members) |
||
315 | { |
||
316 | foreach (var member in members) |
||
317 | { |
||
318 | switch (member.GetType().Name) |
||
319 | { |
||
320 | #region 컨트롤 조건 |
||
321 | case "LineControl": //Angle추가 안했음 |
||
322 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<Thumb>() }); |
||
323 | break; |
||
324 | case "ImgControl": //Angle추가 안했음 |
||
325 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<Thumb>() }); |
||
326 | break; |
||
327 | //case "SymControl": //Angle추가 안했음 |
||
328 | // MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() }); |
||
329 | // break; |
||
330 | //case "SymControlN": //Angle추가 안했음 |
||
331 | // MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = MarkupType.Viewbox, ThumbList = new List<Thumb>() }); |
||
332 | // ViewBoxRotate(member); |
||
333 | // break; |
||
334 | case "ArrowControl": |
||
335 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<Thumb>() }); |
||
336 | break; |
||
337 | case "PolygonControl": //Angle추가 안했음 |
||
338 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<Thumb>() }); |
||
339 | break; |
||
340 | case "ArrowTextControl": |
||
341 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<Thumb>() }); |
||
342 | (member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false; |
||
343 | break; |
||
344 | case "ArcControl": |
||
345 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<Thumb>() }); |
||
346 | break; |
||
347 | case "DateControl": |
||
348 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<Thumb>() }); |
||
349 | break; |
||
350 | case "ArrowControl_Multi": |
||
351 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<Thumb>() }); |
||
352 | break; |
||
353 | case "RectangleControl": |
||
354 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<Thumb>() }); |
||
355 | break; |
||
356 | case "TriControl": |
||
357 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<Thumb>() }); |
||
358 | break; |
||
359 | case "CircleControl": |
||
360 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<Thumb>() }); |
||
361 | break; |
||
362 | case "CloudControl": |
||
363 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<Thumb>() }); |
||
364 | break; |
||
365 | case "RectCloudControl": |
||
366 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<Thumb>() }); |
||
367 | break; |
||
368 | //강인구 추가 |
||
369 | case "SignControl": |
||
370 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<Thumb>() }); |
||
371 | break; |
||
372 | case "SymControl": |
||
373 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<Thumb>() }); |
||
374 | break; |
||
375 | case "SymControlN": |
||
376 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<Thumb>() }); |
||
377 | break; |
||
378 | case "InkControl": //Angle추가 안했음 |
||
379 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<Thumb>() }); |
||
380 | break; |
||
381 | case "TextControl": |
||
382 | MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<Thumb>() }); |
||
383 | Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a => |
||
384 | { |
||
385 | BorderUpdate(); |
||
386 | try |
||
387 | { |
||
388 | ((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; //확인 0403 |
||
389 | } |
||
390 | catch (Exception) |
||
391 | { |
||
392 | |||
393 | } |
||
394 | |||
395 | }); |
||
396 | Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a => |
||
397 | { |
||
398 | BorderUpdate(); |
||
399 | }); |
||
400 | break; |
||
401 | default: |
||
402 | break; |
||
403 | #endregion |
||
404 | } |
||
405 | if (member.GetType().Name == "TextControl") |
||
406 | { |
||
407 | //강인구 추가 |
||
408 | TextControl content = ((TextControl)member); |
||
409 | content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content)); |
||
410 | content.EndPoint = content.StartPoint; |
||
411 | //RegistryPoint(AllControl.PointSet); |
||
412 | } |
||
413 | else |
||
414 | { |
||
415 | RegistryPoint(member, members.Count); |
||
416 | } |
||
417 | } |
||
418 | |||
419 | BorderUpdate(); |
||
420 | } |
||
421 | |||
422 | /// <summary> |
||
423 | /// Border 를 갱신 |
||
424 | /// </summary> |
||
425 | public void BorderUpdate() |
||
426 | { |
||
427 | AdornerBorder.MinWidth = 10; |
||
428 | AdornerBorder.MinHeight = 10; |
||
429 | |||
430 | double minX = 10000; |
||
431 | double minY = 10000; |
||
432 | double maxX = 0; |
||
433 | double maxY = 0; |
||
434 | |||
435 | if (MemberSet.Count == 1) |
||
436 | { |
||
437 | if (MemberSet.First().DrawingData.GetType().Name == "TextControl") |
||
438 | { |
||
439 | if ((MemberSet.First().DrawingData as TextControl).Angle != 0) |
||
440 | { |
||
441 | trRotate.Angle = (MemberSet.First().DrawingData as TextControl).Angle; |
||
442 | trRotateThumb.Angle = (MemberSet.First().DrawingData as TextControl).Angle; |
||
443 | } |
||
444 | else |
||
445 | { |
||
446 | trRotate.Angle = 0; |
||
447 | trRotateThumb.Angle = 0; |
||
448 | } |
||
449 | } |
||
450 | } |
||
451 | foreach (var item in MemberSet) |
||
452 | { |
||
453 | UIElement currentControl = (item as AdornerMember).DrawingData; |
||
454 | if (item.DrawingData.GetType().Name == "TextControl") |
||
455 | { |
||
456 | double textControlWidth; |
||
457 | double textControlHeight; |
||
458 | if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0) |
||
459 | { |
||
460 | textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth); |
||
461 | textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight); |
||
462 | } |
||
463 | else |
||
464 | { |
||
465 | textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth); |
||
466 | textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight); |
||
467 | } |
||
468 | if ((currentControl as TextControl).LineSize.Left == 0) |
||
469 | { |
||
470 | if (TextCompensation) |
||
471 | { |
||
472 | |||
473 | textControlWidth += 1; |
||
474 | textControlHeight += 1; |
||
475 | } |
||
476 | else |
||
477 | { |
||
478 | textControlWidth += 3; |
||
479 | textControlHeight += 3; |
||
480 | } |
||
481 | } |
||
482 | else |
||
483 | { |
||
484 | if (TextCompensation) |
||
485 | { |
||
486 | |||
487 | textControlWidth += 1; |
||
488 | textControlHeight += 1; |
||
489 | } |
||
490 | else |
||
491 | { |
||
492 | textControlWidth += 8; |
||
493 | textControlHeight += 8; |
||
494 | } |
||
495 | |||
496 | } |
||
497 | if ((currentControl as TextControl).EndPoint.X < minX) |
||
498 | { |
||
499 | minX = (currentControl as TextControl).EndPoint.X; |
||
500 | } |
||
501 | if ((currentControl as TextControl).EndPoint.Y < minY) |
||
502 | { |
||
503 | minY = (currentControl as TextControl).EndPoint.Y; |
||
504 | } |
||
505 | if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX) |
||
506 | { |
||
507 | maxX = textControlWidth + (currentControl as TextControl).EndPoint.X; |
||
508 | } |
||
509 | if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY) |
||
510 | { |
||
511 | maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y; |
||
512 | } |
||
513 | } |
||
514 | else if ((currentControl as IViewBox) != null) |
||
515 | { |
||
516 | IViewBox instance = currentControl as IViewBox; |
||
517 | List<Point> am = (currentControl as IPath).PointSet; |
||
518 | List<double> xSet = am.Select(p => p.X).ToList(); |
||
519 | List<double> ySet = am.Select(p => p.Y).ToList(); |
||
520 | if (xSet.Min() < minX) minX = xSet.Min(); |
||
521 | if (ySet.Min() < minY) minY = ySet.Min(); |
||
522 | if (xSet.Max() > maxX) maxX = xSet.Max(); |
||
523 | if (ySet.Max() > maxY) maxY = ySet.Max(); |
||
524 | } |
||
525 | else if ((currentControl as IPath).PathData == null) |
||
526 | { |
||
527 | Rect rt = new Rect |
||
528 | { |
||
529 | X = (currentControl as IPath).StartPoint.X, |
||
530 | Y = (currentControl as IPath).StartPoint.Y, |
||
531 | //Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X, |
||
532 | //Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y |
||
533 | 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), |
||
534 | 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), |
||
535 | }; |
||
536 | if (rt.Left < minX) minX = rt.Left; |
||
537 | if (rt.Top < minY) minY = rt.Top; |
||
538 | if (rt.Right > maxX) maxX = rt.Right; |
||
539 | if (rt.Bottom > maxY) maxY = rt.Bottom; |
||
540 | } |
||
541 | else if ((currentControl as IPath) == null) |
||
542 | { |
||
543 | Rect rt = new Rect |
||
544 | { |
||
545 | X = (currentControl as IPath).StartPoint.X, |
||
546 | Y = (currentControl as IPath).StartPoint.Y, |
||
547 | Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X, |
||
548 | Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y |
||
549 | }; |
||
550 | if (rt.Left < minX) minX = rt.Left; |
||
551 | if (rt.Top < minY) minY = rt.Top; |
||
552 | if (rt.Right > maxX) maxX = rt.Right; |
||
553 | if (rt.Bottom > maxY) maxY = rt.Bottom; |
||
554 | } |
||
555 | else if ((currentControl as CircleControl) != null) |
||
556 | { |
||
557 | //Rect rt = new Rect |
||
558 | //{ |
||
559 | // X = (currentControl as IPath).StartPoint.X, |
||
560 | // Y = (currentControl as IPath).StartPoint.Y, |
||
561 | // Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X, |
||
562 | // Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y |
||
563 | //}; |
||
564 | |||
565 | //Rect rt = new Rect((currentControl as IPath).StartPoint, (currentControl as IPath).EndPoint); |
||
566 | //if (rt.Left < minX) minX = rt.Left; |
||
567 | //if (rt.Top < minY) minY = rt.Top; |
||
568 | //if (rt.Right > maxX) maxX = rt.Right; |
||
569 | //if (rt.Bottom > maxY) maxY = rt.Bottom; |
||
570 | |||
571 | List<Point> am = (currentControl as IPath).PointSet; |
||
572 | List<double> xSet = am.Select(p => p.X).ToList(); |
||
573 | List<double> ySet = am.Select(p => p.Y).ToList(); |
||
574 | if (xSet.Min() < minX) minX = xSet.Min(); |
||
575 | if (ySet.Min() < minY) minY = ySet.Min(); |
||
576 | if (xSet.Max() > maxX) maxX = xSet.Max(); |
||
577 | if (ySet.Max() > maxY) maxY = ySet.Max(); |
||
578 | } |
||
579 | else |
||
580 | { |
||
581 | if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left; |
||
582 | if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top; |
||
583 | if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right; |
||
584 | if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom; |
||
585 | } |
||
586 | } |
||
587 | |||
588 | Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY); |
||
589 | bool addWidthSize = false; |
||
590 | bool addHeightSize = false; |
||
591 | if (ac.Width <= 10) |
||
592 | { |
||
593 | ac.Width += 10; |
||
594 | addWidthSize = true; |
||
595 | } |
||
596 | if (ac.Height <= 10) |
||
597 | { |
||
598 | ac.Height += 10; |
||
599 | addHeightSize = true; |
||
600 | } |
||
601 | BorderSize = ac; |
||
602 | AdornerBorder.MinWidth = 10; |
||
603 | AdornerBorder.MinHeight = 10; |
||
604 | AdornerBorder.Width = ac.Width; |
||
605 | AdornerBorder.Height = ac.Height; |
||
606 | Canvas.SetLeft(AdornerBorder, minX); |
||
607 | Canvas.SetTop(AdornerBorder, minY); |
||
608 | |||
609 | DragThumb.Width = ac.Width; |
||
610 | DragThumb.Height = ac.Height; |
||
611 | |||
612 | DragThumb.MinWidth = 10; |
||
613 | DragThumb.MinHeight = 10; |
||
614 | if (addWidthSize) |
||
615 | { |
||
616 | Canvas.SetLeft(DragThumb, minX - 5); |
||
617 | } |
||
618 | else |
||
619 | { |
||
620 | Canvas.SetLeft(DragThumb, minX); |
||
621 | } |
||
622 | |||
623 | if (addHeightSize) |
||
624 | { |
||
625 | Canvas.SetTop(DragThumb, minY - 5); |
||
626 | } |
||
627 | else |
||
628 | { |
||
629 | Canvas.SetTop(DragThumb, minY); |
||
630 | } |
||
631 | } |
||
632 | /// <summary> |
||
633 | /// UIElement 해제 |
||
634 | /// </summary> |
||
635 | public void unRegister() |
||
636 | { |
||
637 | foreach (var item in this.ContainerContent.Children) |
||
638 | { |
||
639 | if (item is MarkupToPDF.Common.CommentUserInfo) |
||
640 | { |
||
641 | (item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true; |
||
642 | } |
||
643 | } |
||
644 | this.ContainerContent.Children.Clear(); |
||
645 | } |
||
646 | /// <summary> |
||
647 | /// 각 포인트들을 등록합니다. |
||
648 | /// </summary> |
||
649 | /// <param name="pointset">Drawing Point</param> |
||
650 | public void RegistryPoint(CommentUserInfo member, int cnt = 1) |
||
651 | { |
||
652 | int count = 0; |
||
653 | double Minx = 100000000; |
||
654 | double Miny = 100000000; |
||
655 | List<Point> list = (member as IPath).PointSet; |
||
656 | if (member.GetType().Name == "InkControl") |
||
657 | { |
||
658 | list.Clear(); |
||
659 | list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y)); |
||
660 | list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom)); |
||
661 | list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom)); |
||
662 | list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top)); |
||
663 | } |
||
664 | ControlType markT = MemberSet.Where(p => p.DrawingData == member).First().Drawingtype; |
||
665 | foreach (var ax in list) |
||
666 | { |
||
667 | Minx = (ax.X < Minx) ? ax.X : Minx; |
||
668 | Miny = (ax.Y < Miny) ? ax.Y : Miny; |
||
669 | } |
||
670 | for (int i = 0; i < list.Count(); i++) |
||
671 | { |
||
672 | Thumb tm = new Thumb |
||
673 | { |
||
674 | //Name = String.Format("thumb{0}_{1}", count, member.GetType().Name.ToString()), |
||
675 | Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"], |
||
676 | }; |
||
677 | |||
678 | MemberSet.Last().ThumbList.Add(tm); |
||
679 | |||
680 | if (markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) |
||
681 | { |
||
682 | tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"]; |
||
683 | } |
||
684 | if (member.GetType().Name == "ArrowTextControl" && i == 1) |
||
685 | { |
||
686 | //if (MemberSet.Count()<=1) |
||
687 | //{ |
||
688 | tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"]; |
||
689 | List<Point> ps = new List<Point>(); |
||
690 | |||
691 | if ((MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl != null) |
||
692 | { |
||
693 | var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl; |
||
694 | |||
695 | |||
696 | switch (Math.Abs(temp.Angle).ToString()) |
||
697 | { |
||
698 | case "90": |
||
699 | { |
||
700 | ps.Clear(); |
||
701 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
||
702 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간 |
||
703 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽 |
||
704 | |||
705 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
||
706 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
||
707 | |||
708 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); //중간 하단 |
||
709 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 하단 |
||
710 | |||
711 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간 |
||
712 | } |
||
713 | break; |
||
714 | case "270": |
||
715 | { |
||
716 | ps.Clear(); |
||
717 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
||
718 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간 |
||
719 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽 |
||
720 | |||
721 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
||
722 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
||
723 | |||
724 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); //중간 하단 |
||
725 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 하단 |
||
726 | |||
727 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간 |
||
728 | } |
||
729 | break; |
||
730 | default: |
||
731 | { |
||
732 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단 |
||
733 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단 |
||
734 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단 |
||
735 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단 |
||
736 | } |
||
737 | break; |
||
738 | } |
||
739 | |||
740 | ArrowTextControl instance = (member as ArrowTextControl); |
||
741 | if (instance.isTrans) |
||
742 | { |
||
743 | //var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
||
744 | //var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP); |
||
745 | //list[count] = tempP; |
||
746 | list[count] = temp.MidPoint; |
||
747 | } |
||
748 | else |
||
749 | { |
||
750 | if (temp.isFixed) |
||
751 | { |
||
752 | var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
||
753 | var testP = endP; |
||
754 | if (ps[0] == endP) //상단 |
||
755 | { |
||
756 | testP = new Point(endP.X, endP.Y - 50); |
||
757 | } |
||
758 | else if (ps[1] == endP) //하단 |
||
759 | { |
||
760 | testP = new Point(endP.X, endP.Y + 50); |
||
761 | } |
||
762 | else if (ps[2] == endP) //좌단 |
||
763 | { |
||
764 | testP = new Point(endP.X - 50, endP.Y); |
||
765 | } |
||
766 | else if (ps[3] == endP) //우단 |
||
767 | { |
||
768 | testP = new Point(endP.X + 50, endP.Y); |
||
769 | } |
||
770 | list[count] = testP; |
||
771 | } |
||
772 | else |
||
773 | { |
||
774 | var endP = MathSet.getNearPoint(ps, instance.MidPoint); |
||
775 | list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP); |
||
776 | } |
||
777 | } |
||
778 | } |
||
779 | } |
||
780 | if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last()) |
||
781 | { |
||
782 | tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"]; |
||
783 | tm.Width = (member as ArrowTextControl).BoxWidth; |
||
784 | tm.Height = (member as ArrowTextControl).BoxHeight; |
||
785 | var angle = (member as ArrowTextControl).Angle; |
||
786 | if (Math.Abs(angle).ToString() == "90") |
||
787 | { |
||
788 | tm.RenderTransformOrigin = new Point(0, 0); |
||
789 | tm.RenderTransform = new RotateTransform { Angle = 270 }; |
||
790 | } |
||
791 | else if (Math.Abs(angle).ToString() == "270") |
||
792 | { |
||
793 | tm.RenderTransformOrigin = new Point(0, 0); |
||
794 | tm.RenderTransform = new RotateTransform { Angle = 90 }; |
||
795 | |||
796 | } |
||
797 | else |
||
798 | { |
||
799 | tm.RenderTransformOrigin = new Point(0.5, 0.5); |
||
800 | tm.RenderTransform = new RotateTransform() |
||
801 | { |
||
802 | Angle = angle, |
||
803 | }; |
||
804 | } |
||
805 | } |
||
806 | //if (markT == MarkupType.Polygon || markT == MarkupType.Cloud) |
||
807 | //{ |
||
808 | // tm.MouseMove += new MouseEventHandler(resize_MouseMove); |
||
809 | // tm.DragStarted += new DragStartedEventHandler(tm_DragStarted); |
||
810 | // tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted); |
||
811 | //} |
||
812 | //else |
||
813 | //{ |
||
814 | // tm.MouseMove += new MouseEventHandler(resize_MouseMove); |
||
815 | // tm.DragStarted += new DragStartedEventHandler(tm_DragStarted); |
||
816 | // tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted); |
||
817 | //} |
||
818 | |||
819 | if (member.GetType().Name == "CloudControl") |
||
820 | { |
||
821 | if (i == list.Count() - 1) |
||
822 | { |
||
823 | tm.Visibility = System.Windows.Visibility.Collapsed; |
||
824 | } |
||
825 | } |
||
826 | if (member.GetType().Name == "PolygonControl") |
||
827 | { |
||
828 | if (i == list.Count() - 1) |
||
829 | { |
||
830 | if ((member as PolygonControl).ControlType == ControlType.ChainLine) |
||
831 | { |
||
832 | |||
833 | } |
||
834 | else |
||
835 | { |
||
836 | tm.Visibility = System.Windows.Visibility.Collapsed; |
||
837 | } |
||
838 | } |
||
839 | if ((member as PolygonControl).ControlType == ControlType.Ink) |
||
840 | { |
||
841 | tm.Visibility = System.Windows.Visibility.Collapsed; |
||
842 | } |
||
843 | } |
||
844 | |||
845 | //강인구 텀브 없애기 보류 |
||
846 | //if(cnt > 1) |
||
847 | //{ |
||
848 | // tm.Visibility = System.Windows.Visibility.Collapsed; |
||
849 | //} |
||
850 | |||
851 | |||
852 | |||
853 | //if (member.GetType().Name == "InkControl") |
||
854 | //{ |
||
855 | // tm.Visibility = System.Windows.Visibility.Collapsed; |
||
856 | //} |
||
857 | |||
858 | this.ContainerContent.Children.Add(tm); |
||
859 | Canvas.SetLeft(tm, list[count].X); |
||
860 | Canvas.SetTop(tm, list[count].Y); |
||
861 | if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint) |
||
862 | { |
||
863 | Canvas.SetZIndex(tm, 95); |
||
864 | } |
||
865 | else |
||
866 | { |
||
867 | Canvas.SetZIndex(tm, 99); |
||
868 | } |
||
869 | |||
870 | tm.DragStarted += new DragStartedEventHandler(tm_DragStarted); |
||
871 | tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted); |
||
872 | tm.DragDelta += ResizeTm_DragDelta; |
||
873 | tm.MouseMove += new MouseEventHandler(resize_MouseMove); |
||
874 | count++; |
||
875 | } |
||
876 | } |
||
877 | |||
878 | private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e) |
||
879 | { |
||
880 | //한개 이상 선택 시 Resize 금지 |
||
881 | if (MemberSet.Count > 1) |
||
882 | return; |
||
883 | if (reSizePoint != new Point(0, 0)) |
||
884 | { |
||
885 | Thumb thumb = sender as Thumb; |
||
886 | |||
887 | Canvas.SetLeft(thumb, Canvas.GetLeft(thumb) + |
||
888 | e.HorizontalChange); |
||
889 | Canvas.SetTop(thumb, Canvas.GetTop(thumb) + |
||
890 | e.VerticalChange); |
||
891 | |||
892 | Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb)); |
||
893 | |||
894 | //if (this.isDragging && MemberSet.Count <= 1) |
||
895 | //if (thumb.IsDragging && MemberSet.Count <= 1 && DraggerThumb == thumb) |
||
896 | //if (DraggerThumb == thumb) |
||
897 | //{ |
||
898 | //Point setPoint = reSizePoint; |
||
899 | //Canvas.SetLeft(thumb, setPoint.X); |
||
900 | //Canvas.SetTop(thumb, setPoint.Y); |
||
901 | AdornerMember control = (from userThumb in MemberSet |
||
902 | where userThumb.ThumbList.Contains(thumb) |
||
903 | select userThumb).FirstOrDefault(); |
||
904 | Point nearPoint = new Point(0, 0); |
||
905 | IPath AllControl = control.DrawingData as IPath; |
||
906 | if (ControlType.TextControl != control.Drawingtype) |
||
907 | { |
||
908 | |||
909 | var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl; |
||
910 | List<Point> ps = new List<Point>(); |
||
911 | |||
912 | nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint); |
||
913 | //switch (Math.Abs(temp.Angle).ToString()) |
||
914 | //{ |
||
915 | |||
916 | // case "90": |
||
917 | // { |
||
918 | // nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint); |
||
919 | // } |
||
920 | // break; |
||
921 | // case "270": |
||
922 | // { |
||
923 | // nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint); |
||
924 | // } |
||
925 | // break; |
||
926 | // default: |
||
927 | // { |
||
928 | // nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint); |
||
929 | // } |
||
930 | // break; |
||
931 | //} |
||
932 | |||
933 | } |
||
934 | for (int i = 0; i < (control.DrawingData as IPath).PointSet.Count; i++) |
||
935 | { |
||
936 | switch (control.Drawingtype) |
||
937 | { |
||
938 | #region Arc + Line |
||
939 | case ControlType.ArrowMultiLine: |
||
940 | case ControlType.ArcLine: |
||
941 | case ControlType.SingleLine: |
||
942 | case ControlType.Triangle: |
||
943 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
944 | { |
||
945 | AllControl.PointSet[i] = setPoint; |
||
946 | AllControl.updateControl(); |
||
947 | DynamicThumbUpdate(control); |
||
948 | BorderUpdate(); |
||
949 | |||
950 | //if (control.DrawingData.GetType().Name == "ArrowTextControl") |
||
951 | //{ |
||
952 | // Thumb tm = control.ThumbList.Last(); |
||
953 | // //Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width / 2)); |
||
954 | // //Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height / 2)); |
||
955 | // Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width)); |
||
956 | // Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height)); |
||
957 | //} |
||
958 | } |
||
959 | break; |
||
960 | #endregion |
||
961 | #region Shape |
||
962 | //case ControlType.PolygonCloud: |
||
963 | case ControlType.RectCloud: |
||
964 | case ControlType.Rectangle: |
||
965 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
966 | { |
||
967 | AllControl.PointSet[i] = setPoint; |
||
968 | var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count(); |
||
969 | var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count(); |
||
970 | var NextP = (i + 1) % AllControl.PointSet.Count(); |
||
971 | |||
972 | var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]); |
||
973 | |||
974 | var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]); |
||
975 | var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, |
||
976 | AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y); |
||
977 | AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet |
||
978 | [ReverseP].Y |
||
979 | + PreviousV.Y * l); |
||
980 | |||
981 | var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]); |
||
982 | l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet |
||
983 | [i].Y - AllControl.PointSet[ReverseP].Y); |
||
984 | AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y + |
||
985 | NextV.Y * l); |
||
986 | AllControl.updateControl(); |
||
987 | DynamicThumbUpdate(control); |
||
988 | BorderUpdate(); |
||
989 | } |
||
990 | break; |
||
991 | #endregion |
||
992 | #region Polygon |
||
993 | case ControlType.PolygonControl: |
||
994 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
995 | { |
||
996 | AllControl.PointSet[i] = setPoint; |
||
997 | AllControl.updateControl(); |
||
998 | BorderUpdate(); |
||
999 | } |
||
1000 | break; |
||
1001 | #endregion |
||
1002 | #region Cicle |
||
1003 | case ControlType.Circle: |
||
1004 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1005 | { |
||
1006 | AllControl.PointSet[i] = setPoint; |
||
1007 | List<Point> newPointSet = new List<Point> { }; |
||
1008 | Point middle = new Point(AllControl.PathData.Bounds.X + AllControl.PathData.Bounds.Width * 0.5, |
||
1009 | AllControl.PathData.Bounds.Y + |
||
1010 | AllControl.PathData.Bounds.Height * 0.5); |
||
1011 | foreach (Point pt in AllControl.PointSet) |
||
1012 | { |
||
1013 | newPointSet.Add(pt); |
||
1014 | } |
||
1015 | var ReverseP = (i + newPointSet.Count() / 2) % newPointSet.Count(); |
||
1016 | var PreviousP = (i + (newPointSet.Count() - 1)) % newPointSet.Count(); |
||
1017 | var NextP = (i + 1) % newPointSet.Count(); |
||
1018 | var distance = MathSet.DistanceTo(newPointSet[ReverseP], newPointSet[i]); |
||
1019 | var PreviousV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[PreviousP]); |
||
1020 | var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, newPointSet[i].X - newPointSet[ReverseP].X, |
||
1021 | newPointSet[i].Y - newPointSet[ReverseP].Y); |
||
1022 | newPointSet[PreviousP] = new Point(newPointSet[ReverseP].X + PreviousV.X * l, newPointSet[ReverseP].Y |
||
1023 | + PreviousV.Y * l); |
||
1024 | |||
1025 | var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]); |
||
1026 | l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y |
||
1027 | - newPointSet[ReverseP].Y); |
||
1028 | newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l); |
||
1029 | |||
1030 | AllControl.PointSet = newPointSet; |
||
1031 | DynamicThumbUpdate(control); |
||
1032 | AllControl.updateControl(); |
||
1033 | BorderUpdate(); |
||
1034 | } |
||
1035 | break; |
||
1036 | #endregion |
||
1037 | #region ArrowText |
||
1038 | case ControlType.ArrowTextControl: |
||
1039 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1040 | { |
||
1041 | AllControl.PointSet[i] = setPoint; |
||
1042 | AllControl.updateControl(); |
||
1043 | |||
1044 | DynamicThumbUpdate(control); |
||
1045 | BorderUpdate(); |
||
1046 | |||
1047 | //if (control.DrawingData.GetType().Name == "ArrowTextControl") |
||
1048 | //{ |
||
1049 | // Thumb tm = control.ThumbList.Last(); |
||
1050 | // //Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width / 2)); |
||
1051 | // //Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height / 2)); |
||
1052 | // Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width)); |
||
1053 | // Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height)); |
||
1054 | //} |
||
1055 | } |
||
1056 | break; |
||
1057 | #endregion |
||
1058 | #region Text |
||
1059 | case ControlType.TextControl: |
||
1060 | break; |
||
1061 | #endregion |
||
1062 | #region Image |
||
1063 | case ControlType.ImgControl: |
||
1064 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1065 | { |
||
1066 | AllControl.PointSet[i] = setPoint; |
||
1067 | var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count(); |
||
1068 | var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count(); |
||
1069 | var NextP = (i + 1) % AllControl.PointSet.Count(); |
||
1070 | |||
1071 | var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]); |
||
1072 | |||
1073 | var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]); |
||
1074 | var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, |
||
1075 | AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y); |
||
1076 | AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet |
||
1077 | [ReverseP].Y |
||
1078 | + PreviousV.Y * l); |
||
1079 | |||
1080 | var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]); |
||
1081 | l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet |
||
1082 | [i].Y - AllControl.PointSet[ReverseP].Y); |
||
1083 | AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y + |
||
1084 | NextV.Y * l); |
||
1085 | AllControl.updateControl(); |
||
1086 | DynamicThumbUpdate(control); |
||
1087 | BorderUpdate(); |
||
1088 | } |
||
1089 | break; |
||
1090 | #endregion |
||
1091 | //강인구 추가 |
||
1092 | #region Sign |
||
1093 | case ControlType.Sign: |
||
1094 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1095 | { |
||
1096 | AllControl.PointSet[i] = setPoint; |
||
1097 | var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count(); |
||
1098 | var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count(); |
||
1099 | var NextP = (i + 1) % AllControl.PointSet.Count(); |
||
1100 | |||
1101 | var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]); |
||
1102 | |||
1103 | var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]); |
||
1104 | var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, |
||
1105 | AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y); |
||
1106 | AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet |
||
1107 | [ReverseP].Y |
||
1108 | + PreviousV.Y * l); |
||
1109 | |||
1110 | var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]); |
||
1111 | l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet |
||
1112 | [i].Y - AllControl.PointSet[ReverseP].Y); |
||
1113 | AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y + |
||
1114 | NextV.Y * l); |
||
1115 | AllControl.updateControl(); |
||
1116 | DynamicThumbUpdate(control); |
||
1117 | BorderUpdate(); |
||
1118 | } |
||
1119 | break; |
||
1120 | #endregion |
||
1121 | #region Cloud |
||
1122 | case ControlType.PolygonCloud: |
||
1123 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1124 | { |
||
1125 | AllControl.PointSet[i] = setPoint; |
||
1126 | AllControl.updateControl(); |
||
1127 | ((ICloudControl)AllControl).DrawingCloud(); |
||
1128 | BorderUpdate(); |
||
1129 | } |
||
1130 | break; |
||
1131 | #endregion |
||
1132 | #region SymBol |
||
1133 | case ControlType.Symbol: |
||
1134 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1135 | { |
||
1136 | AllControl.PointSet[i] = setPoint; |
||
1137 | var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count(); |
||
1138 | var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count(); |
||
1139 | var NextP = (i + 1) % AllControl.PointSet.Count(); |
||
1140 | |||
1141 | var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]); |
||
1142 | |||
1143 | var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]); |
||
1144 | var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, |
||
1145 | AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y); |
||
1146 | AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet |
||
1147 | [ReverseP].Y |
||
1148 | + PreviousV.Y * l); |
||
1149 | |||
1150 | var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]); |
||
1151 | l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet |
||
1152 | [i].Y - AllControl.PointSet[ReverseP].Y); |
||
1153 | AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y + |
||
1154 | NextV.Y * l); |
||
1155 | AllControl.updateControl(); |
||
1156 | DynamicThumbUpdate(control); |
||
1157 | BorderUpdate(); |
||
1158 | } |
||
1159 | break; |
||
1160 | case ControlType.Stamp: |
||
1161 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1162 | { |
||
1163 | AllControl.PointSet[i] = setPoint; |
||
1164 | var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count(); |
||
1165 | var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count(); |
||
1166 | var NextP = (i + 1) % AllControl.PointSet.Count(); |
||
1167 | |||
1168 | var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]); |
||
1169 | |||
1170 | var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]); |
||
1171 | var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, |
||
1172 | AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y); |
||
1173 | AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet |
||
1174 | [ReverseP].Y |
||
1175 | + PreviousV.Y * l); |
||
1176 | |||
1177 | var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]); |
||
1178 | l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet |
||
1179 | [i].Y - AllControl.PointSet[ReverseP].Y); |
||
1180 | AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y + |
||
1181 | NextV.Y * l); |
||
1182 | AllControl.updateControl(); |
||
1183 | DynamicThumbUpdate(control); |
||
1184 | BorderUpdate(); |
||
1185 | } |
||
1186 | break; |
||
1187 | case ControlType.Date: |
||
1188 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1189 | { |
||
1190 | AllControl.PointSet[i] = setPoint; |
||
1191 | var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count(); |
||
1192 | var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count(); |
||
1193 | var NextP = (i + 1) % AllControl.PointSet.Count(); |
||
1194 | |||
1195 | var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]); |
||
1196 | |||
1197 | var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]); |
||
1198 | var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, |
||
1199 | AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y); |
||
1200 | AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet |
||
1201 | [ReverseP].Y |
||
1202 | + PreviousV.Y * l); |
||
1203 | |||
1204 | var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]); |
||
1205 | l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet |
||
1206 | [i].Y - AllControl.PointSet[ReverseP].Y); |
||
1207 | AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y + |
||
1208 | NextV.Y * l); |
||
1209 | AllControl.updateControl(); |
||
1210 | DynamicThumbUpdate(control); |
||
1211 | BorderUpdate(); |
||
1212 | } |
||
1213 | break; |
||
1214 | //case MarkupType.Viewbox: |
||
1215 | // if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1216 | // { |
||
1217 | // AllControl.PointSet[i] = setPoint; |
||
1218 | // var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count(); |
||
1219 | // var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count(); |
||
1220 | // var NextP = (i + 1) % AllControl.PointSet.Count(); |
||
1221 | |||
1222 | // var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]); |
||
1223 | |||
1224 | // var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]); |
||
1225 | // var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, |
||
1226 | // AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y); |
||
1227 | // AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet |
||
1228 | // [ReverseP].Y |
||
1229 | // + PreviousV.Y * l); |
||
1230 | |||
1231 | // var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]); |
||
1232 | // l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet |
||
1233 | // [i].Y - AllControl.PointSet[ReverseP].Y); |
||
1234 | // AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y + |
||
1235 | // NextV.Y * l); |
||
1236 | // AllControl.updateControl(); |
||
1237 | // DynamicThumbUpdate(control); |
||
1238 | // BorderUpdate(); |
||
1239 | // } |
||
1240 | // break; |
||
1241 | #endregion |
||
1242 | #region Ink |
||
1243 | case ControlType.Ink: |
||
1244 | if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1245 | { |
||
1246 | AllControl.PointSet[i] = setPoint; |
||
1247 | AllControl.updateControl(); |
||
1248 | BorderUpdate(); |
||
1249 | } |
||
1250 | break; |
||
1251 | #endregion |
||
1252 | default: |
||
1253 | break; |
||
1254 | } |
||
1255 | } |
||
1256 | } |
||
1257 | //} |
||
1258 | } |
||
1259 | |||
1260 | |||
1261 | |||
1262 | #endregion |
||
1263 | #region 이벤트 |
||
1264 | |||
1265 | void tm_DragCompleted(object sender, DragCompletedEventArgs e) |
||
1266 | { |
||
1267 | this.isDragging = false; |
||
1268 | DraggerThumb = null; |
||
1269 | |||
1270 | Undo_Event(); |
||
1271 | } |
||
1272 | |||
1273 | void tm_DragStarted(object sender, DragStartedEventArgs e) |
||
1274 | { |
||
1275 | this.DraggerThumb = sender as Thumb; |
||
1276 | this.isDragging = true; |
||
1277 | |||
1278 | if (ViewerDataModel.Instance.UndoDataList == null) |
||
1279 | { |
||
1280 | return; |
||
1281 | } |
||
1282 | |||
1283 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb) |
||
1284 | { |
||
1285 | return; |
||
1286 | } |
||
1287 | |||
1288 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null) |
||
1289 | { |
||
1290 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0) |
||
1291 | { |
||
1292 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null) |
||
1293 | { |
||
1294 | return; |
||
1295 | } |
||
1296 | } |
||
1297 | } |
||
1298 | |||
1299 | Undo_Event(); |
||
1300 | } |
||
1301 | |||
1302 | private void rotate_MouseMove(object sender, MouseEventArgs e) |
||
1303 | { |
||
1304 | System.Diagnostics.Debug.WriteLine("X축 : " + e.GetPosition(this).X); |
||
1305 | |||
1306 | if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl") |
||
1307 | { |
||
1308 | if (LastRotateVerticalValue < e.GetPosition(this).X) |
||
1309 | IsTextAngle = true; |
||
1310 | else |
||
1311 | IsTextAngle = false; |
||
1312 | |||
1313 | System.Diagnostics.Debug.WriteLine("X축 : " + e.GetPosition(this).X + "LastRotateVerticalValue : " + LastRotateVerticalValue); |
||
1314 | LastRotateVerticalValue = e.GetPosition(this).X; |
||
1315 | } |
||
1316 | } |
||
1317 | |||
1318 | private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e) |
||
1319 | { |
||
1320 | Thumb thumb = sender as Thumb; |
||
1321 | MoveAdorner(e); |
||
1322 | } |
||
1323 | public void MoveAdorner(DragDeltaEventArgs e) |
||
1324 | { |
||
1325 | Point dragDelta = new Point(e.HorizontalChange, e.VerticalChange); |
||
1326 | |||
1327 | Dispatcher.BeginInvoke((Action)(() => |
||
1328 | { |
||
1329 | foreach (var item in MemberSet) |
||
1330 | { |
||
1331 | #region 라인 & 아크 |
||
1332 | if (item.Drawingtype == ControlType.SingleLine || item.Drawingtype == ControlType.ArcLine || item.Drawingtype == ControlType.ArrowMultiLine) |
||
1333 | { |
||
1334 | DynamicThumbUpdate(e, item); |
||
1335 | } |
||
1336 | #endregion |
||
1337 | #region 지시선화살표 |
||
1338 | if (item.Drawingtype == ControlType.ArrowTextControl) |
||
1339 | { |
||
1340 | DynamicThumbUpdate(e, item); |
||
1341 | } |
||
1342 | #endregion |
||
1343 | //강인구 추가 Sign, check, Stamp |
||
1344 | #region 써클 |
||
1345 | if (item.Drawingtype == ControlType.Circle || item.Drawingtype == ControlType.Sign || item.Drawingtype == ControlType.Symbol || item.Drawingtype == ControlType.Stamp) |
||
1346 | { |
||
1347 | DynamicThumbUpdate(e, item); |
||
1348 | } |
||
1349 | #endregion |
||
1350 | #region 쉐이프 |
||
1351 | if (item.Drawingtype == ControlType.Rectangle || item.Drawingtype == ControlType.ImgControl || item.Drawingtype == ControlType.RectCloud || item.Drawingtype == ControlType.Triangle) |
||
1352 | { |
||
1353 | DynamicThumbUpdate(e, item); |
||
1354 | } |
||
1355 | #endregion |
||
1356 | #region 텍스트 |
||
1357 | if (item.Drawingtype == ControlType.TextControl) |
||
1358 | { |
||
1359 | //Canvas.SetLeft((item.DrawingData as TextControl), Canvas.GetLeft((item.DrawingData as TextControl)) + e.HorizontalChange / 5); |
||
1360 | //Canvas.SetTop((item.DrawingData as TextControl), Canvas.GetTop((item.DrawingData as TextControl)) + e.VerticalChange / 5); |
||
1361 | //(item.DrawingData as TextControl).StartPoint = |
||
1362 | //new Point(Canvas.GetLeft((item.DrawingData as TextControl)) + e.HorizontalChange / 5, Canvas.GetTop((item.DrawingData as TextControl)) + e.VerticalChange / 5); |
||
1363 | //(item.DrawingData as TextControl).EndPoint = (item.DrawingData as TextControl).StartPoint; |
||
1364 | |||
1365 | Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle); |
||
1366 | Canvas.SetLeft((item.DrawingData as TextControl), Canvas.GetLeft((item.DrawingData as TextControl)) + dx.X); |
||
1367 | Canvas.SetTop((item.DrawingData as TextControl), Canvas.GetTop((item.DrawingData as TextControl)) + dx.Y); |
||
1368 | (item.DrawingData as TextControl).StartPoint = |
||
1369 | new Point(Canvas.GetLeft((item.DrawingData as TextControl)) + e.HorizontalChange / 5, Canvas.GetTop((item.DrawingData as TextControl)) + e.VerticalChange / 5); |
||
1370 | (item.DrawingData as TextControl).EndPoint = (item.DrawingData as TextControl).StartPoint; |
||
1371 | } |
||
1372 | #endregion |
||
1373 | #region 날짜 |
||
1374 | if (item.Drawingtype == ControlType.Date) |
||
1375 | { |
||
1376 | DynamicThumbUpdate(e, item); |
||
1377 | //Canvas.SetLeft((item.DrawingData as DateControl), Canvas.GetLeft((item.DrawingData as DateControl)) + e.HorizontalChange); |
||
1378 | //Canvas.SetTop((item.DrawingData as DateControl), Canvas.GetTop((item.DrawingData as DateControl)) + e.VerticalChange); |
||
1379 | //(item.DrawingData as DateControl).StartPoint = new Point(Canvas.GetLeft((item.DrawingData as DateControl)) |
||
1380 | // + e.HorizontalChange, Canvas.GetTop((item.DrawingData as DateControl)) + e.VerticalChange); |
||
1381 | //(item.DrawingData as DateControl).EndPoint = (item.DrawingData as DateControl).StartPoint; |
||
1382 | //MessageBox.Show("잠시 정확도를 위해 막아두었습니다!"); |
||
1383 | |||
1384 | |||
1385 | } |
||
1386 | #endregion |
||
1387 | #region 클라우드 |
||
1388 | if (item.Drawingtype == ControlType.PolygonCloud) |
||
1389 | { |
||
1390 | ICloudControl temp = ((ICloudControl)item.DrawingData); |
||
1391 | DynamicThumbUpdate(e, item); |
||
1392 | temp.DrawingCloud(); |
||
1393 | } |
||
1394 | #endregion |
||
1395 | //#region 심볼 |
||
1396 | //if (item.Drawingtype == MarkupType.Viewbox) |
||
1397 | //{ |
||
1398 | // DynamicThumbUpdate(e, item); |
||
1399 | // BorderUpdate(); |
||
1400 | //} |
||
1401 | //#endregion |
||
1402 | //#region 폴리곤확장 |
||
1403 | //if (item.Drawingtype == MarkupType.PolygonEx) |
||
1404 | //{ |
||
1405 | // Point px = new Point(e.HorizontalChange, e.VerticalChange); |
||
1406 | // List<StylusPointSet> StylusPointSet = (item.DrawingData as PolyControl).PointC; |
||
1407 | // for (int i = 0; i < StylusPointSet.Count; i++) |
||
1408 | // { |
||
1409 | // List<Point> lstPoint = StylusPointSet[i].pointSet; |
||
1410 | // for (int j = 0; j < lstPoint.Count; j++) |
||
1411 | // { |
||
1412 | // lstPoint[j] = new Point(lstPoint[j].X + px.X, lstPoint[j].Y + px.Y); |
||
1413 | // } |
||
1414 | // } |
||
1415 | |||
1416 | // for (int i = 0; i < item.ThumbList.Count; i++) |
||
1417 | // { |
||
1418 | // Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + px.X); |
||
1419 | // Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + px.Y); |
||
1420 | // } |
||
1421 | // (item.DrawingData as IPath).updateControl(); |
||
1422 | // BorderUpdate(); |
||
1423 | // //for (int i = 0; i < (item.DrawingData as PolyControl).PointC.Count(); i++) |
||
1424 | // //{ |
||
1425 | // // //(item.DrawingData as PolyControl).PointC[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as PolyControl).PointC[i]., dDeltaAngle); |
||
1426 | // // for (int j = 0; j < (item.DrawingData as PolyControl).PointC[i].pointSet.Count; j++) |
||
1427 | // // { |
||
1428 | // // (item.DrawingData as PolyControl).PointC[i].pointSet[j] = new Point { X = (item.DrawingData as PolyControl).PointC[i].pointSet[j].X + dx.X, Y = (item.DrawingData as PolyControl).PointC[i].pointSet[j].Y + dx.Y }; |
||
1429 | // // Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X); |
||
1430 | // // Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y); |
||
1431 | // // } |
||
1432 | // //} |
||
1433 | // //(item.DrawingData as IPath).updateControl(); |
||
1434 | //} |
||
1435 | //#endregion |
||
1436 | #region 폴리곤 |
||
1437 | if (item.Drawingtype == ControlType.PolygonControl) |
||
1438 | { |
||
1439 | DynamicThumbUpdate(e, item); |
||
1440 | BorderUpdate(); |
||
1441 | } |
||
1442 | #endregion |
||
1443 | #region 잉크 |
||
1444 | if (item.Drawingtype == ControlType.Ink) |
||
1445 | { |
||
1446 | //DynamicThumbUpdate(e, item); |
||
1447 | //BorderUpdate(); |
||
1448 | |||
1449 | Point px = new Point(e.HorizontalChange, e.VerticalChange); |
||
1450 | List<StylusPointSet> StylusPointSet = (item.DrawingData as InkControl).PointC; |
||
1451 | for (int i = 0; i < StylusPointSet.Count; i++) |
||
1452 | { |
||
1453 | List<Point> lstPoint = StylusPointSet[i].pointSet; |
||
1454 | for (int j = 0; j < lstPoint.Count; j++) |
||
1455 | { |
||
1456 | lstPoint[j] = new Point(lstPoint[j].X + px.X, lstPoint[j].Y + px.Y); |
||
1457 | } |
||
1458 | } |
||
1459 | |||
1460 | for (int i = 0; i < item.ThumbList.Count; i++) |
||
1461 | { |
||
1462 | Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + px.X); |
||
1463 | Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + px.Y); |
||
1464 | } |
||
1465 | (item.DrawingData as IPath).updateControl(); |
||
1466 | BorderUpdate(); |
||
1467 | |||
1468 | } |
||
1469 | #endregion |
||
1470 | BorderUpdate(); |
||
1471 | } |
||
1472 | })); |
||
1473 | } |
||
1474 | public void DynamicThumbUpdate(DragDeltaEventArgs e, AdornerMember item) |
||
1475 | { |
||
1476 | var AllControl = item.DrawingData as IPath; |
||
1477 | List<Point> point = AllControl.PointSet; |
||
1478 | //for (int i = 0; i < AllControl.PointSet.Count(); i++) |
||
1479 | for (int i = 0; i < item.ThumbList.Count(); i++) |
||
1480 | { |
||
1481 | |||
1482 | if (item.DrawingData.GetType().Name == "ArrowTextControl") |
||
1483 | { |
||
1484 | Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle); |
||
1485 | AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y }; |
||
1486 | AllControl.updateControl(); |
||
1487 | Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X); |
||
1488 | Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y); |
||
1489 | |||
1490 | Canvas.SetLeft(item.ThumbList.Last(), Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox)); |
||
1491 | Canvas.SetTop(item.ThumbList.Last(), Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox)); |
||
1492 | } |
||
1493 | else |
||
1494 | { |
||
1495 | Point dx = MathSet.RotateAbout(new Point(0, 0), new Point(e.HorizontalChange, e.VerticalChange), trRotate.Angle); |
||
1496 | AllControl.PointSet[i] = new Point { X = point[i].X + dx.X, Y = point[i].Y + dx.Y }; |
||
1497 | AllControl.updateControl(); |
||
1498 | Canvas.SetLeft(item.ThumbList[i], Canvas.GetLeft(item.ThumbList[i]) + dx.X); |
||
1499 | Canvas.SetTop(item.ThumbList[i], Canvas.GetTop(item.ThumbList[i]) + dx.Y); |
||
1500 | } |
||
1501 | } |
||
1502 | } |
||
1503 | public void DynamicThumbUpdate(AdornerMember item) |
||
1504 | { |
||
1505 | var AllControl = item.DrawingData as IPath; |
||
1506 | List<Point> point = AllControl.PointSet; |
||
1507 | |||
1508 | //if (item.DrawingData as ArrowTextControl !=null) |
||
1509 | //{ |
||
1510 | // for (int i = 0; i < AllControl.PointSet.Count(); i++) |
||
1511 | // { |
||
1512 | // if ((MemberSet.First() as AdornerMember).ThumbList[1]d) |
||
1513 | // { |
||
1514 | |||
1515 | // } |
||
1516 | // } |
||
1517 | // List<Point> ps = new List<Point>(); |
||
1518 | // var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl; |
||
1519 | // ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단 |
||
1520 | // ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단 |
||
1521 | // ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단 |
||
1522 | // ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단 |
||
1523 | |||
1524 | // var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
||
1525 | // var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP); |
||
1526 | // Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X); |
||
1527 | // Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y); |
||
1528 | //} |
||
1529 | //else |
||
1530 | //{ |
||
1531 | for (int i = 0; i < AllControl.PointSet.Count(); i++) |
||
1532 | { |
||
1533 | |||
1534 | Canvas.SetLeft(item.ThumbList[i], AllControl.PointSet[i].X); |
||
1535 | Canvas.SetTop(item.ThumbList[i], AllControl.PointSet[i].Y); |
||
1536 | } |
||
1537 | |||
1538 | |||
1539 | if (item.DrawingData as ArrowTextControl != null) |
||
1540 | { |
||
1541 | if (!(item.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우 |
||
1542 | { |
||
1543 | List<Point> ps = new List<Point>(); |
||
1544 | //강인구 수정 |
||
1545 | //var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl; |
||
1546 | var temp = item.DrawingData as ArrowTextControl; |
||
1547 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단 |
||
1548 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단 |
||
1549 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단 |
||
1550 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단 |
||
1551 | |||
1552 | |||
1553 | |||
1554 | if (temp.isFixed) |
||
1555 | { |
||
1556 | var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
||
1557 | var testP = endP; |
||
1558 | if (ps[0] == endP) //상단 |
||
1559 | { |
||
1560 | testP = new Point(endP.X, endP.Y - 50); |
||
1561 | System.Diagnostics.Debug.WriteLine("상단"); |
||
1562 | } |
||
1563 | else if (ps[1] == endP) //하단 |
||
1564 | { |
||
1565 | testP = new Point(endP.X, endP.Y + 50); |
||
1566 | System.Diagnostics.Debug.WriteLine("하단"); |
||
1567 | } |
||
1568 | else if (ps[2] == endP) //좌단 |
||
1569 | { |
||
1570 | testP = new Point(endP.X - 50, endP.Y); |
||
1571 | System.Diagnostics.Debug.WriteLine("좌단"); |
||
1572 | } |
||
1573 | else if (ps[3] == endP) //우단 |
||
1574 | { |
||
1575 | testP = new Point(endP.X + 50, endP.Y); |
||
1576 | System.Diagnostics.Debug.WriteLine("우단"); |
||
1577 | } |
||
1578 | Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], testP.X); |
||
1579 | Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], testP.Y); |
||
1580 | } |
||
1581 | else |
||
1582 | { |
||
1583 | var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
||
1584 | var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP); |
||
1585 | Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X); |
||
1586 | Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y); |
||
1587 | } |
||
1588 | } |
||
1589 | } |
||
1590 | //} |
||
1591 | } |
||
1592 | |||
1593 | public void Set_Rotate() |
||
1594 | { |
||
1595 | |||
1596 | double dDeltaAngle = 0; |
||
1597 | List<Point> AllPointSet = new List<Point>(); |
||
1598 | Point CenterPoint = new Point(); |
||
1599 | |||
1600 | |||
1601 | if (AngleValue >= 360) |
||
1602 | { |
||
1603 | AngleValue -= 360; |
||
1604 | } |
||
1605 | else if (AngleValue <= -360) |
||
1606 | { |
||
1607 | AngleValue += 360; |
||
1608 | } |
||
1609 | |||
1610 | #region 센터 포인트 구하기 (그룹핑) |
||
1611 | foreach (var item in MemberSet) |
||
1612 | { |
||
1613 | if (item.DrawingData.GetType().Name == "TextControl") |
||
1614 | { |
||
1615 | } |
||
1616 | else |
||
1617 | { |
||
1618 | foreach (Point itemP in (item.DrawingData as IPath).PointSet) |
||
1619 | { |
||
1620 | AllPointSet.Add(itemP); |
||
1621 | } |
||
1622 | } |
||
1623 | } |
||
1624 | #endregion |
||
1625 | |||
1626 | CenterPoint = MathSet.FindCentroid(AllPointSet); |
||
1627 | |||
1628 | Dispatcher.BeginInvoke((Action)(() => |
||
1629 | { |
||
1630 | foreach (var item in MemberSet) |
||
1631 | { |
||
1632 | foreach (var thumb in item.ThumbList) |
||
1633 | { |
||
1634 | double x = Canvas.GetLeft(thumb); |
||
1635 | double y = Canvas.GetTop(thumb); |
||
1636 | |||
1637 | Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle); |
||
1638 | Canvas.SetLeft(thumb, value.X); |
||
1639 | Canvas.SetTop(thumb, value.Y); |
||
1640 | |||
1641 | if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last()) |
||
1642 | { |
||
1643 | |||
1644 | Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox)); |
||
1645 | Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox)); |
||
1646 | if (!(item.DrawingData as ArrowTextControl).isTrans) |
||
1647 | { |
||
1648 | List<Point> ps = new List<Point>(); |
||
1649 | var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl; |
||
1650 | switch (Math.Abs(temp.Angle).ToString()) |
||
1651 | { |
||
1652 | case "90": |
||
1653 | { |
||
1654 | ps.Clear(); |
||
1655 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
||
1656 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간 |
||
1657 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽 |
||
1658 | |||
1659 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
||
1660 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
||
1661 | |||
1662 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); //중간 하단 |
||
1663 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 하단 |
||
1664 | |||
1665 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간 |
||
1666 | } |
||
1667 | break; |
||
1668 | case "270": |
||
1669 | { |
||
1670 | ps.Clear(); |
||
1671 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
||
1672 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간 |
||
1673 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽 |
||
1674 | |||
1675 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
||
1676 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
||
1677 | |||
1678 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); //중간 하단 |
||
1679 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 하단 |
||
1680 | |||
1681 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간 |
||
1682 | } |
||
1683 | break; |
||
1684 | default: |
||
1685 | { |
||
1686 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단 |
||
1687 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단 |
||
1688 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단 |
||
1689 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단 |
||
1690 | } |
||
1691 | break; |
||
1692 | } |
||
1693 | |||
1694 | var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
||
1695 | var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP); |
||
1696 | Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X); |
||
1697 | Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y); |
||
1698 | } |
||
1699 | } |
||
1700 | } |
||
1701 | |||
1702 | for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++) |
||
1703 | { |
||
1704 | (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle); |
||
1705 | } |
||
1706 | } |
||
1707 | #region 컨트롤 업데이트 |
||
1708 | foreach (var item in MemberSet) |
||
1709 | { |
||
1710 | switch (item.Drawingtype) |
||
1711 | { |
||
1712 | case ControlType.TextControl: |
||
1713 | ((TextControl)item.DrawingData).Angle = AngleValue; |
||
1714 | //trRotate.Angle = AngleValue; |
||
1715 | |||
1716 | RectangleGeometry Data = new RectangleGeometry |
||
1717 | { |
||
1718 | Rect = new Rect() |
||
1719 | { |
||
1720 | X = Canvas.GetLeft((item.DrawingData as TextControl)), |
||
1721 | Y = Canvas.GetTop((item.DrawingData as TextControl)), |
||
1722 | Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2, |
||
1723 | Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2, |
||
1724 | } |
||
1725 | }; |
||
1726 | //if ((firstCondition as TextControl).Angle != 0) |
||
1727 | //{ |
||
1728 | Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom); |
||
1729 | Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV); |
||
1730 | |||
1731 | |||
1732 | //AdornerBorder.RenderTransformOrigin = new Point(1, 1); |
||
1733 | //AdornerBorder.RenderTransform = new RotateTransform() |
||
1734 | //{ |
||
1735 | // Angle = (member as TextControl).Angle * -1, |
||
1736 | // CenterX = middle.X + ((member as TextControl) as FrameworkElement).ActualWidth /2, |
||
1737 | // CenterY = middle.Y + ((member as TextControl) as FrameworkElement).ActualHeight /2, |
||
1738 | //}; |
||
1739 | |||
1740 | DragThumb.RenderTransformOrigin = new Point(0.0, 0.0); |
||
1741 | DragThumb.RenderTransform = new RotateTransform() |
||
1742 | { |
||
1743 | Angle = (item.DrawingData as TextControl).Angle, |
||
1744 | //CenterX = middle.X, |
||
1745 | //CenterY = middle.Y, |
||
1746 | }; |
||
1747 | |||
1748 | AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0); |
||
1749 | AdornerBorder.RenderTransform = new RotateTransform() |
||
1750 | { |
||
1751 | Angle = (item.DrawingData as TextControl).Angle, |
||
1752 | //CenterX = middle.X, |
||
1753 | //CenterY = middle.Y, |
||
1754 | }; |
||
1755 | |||
1756 | (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform() |
||
1757 | { |
||
1758 | Angle = (item.DrawingData as TextControl).Angle, |
||
1759 | }; |
||
1760 | |||
1761 | BorderUpdate(); |
||
1762 | break; |
||
1763 | //case ControlType.Viewbox: |
||
1764 | // (item.DrawingData as IPath).updateControl(); |
||
1765 | // ((IViewBox)item.DrawingData).Angle = AngleValue; |
||
1766 | // BorderUpdate(); |
||
1767 | // break; |
||
1768 | case ControlType.Date: |
||
1769 | //강인구 추가(2018.02.22) |
||
1770 | ((DateControl)item.DrawingData).Angle = AngleValue; |
||
1771 | (item.DrawingData as IPath).updateControl(); |
||
1772 | BorderUpdate(); |
||
1773 | //MessageBox.Show("잠시 정확도를 위해 막아두었습니다!"); |
||
1774 | break; |
||
1775 | case ControlType.ArrowMultiLine: |
||
1776 | case ControlType.ArcLine: |
||
1777 | case ControlType.SingleLine: |
||
1778 | case ControlType.Triangle: |
||
1779 | (item.DrawingData as IPath).updateControl(); |
||
1780 | BorderUpdate(); |
||
1781 | break; |
||
1782 | case ControlType.ArrowTextControl: |
||
1783 | (item.DrawingData as IPath).updateControl(); |
||
1784 | BorderUpdate(); |
||
1785 | break; |
||
1786 | case ControlType.RectCloud: |
||
1787 | ((RectCloudControl)item.DrawingData).Angle = AngleValue; |
||
1788 | (item.DrawingData as IPath).updateControl(); |
||
1789 | BorderUpdate(); |
||
1790 | break; |
||
1791 | case ControlType.Rectangle: |
||
1792 | ((RectangleControl)item.DrawingData).Angle = AngleValue; |
||
1793 | (item.DrawingData as IPath).updateControl(); |
||
1794 | BorderUpdate(); |
||
1795 | break; |
||
1796 | case ControlType.ImgControl: |
||
1797 | ((ImgControl)item.DrawingData).Angle = AngleValue; |
||
1798 | (item.DrawingData as IPath).updateControl(); |
||
1799 | BorderUpdate(); |
||
1800 | break; |
||
1801 | //강인구 추가 |
||
1802 | case ControlType.Sign: |
||
1803 | ((SignControl)item.DrawingData).Angle = AngleValue; |
||
1804 | (item.DrawingData as IPath).updateControl(); |
||
1805 | BorderUpdate(); |
||
1806 | break; |
||
1807 | //강인구 추가 |
||
1808 | case ControlType.Symbol: |
||
1809 | ((SymControl)item.DrawingData).Angle = AngleValue; |
||
1810 | (item.DrawingData as IPath).updateControl(); |
||
1811 | BorderUpdate(); |
||
1812 | break; |
||
1813 | //강인구 추가 |
||
1814 | case ControlType.Stamp: |
||
1815 | ((SymControlN)item.DrawingData).Angle = AngleValue; |
||
1816 | (item.DrawingData as IPath).updateControl(); |
||
1817 | BorderUpdate(); |
||
1818 | break; |
||
1819 | case ControlType.PolygonControl: |
||
1820 | //((IShapeControl)AllControl).Angle = AngleValue; |
||
1821 | (item.DrawingData as IPath).updateControl(); |
||
1822 | BorderUpdate(); |
||
1823 | break; |
||
1824 | case ControlType.PolygonCloud: |
||
1825 | //((IShapeControl)AllControl).Angle = AngleValue; |
||
1826 | ((ICloudControl)item.DrawingData).DrawingCloud(); |
||
1827 | (item.DrawingData as IPath).updateControl(); |
||
1828 | BorderUpdate(); |
||
1829 | break; |
||
1830 | case ControlType.Circle: |
||
1831 | ((IShapeControl)item.DrawingData).Angle = AngleValue; |
||
1832 | (item.DrawingData as IPath).updateControl(); |
||
1833 | ((CircleControl)item.DrawingData).SetCenterXY(); |
||
1834 | BorderUpdate(); |
||
1835 | break; |
||
1836 | case ControlType.Ink: |
||
1837 | //((IShapeControl)AllControl).Angle = AngleValue; |
||
1838 | (item.DrawingData as IPath).updateControl(); |
||
1839 | BorderUpdate(); |
||
1840 | break; |
||
1841 | default: |
||
1842 | break; |
||
1843 | } |
||
1844 | } |
||
1845 | #endregion |
||
1846 | })); |
||
1847 | //BorderUpdate(); |
||
1848 | } |
||
1849 | |||
1850 | private void resize_MouseMove(object sender, MouseEventArgs e) |
||
1851 | { |
||
1852 | reSizePoint = e.GetPosition(this); |
||
1853 | //Thumb thumb = sender as Thumb; |
||
1854 | //if (this.isDragging && MemberSet.Count <= 1 && DraggerThumb == thumb) |
||
1855 | ////if (thumb.IsDragging && MemberSet.Count <= 1 && DraggerThumb == thumb) |
||
1856 | ////if (DraggerThumb == thumb) |
||
1857 | //{ |
||
1858 | // Point setPoint = e.GetPosition(this); |
||
1859 | // Canvas.SetLeft(thumb, setPoint.X); |
||
1860 | // Canvas.SetTop(thumb, setPoint.Y); |
||
1861 | // AdornerMember control = (from userThumb in MemberSet |
||
1862 | // where userThumb.ThumbList.Contains(thumb) |
||
1863 | // select userThumb).FirstOrDefault(); |
||
1864 | // Point nearPoint = new Point(0, 0); |
||
1865 | // IPath AllControl = control.DrawingData as IPath; |
||
1866 | // if (ControlType.TextControl != control.Drawingtype) |
||
1867 | // { |
||
1868 | |||
1869 | // var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl; |
||
1870 | // List<Point> ps = new List<Point>(); |
||
1871 | |||
1872 | // nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint); |
||
1873 | // //switch (Math.Abs(temp.Angle).ToString()) |
||
1874 | // //{ |
||
1875 | |||
1876 | // // case "90": |
||
1877 | // // { |
||
1878 | // // nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint); |
||
1879 | // // } |
||
1880 | // // break; |
||
1881 | // // case "270": |
||
1882 | // // { |
||
1883 | // // nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint); |
||
1884 | // // } |
||
1885 | // // break; |
||
1886 | // // default: |
||
1887 | // // { |
||
1888 | // // nearPoint = MathSet.getNearPoint((control.DrawingData as IPath).PointSet, setPoint); |
||
1889 | // // } |
||
1890 | // // break; |
||
1891 | // //} |
||
1892 | |||
1893 | // } |
||
1894 | // for (int i = 0; i < (control.DrawingData as IPath).PointSet.Count; i++) |
||
1895 | // { |
||
1896 | // switch (control.Drawingtype) |
||
1897 | // { |
||
1898 | // #region Arc + Line |
||
1899 | // case ControlType.ArcLine: |
||
1900 | // case ControlType.SingleLine: |
||
1901 | // if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1902 | // { |
||
1903 | // AllControl.PointSet[i] = setPoint; |
||
1904 | // AllControl.updateControl(); |
||
1905 | // DynamicThumbUpdate(control); |
||
1906 | // BorderUpdate(); |
||
1907 | |||
1908 | // //if (control.DrawingData.GetType().Name == "ArrowTextControl") |
||
1909 | // //{ |
||
1910 | // // Thumb tm = control.ThumbList.Last(); |
||
1911 | // // //Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width / 2)); |
||
1912 | // // //Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height / 2)); |
||
1913 | // // Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width)); |
||
1914 | // // Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height)); |
||
1915 | // //} |
||
1916 | // } |
||
1917 | // break; |
||
1918 | // #endregion |
||
1919 | // #region Shape |
||
1920 | // case ControlType.Rectangle: |
||
1921 | // if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1922 | // { |
||
1923 | // AllControl.PointSet[i] = setPoint; |
||
1924 | // var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count(); |
||
1925 | // var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count(); |
||
1926 | // var NextP = (i + 1) % AllControl.PointSet.Count(); |
||
1927 | |||
1928 | // var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]); |
||
1929 | |||
1930 | // var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]); |
||
1931 | // var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, |
||
1932 | // AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y); |
||
1933 | // AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet |
||
1934 | // [ReverseP].Y |
||
1935 | // + PreviousV.Y * l); |
||
1936 | |||
1937 | // var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]); |
||
1938 | // l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet |
||
1939 | // [i].Y - AllControl.PointSet[ReverseP].Y); |
||
1940 | // AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y + |
||
1941 | // NextV.Y * l); |
||
1942 | // AllControl.updateControl(); |
||
1943 | // DynamicThumbUpdate(control); |
||
1944 | // BorderUpdate(); |
||
1945 | // } |
||
1946 | // break; |
||
1947 | // #endregion |
||
1948 | // #region Polygon |
||
1949 | // case ControlType.PolygonControl: |
||
1950 | // if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1951 | // { |
||
1952 | // AllControl.PointSet[i] = setPoint; |
||
1953 | // AllControl.updateControl(); |
||
1954 | // BorderUpdate(); |
||
1955 | // } |
||
1956 | // break; |
||
1957 | // #endregion |
||
1958 | // #region Cicle |
||
1959 | // case ControlType.Circle: |
||
1960 | // if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1961 | // { |
||
1962 | // AllControl.PointSet[i] = setPoint; |
||
1963 | // List<Point> newPointSet = new List<Point> { }; |
||
1964 | // Point middle = new Point(AllControl.PathData.Bounds.X + AllControl.PathData.Bounds.Width * 0.5, |
||
1965 | // AllControl.PathData.Bounds.Y + |
||
1966 | // AllControl.PathData.Bounds.Height * 0.5); |
||
1967 | // foreach (Point pt in AllControl.PointSet) |
||
1968 | // { |
||
1969 | // newPointSet.Add(pt); |
||
1970 | // } |
||
1971 | // var ReverseP = (i + newPointSet.Count() / 2) % newPointSet.Count(); |
||
1972 | // var PreviousP = (i + (newPointSet.Count() - 1)) % newPointSet.Count(); |
||
1973 | // var NextP = (i + 1) % newPointSet.Count(); |
||
1974 | // var distance = MathSet.DistanceTo(newPointSet[ReverseP], newPointSet[i]); |
||
1975 | // var PreviousV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[PreviousP]); |
||
1976 | // var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, newPointSet[i].X - newPointSet[ReverseP].X, |
||
1977 | // newPointSet[i].Y - newPointSet[ReverseP].Y); |
||
1978 | // newPointSet[PreviousP] = new Point(newPointSet[ReverseP].X + PreviousV.X * l, newPointSet[ReverseP].Y |
||
1979 | // + PreviousV.Y * l); |
||
1980 | |||
1981 | // var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]); |
||
1982 | // l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y |
||
1983 | // - newPointSet[ReverseP].Y); |
||
1984 | // newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l); |
||
1985 | |||
1986 | // AllControl.PointSet = newPointSet; |
||
1987 | // DynamicThumbUpdate(control); |
||
1988 | // AllControl.updateControl(); |
||
1989 | // BorderUpdate(); |
||
1990 | // } |
||
1991 | // break; |
||
1992 | // #endregion |
||
1993 | // #region ArrowText |
||
1994 | // case ControlType.ArrowTextControl: |
||
1995 | // if (nearPoint.Equals(AllControl.PointSet[i])) |
||
1996 | // { |
||
1997 | // AllControl.PointSet[i] = setPoint; |
||
1998 | // AllControl.updateControl(); |
||
1999 | |||
2000 | // DynamicThumbUpdate(control); |
||
2001 | // BorderUpdate(); |
||
2002 | |||
2003 | // //if (control.DrawingData.GetType().Name == "ArrowTextControl") |
||
2004 | // //{ |
||
2005 | // // Thumb tm = control.ThumbList.Last(); |
||
2006 | // // //Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width / 2)); |
||
2007 | // // //Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height / 2)); |
||
2008 | // // Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width)); |
||
2009 | // // Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height)); |
||
2010 | // //} |
||
2011 | // } |
||
2012 | // break; |
||
2013 | // #endregion |
||
2014 | // #region Text |
||
2015 | // case ControlType.TextControl: |
||
2016 | // break; |
||
2017 | // #endregion |
||
2018 | // #region Image |
||
2019 | // case ControlType.ImgControl: |
||
2020 | // if (nearPoint.Equals(AllControl.PointSet[i])) |
||
2021 | // { |
||
2022 | // AllControl.PointSet[i] = setPoint; |
||
2023 | // var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count(); |
||
2024 | // var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count(); |
||
2025 | // var NextP = (i + 1) % AllControl.PointSet.Count(); |
||
2026 | |||
2027 | // var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]); |
||
2028 | |||
2029 | // var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]); |
||
2030 | // var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, |
||
2031 | // AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y); |
||
2032 | // AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet |
||
2033 | // [ReverseP].Y |
||
2034 | // + PreviousV.Y * l); |
||
2035 | |||
2036 | // var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]); |
||
2037 | // l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet |
||
2038 | // [i].Y - AllControl.PointSet[ReverseP].Y); |
||
2039 | // AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y + |
||
2040 | // NextV.Y * l); |
||
2041 | // AllControl.updateControl(); |
||
2042 | // DynamicThumbUpdate(control); |
||
2043 | // BorderUpdate(); |
||
2044 | // } |
||
2045 | // break; |
||
2046 | // #endregion |
||
2047 | // #region Cloud |
||
2048 | // case ControlType.PolygonCloud: |
||
2049 | // if (nearPoint.Equals(AllControl.PointSet[i])) |
||
2050 | // { |
||
2051 | // AllControl.PointSet[i] = setPoint; |
||
2052 | // AllControl.updateControl(); |
||
2053 | // ((ICloudControl)AllControl).DrawingCloud(); |
||
2054 | // BorderUpdate(); |
||
2055 | // } |
||
2056 | // break; |
||
2057 | // #endregion |
||
2058 | // #region SymBol |
||
2059 | // //case MarkupType.Viewbox: |
||
2060 | // // if (nearPoint.Equals(AllControl.PointSet[i])) |
||
2061 | // // { |
||
2062 | // // AllControl.PointSet[i] = setPoint; |
||
2063 | // // var ReverseP = (i + AllControl.PointSet.Count() / 2) % AllControl.PointSet.Count(); |
||
2064 | // // var PreviousP = (i + (AllControl.PointSet.Count() - 1)) % AllControl.PointSet.Count(); |
||
2065 | // // var NextP = (i + 1) % AllControl.PointSet.Count(); |
||
2066 | |||
2067 | // // var distance = MathSet.DistanceTo(AllControl.PointSet[ReverseP], AllControl.PointSet[i]); |
||
2068 | |||
2069 | // // var PreviousV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[PreviousP]); |
||
2070 | // // var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, |
||
2071 | // // AllControl.PointSet[i].Y - AllControl.PointSet[ReverseP].Y); |
||
2072 | // // AllControl.PointSet[PreviousP] = new Point(AllControl.PointSet[ReverseP].X + PreviousV.X * l, AllControl.PointSet |
||
2073 | // // [ReverseP].Y |
||
2074 | // // + PreviousV.Y * l); |
||
2075 | |||
2076 | // // var NextV = MathSet.GetNormVectorBetween(AllControl.PointSet[ReverseP], AllControl.PointSet[NextP]); |
||
2077 | // // l = MathSet.DotProduct(NextV.X, NextV.Y, AllControl.PointSet[i].X - AllControl.PointSet[ReverseP].X, AllControl.PointSet |
||
2078 | // // [i].Y - AllControl.PointSet[ReverseP].Y); |
||
2079 | // // AllControl.PointSet[NextP] = new Point(AllControl.PointSet[ReverseP].X + NextV.X * l, AllControl.PointSet[ReverseP].Y + |
||
2080 | // // NextV.Y * l); |
||
2081 | // // AllControl.updateControl(); |
||
2082 | // // DynamicThumbUpdate(control); |
||
2083 | // // BorderUpdate(); |
||
2084 | // // } |
||
2085 | // // break; |
||
2086 | // #endregion |
||
2087 | // default: |
||
2088 | // break; |
||
2089 | // } |
||
2090 | // } |
||
2091 | //} |
||
2092 | } |
||
2093 | /// <summary> |
||
2094 | /// 회전 |
||
2095 | /// </summary> |
||
2096 | /// <param name="sender"></param> |
||
2097 | /// <param name="e"></param> |
||
2098 | public void rotate_DragDelta(object sender, DragDeltaEventArgs e) |
||
2099 | { |
||
2100 | |||
2101 | MoveRotate(e); |
||
2102 | } |
||
2103 | |||
2104 | double LastRotateHorizontalValue = 0; |
||
2105 | double LastRotateVerticalValue = 0; |
||
2106 | public void MoveRotate(DragDeltaEventArgs e) |
||
2107 | { |
||
2108 | double dDeltaAngle = 0; |
||
2109 | |||
2110 | List<Point> AllPointSet = new List<Point>(); |
||
2111 | Point CenterPoint = new Point(); |
||
2112 | #region 회전율에 따른 DragDelta 값 |
||
2113 | |||
2114 | #region 원본소스 |
||
2115 | ////if (Math.Abs(e.HorizontalChange) > Math.Abs(e.VerticalChange)) |
||
2116 | ////{ |
||
2117 | // //dDeltaAngle = +2; |
||
2118 | // //dDeltaAngle = (e.HorizontalChange / 20); |
||
2119 | // AngleValue = AngleValue + dDeltaAngle; |
||
2120 | // if (Math.Abs(e.HorizontalChange) > Math.Abs(e.VerticalChange)) |
||
2121 | // { |
||
2122 | // if (LastRotateHorizontalValue < e.HorizontalChange) |
||
2123 | // { |
||
2124 | // dDeltaAngle = 2; |
||
2125 | // AngleValue = AngleValue + dDeltaAngle; |
||
2126 | // } |
||
2127 | // else |
||
2128 | // { |
||
2129 | // dDeltaAngle = -2; |
||
2130 | // AngleValue = AngleValue + dDeltaAngle; |
||
2131 | // } |
||
2132 | // } |
||
2133 | // //else |
||
2134 | // //{ |
||
2135 | // // if (LastRotateVerticalValue < e.VerticalChange) |
||
2136 | // // { |
||
2137 | // // dDeltaAngle = -2; |
||
2138 | // // AngleValue = AngleValue + dDeltaAngle; |
||
2139 | |||
2140 | // // } |
||
2141 | // // else |
||
2142 | // // { |
||
2143 | // // dDeltaAngle = 2; |
||
2144 | // // AngleValue = AngleValue + dDeltaAngle; |
||
2145 | // // } |
||
2146 | // //} |
||
2147 | ////} |
||
2148 | ////else if (Math.Abs(e.HorizontalChange) < Math.Abs(e.VerticalChange)) |
||
2149 | ////{ |
||
2150 | //// //dDeltaAngle = (e.VerticalChange / 20); |
||
2151 | //// dDeltaAngle = -2; |
||
2152 | //// AngleValue = AngleValue + dDeltaAngle; |
||
2153 | ////} |
||
2154 | #endregion |
||
2155 | |||
2156 | //강인구 수정 |
||
2157 | AngleValue = AngleValue + dDeltaAngle; |
||
2158 | |||
2159 | if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name != "TextControl") |
||
2160 | { |
||
2161 | if (Math.Abs(e.HorizontalChange) > Math.Abs(e.VerticalChange)) |
||
2162 | { |
||
2163 | if (LastRotateHorizontalValue < e.HorizontalChange) |
||
2164 | { |
||
2165 | dDeltaAngle = 5; |
||
2166 | AngleValue = AngleValue + dDeltaAngle; |
||
2167 | } |
||
2168 | else |
||
2169 | { |
||
2170 | dDeltaAngle = -5; |
||
2171 | AngleValue = AngleValue + dDeltaAngle; |
||
2172 | } |
||
2173 | } |
||
2174 | } |
||
2175 | else |
||
2176 | { |
||
2177 | if (IsTextAngle) |
||
2178 | { |
||
2179 | AngleValue = ((MemberSet.First() as AdornerMember).DrawingData as TextControl).Angle + 5; |
||
2180 | //AngleValue = AngleValue + 2; |
||
2181 | } |
||
2182 | else |
||
2183 | { |
||
2184 | AngleValue = ((MemberSet.First() as AdornerMember).DrawingData as TextControl).Angle - 5; |
||
2185 | //AngleValue = AngleValue - 2; |
||
2186 | } |
||
2187 | } |
||
2188 | |||
2189 | LastRotateHorizontalValue = e.HorizontalChange; |
||
2190 | //LastRotateVerticalValue = e.VerticalChange; |
||
2191 | |||
2192 | //Set_Rotate(); |
||
2193 | |||
2194 | if (AngleValue >= 360) |
||
2195 | { |
||
2196 | AngleValue -= 360; |
||
2197 | dDeltaAngle -= 360; |
||
2198 | } |
||
2199 | else if (AngleValue <= -360) |
||
2200 | { |
||
2201 | AngleValue += 360; |
||
2202 | dDeltaAngle += 360; |
||
2203 | } |
||
2204 | #endregion |
||
2205 | |||
2206 | #region 센터 포인트 구하기 (그룹핑) |
||
2207 | foreach (var item in MemberSet) |
||
2208 | { |
||
2209 | if (item.DrawingData.GetType().Name == "TextControl") |
||
2210 | { |
||
2211 | } |
||
2212 | else |
||
2213 | { |
||
2214 | foreach (Point itemP in (item.DrawingData as IPath).PointSet) |
||
2215 | { |
||
2216 | AllPointSet.Add(itemP); |
||
2217 | } |
||
2218 | } |
||
2219 | } |
||
2220 | #endregion |
||
2221 | CenterPoint = MathSet.FindCentroid(AllPointSet); |
||
2222 | |||
2223 | Dispatcher.BeginInvoke((Action)(() => |
||
2224 | { |
||
2225 | foreach (var item in MemberSet) |
||
2226 | { |
||
2227 | foreach (var thumb in item.ThumbList) |
||
2228 | { |
||
2229 | double x = Canvas.GetLeft(thumb); |
||
2230 | double y = Canvas.GetTop(thumb); |
||
2231 | |||
2232 | Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle); |
||
2233 | Canvas.SetLeft(thumb, value.X); |
||
2234 | Canvas.SetTop(thumb, value.Y); |
||
2235 | |||
2236 | if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last()) |
||
2237 | { |
||
2238 | Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox)); |
||
2239 | Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox)); |
||
2240 | if (!(item.DrawingData as ArrowTextControl).isTrans) |
||
2241 | { |
||
2242 | List<Point> ps = new List<Point>(); |
||
2243 | |||
2244 | //강인구 추가 |
||
2245 | //var temp = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl; |
||
2246 | var temp = item.DrawingData as ArrowTextControl; |
||
2247 | switch (Math.Abs(temp.Angle).ToString()) |
||
2248 | { |
||
2249 | case "90": |
||
2250 | { |
||
2251 | ps.Clear(); |
||
2252 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
||
2253 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간 |
||
2254 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽 |
||
2255 | |||
2256 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
||
2257 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
||
2258 | |||
2259 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); //중간 하단 |
||
2260 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 하단 |
||
2261 | |||
2262 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간 |
||
2263 | } |
||
2264 | break; |
||
2265 | case "270": |
||
2266 | { |
||
2267 | ps.Clear(); |
||
2268 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
||
2269 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간 |
||
2270 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽 |
||
2271 | |||
2272 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
||
2273 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
||
2274 | |||
2275 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); //중간 하단 |
||
2276 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 하단 |
||
2277 | |||
2278 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간 |
||
2279 | } |
||
2280 | break; |
||
2281 | default: |
||
2282 | { |
||
2283 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단 |
||
2284 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단 |
||
2285 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단 |
||
2286 | ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단 |
||
2287 | } |
||
2288 | break; |
||
2289 | } |
||
2290 | |||
2291 | var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
||
2292 | var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP); |
||
2293 | |||
2294 | Canvas.SetLeft((MemberSet.Where(data => data.DrawingData.GetType().Name == "ArrowTextControl")).FirstOrDefault().ThumbList[1], tempP.X); |
||
2295 | Canvas.SetTop((MemberSet.Where(data => data.DrawingData.GetType().Name == "ArrowTextControl")).FirstOrDefault().ThumbList[1], tempP.Y); |
||
2296 | //Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X); |
||
2297 | //Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y); |
||
2298 | } |
||
2299 | } |
||
2300 | } |
||
2301 | |||
2302 | for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++) |
||
2303 | { |
||
2304 | (item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle); |
||
2305 | } |
||
2306 | } |
||
2307 | #region 컨트롤 업데이트 |
||
2308 | foreach (var item in MemberSet) |
||
2309 | { |
||
2310 | switch (item.Drawingtype) |
||
2311 | { |
||
2312 | case ControlType.TextControl: |
||
2313 | ((TextControl)item.DrawingData).Angle = AngleValue; |
||
2314 | //trRotate.Angle = AngleValue; |
||
2315 | |||
2316 | RectangleGeometry Data = new RectangleGeometry |
||
2317 | { |
||
2318 | Rect = new Rect() |
||
2319 | { |
||
2320 | X = Canvas.GetLeft((item.DrawingData as TextControl)), |
||
2321 | Y = Canvas.GetTop((item.DrawingData as TextControl)), |
||
2322 | Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2, |
||
2323 | Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2, |
||
2324 | } |
||
2325 | }; |
||
2326 | //if ((firstCondition as TextControl).Angle != 0) |
||
2327 | //{ |
||
2328 | Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom); |
||
2329 | Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV); |
||
2330 | |||
2331 | |||
2332 | //AdornerBorder.RenderTransformOrigin = new Point(1, 1); |
||
2333 | //AdornerBorder.RenderTransform = new RotateTransform() |
||
2334 | //{ |
||
2335 | // Angle = (member as TextControl).Angle * -1, |
||
2336 | // CenterX = middle.X + ((member as TextControl) as FrameworkElement).ActualWidth /2, |
||
2337 | // CenterY = middle.Y + ((member as TextControl) as FrameworkElement).ActualHeight /2, |
||
2338 | //}; |
||
2339 | |||
2340 | DragThumb.RenderTransformOrigin = new Point(0.0, 0.0); |
||
2341 | DragThumb.RenderTransform = new RotateTransform() |
||
2342 | { |
||
2343 | Angle = (item.DrawingData as TextControl).Angle, |
||
2344 | //CenterX = middle.X, |
||
2345 | //CenterY = middle.Y, |
||
2346 | }; |
||
2347 | |||
2348 | AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0); |
||
2349 | AdornerBorder.RenderTransform = new RotateTransform() |
||
2350 | { |
||
2351 | Angle = (item.DrawingData as TextControl).Angle, |
||
2352 | //CenterX = middle.X, |
||
2353 | //CenterY = middle.Y, |
||
2354 | }; |
||
2355 | |||
2356 | (item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform() |
||
2357 | { |
||
2358 | Angle = (item.DrawingData as TextControl).Angle, |
||
2359 | }; |
||
2360 | |||
2361 | BorderUpdate(); |
||
2362 | break; |
||
2363 | //case ControlType.Viewbox: |
||
2364 | // (item.DrawingData as IPath).updateControl(); |
||
2365 | // ((IViewBox)item.DrawingData).Angle = AngleValue; |
||
2366 | // BorderUpdate(); |
||
2367 | // break; |
||
2368 | case ControlType.Date: |
||
2369 | |||
2370 | //강인구 추가(2018.02.22) |
||
2371 | ((DateControl)item.DrawingData).Angle = AngleValue; |
||
2372 | (item.DrawingData as IPath).updateControl(); |
||
2373 | |||
2374 | BorderUpdate(); |
||
2375 | //MessageBox.Show("잠시 정확도를 위해 막아두었습니다!"); |
||
2376 | break; |
||
2377 | case ControlType.ArrowMultiLine: |
||
2378 | case ControlType.ArcLine: |
||
2379 | case ControlType.SingleLine: |
||
2380 | case ControlType.Triangle: |
||
2381 | (item.DrawingData as IPath).updateControl(); |
||
2382 | BorderUpdate(); |
||
2383 | break; |
||
2384 | case ControlType.ArrowTextControl: |
||
2385 | (item.DrawingData as IPath).updateControl(); |
||
2386 | BorderUpdate(); |
||
2387 | break; |
||
2388 | case ControlType.RectCloud: |
||
2389 | ((RectCloudControl)item.DrawingData).Angle = AngleValue; |
||
2390 | (item.DrawingData as IPath).updateControl(); |
||
2391 | BorderUpdate(); |
||
2392 | break; |
||
2393 | case ControlType.Rectangle: |
||
2394 | ((RectangleControl)item.DrawingData).Angle = AngleValue; |
||
2395 | (item.DrawingData as IPath).updateControl(); |
||
2396 | BorderUpdate(); |
||
2397 | break; |
||
2398 | case ControlType.ImgControl: |
||
2399 | ((ImgControl)item.DrawingData).Angle = AngleValue; |
||
2400 | (item.DrawingData as IPath).updateControl(); |
||
2401 | BorderUpdate(); |
||
2402 | break; |
||
2403 | //강인구 추가 |
||
2404 | case ControlType.Sign: |
||
2405 | ((SignControl)item.DrawingData).Angle = AngleValue; |
||
2406 | (item.DrawingData as IPath).updateControl(); |
||
2407 | BorderUpdate(); |
||
2408 | break; |
||
2409 | //강인구 추가 |
||
2410 | case ControlType.Symbol: |
||
2411 | ((SymControl)item.DrawingData).Angle = AngleValue; |
||
2412 | (item.DrawingData as IPath).updateControl(); |
||
2413 | BorderUpdate(); |
||
2414 | break; |
||
2415 | //강인구 추가 |
||
2416 | case ControlType.Stamp: |
||
2417 | ((SymControlN)item.DrawingData).Angle = AngleValue; |
||
2418 | (item.DrawingData as IPath).updateControl(); |
||
2419 | BorderUpdate(); |
||
2420 | break; |
||
2421 | case ControlType.PolygonControl: |
||
2422 | //((IShapeControl)AllControl).Angle = AngleValue; |
||
2423 | (item.DrawingData as IPath).updateControl(); |
||
2424 | BorderUpdate(); |
||
2425 | break; |
||
2426 | case ControlType.PolygonCloud: |
||
2427 | //((IShapeControl)AllControl).Angle = AngleValue; |
||
2428 | ((ICloudControl)item.DrawingData).DrawingCloud(); |
||
2429 | (item.DrawingData as IPath).updateControl(); |
||
2430 | BorderUpdate(); |
||
2431 | break; |
||
2432 | case ControlType.Circle: |
||
2433 | ((IShapeControl)item.DrawingData).Angle = AngleValue; |
||
2434 | (item.DrawingData as IPath).updateControl(); |
||
2435 | ((CircleControl)item.DrawingData).SetCenterXY(); |
||
2436 | BorderUpdate(); |
||
2437 | break; |
||
2438 | case ControlType.Ink: |
||
2439 | for (int i = 0; i < (item.DrawingData as InkControl).PointC.Count(); i++) |
||
2440 | { |
||
2441 | for (int j = 0; j < (item.DrawingData as InkControl).PointC[i].pointSet.Count; j++) |
||
2442 | { |
||
2443 | (item.DrawingData as InkControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as InkControl).PointC[i].pointSet[j], dDeltaAngle); |
||
2444 | } |
||
2445 | } |
||
2446 | (item.DrawingData as IPath).updateControl(); |
||
2447 | BorderUpdate(); |
||
2448 | break; |
||
2449 | //case MarkupType.PolygonEx: |
||
2450 | // //trRotate.Angle = AngleValue; |
||
2451 | // for (int i = 0; i < (item.DrawingData as PolyControl).PointC.Count(); i++) |
||
2452 | // { |
||
2453 | // //(item.DrawingData as PolyControl).PointC[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as PolyControl).PointC[i]., dDeltaAngle); |
||
2454 | // for (int j = 0; j < (item.DrawingData as PolyControl).PointC[i].pointSet.Count; j++) |
||
2455 | // { |
||
2456 | // (item.DrawingData as PolyControl).PointC[i].pointSet[j] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as PolyControl).PointC[i].pointSet[j], dDeltaAngle); |
||
2457 | // } |
||
2458 | // } |
||
2459 | // (item.DrawingData as IPath).updateControl(); |
||
2460 | // BorderUpdate(); |
||
2461 | // break; |
||
2462 | default: |
||
2463 | break; |
||
2464 | } |
||
2465 | } |
||
2466 | #endregion |
||
2467 | })); |
||
2468 | BorderUpdate(); |
||
2469 | } |
||
2470 | private void rotate_DragStarted(object sender, DragStartedEventArgs e) |
||
2471 | { |
||
2472 | //CustomCursor.SetCursorTemplate(rotateTop, this.Resources["AnimatedCursor"] as DataTemplate); |
||
2473 | rotateTop.Cursor = Cursors.None; |
||
2474 | |||
2475 | //if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().PointSet != null) |
||
2476 | //{ |
||
2477 | // return; |
||
2478 | //} |
||
2479 | if(ViewerDataModel.Instance.UndoDataList == null) |
||
2480 | { |
||
2481 | return; |
||
2482 | } |
||
2483 | |||
2484 | |||
2485 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb) |
||
2486 | { |
||
2487 | return; |
||
2488 | } |
||
2489 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null) |
||
2490 | { |
||
2491 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0) |
||
2492 | { |
||
2493 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null) |
||
2494 | { |
||
2495 | return; |
||
2496 | } |
||
2497 | } |
||
2498 | } |
||
2499 | |||
2500 | Undo_Event(); |
||
2501 | } |
||
2502 | |||
2503 | private void rotate_DragCompleted(object sender, DragCompletedEventArgs e) |
||
2504 | { |
||
2505 | //CustomCursor.SetCursorTemplate(rotateTop, null); |
||
2506 | rotateTop.Cursor = Cursors.Arrow; |
||
2507 | |||
2508 | Undo_Event(); |
||
2509 | } |
||
2510 | |||
2511 | private void drag_DragStarted(object sender, DragStartedEventArgs e) |
||
2512 | { |
||
2513 | DragThumb.Cursor = Cursors.None; |
||
2514 | |||
2515 | if (ViewerDataModel.Instance.UndoDataList == null) |
||
2516 | { |
||
2517 | return; |
||
2518 | } |
||
2519 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb) |
||
2520 | { |
||
2521 | return; |
||
2522 | } |
||
2523 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null) |
||
2524 | { |
||
2525 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0) |
||
2526 | { |
||
2527 | if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null) |
||
2528 | { |
||
2529 | return; |
||
2530 | } |
||
2531 | } |
||
2532 | } |
||
2533 | |||
2534 | Undo_Event(); |
||
2535 | } |
||
2536 | |||
2537 | private void Undo_Event() |
||
2538 | { |
||
2539 | List<Point> p_set = new List<Point>(); |
||
2540 | |||
2541 | Undo_data UndoData = new Undo_data() |
||
2542 | { |
||
2543 | IsUndo = false, |
||
2544 | Event = Event_Type.Thumb, |
||
2545 | EventTime = DateTime.Now, |
||
2546 | Markup_List = new List<Multi_Undo_data>(), |
||
2547 | }; |
||
2548 | |||
2549 | Multi_Undo_data multi_Undo_Data = new Multi_Undo_data(); |
||
2550 | |||
2551 | foreach (var control in MemberSet) |
||
2552 | { |
||
2553 | multi_Undo_Data.PointSet = new List<Point>(); |
||
2554 | p_set = new List<Point>(); |
||
2555 | |||
2556 | if(control.DrawingData as TextControl != null) |
||
2557 | { |
||
2558 | multi_Undo_Data.PointSet.Add((control.DrawingData as TextControl).StartPoint); |
||
2559 | multi_Undo_Data.PointSet.Add((control.DrawingData as TextControl).EndPoint); |
||
2560 | } |
||
2561 | |||
2562 | foreach (var point in ((control.DrawingData as CommentUserInfo) as IPath).PointSet) |
||
2563 | { |
||
2564 | multi_Undo_Data.PointSet.Add(point); |
||
2565 | } |
||
2566 | |||
2567 | multi_Undo_Data.Angle = AngleValue; |
||
2568 | |||
2569 | multi_Undo_Data.Markup = control.DrawingData as CommentUserInfo; |
||
2570 | UndoData.Markup_List.Add(multi_Undo_Data); |
||
2571 | multi_Undo_Data = new Multi_Undo_data(); |
||
2572 | } |
||
2573 | ViewerDataModel.Instance.UndoDataList.Where(data => data.IsUndo == true).ToList().ForEach(i => |
||
2574 | { |
||
2575 | ViewerDataModel.Instance.UndoDataList.Remove(i); |
||
2576 | }); |
||
2577 | |||
2578 | ViewerDataModel.Instance.UndoDataList.Add(UndoData); |
||
2579 | |||
2580 | } |
||
2581 | |||
2582 | private void drag_DragCompleted(object sender, DragCompletedEventArgs e) |
||
2583 | { |
||
2584 | DragThumb.Cursor = Cursors.Arrow; |
||
2585 | Undo_Event(); |
||
2586 | } |
||
2587 | |||
2588 | public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
||
2589 | { |
||
2590 | AdornerMember control = MemberSet.FirstOrDefault(); |
||
2591 | |||
2592 | if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null) |
||
2593 | { |
||
2594 | if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false) |
||
2595 | { |
||
2596 | (control.DrawingData as ArrowTextControl).isTrans = true; |
||
2597 | } |
||
2598 | } |
||
2599 | |||
2600 | } |
||
2601 | public void TextControlChanger() |
||
2602 | { |
||
2603 | if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl") |
||
2604 | { |
||
2605 | TextControl AllControl = (MemberSet.First() as AdornerMember).DrawingData as TextControl; |
||
2606 | AllControl.Base_TextBox.Focus(); |
||
2607 | AllControl.Base_TextBox.Visibility = Visibility.Visible; |
||
2608 | AllControl.Base_TextBlock.Visibility = Visibility.Collapsed; |
||
2609 | AllControl.Base_TextBox.Focus(); |
||
2610 | AllControl.SizeChanged += (sen, ea) => |
||
2611 | { |
||
2612 | if (AllControl.Base_TextBox != null) |
||
2613 | { |
||
2614 | RectangleGeometry Data = new RectangleGeometry |
||
2615 | { |
||
2616 | Rect = new Rect() |
||
2617 | { |
||
2618 | X = AllControl.StartPoint.X, |
||
2619 | Y = AllControl.StartPoint.Y, |
||
2620 | Width = AllControl.Base_TextBox.Width, |
||
2621 | Height = AllControl.Base_TextBox.Height, |
||
2622 | } |
||
2623 | }; |
||
2624 | |||
2625 | Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom); |
||
2626 | Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV); |
||
2627 | AllControl.Base_Grid.RenderTransform = new RotateTransform() |
||
2628 | { |
||
2629 | Angle = AllControl.Angle, |
||
2630 | CenterX = middle.X, |
||
2631 | CenterY = middle.Y, |
||
2632 | }; |
||
2633 | } |
||
2634 | BorderUpdate(); |
||
2635 | }; |
||
2636 | } |
||
2637 | } |
||
2638 | private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭 |
||
2639 | { |
||
2640 | if (e.ClickCount == 2 && MemberSet.Count == 1) |
||
2641 | { |
||
2642 | |||
2643 | if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl") |
||
2644 | { |
||
2645 | TextControlChanger(); |
||
2646 | // TextControl AllControl = (MemberSet.First() as AdornerMember).DrawingData as TextControl; |
||
2647 | // AllControl.Base_TextBox.Focus(); |
||
2648 | // AllControl.Base_TextBox.Visibility = Visibility.Visible; |
||
2649 | // AllControl.Base_TextBlock.Visibility = Visibility.Collapsed; |
||
2650 | // AllControl.Base_TextBox.Focus(); |
||
2651 | // AllControl.SizeChanged += (sen, ea) => |
||
2652 | // { |
||
2653 | // if (AllControl.Base_TextBox != null) |
||
2654 | // { |
||
2655 | // RectangleGeometry Data = new RectangleGeometry |
||
2656 | // { |
||
2657 | // Rect = new Rect() |
||
2658 | // { |
||
2659 | // X = AllControl.StartPoint.X, |
||
2660 | // Y = AllControl.StartPoint.Y, |
||
2661 | // Width = AllControl.Base_TextBox.Width, |
||
2662 | // Height = AllControl.Base_TextBox.Height, |
||
2663 | // } |
||
2664 | // }; |
||
2665 | |||
2666 | // Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom); |
||
2667 | // Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV); |
||
2668 | // AllControl.Base_Grid.RenderTransform = new RotateTransform() |
||
2669 | // { |
||
2670 | // Angle = AllControl.Angle, |
||
2671 | // CenterX = middle.X, |
||
2672 | // CenterY = middle.Y, |
||
2673 | // }; |
||
2674 | // } |
||
2675 | // BorderUpdate(); |
||
2676 | // }; |
||
2677 | } |
||
2678 | |||
2679 | else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl") |
||
2680 | { |
||
2681 | ArrowTextControl AllControl = (MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl; |
||
2682 | Thumb tm = (MemberSet.First() as AdornerMember).ThumbList.Last(); |
||
2683 | ((ArrowTextControl)AllControl).Base_TextBox.Focus(); |
||
2684 | |||
2685 | //강인구 추가(ArrowControl TextBox Thumb없애기 |
||
2686 | tm.Visibility = Visibility.Collapsed; |
||
2687 | |||
2688 | ((MemberSet.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true; |
||
2689 | |||
2690 | //(sender as System.Windows.Shapes.Rectangle).IsHitTestVisible = false; |
||
2691 | //(sender as System.Windows.Shapes.Rectangle).Visibility = Visibility.Hidden; |
||
2692 | //Canvas.SetZIndex(((ArrowTextControl)AllControl).Base_TextBox,9999); |
||
2693 | //editTextBox = ((ArrowTextControl)AllControl).Base_TextBox; |
||
2694 | //editTextBox.Style = ((ArrowTextControl)AllControl).Base_TextBox.Style; |
||
2695 | //editTextBox.Text = (AllControl as ArrowTextControl).ArrowText; |
||
2696 | //editTextBox.FontSize = (AllControl as ArrowTextControl).FontSize; |
||
2697 | //editTextBox.Foreground = (AllControl as ArrowTextControl).Foreground; |
||
2698 | //editTextBox.FontWeight = (AllControl as ArrowTextControl).FontWeight; |
||
2699 | |||
2700 | //(AllControl as ArrowTextControl).Base_TextBox.Visibility = Visibility.Collapsed; |
||
2701 | //editTextBox = (AllControl as ArrowTextControl).Base_TextBox; |
||
2702 | //editTextBox.TextChanged += (sen, ea) => |
||
2703 | // { |
||
2704 | // ((ArrowTextControl)AllControl).ArrowText = editTextBox.Text; |
||
2705 | // }; |
||
2706 | |||
2707 | |||
2708 | //(sender as System.Windows.Shapes.Rectangle).Visibility = Visibility.Hidden; |
||
2709 | //((ArrowTextControl)AllControl).Base_TextBox.Background = new SolidColorBrush(Colors.Blue); |
||
2710 | //((ArrowTextControl)AllControl).Base_TextBox.Opacity = 1; |
||
2711 | //((ArrowTextControl)AllControl).Base_TextBox.Focus(); |
||
2712 | |||
2713 | ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) => |
||
2714 | |||
2715 | { |
||
2716 | tm.Width = (AllControl as ArrowTextControl).BoxWidth; |
||
2717 | tm.Height = (AllControl as ArrowTextControl).BoxHeight; |
||
2718 | |||
2719 | List<Point> ps = new List<Point>(); |
||
2720 | //RotateTransform myRotateTransform = new RotateTransform(); |
||
2721 | |||
2722 | |||
2723 | //if (control.Angle == -270) |
||
2724 | //{ |
||
2725 | // myRotateTransform.Angle = 90; |
||
2726 | // myRotateTransform.CenterX = Canvas.GetLeft(control.Base_TextBox); |
||
2727 | // myRotateTransform.CenterY = Canvas.GetTop(control.Base_TextBox); |
||
2728 | //} |
||
2729 | //else if (control.Angle == -90) |
||
2730 | //{ |
||
2731 | // myRotateTransform.Angle = 270; |
||
2732 | // myRotateTransform.CenterX = Canvas.GetLeft(control.Base_TextBox); |
||
2733 | // myRotateTransform.CenterY = Canvas.GetTop(control.Base_TextBox); |
||
2734 | //} |
||
2735 | //TransformGroup myTransformGroup = new TransformGroup(); |
||
2736 | //myTransformGroup.Children.Add(myRotateTransform); |
||
2737 | |||
2738 | ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단 |
||
2739 | ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단 |
||
2740 | ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단 |
||
2741 | ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //우단 |
||
2742 | |||
2743 | |||
2744 | |||
2745 | |||
2746 | var endP = MathSet.getNearPoint(ps, AllControl.MidPoint); |
||
2747 | var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP); |
||
2748 | if (AllControl.isTrans) |
||
2749 | { |
||
2750 | Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X); |
||
2751 | Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y); |
||
2752 | } |
||
2753 | else |
||
2754 | { |
||
2755 | Canvas.SetLeft((MemberSet.First() as AdornerMember).ThumbList[1], tempP.X); |
||
2756 | Canvas.SetTop((MemberSet.First() as AdornerMember).ThumbList[1], tempP.Y); |
||
2757 | } |
||
2758 | |||
2759 | |||
2760 | BorderUpdate(); |
||
2761 | |||
2762 | }; |
||
2763 | } |
||
2764 | else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "DateControl") |
||
2765 | { |
||
2766 | DateControl data = (MemberSet.First() as AdornerMember).DrawingData as DateControl; |
||
2767 | CalendarControl instanceCal = new CalendarControl(data.Text); |
||
2768 | //dropData.IsOpen = true; |
||
2769 | RadWindow rc = new RadWindow(); |
||
2770 | rc.Width = 300; |
||
2771 | rc.Height = 300; |
||
2772 | rc.Header = "Change Date"; |
||
2773 | rc.Content = instanceCal; |
||
2774 | rc.BorderThickness = new Thickness(3); |
||
2775 | rc.ResizeMode = ResizeMode.NoResize; |
||
2776 | rc.WindowStartupLocation = WindowStartupLocation.CenterScreen; |
||
2777 | rc.ModalBackground = new SolidColorBrush(Colors.Black); |
||
2778 | rc.ModalBackground.Opacity = 0.6; |
||
2779 | Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme()); |
||
2780 | instanceCal.changeDateCal.SelectionChanged += (sen, ea) => |
||
2781 | { |
||
2782 | data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString(); |
||
2783 | rc.Close(); |
||
2784 | }; |
||
2785 | rc.ShowDialog(); |
||
2786 | //CalendarControl.xaml |
||
2787 | } |
||
2788 | else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl") |
||
2789 | { |
||
2790 | ArcControl instance = ((MemberSet.First() as AdornerMember).DrawingData as ArcControl); |
||
2791 | if (instance.isTransOn) |
||
2792 | { |
||
2793 | instance.isTransOn = false; |
||
2794 | } |
||
2795 | else |
||
2796 | { |
||
2797 | instance.isTransOn = true; |
||
2798 | } |
||
2799 | instance.SetArcPath(); |
||
2800 | BorderUpdate(); |
||
2801 | } |
||
2802 | else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "CloudControl") |
||
2803 | { |
||
2804 | CloudControl instance = ((MemberSet.First() as AdornerMember).DrawingData as CloudControl); |
||
2805 | if (!instance.isChain) |
||
2806 | { |
||
2807 | if (instance.isTransOn) |
||
2808 | { |
||
2809 | instance.isTransOn = false; |
||
2810 | } |
||
2811 | else |
||
2812 | { |
||
2813 | instance.isTransOn = true; |
||
2814 | } |
||
2815 | |||
2816 | instance.SetCloud(); |
||
2817 | BorderUpdate(); |
||
2818 | } |
||
2819 | } |
||
2820 | //else if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "LineControl") |
||
2821 | //{ |
||
2822 | // LineControl instance = ((MemberSet.First() as AdornerMember).DrawingData as LineControl); |
||
2823 | // if (instance.LineStyle == LineControl.LineStyleSet.MultiLine) |
||
2824 | // { |
||
2825 | // instance.Interval += 1; |
||
2826 | // instance.SetLinePath(); |
||
2827 | // BorderUpdate(); |
||
2828 | // } |
||
2829 | |||
2830 | // //instance.SetCloud(); |
||
2831 | // //BorderUpdate(); |
||
2832 | //} |
||
2833 | |||
2834 | } |
||
2835 | //if (e.ClickCount == 2 && AllControl.GetType().Name == "TextControl") // Edit Mode |
||
2836 | //{ |
||
2837 | // ((TextControl)AllControl).Base_TextBox.Focus(); |
||
2838 | // ((TextControl)AllControl).Base_TextBox.Visibility = Visibility.Visible; |
||
2839 | // ((TextControl)AllControl).Base_TextBlock.Visibility = Visibility.Collapsed; |
||
2840 | //} |
||
2841 | //if (e.ClickCount == 2 && AllControl.GetType().Name == "ArrowTextControl") // Edit Mode |
||
2842 | //{ |
||
2843 | // Thumb tm = (from kkk in this.ContainerContent.Children |
||
2844 | // where (kkk as FrameworkElement).Name == "LastThumb" |
||
2845 | // select kkk).FirstOrDefault() as Thumb; |
||
2846 | // ((ArrowTextControl)AllControl).Base_TextBox.Focus(); |
||
2847 | // ((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) => |
||
2848 | // { |
||
2849 | // tm.Width = (AllControl as ArrowTextControl).BoxWidth; |
||
2850 | // tm.Height = (AllControl as ArrowTextControl).BoxHeight; |
||
2851 | // Canvas.SetLeft(tm, (AllControl.EndPoint.X - tm.Width / 2)); |
||
2852 | // Canvas.SetTop(tm, (AllControl.EndPoint.Y - tm.Height / 2)); |
||
2853 | // Canvas.SetLeft((AllControl as ArrowTextControl).Base_TextBox, (AllControl.EndPoint.X - tm.Width / 2)); |
||
2854 | // Canvas.SetTop((AllControl as ArrowTextControl).Base_TextBox, (AllControl.EndPoint.Y - tm.Height / 2)); |
||
2855 | // }; |
||
2856 | //} |
||
2857 | } |
||
2858 | #endregion |
||
2859 | |||
2860 | private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e) |
||
2861 | { |
||
2862 | if ((MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (MemberSet.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl") |
||
2863 | { |
||
2864 | DragThumb.Visibility = Visibility.Collapsed; |
||
2865 | } |
||
2866 | } |
||
2867 | |||
2868 | //private void testText_Loaded(object sender, RoutedEventArgs e) |
||
2869 | //{ |
||
2870 | // editTextBox = sender as TextBox; |
||
2871 | //} |
||
2872 | } |
||
2873 | } |