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