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