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