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