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