markus / KCOM / Controls / AdornerFinal.xaml.cs @ 554aae3b
이력 | 보기 | 이력해설 | 다운로드 (82.5 KB)
1 |
using KCOM.Common; |
---|---|
2 |
using KCOM.Events; |
3 |
using MarkupToPDF.Common; |
4 |
using MarkupToPDF.Controls.Cad; |
5 |
using MarkupToPDF.Controls.Common; |
6 |
using MarkupToPDF.Controls.Etc; |
7 |
using MarkupToPDF.Controls.Line; |
8 |
using MarkupToPDF.Controls.Polygon; |
9 |
using MarkupToPDF.Controls.Shape; |
10 |
using MarkupToPDF.Controls.Text; |
11 |
using System; |
12 |
using System.Collections.Generic; |
13 |
using System.Diagnostics; |
14 |
using System.Linq; |
15 |
using System.Reactive.Linq; |
16 |
using System.Text; |
17 |
using System.Windows; |
18 |
using System.Windows.Controls; |
19 |
using System.Windows.Controls.Primitives; |
20 |
using System.Windows.Input; |
21 |
using System.Windows.Media; |
22 |
using Telerik.Windows.Controls; |
23 |
|
24 |
namespace KCOM.Controls |
25 |
{ |
26 |
public class MyThumb : Thumb |
27 |
{ |
28 |
public MyThumb() |
29 |
{ |
30 |
this.Opacity = 0.6; |
31 |
this.MouseEnter += MyThumb_MouseEnter; |
32 |
this.MouseLeave += MyThumb_MouseLeave; |
33 |
} |
34 |
|
35 |
/// <summary> |
36 |
/// translate thumb with given delta and angle |
37 |
/// </summary> |
38 |
/// <param name="e"></param> |
39 |
/// <param name="angle"></param> |
40 |
public void Translate(double dx, double dy, double angle) |
41 |
{ |
42 |
double radian = angle * Math.PI / 180; |
43 |
double cos = Math.Cos(radian); |
44 |
double sin = Math.Sin(radian); |
45 |
|
46 |
double _dx = dx * cos - dy * sin; |
47 |
double _dy = dx * sin + dy * cos; |
48 |
Canvas.SetLeft(this, Canvas.GetLeft(this) + _dx); |
49 |
Canvas.SetTop(this, Canvas.GetTop(this) + _dy); |
50 |
} |
51 |
|
52 |
/// <summary> |
53 |
/// </summary> |
54 |
/// <param name="sender"></param> |
55 |
/// <param name="e"></param> |
56 |
private void MyThumb_MouseLeave(object sender, MouseEventArgs e) |
57 |
{ |
58 |
this.Opacity = 0.6; |
59 |
} |
60 |
|
61 |
/// <summary> |
62 |
/// |
63 |
/// </summary> |
64 |
/// <param name="sender"></param> |
65 |
/// <param name="e"></param> |
66 |
private void MyThumb_MouseEnter(object sender, MouseEventArgs e) |
67 |
{ |
68 |
this.Opacity = 1.0; |
69 |
} |
70 |
} |
71 |
|
72 |
/// <summary> |
73 |
/// Interaction logic for AdornerFinal.xaml |
74 |
/// </summary> |
75 |
public class AdornerMember |
76 |
{ |
77 |
public UIElement DrawingData { get; set; } |
78 |
public ControlType Drawingtype { get; set; } |
79 |
public double DrawingAngle { get; set; } |
80 |
public List<MyThumb> ThumbList { get; set; } |
81 |
public string Symbol_ID { get; set; } |
82 |
public long Group_ID { get; set; } |
83 |
|
84 |
/// <summary> |
85 |
/// update thumb |
86 |
/// </summary> |
87 |
public void UpdateThumb() |
88 |
{ |
89 |
var path = this.DrawingData as IPath; |
90 |
for (int i = 0; i < path.PointSet.Count; ++i) |
91 |
{ |
92 |
Canvas.SetLeft(this.ThumbList[i], path.PointSet[i].X); |
93 |
Canvas.SetTop(this.ThumbList[i], path.PointSet[i].Y); |
94 |
} |
95 |
|
96 |
if (this.DrawingData as ArrowTextControl != null) |
97 |
{ |
98 |
if (!(this.DrawingData as ArrowTextControl).isTrans) //trans가 True인경우 |
99 |
{ |
100 |
List<Point> ps = new List<Point>(); |
101 |
|
102 |
var temp = this.DrawingData as ArrowTextControl; |
103 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단 |
104 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단 |
105 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단 |
106 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단 |
107 |
|
108 |
if (temp.isFixed) |
109 |
{ |
110 |
var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
111 |
var testP = endP; |
112 |
if (ps[0] == endP) //상단 |
113 |
{ |
114 |
testP = new Point(endP.X, endP.Y - 50); |
115 |
} |
116 |
else if (ps[1] == endP) //하단 |
117 |
{ |
118 |
testP = new Point(endP.X, endP.Y + 50); |
119 |
} |
120 |
else if (ps[2] == endP) //좌단 |
121 |
{ |
122 |
testP = new Point(endP.X - 50, endP.Y); |
123 |
} |
124 |
else if (ps[3] == endP) //우단 |
125 |
{ |
126 |
testP = new Point(endP.X + 50, endP.Y); |
127 |
} |
128 |
Canvas.SetLeft(this.ThumbList[1], testP.X); |
129 |
Canvas.SetTop(this.ThumbList[1], testP.Y); |
130 |
} |
131 |
else |
132 |
{ |
133 |
var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
134 |
var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP); |
135 |
Canvas.SetLeft(this.ThumbList[1], tempP.X); |
136 |
Canvas.SetTop(this.ThumbList[1], tempP.Y); |
137 |
} |
138 |
} |
139 |
} |
140 |
} |
141 |
|
142 |
/// <summary> |
143 |
/// rotate members about given position and angle |
144 |
/// </summary> |
145 |
/// <param name="at"></param> |
146 |
/// <param name="angle">in degree</param> |
147 |
public void RotateAbout(Point at, double angle) |
148 |
{ |
149 |
for (int i = 0; i < (this.DrawingData as IPath).PointSet.Count; i++) |
150 |
{ |
151 |
(this.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(at, (this.DrawingData as IPath).PointSet[i], angle); |
152 |
} |
153 |
(this.DrawingData as CommentUserInfo).UpdateControl(); |
154 |
|
155 |
this.UpdateThumb(); |
156 |
} |
157 |
} |
158 |
|
159 |
public partial class AdornerFinal : UserControl |
160 |
{ |
161 |
public TextBox editTextBox { get; set; } |
162 |
#region 공용 인스턴스 |
163 |
public List<AdornerMember> Members { get; } = new List<AdornerMember>(); |
164 |
public Dictionary<Thumb, DragData> _dragData = new Dictionary<Thumb, DragData>(); |
165 |
public double AngleValue = 0; |
166 |
public bool IsTextAngle = false; |
167 |
public Rect BorderSize { get; set; } |
168 |
public bool TextCompensation = false; |
169 |
public bool isDragging { get; set; } |
170 |
public Thumb DraggerThumb { get; set; } |
171 |
public RadDropDownButton dropData; |
172 |
public RadCalendar dropCalendar; |
173 |
public Thumb mainDragThumb { get; set; } |
174 |
|
175 |
private bool disposed; |
176 |
|
177 |
public Point reSizePoint { get; set; } |
178 |
private Point rotatePoint { get; set; } /// 2018.05.09 added by humkyung |
179 |
private Point MouseDownPoint = new Point(); |
180 |
private Point CurrentMousePoint = new Point(); |
181 |
#endregion |
182 |
#region 생성자 |
183 |
private void RadDropDownButton_Loaded(object sender, RoutedEventArgs e) |
184 |
{ |
185 |
dropData = sender as RadDropDownButton; |
186 |
} |
187 |
|
188 |
private void Date_Calendar_Loaded(object sender, RoutedEventArgs e) |
189 |
{ |
190 |
dropCalendar = sender as RadCalendar; |
191 |
dropCalendar.SelectionChanged += (sen, ea) => |
192 |
{ |
193 |
dropData.IsOpen = false; |
194 |
if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl") |
195 |
{ |
196 |
DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl; |
197 |
data.Text = dropCalendar.SelectedDate.Value.ToShortDateString(); |
198 |
} |
199 |
}; |
200 |
} |
201 |
|
202 |
public AdornerFinal() |
203 |
{ |
204 |
InitializeComponent(); |
205 |
BorderSize = new Rect(); |
206 |
_dragData.Add(rotateTop, new DragData() { CursorAngle = 0, DragType = DragType.Rotate, RotateIsLeft = true, RotateIsTop = true }); |
207 |
} |
208 |
|
209 |
~AdornerFinal() |
210 |
{ |
211 |
this.Dispose(false); |
212 |
} |
213 |
|
214 |
public void Dispose() |
215 |
{ |
216 |
this.Dispose(true); |
217 |
GC.SuppressFinalize(this); |
218 |
} |
219 |
|
220 |
protected virtual void Dispose(bool disposing) |
221 |
{ |
222 |
if (this.disposed) return; |
223 |
if (disposing) |
224 |
{ |
225 |
foreach (var member in this.Members) |
226 |
{ |
227 |
if(!Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member.DrawingData)) |
228 |
Common.ViewerDataModel.Instance.MarkupControls_USER.Add(member.DrawingData as CommentUserInfo); |
229 |
} |
230 |
// IDisposable 인터페이스를 구현하는 멤버들을 여기서 정리합니다. |
231 |
} |
232 |
// .NET Framework에 의하여 관리되지 않는 외부 리소스들을 여기서 정리합니다. |
233 |
this.disposed = true; |
234 |
} |
235 |
|
236 |
void DragThumb_Loaded(object sender, RoutedEventArgs e) |
237 |
{ |
238 |
mainDragThumb = DragThumb; |
239 |
} |
240 |
|
241 |
public AdornerFinal(CommentUserInfo objectData) : this() |
242 |
{ |
243 |
InitializeComponent(); |
244 |
objectData.IsHitTestVisible = false; |
245 |
if ((objectData as ArrowTextControl) != null) |
246 |
{ |
247 |
(objectData as ArrowTextControl).Base_TextBox.Focusable = true; |
248 |
} |
249 |
Canvas.SetZIndex(objectData, 84); |
250 |
try |
251 |
{ |
252 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(objectData); |
253 |
this.ContainerContent.Children.Add(objectData); |
254 |
} |
255 |
catch (Exception ex) |
256 |
{ |
257 |
|
258 |
} |
259 |
|
260 |
SetAdornerMember(objectData as CommentUserInfo); |
261 |
this.Focus(); |
262 |
} |
263 |
|
264 |
public AdornerFinal(List<CommentUserInfo> objectData) : this() |
265 |
{ |
266 |
InitializeComponent(); |
267 |
foreach (var item in objectData) |
268 |
{ |
269 |
//item.IsHitTestVisible = false; |
270 |
if ((item as ArrowTextControl) != null) |
271 |
{ |
272 |
(item as ArrowTextControl).Base_TextBox.Focusable = true; |
273 |
} |
274 |
try |
275 |
{ |
276 |
Canvas.SetZIndex(item, 80); |
277 |
ViewerDataModel.Instance.MarkupControls_USER.Remove(item); |
278 |
this.ContainerContent.Children.Add(item); |
279 |
} |
280 |
catch //(Exception ex) |
281 |
{ |
282 |
} |
283 |
finally |
284 |
{ |
285 |
|
286 |
} |
287 |
} |
288 |
this.SetAdornerMember(objectData); |
289 |
this.Focus(); |
290 |
} |
291 |
|
292 |
#endregion |
293 |
#region 메서드 |
294 |
public Rect getAdornerSize() |
295 |
{ |
296 |
return BorderSize; |
297 |
} |
298 |
public void addMemberControl(UIElement objectData) |
299 |
{ |
300 |
this.ContainerContent.Children.Add(objectData); |
301 |
SetAdornerMember(objectData as CommentUserInfo); |
302 |
this.Focus(); |
303 |
} |
304 |
/// <summary> |
305 |
/// UIElement를 종류에 맞게 등록시킴 |
306 |
/// </summary> |
307 |
/// <param name="member">UIElement 타입으로 BaseLayer에 있는 것들이 들어옵니다.</param> |
308 |
public void SetAdornerMember(MarkupToPDF.Common.CommentUserInfo member) |
309 |
{ |
310 |
switch (member.GetType().Name) |
311 |
{ |
312 |
#region 컨트롤 조건 |
313 |
case "LineControl": |
314 |
case "PolygonControl": |
315 |
case "ArrowControl": |
316 |
case "ArcControl": |
317 |
case "ArrowArcControl": |
318 |
case "ArrowControl_Multi": |
319 |
case "RectangleControl": |
320 |
case "TriControl": |
321 |
case "CircleControl": |
322 |
case "CloudControl": |
323 |
case "RectCloudControl": |
324 |
case "InkControl": |
325 |
case "InsideWhiteControl": |
326 |
case "OverlapWhiteControl": |
327 |
case "ClipWhiteControl": |
328 |
case "CoordinateControl": |
329 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
330 |
break; |
331 |
case "ArrowTextControl": |
332 |
this.Members.Add(new AdornerMember |
333 |
{ |
334 |
DrawingData = member, |
335 |
Drawingtype = ControlType.ArrowTextControl, |
336 |
ThumbList = new List<MyThumb>(), |
337 |
Symbol_ID = member.SymbolID, |
338 |
Group_ID = member.GroupID, |
339 |
}); |
340 |
(member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false; |
341 |
AngleValue = (member as ArrowTextControl).Angle; |
342 |
Observable.FromEventPattern(((ArrowTextControl)member).Base_TextBox, "LostFocus").Subscribe(a => |
343 |
{ |
344 |
TextCompensation = false; |
345 |
BorderUpdate(); |
346 |
if ((a.Sender as TextBox).Text == "") //보류 |
347 |
{ |
348 |
this.ContainerContent.Children.Remove(member); |
349 |
this.Visibility = Visibility.Collapsed; |
350 |
} |
351 |
}); |
352 |
break; |
353 |
case "ImgControl": |
354 |
case "DateControl": |
355 |
case "SignControl": |
356 |
case "SymControl": |
357 |
case "SymControlN": |
358 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = member.ControlType, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
359 |
AngleValue = (member as DateControl).Angle; |
360 |
break; |
361 |
case "TextControl": |
362 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
363 |
RectangleGeometry Data = new RectangleGeometry |
364 |
{ |
365 |
Rect = new Rect() |
366 |
{ |
367 |
X = Canvas.GetLeft((member as TextControl)), |
368 |
Y = Canvas.GetTop((member as TextControl)), |
369 |
Width = (member as TextControl).Base_TextBlock.ActualWidth / 2, |
370 |
Height = (member as TextControl).Base_TextBlock.ActualHeight / 2, |
371 |
//Width = (member as TextControl).BoxWidth / 2, |
372 |
//Height = (member as TextControl).BoxHeight / 2, |
373 |
} |
374 |
}; |
375 |
Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom); |
376 |
Point middle = MathSet.getMiddlePoint((member as TextControl).StartPoint, endPointV); |
377 |
|
378 |
|
379 |
DragThumb.RenderTransformOrigin = new Point(0.0, 0.0); |
380 |
DragThumb.RenderTransform = new RotateTransform() |
381 |
{ |
382 |
Angle = (member as TextControl).Angle, |
383 |
//CenterX = middle.X, |
384 |
//CenterY = middle.Y, |
385 |
}; |
386 |
|
387 |
AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0); |
388 |
AdornerBorder.RenderTransform = new RotateTransform() |
389 |
{ |
390 |
Angle = (member as TextControl).Angle, |
391 |
//CenterX = middle.X, |
392 |
//CenterY = middle.Y, |
393 |
}; |
394 |
Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a => |
395 |
{ |
396 |
TextCompensation = true; |
397 |
BorderUpdate(); |
398 |
((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; |
399 |
}); |
400 |
Observable.FromEventPattern(((TextControl)member).Base_TextBox, "LostFocus").Subscribe(a => |
401 |
{ |
402 |
TextCompensation = false; |
403 |
BorderUpdate(); |
404 |
if ((a.Sender as TextBox).Text == "") //보류 |
405 |
{ |
406 |
this.ContainerContent.Children.Remove(member); |
407 |
this.Visibility = Visibility.Collapsed; |
408 |
} |
409 |
|
410 |
//((TextControl)member).UnEditingMode(); |
411 |
//((TextControl)member).Base_TextBlock.Visibility = Visibility.Collapsed; |
412 |
//((TextControl)member).Base_Border.Visibility = Visibility.Collapsed; |
413 |
//((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed; |
414 |
}); |
415 |
break; |
416 |
default: |
417 |
break; |
418 |
#endregion |
419 |
} |
420 |
|
421 |
if (member.GetType().Name == "TextControl") |
422 |
{ |
423 |
TextControl content = ((TextControl)member); |
424 |
content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content)); |
425 |
content.EndPoint = content.StartPoint; |
426 |
} |
427 |
else |
428 |
{ |
429 |
RegistryPoint(member); |
430 |
} |
431 |
BorderUpdate(); |
432 |
|
433 |
if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); |
434 |
} |
435 |
|
436 |
private void ViewBoxRotate(UIElement member) |
437 |
{ |
438 |
AdornerBorder.RenderTransformOrigin = new Point(0.5, 0.5); |
439 |
DragThumb.RenderTransformOrigin = new Point(0.5, 0.5); |
440 |
AdornerBorder.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle }; |
441 |
DragThumb.RenderTransform = new RotateTransform() { Angle = (member as IViewBox).Angle }; |
442 |
} |
443 |
|
444 |
public void SetAdornerMember(List<CommentUserInfo> members) |
445 |
{ |
446 |
foreach (var member in members) |
447 |
{ |
448 |
switch (member.GetType().Name) |
449 |
{ |
450 |
#region 컨트롤 조건 |
451 |
case "LineControl": |
452 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.SingleLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
453 |
break; |
454 |
case "ImgControl": |
455 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ImgControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
456 |
break; |
457 |
case "ArrowControl": |
458 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
459 |
break; |
460 |
case "PolygonControl": |
461 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
462 |
break; |
463 |
case "ArrowTextControl": |
464 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowTextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
465 |
(member as ArrowTextControl).Base_TextBox.IsHitTestVisible = false; |
466 |
break; |
467 |
case "ArcControl": |
468 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
469 |
break; |
470 |
case "ArrowArcControl": |
471 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArcArrow, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
472 |
break; |
473 |
case "DateControl": |
474 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Date, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
475 |
break; |
476 |
case "ArrowControl_Multi": |
477 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ArrowMultiLine, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
478 |
break; |
479 |
case "RectangleControl": |
480 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Rectangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
481 |
break; |
482 |
case "TriControl": |
483 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Triangle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
484 |
break; |
485 |
case "CircleControl": |
486 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Circle, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
487 |
break; |
488 |
case "CloudControl": |
489 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.PolygonCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
490 |
break; |
491 |
case "RectCloudControl": |
492 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.RectCloud, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
493 |
break; |
494 |
case "SignControl": |
495 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Sign, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
496 |
break; |
497 |
case "SymControl": |
498 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Symbol, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
499 |
break; |
500 |
case "SymControlN": |
501 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Stamp, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
502 |
break; |
503 |
case "InkControl": |
504 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Ink, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
505 |
break; |
506 |
case "TextControl": |
507 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.TextControl, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
508 |
Observable.FromEventPattern(((TextControl)member), "PropertyChanged").Subscribe(a => |
509 |
{ |
510 |
BorderUpdate(); |
511 |
try |
512 |
{ |
513 |
((TextControl)member).Base_TextBlock.TextDecorations = ((TextControl)member).UnderLine; |
514 |
} |
515 |
catch (Exception) |
516 |
{ |
517 |
|
518 |
} |
519 |
|
520 |
}); |
521 |
Observable.FromEventPattern(((TextControl)member).Base_TextBox, "SelectionChanged").Subscribe(a => |
522 |
{ |
523 |
BorderUpdate(); |
524 |
}); |
525 |
break; |
526 |
case "InsideWhiteControl": |
527 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
528 |
break; |
529 |
case "OverlapWhiteControl": |
530 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
531 |
break; |
532 |
case "ClipWhiteControl": |
533 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
534 |
break; |
535 |
case "CoordinateControl": |
536 |
this.Members.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<MyThumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID }); |
537 |
break; |
538 |
default: |
539 |
break; |
540 |
#endregion |
541 |
} |
542 |
if (member.GetType().Name == "TextControl") |
543 |
{ |
544 |
TextControl content = ((TextControl)member); |
545 |
content.StartPoint = new Point(Canvas.GetLeft(content), Canvas.GetTop(content)); |
546 |
content.EndPoint = content.StartPoint; |
547 |
} |
548 |
else |
549 |
{ |
550 |
RegistryPoint(member, members.Count); |
551 |
} |
552 |
|
553 |
if (Common.ViewerDataModel.Instance.MarkupControls_USER.Contains(member)) Common.ViewerDataModel.Instance.MarkupControls_USER.Remove(member); /// remove commment from mycontrols |
554 |
} |
555 |
|
556 |
BorderUpdate(); |
557 |
} |
558 |
|
559 |
/// <summary> |
560 |
/// Border 를 갱신 |
561 |
/// </summary> |
562 |
public void BorderUpdate() |
563 |
{ |
564 |
AdornerBorder.MinWidth = 10; |
565 |
AdornerBorder.MinHeight = 10; |
566 |
|
567 |
double minX = double.MaxValue; |
568 |
double minY = double.MaxValue; |
569 |
double maxX = double.MinValue; |
570 |
double maxY = double.MinValue; |
571 |
|
572 |
if (this.Members.Count == 1) |
573 |
{ |
574 |
if (this.Members.First().DrawingData.GetType().Name == "TextControl") |
575 |
{ |
576 |
if ((this.Members.First().DrawingData as TextControl).Angle != 0) |
577 |
{ |
578 |
trRotate.Angle = (this.Members.First().DrawingData as TextControl).Angle; |
579 |
trRotateThumb.Angle = (this.Members.First().DrawingData as TextControl).Angle; |
580 |
} |
581 |
else |
582 |
{ |
583 |
trRotate.Angle = 0; |
584 |
trRotateThumb.Angle = 0; |
585 |
} |
586 |
} |
587 |
} |
588 |
foreach (var item in this.Members) |
589 |
{ |
590 |
UIElement currentControl = (item as AdornerMember).DrawingData; |
591 |
if (item.DrawingData.GetType().Name == "TextControl") |
592 |
{ |
593 |
double textControlWidth; |
594 |
double textControlHeight; |
595 |
if (((currentControl as TextControl).Base_TextBox.ActualWidth) == 0) |
596 |
{ |
597 |
textControlWidth = ((currentControl as TextControl).Base_TextBlock.ActualWidth); |
598 |
textControlHeight = ((currentControl as TextControl).Base_TextBlock.ActualHeight); |
599 |
} |
600 |
else |
601 |
{ |
602 |
textControlWidth = ((currentControl as TextControl).Base_TextBox.ActualWidth); |
603 |
textControlHeight = ((currentControl as TextControl).Base_TextBox.ActualHeight); |
604 |
} |
605 |
|
606 |
if ((currentControl as TextControl).EndPoint.X < minX) |
607 |
{ |
608 |
minX = (currentControl as TextControl).EndPoint.X; |
609 |
} |
610 |
if ((currentControl as TextControl).EndPoint.Y < minY) |
611 |
{ |
612 |
minY = (currentControl as TextControl).EndPoint.Y; |
613 |
} |
614 |
if (textControlWidth + (currentControl as TextControl).EndPoint.X > maxX) |
615 |
{ |
616 |
maxX = textControlWidth + (currentControl as TextControl).EndPoint.X; |
617 |
} |
618 |
if (textControlHeight + (currentControl as TextControl).EndPoint.Y > maxY) |
619 |
{ |
620 |
maxY = textControlHeight + (currentControl as TextControl).EndPoint.Y; |
621 |
} |
622 |
} |
623 |
else if ((currentControl as IViewBox) != null) |
624 |
{ |
625 |
IViewBox instance = currentControl as IViewBox; |
626 |
List<Point> am = (currentControl as IPath).PointSet; |
627 |
List<double> xSet = am.Select(p => p.X).ToList(); |
628 |
List<double> ySet = am.Select(p => p.Y).ToList(); |
629 |
if (xSet.Min() < minX) minX = xSet.Min(); |
630 |
if (ySet.Min() < minY) minY = ySet.Min(); |
631 |
if (xSet.Max() > maxX) maxX = xSet.Max(); |
632 |
if (ySet.Max() > maxY) maxY = ySet.Max(); |
633 |
} |
634 |
else if ((currentControl as IPath).PathData == null) |
635 |
{ |
636 |
Rect rt = new Rect |
637 |
{ |
638 |
X = (currentControl as IPath).StartPoint.X, |
639 |
Y = (currentControl as IPath).StartPoint.Y, |
640 |
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), |
641 |
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), |
642 |
}; |
643 |
if (rt.Left < minX) minX = rt.Left; |
644 |
if (rt.Top < minY) minY = rt.Top; |
645 |
if (rt.Right > maxX) maxX = rt.Right; |
646 |
if (rt.Bottom > maxY) maxY = rt.Bottom; |
647 |
} |
648 |
else if ((currentControl as IPath) == null) |
649 |
{ |
650 |
Rect rt = new Rect |
651 |
{ |
652 |
X = (currentControl as IPath).StartPoint.X, |
653 |
Y = (currentControl as IPath).StartPoint.Y, |
654 |
Width = (currentControl as IPath).EndPoint.X - (currentControl as IPath).StartPoint.X, |
655 |
Height = (currentControl as IPath).EndPoint.Y - (currentControl as IPath).StartPoint.Y |
656 |
}; |
657 |
if (rt.Left < minX) minX = rt.Left; |
658 |
if (rt.Top < minY) minY = rt.Top; |
659 |
if (rt.Right > maxX) maxX = rt.Right; |
660 |
if (rt.Bottom > maxY) maxY = rt.Bottom; |
661 |
} |
662 |
else if ((currentControl as CircleControl) != null) |
663 |
{ |
664 |
List<Point> am = (currentControl as IPath).PointSet; |
665 |
List<double> xSet = am.Select(p => p.X).ToList(); |
666 |
List<double> ySet = am.Select(p => p.Y).ToList(); |
667 |
if (xSet.Min() < minX) minX = xSet.Min(); |
668 |
if (ySet.Min() < minY) minY = ySet.Min(); |
669 |
if (xSet.Max() > maxX) maxX = xSet.Max(); |
670 |
if (ySet.Max() > maxY) maxY = ySet.Max(); |
671 |
} |
672 |
else |
673 |
{ |
674 |
if ((currentControl as IPath).PathData.Bounds.Left < minX) minX = (currentControl as IPath).PathData.Bounds.Left; |
675 |
if ((currentControl as IPath).PathData.Bounds.Top < minY) minY = (currentControl as IPath).PathData.Bounds.Top; |
676 |
if ((currentControl as IPath).PathData.Bounds.Right > maxX) maxX = (currentControl as IPath).PathData.Bounds.Right; |
677 |
if ((currentControl as IPath).PathData.Bounds.Bottom > maxY) maxY = (currentControl as IPath).PathData.Bounds.Bottom; |
678 |
} |
679 |
} |
680 |
|
681 |
Rect ac = new Rect(minX, minY, maxX - minX, maxY - minY); |
682 |
bool addWidthSize = false; |
683 |
bool addHeightSize = false; |
684 |
if (ac.Width <= 10) |
685 |
{ |
686 |
ac.Width += 10; |
687 |
addWidthSize = true; |
688 |
} |
689 |
if (ac.Height <= 10) |
690 |
{ |
691 |
ac.Height += 10; |
692 |
addHeightSize = true; |
693 |
} |
694 |
BorderSize = ac; |
695 |
AdornerBorder.MinWidth = 10; |
696 |
AdornerBorder.MinHeight = 10; |
697 |
AdornerBorder.Width = ac.Width; |
698 |
AdornerBorder.Height = ac.Height; |
699 |
Canvas.SetLeft(AdornerBorder, minX); |
700 |
Canvas.SetTop(AdornerBorder, minY); |
701 |
|
702 |
DragThumb.Width = ac.Width; |
703 |
DragThumb.Height = ac.Height; |
704 |
|
705 |
DragThumb.MinWidth = 10; |
706 |
DragThumb.MinHeight = 10; |
707 |
if (addWidthSize) |
708 |
{ |
709 |
Canvas.SetLeft(DragThumb, minX - 5); |
710 |
} |
711 |
else |
712 |
{ |
713 |
Canvas.SetLeft(DragThumb, minX); |
714 |
} |
715 |
|
716 |
if (addHeightSize) |
717 |
{ |
718 |
Canvas.SetTop(DragThumb, minY - 5); |
719 |
} |
720 |
else |
721 |
{ |
722 |
Canvas.SetTop(DragThumb, minY); |
723 |
} |
724 |
} |
725 |
/// <summary> |
726 |
/// UIElement 해제 |
727 |
/// </summary> |
728 |
public void unRegister() |
729 |
{ |
730 |
foreach (var item in this.ContainerContent.Children) |
731 |
{ |
732 |
if (item is MarkupToPDF.Common.CommentUserInfo) |
733 |
{ |
734 |
(item as MarkupToPDF.Common.CommentUserInfo).IsHitTestVisible = true; |
735 |
} |
736 |
} |
737 |
this.ContainerContent.Children.Clear(); |
738 |
} |
739 |
|
740 |
/// <summary> |
741 |
/// 각 포인트들을 등록합니다. |
742 |
/// </summary> |
743 |
/// <param name="pointset">Drawing Point</param> |
744 |
public void RegistryPoint(CommentUserInfo member, int cnt = 1) |
745 |
{ |
746 |
int count = 0; |
747 |
double Minx = 100000000; |
748 |
double Miny = 100000000; |
749 |
List<Point> list = (member as IPath).PointSet; |
750 |
if (member.GetType().Name == "InkControl") |
751 |
{ |
752 |
list.Clear(); |
753 |
list.Add(new Point((member as IPath).PathData.Bounds.X, (member as IPath).PathData.Bounds.Y)); |
754 |
list.Add(new Point((member as IPath).PathData.Bounds.Left, (member as IPath).PathData.Bounds.Bottom)); |
755 |
list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Bottom)); |
756 |
list.Add(new Point((member as IPath).PathData.Bounds.Right, (member as IPath).PathData.Bounds.Top)); |
757 |
} |
758 |
ControlType markT = this.Members.Where(p => p.DrawingData == member).First().Drawingtype; |
759 |
foreach (var ax in list) |
760 |
{ |
761 |
Minx = (ax.X < Minx) ? ax.X : Minx; |
762 |
Miny = (ax.Y < Miny) ? ax.Y : Miny; |
763 |
} |
764 |
for (int i = 0; i < list.Count(); i++) |
765 |
{ |
766 |
MyThumb tm = new MyThumb |
767 |
{ |
768 |
Style = (Style)this.LayoutRoot.Resources["ThumbResizeStyle"], |
769 |
}; |
770 |
|
771 |
this.Members.Last().ThumbList.Add(tm); |
772 |
|
773 |
if ((markT == ControlType.ArcLine && list[i] == (member as ArcControl).MidPoint) || (markT == ControlType.ArcArrow && list[i] == (member as ArrowArcControl).MidPoint)) |
774 |
{ |
775 |
tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"]; |
776 |
} |
777 |
if (member.GetType().Name == "ArrowTextControl" && i == 1) |
778 |
{ |
779 |
//if (this.Members.Count()<=1) |
780 |
//{ |
781 |
tm.Style = (Style)this.LayoutRoot.Resources["ThumbArcControlStyle"]; |
782 |
List<Point> ps = new List<Point>(); |
783 |
|
784 |
if ((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl != null) |
785 |
{ |
786 |
var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl; |
787 |
|
788 |
|
789 |
switch (Math.Abs(temp.Angle).ToString()) |
790 |
{ |
791 |
case "90": |
792 |
{ |
793 |
ps.Clear(); |
794 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
795 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간 |
796 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽 |
797 |
|
798 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
799 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
800 |
|
801 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); //중간 하단 |
802 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 하단 |
803 |
|
804 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간 |
805 |
} |
806 |
break; |
807 |
case "270": |
808 |
{ |
809 |
ps.Clear(); |
810 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
811 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간 |
812 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽 |
813 |
|
814 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
815 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
816 |
|
817 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); //중간 하단 |
818 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 하단 |
819 |
|
820 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간 |
821 |
} |
822 |
break; |
823 |
default: |
824 |
{ |
825 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단 |
826 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단 |
827 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단 |
828 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단 |
829 |
} |
830 |
break; |
831 |
} |
832 |
|
833 |
ArrowTextControl instance = (member as ArrowTextControl); |
834 |
if (instance.isTrans) |
835 |
{ |
836 |
//var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
837 |
//var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP); |
838 |
//list[count] = tempP; |
839 |
list[count] = temp.MidPoint; |
840 |
} |
841 |
else |
842 |
{ |
843 |
if (temp.isFixed) |
844 |
{ |
845 |
var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
846 |
var testP = endP; |
847 |
if (ps[0] == endP) //상단 |
848 |
{ |
849 |
testP = new Point(endP.X, endP.Y - 50); |
850 |
} |
851 |
else if (ps[1] == endP) //하단 |
852 |
{ |
853 |
testP = new Point(endP.X, endP.Y + 50); |
854 |
} |
855 |
else if (ps[2] == endP) //좌단 |
856 |
{ |
857 |
testP = new Point(endP.X - 50, endP.Y); |
858 |
} |
859 |
else if (ps[3] == endP) //우단 |
860 |
{ |
861 |
testP = new Point(endP.X + 50, endP.Y); |
862 |
} |
863 |
list[count] = testP; |
864 |
} |
865 |
else |
866 |
{ |
867 |
var endP = MathSet.getNearPoint(ps, instance.MidPoint); |
868 |
list[count] = MathSet.getMiddlePoint(instance.StartPoint, endP); |
869 |
} |
870 |
} |
871 |
} |
872 |
} |
873 |
if (member.GetType().Name == "ArrowTextControl" && list[i] == list.Last()) |
874 |
{ |
875 |
tm.Style = (Style)this.LayoutRoot.Resources["ThumbTextStyle"]; |
876 |
tm.Width = (member as ArrowTextControl).BoxWidth; |
877 |
tm.Height = (member as ArrowTextControl).BoxHeight; |
878 |
var angle = (member as ArrowTextControl).Angle; |
879 |
if (Math.Abs(angle).ToString() == "90") |
880 |
{ |
881 |
tm.RenderTransformOrigin = new Point(0, 0); |
882 |
tm.RenderTransform = new RotateTransform { Angle = 270 }; |
883 |
} |
884 |
else if (Math.Abs(angle).ToString() == "270") |
885 |
{ |
886 |
tm.RenderTransformOrigin = new Point(0, 0); |
887 |
tm.RenderTransform = new RotateTransform { Angle = 90 }; |
888 |
} |
889 |
else |
890 |
{ |
891 |
tm.RenderTransformOrigin = new Point(0.5, 0.5); |
892 |
tm.RenderTransform = new RotateTransform() |
893 |
{ |
894 |
Angle = angle, |
895 |
}; |
896 |
} |
897 |
} |
898 |
|
899 |
if (member.GetType().Name == "CloudControl") |
900 |
{ |
901 |
if (i == list.Count() - 1) |
902 |
{ |
903 |
tm.Visibility = System.Windows.Visibility.Collapsed; |
904 |
} |
905 |
} |
906 |
if (member.GetType().Name == "PolygonControl") |
907 |
{ |
908 |
if (i == list.Count() - 1) |
909 |
{ |
910 |
if ((member as PolygonControl).ControlType == ControlType.ChainLine) |
911 |
{ |
912 |
|
913 |
} |
914 |
else |
915 |
{ |
916 |
tm.Visibility = System.Windows.Visibility.Collapsed; |
917 |
} |
918 |
} |
919 |
if ((member as PolygonControl).ControlType == ControlType.Ink) |
920 |
{ |
921 |
tm.Visibility = System.Windows.Visibility.Collapsed; |
922 |
} |
923 |
} |
924 |
|
925 |
this.ContainerContent.Children.Add(tm); |
926 |
Canvas.SetLeft(tm, list[count].X); |
927 |
Canvas.SetTop(tm, list[count].Y); |
928 |
if (member.GetType().Name == "ArrowTextControl" && list[i] == (member as ArrowTextControl).MidPoint) |
929 |
{ |
930 |
Canvas.SetZIndex(tm, 95); |
931 |
} |
932 |
else |
933 |
{ |
934 |
Canvas.SetZIndex(tm, 99); |
935 |
} |
936 |
|
937 |
tm.DragStarted += new DragStartedEventHandler(tm_DragStarted); |
938 |
tm.DragCompleted += new DragCompletedEventHandler(tm_DragCompleted); |
939 |
tm.DragDelta += ResizeTm_DragDelta; |
940 |
tm.MouseMove += new MouseEventHandler(resize_MouseMove); |
941 |
count++; |
942 |
} |
943 |
} |
944 |
|
945 |
private void ResizeTm_DragDelta(object sender, DragDeltaEventArgs e) |
946 |
{ |
947 |
if (this.Members.Count > 1) return; |
948 |
if (reSizePoint != new Point(0, 0)) |
949 |
{ |
950 |
MyThumb thumb = sender as MyThumb; |
951 |
Point setPoint = new Point(Canvas.GetLeft(thumb), Canvas.GetTop(thumb)); |
952 |
thumb.Translate(e.HorizontalChange, e.VerticalChange, this.AngleValue); |
953 |
|
954 |
AdornerMember control = (from userThumb in this.Members |
955 |
where userThumb.ThumbList.Contains(thumb) |
956 |
select userThumb).FirstOrDefault(); |
957 |
|
958 |
IPath AllControl = control.DrawingData as IPath; |
959 |
((control.DrawingData) as CommentUserInfo).OnMoveCtrlPoint(setPoint, e.HorizontalChange, e.VerticalChange); |
960 |
control.UpdateThumb(); |
961 |
this.BorderUpdate(); |
962 |
} |
963 |
} |
964 |
|
965 |
#endregion |
966 |
#region 이벤트 |
967 |
|
968 |
void tm_DragCompleted(object sender, DragCompletedEventArgs e) |
969 |
{ |
970 |
this.isDragging = false; |
971 |
DraggerThumb = null; |
972 |
|
973 |
var comments = (from drawing in this.Members |
974 |
select drawing.DrawingData as CommentUserInfo).ToList(); |
975 |
UndoCommand.Instance.Push(comments, this.AngleValue); |
976 |
} |
977 |
|
978 |
/// <summary> |
979 |
/// start drag |
980 |
/// </summary> |
981 |
/// <param name="sender"></param> |
982 |
/// <param name="e"></param> |
983 |
void tm_DragStarted(object sender, DragStartedEventArgs e) |
984 |
{ |
985 |
this.DraggerThumb = sender as Thumb; |
986 |
this.isDragging = true; |
987 |
|
988 |
if (ViewerDataModel.Instance.UndoDataList == null) |
989 |
{ |
990 |
return; |
991 |
} |
992 |
|
993 |
if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)) |
994 |
{ |
995 |
return; |
996 |
} |
997 |
|
998 |
if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)) |
999 |
{ |
1000 |
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0) |
1001 |
{ |
1002 |
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null) |
1003 |
{ |
1004 |
return; |
1005 |
} |
1006 |
} |
1007 |
} |
1008 |
|
1009 |
var comments = (from drawing in this.Members |
1010 |
select drawing.DrawingData as CommentUserInfo).ToList(); |
1011 |
UndoCommand.Instance.Push(comments, this.AngleValue); |
1012 |
} |
1013 |
|
1014 |
private void rotate_MouseMove(object sender, MouseEventArgs e) |
1015 |
{ |
1016 |
if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl") |
1017 |
{ |
1018 |
if (LastRotateVerticalValue < e.GetPosition(this).X) |
1019 |
IsTextAngle = true; |
1020 |
else |
1021 |
IsTextAngle = false; |
1022 |
LastRotateVerticalValue = e.GetPosition(this).X; |
1023 |
} |
1024 |
else |
1025 |
{ |
1026 |
if (e.GetPosition(this).X > LastRotateHorizontalValue) |
1027 |
{ |
1028 |
RotateFlag = true; |
1029 |
} |
1030 |
else |
1031 |
{ |
1032 |
RotateFlag = false; |
1033 |
} |
1034 |
LastRotateHorizontalValue = e.GetPosition(this).X; |
1035 |
} |
1036 |
} |
1037 |
|
1038 |
private void drag_DragStarted(object sender, DragStartedEventArgs e) |
1039 |
{ |
1040 |
/// save mouse down and current mouse point |
1041 |
this.MouseDownPoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender)); |
1042 |
this.CurrentMousePoint = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender)); |
1043 |
/// up to here |
1044 |
|
1045 |
if (ViewerDataModel.Instance.UndoDataList == null) |
1046 |
{ |
1047 |
return; |
1048 |
} |
1049 |
if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb)) |
1050 |
{ |
1051 |
return; |
1052 |
} |
1053 |
if ((null != ViewerDataModel.Instance.UndoDataList.LastOrDefault()) && (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null)) |
1054 |
{ |
1055 |
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0) |
1056 |
{ |
1057 |
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null) |
1058 |
{ |
1059 |
return; |
1060 |
} |
1061 |
} |
1062 |
} |
1063 |
|
1064 |
var comments = (from drawing in this.Members |
1065 |
select drawing.DrawingData as CommentUserInfo).ToList(); |
1066 |
UndoCommand.Instance.Push(comments, this.AngleValue); |
1067 |
} |
1068 |
|
1069 |
private void drag_DragCompleted(object sender, DragCompletedEventArgs e) |
1070 |
{ |
1071 |
DragThumb.Cursor = new Cursor(MainWindow.CursorChange().StreamSource); |
1072 |
|
1073 |
var comments = (from drawing in this.Members |
1074 |
select drawing.DrawingData as CommentUserInfo).ToList(); |
1075 |
UndoCommand.Instance.Push(comments, this.AngleValue); |
1076 |
} |
1077 |
|
1078 |
private void DragThumb_DragDelta(object sender, DragDeltaEventArgs e) |
1079 |
{ |
1080 |
double scale = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.zoomAndPanControl.ContentScale; |
1081 |
var tmp = Mouse.GetPosition(Window.GetWindow((DependencyObject)sender)); |
1082 |
|
1083 |
var horzChange = Math.Round(tmp.X - this.CurrentMousePoint.X) / scale; |
1084 |
var vertChange = Math.Round(tmp.Y - this.CurrentMousePoint.Y) / scale; |
1085 |
try |
1086 |
{ |
1087 |
DragThumb.Cursor = Cursors.SizeAll; |
1088 |
this.TranslateItems(horzChange, vertChange); |
1089 |
} |
1090 |
finally |
1091 |
{ |
1092 |
/// update CurrentMousePoint |
1093 |
this.CurrentMousePoint = tmp; |
1094 |
} |
1095 |
} |
1096 |
|
1097 |
/// <summary> |
1098 |
/// translate all members |
1099 |
/// </summary> |
1100 |
/// <param name="e"></param> |
1101 |
public void TranslateItems(double dx, double dy) |
1102 |
{ |
1103 |
Dispatcher.BeginInvoke((Action)(() => |
1104 |
{ |
1105 |
foreach (var item in this.Members) |
1106 |
{ |
1107 |
this.TranslateItem(dx, dy, item); |
1108 |
} |
1109 |
})); |
1110 |
this.BorderUpdate(); |
1111 |
} |
1112 |
|
1113 |
/// <summary> |
1114 |
/// translate a item |
1115 |
/// </summary> |
1116 |
/// <param name="e"></param> |
1117 |
/// <param name="item"></param> |
1118 |
private void TranslateItem(double dx, double dy, AdornerMember item) |
1119 |
{ |
1120 |
/// rotate point with page rotation |
1121 |
var rotation = Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.rotate.Angle; |
1122 |
Point delta = MathSet.RotateAbout(new Point(0, 0), new Point(dx, dy), -rotation); |
1123 |
/// up to here |
1124 |
(item.DrawingData as CommentUserInfo).OnTranslate(delta.X, delta.Y); |
1125 |
item.UpdateThumb(); |
1126 |
} |
1127 |
|
1128 |
public void Set_Rotate() |
1129 |
{ |
1130 |
double dDeltaAngle = 0; |
1131 |
List<Point> AllPointSet = new List<Point>(); |
1132 |
Point CenterPoint = new Point(); |
1133 |
|
1134 |
if (AngleValue >= 360) |
1135 |
{ |
1136 |
AngleValue -= 360; |
1137 |
} |
1138 |
else if (AngleValue <= -360) |
1139 |
{ |
1140 |
AngleValue += 360; |
1141 |
} |
1142 |
|
1143 |
#region 센터 포인트 구하기 (그룹핑) |
1144 |
foreach (var item in this.Members) |
1145 |
{ |
1146 |
if (item.DrawingData.GetType().Name == "TextControl") |
1147 |
{ |
1148 |
} |
1149 |
else |
1150 |
{ |
1151 |
foreach (Point itemP in (item.DrawingData as IPath).PointSet) |
1152 |
{ |
1153 |
AllPointSet.Add(itemP); |
1154 |
} |
1155 |
} |
1156 |
} |
1157 |
#endregion |
1158 |
|
1159 |
CenterPoint = MathSet.FindCentroid(AllPointSet); |
1160 |
|
1161 |
Dispatcher.BeginInvoke((Action)(() => |
1162 |
{ |
1163 |
foreach (var item in this.Members) |
1164 |
{ |
1165 |
foreach (var thumb in item.ThumbList) |
1166 |
{ |
1167 |
double x = Canvas.GetLeft(thumb); |
1168 |
double y = Canvas.GetTop(thumb); |
1169 |
|
1170 |
Point value = MathSet.RotateAbout(CenterPoint, new Point(x, y), dDeltaAngle); |
1171 |
Canvas.SetLeft(thumb, value.X); |
1172 |
Canvas.SetTop(thumb, value.Y); |
1173 |
|
1174 |
if (item.DrawingData.GetType().Name == "ArrowTextControl" && thumb == item.ThumbList.Last()) |
1175 |
{ |
1176 |
|
1177 |
Canvas.SetLeft(thumb, Canvas.GetLeft((item.DrawingData as ArrowTextControl).Base_TextBox)); |
1178 |
Canvas.SetTop(thumb, Canvas.GetTop((item.DrawingData as ArrowTextControl).Base_TextBox)); |
1179 |
if (!(item.DrawingData as ArrowTextControl).isTrans) |
1180 |
{ |
1181 |
List<Point> ps = new List<Point>(); |
1182 |
var temp = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl; |
1183 |
switch (Math.Abs(temp.Angle).ToString()) |
1184 |
{ |
1185 |
case "90": |
1186 |
{ |
1187 |
ps.Clear(); |
1188 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
1189 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); // 위 중간 |
1190 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); // 위 오른쪽 |
1191 |
|
1192 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
1193 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
1194 |
|
1195 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth / 2)); //중간 하단 |
1196 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 하단 |
1197 |
|
1198 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) - temp.BoxWidth)); //오른쪽 중간 |
1199 |
} |
1200 |
break; |
1201 |
case "270": |
1202 |
{ |
1203 |
ps.Clear(); |
1204 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox))); //위 왼쪽 |
1205 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); // 위 중간 |
1206 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); // 위 오른쪽 |
1207 |
|
1208 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 중간 |
1209 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox))); //왼쪽 하단 |
1210 |
|
1211 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth / 2)); //중간 하단 |
1212 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 하단 |
1213 |
|
1214 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) - temp.BoxHeight / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxWidth)); //오른쪽 중간 |
1215 |
} |
1216 |
break; |
1217 |
default: |
1218 |
{ |
1219 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox))); //상단 |
1220 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth / 2, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight)); // 하단 |
1221 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox), Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //좌단 |
1222 |
ps.Add(new Point(Canvas.GetLeft(temp.Base_TextBox) + temp.BoxWidth, Canvas.GetTop(temp.Base_TextBox) + temp.BoxHeight / 2)); //우단 |
1223 |
} |
1224 |
break; |
1225 |
} |
1226 |
|
1227 |
var endP = MathSet.getNearPoint(ps, temp.MidPoint); |
1228 |
var tempP = MathSet.getMiddlePoint(temp.StartPoint, endP); |
1229 |
Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X); |
1230 |
Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y); |
1231 |
} |
1232 |
} |
1233 |
} |
1234 |
|
1235 |
for (int i = 0; i < (item.DrawingData as IPath).PointSet.Count(); i++) |
1236 |
{ |
1237 |
(item.DrawingData as IPath).PointSet[i] = MathSet.RotateAbout(CenterPoint, (item.DrawingData as IPath).PointSet[i], dDeltaAngle); |
1238 |
} |
1239 |
} |
1240 |
#region 컨트롤 업데이트 |
1241 |
foreach (var item in this.Members) |
1242 |
{ |
1243 |
switch (item.Drawingtype) |
1244 |
{ |
1245 |
case ControlType.TextControl: |
1246 |
((TextControl)item.DrawingData).Angle = AngleValue; |
1247 |
|
1248 |
RectangleGeometry Data = new RectangleGeometry |
1249 |
{ |
1250 |
Rect = new Rect() |
1251 |
{ |
1252 |
X = Canvas.GetLeft((item.DrawingData as TextControl)), |
1253 |
Y = Canvas.GetTop((item.DrawingData as TextControl)), |
1254 |
Width = (item.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2, |
1255 |
Height = (item.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2, |
1256 |
} |
1257 |
}; |
1258 |
|
1259 |
Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom); |
1260 |
Point middle = MathSet.getMiddlePoint((item.DrawingData as TextControl).StartPoint, endPointV); |
1261 |
|
1262 |
DragThumb.RenderTransformOrigin = new Point(0.0, 0.0); |
1263 |
DragThumb.RenderTransform = new RotateTransform() |
1264 |
{ |
1265 |
Angle = (item.DrawingData as TextControl).Angle, |
1266 |
|
1267 |
}; |
1268 |
|
1269 |
AdornerBorder.RenderTransformOrigin = new Point(0.0, 0.0); |
1270 |
AdornerBorder.RenderTransform = new RotateTransform() |
1271 |
{ |
1272 |
Angle = (item.DrawingData as TextControl).Angle, |
1273 |
|
1274 |
}; |
1275 |
|
1276 |
(item.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform() |
1277 |
{ |
1278 |
Angle = (item.DrawingData as TextControl).Angle, |
1279 |
}; |
1280 |
BorderUpdate(); |
1281 |
break; |
1282 |
|
1283 |
case ControlType.Date: |
1284 |
((DateControl)item.DrawingData).Angle = AngleValue; |
1285 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1286 |
BorderUpdate(); |
1287 |
break; |
1288 |
case ControlType.ArrowMultiLine: |
1289 |
case ControlType.ArcLine: |
1290 |
case ControlType.ArcArrow: |
1291 |
case ControlType.SingleLine: |
1292 |
case ControlType.Triangle: |
1293 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1294 |
BorderUpdate(); |
1295 |
break; |
1296 |
case ControlType.ArrowTextControl: |
1297 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1298 |
BorderUpdate(); |
1299 |
break; |
1300 |
case ControlType.RectCloud: |
1301 |
((RectCloudControl)item.DrawingData).Angle = AngleValue; |
1302 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1303 |
BorderUpdate(); |
1304 |
break; |
1305 |
case ControlType.Rectangle: |
1306 |
((RectangleControl)item.DrawingData).Angle = AngleValue; |
1307 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1308 |
BorderUpdate(); |
1309 |
break; |
1310 |
case ControlType.ImgControl: |
1311 |
((ImgControl)item.DrawingData).Angle = AngleValue; |
1312 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1313 |
BorderUpdate(); |
1314 |
break; |
1315 |
case ControlType.Sign: |
1316 |
((SignControl)item.DrawingData).Angle = AngleValue; |
1317 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1318 |
BorderUpdate(); |
1319 |
break; |
1320 |
case ControlType.Symbol: |
1321 |
((SymControl)item.DrawingData).Angle = AngleValue; |
1322 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1323 |
BorderUpdate(); |
1324 |
break; |
1325 |
case ControlType.Stamp: |
1326 |
((SymControlN)item.DrawingData).Angle = AngleValue; |
1327 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1328 |
BorderUpdate(); |
1329 |
break; |
1330 |
case ControlType.PolygonControl: |
1331 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1332 |
BorderUpdate(); |
1333 |
break; |
1334 |
case ControlType.PolygonCloud: |
1335 |
((ICloudControl)item.DrawingData).DrawingCloud(); |
1336 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1337 |
BorderUpdate(); |
1338 |
break; |
1339 |
case ControlType.Circle: |
1340 |
((IShapeControl)item.DrawingData).Angle = AngleValue; |
1341 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1342 |
((CircleControl)item.DrawingData).SetCenterXY(); |
1343 |
BorderUpdate(); |
1344 |
break; |
1345 |
case ControlType.Ink: |
1346 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1347 |
BorderUpdate(); |
1348 |
break; |
1349 |
case ControlType.InsideWhite: |
1350 |
((InsideWhiteControl)item.DrawingData).Angle = AngleValue; |
1351 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1352 |
BorderUpdate(); |
1353 |
break; |
1354 |
case ControlType.OverlapWhite: |
1355 |
((OverlapWhiteControl)item.DrawingData).Angle = AngleValue; |
1356 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1357 |
BorderUpdate(); |
1358 |
break; |
1359 |
case ControlType.ClipWhite: |
1360 |
((ClipWhiteControl)item.DrawingData).Angle = AngleValue; |
1361 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1362 |
BorderUpdate(); |
1363 |
break; |
1364 |
case ControlType.Coordinate: |
1365 |
((CoordinateControl)item.DrawingData).Angle = AngleValue; |
1366 |
(item.DrawingData as CommentUserInfo).UpdateControl(); |
1367 |
BorderUpdate(); |
1368 |
break; |
1369 |
default: |
1370 |
break; |
1371 |
} |
1372 |
} |
1373 |
#endregion |
1374 |
})); |
1375 |
} |
1376 |
|
1377 |
private void resize_MouseMove(object sender, MouseEventArgs e) |
1378 |
{ |
1379 |
reSizePoint = e.GetPosition(this); |
1380 |
} |
1381 |
|
1382 |
/// <summary> |
1383 |
/// 회전 |
1384 |
/// </summary> |
1385 |
/// <param name="sender"></param> |
1386 |
/// <param name="e"></param> |
1387 |
public void rotate_DragDelta(object sender, DragDeltaEventArgs e) |
1388 |
{ |
1389 |
MoveRotate(e); |
1390 |
} |
1391 |
|
1392 |
double LastRotateHorizontalValue = 0; |
1393 |
double LastRotateVerticalValue = 0; |
1394 |
bool RotateFlag = false; |
1395 |
|
1396 |
/// <summary> |
1397 |
/// <history>humkyung 2018.05.09 upgrade rotate shape peformance</history> |
1398 |
/// </summary> |
1399 |
/// <param name="e"></param> |
1400 |
public void MoveRotate(DragDeltaEventArgs e) |
1401 |
{ |
1402 |
double dDeltaAngle = 0; |
1403 |
|
1404 |
List<Point> AllPointSet = new List<Point>(); |
1405 |
Point CenterPoint = new Point(); |
1406 |
|
1407 |
#region 센터 포인트 구하기 (그룹핑) |
1408 |
foreach (var item in this.Members) |
1409 |
{ |
1410 |
if (item.DrawingData.GetType().Name == "TextControl") |
1411 |
{ |
1412 |
if (AngleValue == 0) |
1413 |
{ |
1414 |
AngleValue = (item.DrawingData as TextControl).Angle; |
1415 |
} |
1416 |
double X = Canvas.GetLeft((item.DrawingData as TextControl)); |
1417 |
double Y = Canvas.GetTop((item.DrawingData as TextControl)); |
1418 |
AllPointSet.Add(new Point(X, Y)); |
1419 |
} |
1420 |
else |
1421 |
{ |
1422 |
foreach (Point itemP in (item.DrawingData as IPath).PointSet) |
1423 |
{ |
1424 |
AllPointSet.Add(itemP); |
1425 |
} |
1426 |
} |
1427 |
} |
1428 |
#endregion |
1429 |
CenterPoint = MathSet.FindCentroid(AllPointSet); |
1430 |
Point pt = Mouse.GetPosition(this); |
1431 |
|
1432 |
Point vec1 = new Point(this.rotatePoint.X - CenterPoint.X, this.rotatePoint.Y - CenterPoint.Y); |
1433 |
Point vec2 = new Point(pt.X - CenterPoint.X, pt.Y - CenterPoint.Y); |
1434 |
dDeltaAngle = (MathSet.getAngleBetweenVectors(vec1, vec2)); |
1435 |
|
1436 |
AngleValue += dDeltaAngle; |
1437 |
if (AngleValue > 360) AngleValue -= 360; |
1438 |
if (AngleValue < 0) AngleValue += 360; |
1439 |
this.rotatePoint = pt; /// save rotatePoint |
1440 |
|
1441 |
Dispatcher.BeginInvoke((Action)(() => |
1442 |
{ |
1443 |
foreach (var member in this.Members) |
1444 |
{ |
1445 |
member.RotateAbout(CenterPoint, dDeltaAngle); |
1446 |
#region 보더 업데이트 |
1447 |
switch (member.Drawingtype) |
1448 |
{ |
1449 |
case ControlType.TextControl: |
1450 |
(member.DrawingData as CommentUserInfo).Angle = AngleValue; |
1451 |
|
1452 |
RectangleGeometry Data = new RectangleGeometry |
1453 |
{ |
1454 |
Rect = new Rect() |
1455 |
{ |
1456 |
X = Canvas.GetLeft((member.DrawingData as TextControl)), |
1457 |
Y = Canvas.GetTop((member.DrawingData as TextControl)), |
1458 |
Width = (member.DrawingData as TextControl).Base_TextBlock.ActualWidth / 2, |
1459 |
Height = (member.DrawingData as TextControl).Base_TextBlock.ActualHeight / 2, |
1460 |
} |
1461 |
}; |
1462 |
|
1463 |
Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom); |
1464 |
Point middle = MathSet.getMiddlePoint((member.DrawingData as TextControl).StartPoint, endPointV); |
1465 |
|
1466 |
DragThumb.RenderTransformOrigin = new Point(0, 0); |
1467 |
DragThumb.RenderTransform = new RotateTransform() |
1468 |
{ |
1469 |
Angle = (member.DrawingData as TextControl).Angle, |
1470 |
}; |
1471 |
|
1472 |
AdornerBorder.RenderTransformOrigin = new Point(0, 0); |
1473 |
AdornerBorder.RenderTransform = new RotateTransform() |
1474 |
{ |
1475 |
Angle = (member.DrawingData as TextControl).Angle, |
1476 |
}; |
1477 |
|
1478 |
(member.DrawingData as TextControl).Base_Grid.RenderTransform = new RotateTransform() |
1479 |
{ |
1480 |
Angle = (member.DrawingData as TextControl).Angle, |
1481 |
}; |
1482 |
|
1483 |
BorderUpdate(); |
1484 |
break; |
1485 |
|
1486 |
case ControlType.ArrowMultiLine: |
1487 |
case ControlType.ArcLine: |
1488 |
case ControlType.ArcArrow: |
1489 |
case ControlType.SingleLine: |
1490 |
case ControlType.Triangle: |
1491 |
case ControlType.ArrowTextControl: |
1492 |
case ControlType.PolygonControl: |
1493 |
case ControlType.Ink: |
1494 |
BorderUpdate(); |
1495 |
break; |
1496 |
case ControlType.Date: |
1497 |
case ControlType.RectCloud: |
1498 |
case ControlType.Rectangle: |
1499 |
case ControlType.ImgControl: |
1500 |
case ControlType.Sign: |
1501 |
case ControlType.Symbol: |
1502 |
case ControlType.Stamp: |
1503 |
(member.DrawingData as CommentUserInfo).Angle = AngleValue; |
1504 |
BorderUpdate(); |
1505 |
break; |
1506 |
case ControlType.PolygonCloud: |
1507 |
((ICloudControl)member.DrawingData).DrawingCloud(); |
1508 |
BorderUpdate(); |
1509 |
break; |
1510 |
case ControlType.Circle: |
1511 |
(member.DrawingData as CommentUserInfo).Angle = AngleValue; |
1512 |
((CircleControl)member.DrawingData).SetCenterXY(); |
1513 |
BorderUpdate(); |
1514 |
break; |
1515 |
default: |
1516 |
break; |
1517 |
} |
1518 |
} |
1519 |
#endregion |
1520 |
})); |
1521 |
} |
1522 |
|
1523 |
private void rotate_DragStarted(object sender, DragStartedEventArgs e) |
1524 |
{ |
1525 |
|
1526 |
this.rotatePoint = Mouse.GetPosition(this); /// 2018.05.09 added by humkyung |
1527 |
rotateTop.Cursor = Cursors.SizeAll; |
1528 |
|
1529 |
/// get angle from text controls' angle if only text control exists - 2018.05.10 added by humkyung |
1530 |
if ((1 == this.Members.Count) && (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl") |
1531 |
{ |
1532 |
this.AngleValue = ((this.Members.First() as AdornerMember).DrawingData as TextControl).Angle; |
1533 |
} |
1534 |
/// up to here |
1535 |
|
1536 |
|
1537 |
|
1538 |
if (ViewerDataModel.Instance.UndoDataList == null) |
1539 |
{ |
1540 |
return; |
1541 |
} |
1542 |
|
1543 |
if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Event == Event_Type.Thumb) |
1544 |
{ |
1545 |
return; |
1546 |
} |
1547 |
|
1548 |
if ((ViewerDataModel.Instance.UndoDataList.Count > 0) && ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List != null) |
1549 |
{ |
1550 |
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.Count > 0) |
1551 |
{ |
1552 |
if (ViewerDataModel.Instance.UndoDataList.LastOrDefault().Markup_List.FirstOrDefault().PointSet != null) |
1553 |
{ |
1554 |
return; |
1555 |
} |
1556 |
} |
1557 |
} |
1558 |
|
1559 |
var comments = (from drawing in this.Members |
1560 |
select drawing.DrawingData as CommentUserInfo).ToList(); |
1561 |
UndoCommand.Instance.Push(comments, this.AngleValue); |
1562 |
} |
1563 |
|
1564 |
private void rotate_DragCompleted(object sender, DragCompletedEventArgs e) |
1565 |
{ |
1566 |
rotateTop.Cursor = new Cursor(MainWindow.CursorChange().StreamSource); |
1567 |
|
1568 |
var comments = (from drawing in this.Members |
1569 |
select drawing.DrawingData as CommentUserInfo).ToList(); |
1570 |
UndoCommand.Instance.Push(comments, this.AngleValue); |
1571 |
} |
1572 |
|
1573 |
public void ControlPointMouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
1574 |
{ |
1575 |
AdornerMember control = this.Members.FirstOrDefault(); |
1576 |
|
1577 |
if ((control.DrawingData as ArrowTextControl) != null && DraggerThumb == null) |
1578 |
{ |
1579 |
if ((control.DrawingData as ArrowTextControl).isTrans == false && (control.DrawingData as ArrowTextControl).isFixed == false) |
1580 |
{ |
1581 |
(control.DrawingData as ArrowTextControl).isTrans = true; |
1582 |
} |
1583 |
} |
1584 |
|
1585 |
} |
1586 |
|
1587 |
public void TextControlChanger() |
1588 |
{ |
1589 |
if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl") |
1590 |
{ |
1591 |
TextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as TextControl; |
1592 |
AllControl.Base_TextBox.Focus(); |
1593 |
AllControl.Base_TextBox.Visibility = Visibility.Visible; |
1594 |
AllControl.Base_TextBlock.Visibility = Visibility.Collapsed; |
1595 |
AllControl.Base_TextBox.Focus(); |
1596 |
AllControl.SizeChanged += (sen, ea) => |
1597 |
{ |
1598 |
if (AllControl.Base_TextBox != null) |
1599 |
{ |
1600 |
RectangleGeometry Data = new RectangleGeometry |
1601 |
{ |
1602 |
Rect = new Rect() |
1603 |
{ |
1604 |
X = AllControl.StartPoint.X, |
1605 |
Y = AllControl.StartPoint.Y, |
1606 |
Width = AllControl.Base_TextBox.Width, |
1607 |
Height = AllControl.Base_TextBox.Height, |
1608 |
} |
1609 |
}; |
1610 |
|
1611 |
Point endPointV = new Point(Data.Bounds.Right, Data.Bounds.Bottom); |
1612 |
Point middle = MathSet.getMiddlePoint(AllControl.StartPoint, endPointV); |
1613 |
AllControl.Base_Grid.RenderTransform = new RotateTransform() |
1614 |
{ |
1615 |
Angle = AllControl.Angle, |
1616 |
CenterX = middle.X, |
1617 |
CenterY = middle.Y, |
1618 |
}; |
1619 |
} |
1620 |
BorderUpdate(); |
1621 |
}; |
1622 |
} |
1623 |
} |
1624 |
|
1625 |
private void RectThumb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) //더블클릭 |
1626 |
{ |
1627 |
if (e.ClickCount == 2 && this.Members.Count == 1) |
1628 |
{ |
1629 |
|
1630 |
if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl") |
1631 |
{ |
1632 |
TextControlChanger(); |
1633 |
} |
1634 |
|
1635 |
else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl") |
1636 |
{ |
1637 |
ArrowTextControl AllControl = (this.Members.First() as AdornerMember).DrawingData as ArrowTextControl; |
1638 |
Thumb tm = (this.Members.First() as AdornerMember).ThumbList.Last(); |
1639 |
((ArrowTextControl)AllControl).Base_TextBox.Focus(); |
1640 |
|
1641 |
//ArrowControl TextBox Thumb없애기 |
1642 |
tm.Visibility = Visibility.Collapsed; |
1643 |
|
1644 |
((this.Members.First() as AdornerMember).DrawingData as ArrowTextControl).Base_TextBox.IsHitTestVisible = true; |
1645 |
|
1646 |
((ArrowTextControl)AllControl).Base_TextBox.SizeChanged += (sen, ea) => |
1647 |
|
1648 |
{ |
1649 |
tm.Width = (AllControl as ArrowTextControl).BoxWidth; |
1650 |
tm.Height = (AllControl as ArrowTextControl).BoxHeight; |
1651 |
|
1652 |
List<Point> ps = new List<Point>(); |
1653 |
|
1654 |
ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox))); //상단 |
1655 |
ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth / 2, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight)); // 하단 |
1656 |
ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox), Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //좌단 |
1657 |
ps.Add(new Point(Canvas.GetLeft(AllControl.Base_TextBox) + AllControl.BoxWidth, Canvas.GetTop(AllControl.Base_TextBox) + AllControl.BoxHeight / 2)); //우단 |
1658 |
|
1659 |
|
1660 |
|
1661 |
|
1662 |
var endP = MathSet.getNearPoint(ps, AllControl.MidPoint); |
1663 |
var tempP = MathSet.getMiddlePoint(AllControl.StartPoint, endP); |
1664 |
if (AllControl.isTrans) |
1665 |
{ |
1666 |
Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.X); |
1667 |
Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], AllControl.MidPoint.Y); |
1668 |
} |
1669 |
else |
1670 |
{ |
1671 |
Canvas.SetLeft((this.Members.First() as AdornerMember).ThumbList[1], tempP.X); |
1672 |
Canvas.SetTop((this.Members.First() as AdornerMember).ThumbList[1], tempP.Y); |
1673 |
} |
1674 |
|
1675 |
|
1676 |
BorderUpdate(); |
1677 |
|
1678 |
}; |
1679 |
} |
1680 |
else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "DateControl") |
1681 |
{ |
1682 |
DateControl data = (this.Members.First() as AdornerMember).DrawingData as DateControl; |
1683 |
CalendarControl instanceCal = new CalendarControl(data.Text); |
1684 |
//dropData.IsOpen = true; |
1685 |
RadWindow rc = new RadWindow(); |
1686 |
rc.Width = 300; |
1687 |
rc.Height = 300; |
1688 |
rc.Header = "Change Date"; |
1689 |
rc.Content = instanceCal; |
1690 |
rc.BorderThickness = new Thickness(3); |
1691 |
rc.ResizeMode = ResizeMode.NoResize; |
1692 |
rc.WindowStartupLocation = WindowStartupLocation.CenterScreen; |
1693 |
rc.ModalBackground = new SolidColorBrush(Colors.Black); |
1694 |
rc.ModalBackground.Opacity = 0.6; |
1695 |
Telerik.Windows.Controls.StyleManager.SetTheme(rc, new Telerik.Windows.Controls.Windows8Theme()); |
1696 |
instanceCal.changeDateCal.SelectionChanged += (sen, ea) => |
1697 |
{ |
1698 |
data.Text = instanceCal.changeDateCal.SelectedDate.Value.ToShortDateString(); |
1699 |
rc.Close(); |
1700 |
}; |
1701 |
rc.ShowDialog(); |
1702 |
//CalendarControl.xaml |
1703 |
} |
1704 |
else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArcControl") |
1705 |
{ |
1706 |
ArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArcControl); |
1707 |
if (instance.isTransOn) |
1708 |
{ |
1709 |
instance.isTransOn = false; |
1710 |
} |
1711 |
else |
1712 |
{ |
1713 |
instance.isTransOn = true; |
1714 |
} |
1715 |
///instance.SetArcPath(); |
1716 |
BorderUpdate(); |
1717 |
} |
1718 |
else if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowArcControl") |
1719 |
{ |
1720 |
ArrowArcControl instance = ((this.Members.First() as AdornerMember).DrawingData as ArrowArcControl); |
1721 |
if (instance.isTransOn) |
1722 |
{ |
1723 |
instance.isTransOn = false; |
1724 |
} |
1725 |
else |
1726 |
{ |
1727 |
instance.isTransOn = true; |
1728 |
} |
1729 |
instance.SetArcPath(); |
1730 |
BorderUpdate(); |
1731 |
} |
1732 |
|
1733 |
} |
1734 |
|
1735 |
} |
1736 |
#endregion |
1737 |
|
1738 |
private void DragThumb_MouseDoubleClick(object sender, MouseButtonEventArgs e) |
1739 |
{ |
1740 |
if ((this.Members.First() as AdornerMember).DrawingData.GetType().Name == "TextControl" || (this.Members.First() as AdornerMember).DrawingData.GetType().Name == "ArrowTextControl") |
1741 |
{ |
1742 |
DragThumb.Visibility = Visibility.Collapsed; |
1743 |
} |
1744 |
} |
1745 |
} |
1746 |
} |