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