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