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