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