markus / MarkupToPDF / Controls / Text / ArrowTextControl.cs @ e024b149
이력 | 보기 | 이력해설 | 다운로드 (79.7 KB)
1 |
using MarkupToPDF.Controls.Common; |
---|---|
2 |
using System; |
3 |
using System.Collections.Generic; |
4 |
using System.ComponentModel; |
5 |
using System.Linq; |
6 |
using System.Text; |
7 |
using System.Threading.Tasks; |
8 |
using System.Windows; |
9 |
using System.Windows.Controls; |
10 |
using System.Windows.Media; |
11 |
using System.Windows.Shapes; |
12 |
using MarkupToPDF.Controls.Custom; |
13 |
using MarkupToPDF.Common; |
14 |
using MarkupToPDF.Serialize.Core; |
15 |
using MarkupToPDF.Serialize.S_Control; |
16 |
using Markus.Fonts; |
17 |
using System.Runtime.CompilerServices; |
18 |
using System.Windows.Controls.Primitives; |
19 |
|
20 |
namespace MarkupToPDF.Controls.Text |
21 |
{ |
22 |
public class ArrowTextControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, ITextControl, IMarkupControlData,ICommentRect |
23 |
{ |
24 |
private const string PART_ArrowPath = "PART_ArrowPath"; |
25 |
private const string PART_TextBox = "PART_ArrowTextBox"; |
26 |
private const string PART_ArrowSubPath = "PART_ArrowSubPath"; |
27 |
private const string PART_Border = "PART_Border"; |
28 |
private const string PART_BaseTextbox_Caret = "Caret"; |
29 |
|
30 |
public Path Base_ArrowPath = null; |
31 |
public Path Base_ArrowSubPath = null; |
32 |
public TextBox Base_TextBox = null; |
33 |
public TextBlock Base_TextBlock = null; |
34 |
public Border BaseTextbox_Caret = null; |
35 |
public event EventHandler<EventArgs> EditEnded; |
36 |
|
37 |
private const double _CloudArcDepth = 0.8; /// 2018.05.14 added by humkyung |
38 |
private const int _BendingLineLength = 50; |
39 |
|
40 |
#region Object & Variable |
41 |
GeometryGroup instanceGroup { get; } = new GeometryGroup(); |
42 |
LineGeometry connectorSMGeometry { get; } = new LineGeometry(); |
43 |
LineGeometry connectorMEGeometry { get; } = new LineGeometry(); |
44 |
|
45 |
public enum ArrowTextStyleSet { Normal, Cloud, Rect }; |
46 |
|
47 |
#endregion |
48 |
|
49 |
static ArrowTextControl() |
50 |
{ |
51 |
DefaultStyleKeyProperty.OverrideMetadata(typeof(ArrowTextControl), new FrameworkPropertyMetadata(typeof(ArrowTextControl))); |
52 |
} |
53 |
|
54 |
public ArrowTextControl() : base() |
55 |
{ |
56 |
} |
57 |
|
58 |
public override void Copy(CommentUserInfo lhs) |
59 |
{ |
60 |
if (lhs is ArrowTextControl item) |
61 |
{ |
62 |
this.PageAngle = item.PageAngle; |
63 |
this.LineSize = item.LineSize; |
64 |
this.PointSet = item.PointSet.ConvertAll(x => new Point(x.X, x.Y)); |
65 |
this.StartPoint = new Point(item.StartPoint.X, item.StartPoint.Y); |
66 |
this.EndPoint = new Point(item.EndPoint.X, item.EndPoint.Y); |
67 |
this.StrokeColor = item.StrokeColor; |
68 |
this.ArcLength = item.ArcLength; |
69 |
this.ArrowTextStyle = item.ArrowTextStyle; |
70 |
this.isHighLight = item.isHighLight; |
71 |
this.ArrowText = item.ArrowText; |
72 |
this.Opacity = item.Opacity; |
73 |
this.BorderSize = item.BorderSize; |
74 |
this.BoxWidth = item.BoxWidth; |
75 |
this.BoxHeight = item.BoxHeight; |
76 |
this.isFixed = item.isFixed; |
77 |
this.ControlType = item.ControlType; |
78 |
this.UserID = item.UserID; |
79 |
this.isTrans = item.isTrans; |
80 |
this.MidPoint = item.MidPoint; |
81 |
this.Memo = item.Memo; |
82 |
this.TextFamily = item.TextFamily; |
83 |
this.TextStyle = item.TextStyle; |
84 |
this.TextWeight = item.TextWeight; |
85 |
this.TextSize = item.TextSize; |
86 |
this.UnderLine = item.UnderLine; |
87 |
this.GroupID = item.GroupID; |
88 |
} |
89 |
} |
90 |
|
91 |
public override CommentUserInfo Clone() |
92 |
{ |
93 |
var clone = new ArrowTextControl(); |
94 |
clone.Copy(this); |
95 |
return clone; |
96 |
} |
97 |
|
98 |
public override void OnApplyTemplate() |
99 |
{ |
100 |
base.OnApplyTemplate(); |
101 |
Base_ArrowPath = GetTemplateChild(PART_ArrowPath) as Path; |
102 |
Base_ArrowSubPath = GetTemplateChild(PART_ArrowSubPath) as Path; |
103 |
Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox; |
104 |
BaseTextbox_Caret = GetTemplateChild(PART_BaseTextbox_Caret) as Border; |
105 |
Base_TextBox.FontFamily = this.TextFamily; |
106 |
if (Base_TextBox != null) |
107 |
{ |
108 |
this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length; |
109 |
this.Base_TextBox.CaretBrush = new SolidColorBrush(Colors.Transparent); |
110 |
|
111 |
if (this.ArrowTextStyle == ArrowTextStyleSet.Cloud) |
112 |
{ |
113 |
|
114 |
} |
115 |
|
116 |
this.Base_TextBox.ApplyTemplate(); |
117 |
this.Base_TextBox.Text = this.ArrowText; |
118 |
|
119 |
MoveCustomCaret(); |
120 |
|
121 |
Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged); |
122 |
Base_TextBox.GotFocus += new RoutedEventHandler(Base_TextBox_GotFocus); |
123 |
Base_TextBox.LostFocus += new RoutedEventHandler(Base_TextBox_LostFocus); |
124 |
Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret(); |
125 |
this.KeyDown += ArrowTextControl_KeyDown; |
126 |
|
127 |
SetArrowTextPath(true); |
128 |
|
129 |
Base_TextBox.IsTabStop = true; |
130 |
} |
131 |
} |
132 |
|
133 |
private void ArrowTextControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) |
134 |
{ |
135 |
if(e.Key == System.Windows.Input.Key.Escape) |
136 |
{ |
137 |
if(string.IsNullOrEmpty(Base_TextBox.Text)) |
138 |
{ |
139 |
this.Visibility = Visibility.Collapsed; |
140 |
} |
141 |
|
142 |
EditEnd(); |
143 |
} |
144 |
} |
145 |
|
146 |
public void SetFontFamily(FontFamily fontFamily) |
147 |
{ |
148 |
if (this.Base_TextBlock != null) |
149 |
{ |
150 |
this.Base_TextBlock.FontFamily = fontFamily; |
151 |
} |
152 |
|
153 |
if (this.Base_TextBox != null) |
154 |
{ |
155 |
this.Base_TextBox.FontFamily = fontFamily; |
156 |
} |
157 |
this.FontFamily = fontFamily; |
158 |
this.TextFamily = fontFamily; |
159 |
} |
160 |
|
161 |
/// <summary> |
162 |
/// Moves the custom caret on the canvas. |
163 |
/// </summary> |
164 |
public void MoveCustomCaret() |
165 |
{ |
166 |
var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location; |
167 |
|
168 |
var angle = Math.Abs(this.PageAngle); |
169 |
//angle = 0; |
170 |
System.Diagnostics.Debug.WriteLine("Page Angle : " + this.PageAngle); |
171 |
|
172 |
if (!double.IsInfinity(caretLocation.X)) |
173 |
{ |
174 |
if (angle == 90) |
175 |
{ |
176 |
Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.Y); |
177 |
} |
178 |
else if (angle == 180) |
179 |
{ |
180 |
|
181 |
Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X+ this.Base_TextBox.ActualWidth) - caretLocation.X) ; |
182 |
System.Diagnostics.Debug.WriteLine("Caret X : " + ((this.EndPoint.X + this.Base_TextBox.ActualWidth) - caretLocation.X)); |
183 |
} |
184 |
else if (angle == 270) |
185 |
{ |
186 |
Canvas.SetLeft(this.BaseTextbox_Caret, (this.EndPoint.X) - caretLocation.Y); |
187 |
} |
188 |
else |
189 |
{ |
190 |
System.Diagnostics.Debug.WriteLine("Caret X : " + (this.EndPoint.X - caretLocation.X)); |
191 |
Canvas.SetLeft(this.BaseTextbox_Caret, this.EndPoint.X + caretLocation.X); |
192 |
} |
193 |
} |
194 |
|
195 |
if (!double.IsInfinity(caretLocation.Y)) |
196 |
{ |
197 |
if (angle == 90) |
198 |
{ |
199 |
Canvas.SetTop(this.BaseTextbox_Caret, this.EndPoint.Y - caretLocation.X); |
200 |
} |
201 |
else if (angle == 180) |
202 |
{//보정치40 |
203 |
Canvas.SetTop(this.BaseTextbox_Caret, ((this.EndPoint.Y -40) + this.Base_TextBox.ActualHeight)- caretLocation.Y ); |
204 |
System.Diagnostics.Debug.WriteLine("Caret Y : " + (((this.EndPoint.Y - 40) + this.Base_TextBox.ActualHeight) - caretLocation.Y)); |
205 |
} |
206 |
else if (angle == 270) |
207 |
{ |
208 |
Canvas.SetTop(this.BaseTextbox_Caret, (this.EndPoint.Y) + caretLocation.X); |
209 |
} |
210 |
else |
211 |
{ |
212 |
Canvas.SetTop(this.BaseTextbox_Caret, this.EndPoint.Y + caretLocation.Y); |
213 |
System.Diagnostics.Debug.WriteLine("Caret Y : " + (this.EndPoint.Y + caretLocation.Y - BaseTextbox_Caret.ActualHeight)); |
214 |
} |
215 |
} |
216 |
} |
217 |
|
218 |
void Base_TextBox_LostFocus(object sender, RoutedEventArgs e) |
219 |
{ |
220 |
EditEnd(); |
221 |
} |
222 |
|
223 |
private void EditEnd() |
224 |
{ |
225 |
this.ArrowText = Base_TextBox.Text; |
226 |
Base_TextBox.Focusable = false; |
227 |
this.BaseTextbox_Caret.Visibility = Visibility.Collapsed; |
228 |
this.IsEditingMode = false; |
229 |
ApplyOverViewData(); |
230 |
|
231 |
if(EditEnded != null) |
232 |
{ |
233 |
EditEnded(this, new EventArgs()); |
234 |
} |
235 |
} |
236 |
|
237 |
void Base_TextBox_GotFocus(object sender, RoutedEventArgs e) |
238 |
{ |
239 |
this.BaseTextbox_Caret.Visibility = Visibility.Visible; |
240 |
MoveCustomCaret(); |
241 |
Base_TextBox.Focus(); |
242 |
this.IsEditingMode = true; |
243 |
} |
244 |
|
245 |
void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e) |
246 |
{ |
247 |
if(this.IsEditingMode) |
248 |
{ |
249 |
if (Base_TextBox.Text.Contains("|OR||DZ|")) |
250 |
{ |
251 |
Base_TextBox.Text = this.ArrowText; |
252 |
} |
253 |
|
254 |
this.ArrowText = Base_TextBox.Text; |
255 |
|
256 |
} |
257 |
BoxWidth = e.NewSize.Width; |
258 |
BoxHeight = e.NewSize.Height; |
259 |
SetArrowTextPath(); |
260 |
} |
261 |
|
262 |
#region Properties |
263 |
private bool _IsEditingMode; |
264 |
public bool IsEditingMode |
265 |
{ |
266 |
get |
267 |
{ |
268 |
return _IsEditingMode; |
269 |
} |
270 |
set |
271 |
{ |
272 |
_IsEditingMode = value; |
273 |
OnPropertyChanged("IsEditingMode"); |
274 |
} |
275 |
} |
276 |
|
277 |
|
278 |
#endregion |
279 |
|
280 |
#region dp Properties |
281 |
//강인구 주석 풀기 |
282 |
public Visibility TextBoxVisibility |
283 |
{ |
284 |
get { return (Visibility)GetValue(TextBoxVisibilityProperty); } |
285 |
set |
286 |
{ |
287 |
if (this.TextBoxVisibility != value) |
288 |
{ |
289 |
SetValue(TextBoxVisibilityProperty, value); |
290 |
OnPropertyChanged("TextBoxVisibility"); |
291 |
} |
292 |
} |
293 |
} |
294 |
|
295 |
//강인구 주석 풀기 |
296 |
public Visibility TextBlockVisibility |
297 |
{ |
298 |
get { return (Visibility)GetValue(TextBlockVisibilityProperty); } |
299 |
set |
300 |
{ |
301 |
if (this.TextBlockVisibility != value) |
302 |
{ |
303 |
SetValue(TextBlockVisibilityProperty, value); |
304 |
OnPropertyChanged("TextBlockVisibility"); |
305 |
} |
306 |
} |
307 |
} |
308 |
|
309 |
|
310 |
public override SolidColorBrush StrokeColor |
311 |
{ |
312 |
get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
313 |
set |
314 |
{ |
315 |
if (this.StrokeColor != value) |
316 |
{ |
317 |
SetValue(StrokeColorProperty, value); |
318 |
} |
319 |
} |
320 |
} |
321 |
|
322 |
public Double ArcLength |
323 |
{ |
324 |
get { return (Double)GetValue(ArcLengthProperty); } |
325 |
set |
326 |
{ |
327 |
if (this.ArcLength != value) |
328 |
{ |
329 |
SetValue(ArcLengthProperty, value); |
330 |
OnPropertyChanged("ArcLength"); |
331 |
} |
332 |
} |
333 |
} |
334 |
|
335 |
public PathGeometry SubPathData |
336 |
{ |
337 |
get { return (PathGeometry)GetValue(SubPathDataProperty); } |
338 |
set |
339 |
{ |
340 |
if (this.SubPathData != value) |
341 |
{ |
342 |
SetValue(SubPathDataProperty, value); |
343 |
} |
344 |
} |
345 |
} |
346 |
|
347 |
public string UserID |
348 |
{ |
349 |
get { return (string)GetValue(UserIDProperty); } |
350 |
set |
351 |
{ |
352 |
if (this.UserID != value) |
353 |
{ |
354 |
SetValue(UserIDProperty, value); |
355 |
OnPropertyChanged("UserID"); |
356 |
} |
357 |
} |
358 |
} |
359 |
|
360 |
public List<Point> PointSet |
361 |
{ |
362 |
get { return (List<Point>)GetValue(PointSetProperty); } |
363 |
set { SetValue(PointSetProperty, value); } |
364 |
} |
365 |
|
366 |
public override bool IsSelected |
367 |
{ |
368 |
get |
369 |
{ |
370 |
return (bool)GetValue(IsSelectedProperty); |
371 |
} |
372 |
set |
373 |
{ |
374 |
SetValue(IsSelectedProperty, value); |
375 |
OnPropertyChanged("IsSelected"); |
376 |
} |
377 |
} |
378 |
|
379 |
public override ControlType ControlType |
380 |
{ |
381 |
set |
382 |
{ |
383 |
SetValue(ControlTypeProperty, value); |
384 |
OnPropertyChanged("ControlType"); |
385 |
} |
386 |
get |
387 |
{ |
388 |
return (ControlType)GetValue(ControlTypeProperty); |
389 |
} |
390 |
} |
391 |
|
392 |
public Point StartPoint |
393 |
{ |
394 |
get { return (Point)GetValue(StartPointProperty); } |
395 |
set { SetValue(StartPointProperty, value); } |
396 |
} |
397 |
|
398 |
public Point EndPoint |
399 |
{ |
400 |
get { return (Point)GetValue(EndPointProperty); } |
401 |
set { SetValue(EndPointProperty, value); } |
402 |
} |
403 |
|
404 |
public Point OverViewStartPoint |
405 |
{ |
406 |
get { return (Point)GetValue(OverViewStartPointProperty); } |
407 |
set { SetValue(OverViewStartPointProperty, value); } |
408 |
} |
409 |
|
410 |
public Point OverViewEndPoint |
411 |
{ |
412 |
get { return (Point)GetValue(OverViewEndPointProperty); } |
413 |
set { SetValue(OverViewEndPointProperty, value); } |
414 |
} |
415 |
|
416 |
|
417 |
//public double Angle |
418 |
//{ |
419 |
// get { return (double)GetValue(AngleProperty); } |
420 |
// set { SetValue(AngleProperty, value); } |
421 |
//} |
422 |
|
423 |
public Thickness BorderSize |
424 |
{ |
425 |
get { return (Thickness)GetValue(BorderSizeProperty); } |
426 |
set |
427 |
{ |
428 |
if (this.BorderSize != value) |
429 |
{ |
430 |
SetValue(BorderSizeProperty, value); |
431 |
} |
432 |
} |
433 |
} |
434 |
|
435 |
|
436 |
public Point MidPoint |
437 |
{ |
438 |
get { return (Point)GetValue(MidPointProperty); } |
439 |
set { SetValue(MidPointProperty, value); } |
440 |
} |
441 |
|
442 |
public bool isFixed |
443 |
{ |
444 |
get { return (bool)GetValue(IsFixedProperty); } |
445 |
set { SetValue(IsFixedProperty, value); } |
446 |
} |
447 |
|
448 |
public bool isTrans |
449 |
{ |
450 |
get { return (bool)GetValue(TransformerProperty); } |
451 |
set { SetValue(TransformerProperty, value); } |
452 |
} |
453 |
|
454 |
public bool isHighLight |
455 |
{ |
456 |
get { return (bool)GetValue(isHighlightProperty); } |
457 |
set |
458 |
{ |
459 |
if (this.isHighLight != value) |
460 |
{ |
461 |
SetValue(isHighlightProperty, value); |
462 |
OnPropertyChanged("isHighLight"); |
463 |
} |
464 |
} |
465 |
} |
466 |
|
467 |
public FontWeight TextWeight |
468 |
{ |
469 |
get { return (FontWeight)GetValue(TextWeightProperty); } |
470 |
set |
471 |
{ |
472 |
if (this.TextWeight != value) |
473 |
{ |
474 |
SetValue(TextWeightProperty, value); |
475 |
OnPropertyChanged("TextWeight"); |
476 |
} |
477 |
} |
478 |
} |
479 |
|
480 |
public Double LineSize |
481 |
{ |
482 |
get { return (Double)GetValue(LineSizeProperty); } |
483 |
set |
484 |
{ |
485 |
if (this.LineSize != value) |
486 |
{ |
487 |
SetValue(LineSizeProperty, value); |
488 |
} |
489 |
} |
490 |
} |
491 |
|
492 |
public Double BoxWidth |
493 |
{ |
494 |
get { return (Double)GetValue(BoxWidthProperty); } |
495 |
set |
496 |
{ |
497 |
if (this.BoxWidth != value) |
498 |
{ |
499 |
SetValue(BoxWidthProperty, value); |
500 |
} |
501 |
} |
502 |
} |
503 |
|
504 |
public Double BoxHeight |
505 |
{ |
506 |
get { return (Double)GetValue(BoxHeightProperty); } |
507 |
set |
508 |
{ |
509 |
if (this.BoxHeight != value) |
510 |
{ |
511 |
SetValue(BoxHeightProperty, value); |
512 |
} |
513 |
} |
514 |
} |
515 |
|
516 |
public ArrowTextStyleSet ArrowTextStyle |
517 |
{ |
518 |
get { return (ArrowTextStyleSet)GetValue(ArrowTextStyleProperty); } |
519 |
set |
520 |
{ |
521 |
if (this.ArrowTextStyle != value) |
522 |
{ |
523 |
SetValue(ArrowTextStyleProperty, value); |
524 |
} |
525 |
} |
526 |
} |
527 |
|
528 |
public Geometry PathData |
529 |
{ |
530 |
get { return (Geometry)GetValue(PathDataProperty); } |
531 |
set { SetValue(PathDataProperty, value); |
532 |
|
533 |
OnPropertyChanged("PathData"); |
534 |
} |
535 |
} |
536 |
|
537 |
public SolidColorBrush BackInnerColor |
538 |
{ |
539 |
get { return (SolidColorBrush)GetValue(BackInnerColorProperty); } |
540 |
set |
541 |
{ |
542 |
if (this.BackInnerColor != value) |
543 |
{ |
544 |
SetValue(BackInnerColorProperty, value); |
545 |
OnPropertyChanged("BackInnerColor"); |
546 |
} |
547 |
} |
548 |
} |
549 |
|
550 |
public Geometry PathDataInner |
551 |
{ |
552 |
get { return (Geometry)GetValue(PathDataInnerProperty); } |
553 |
set |
554 |
{ |
555 |
SetValue(PathDataInnerProperty, value); |
556 |
OnPropertyChanged("PathDataInner"); |
557 |
} |
558 |
} |
559 |
|
560 |
public Geometry OverViewPathData |
561 |
{ |
562 |
get { return (Geometry)GetValue(OverViewPathDataProperty); } |
563 |
set { SetValue(OverViewPathDataProperty, value); |
564 |
|
565 |
OnPropertyChanged("OverViewPathData"); |
566 |
|
567 |
} |
568 |
} |
569 |
|
570 |
public FontFamily TextFamily |
571 |
{ |
572 |
get { return (FontFamily)GetValue(TextFamilyProperty); } |
573 |
set |
574 |
{ |
575 |
if (this.TextFamily != value) |
576 |
{ |
577 |
SetValue(TextFamilyProperty, value); |
578 |
OnPropertyChanged("TextFamily"); |
579 |
} |
580 |
} |
581 |
} |
582 |
|
583 |
public string ArrowText |
584 |
{ |
585 |
get { return (string)GetValue(ArrowTextProperty); } |
586 |
set |
587 |
{ |
588 |
if (this.ArrowText != value) |
589 |
{ |
590 |
SetValue(ArrowTextProperty, value); |
591 |
OnPropertyChanged("ArrowText"); |
592 |
} |
593 |
} |
594 |
} |
595 |
|
596 |
public string OverViewArrowText |
597 |
{ |
598 |
|
599 |
get { return (string)GetValue(OverViewArrowTextProperty); |
600 |
} |
601 |
set |
602 |
{ |
603 |
if (this.OverViewArrowText != value) |
604 |
{ |
605 |
SetValue(OverViewArrowTextProperty, value); |
606 |
OnPropertyChanged("OverViewArrowText"); |
607 |
} |
608 |
} |
609 |
} |
610 |
|
611 |
public Double TextSize |
612 |
{ |
613 |
get { return (Double)GetValue(TextSizeProperty); } |
614 |
set |
615 |
{ |
616 |
if (this.TextSize != value) |
617 |
{ |
618 |
SetValue(TextSizeProperty, value); |
619 |
OnPropertyChanged("TextSize"); |
620 |
} |
621 |
} |
622 |
} |
623 |
|
624 |
public FontStyle TextStyle |
625 |
{ |
626 |
get { return (FontStyle)GetValue(TextStyleProperty); } |
627 |
set |
628 |
{ |
629 |
if (this.TextStyle != value) |
630 |
{ |
631 |
SetValue(TextStyleProperty, value); |
632 |
OnPropertyChanged("TextStyle"); |
633 |
} |
634 |
} |
635 |
} |
636 |
|
637 |
//강인구 추가 |
638 |
public TextDecorationCollection UnderLine |
639 |
{ |
640 |
get |
641 |
{ |
642 |
return (TextDecorationCollection)GetValue(UnderLineProperty); |
643 |
} |
644 |
set |
645 |
{ |
646 |
if (this.UnderLine != value) |
647 |
{ |
648 |
SetValue(UnderLineProperty, value); |
649 |
OnPropertyChanged("UnderLine"); |
650 |
} |
651 |
} |
652 |
} |
653 |
|
654 |
public double CanvasX |
655 |
{ |
656 |
get { return (double)GetValue(CanvasXProperty); } |
657 |
set |
658 |
{ |
659 |
if (this.CanvasX != value) |
660 |
{ |
661 |
SetValue(CanvasXProperty, value); |
662 |
OnPropertyChanged("CanvasX"); |
663 |
} |
664 |
} |
665 |
} |
666 |
|
667 |
public double CanvasY |
668 |
{ |
669 |
get { return (double)GetValue(CanvasYProperty); } |
670 |
set |
671 |
{ |
672 |
if (this.CanvasY != value) |
673 |
{ |
674 |
SetValue(CanvasYProperty, value); |
675 |
OnPropertyChanged("CanvasY"); |
676 |
} |
677 |
} |
678 |
} |
679 |
|
680 |
public double CenterX |
681 |
{ |
682 |
get { return (double)GetValue(CenterXProperty); } |
683 |
set { SetValue(CenterXProperty, value); |
684 |
OnPropertyChanged("CenterX"); |
685 |
|
686 |
} |
687 |
} |
688 |
|
689 |
public double CenterY |
690 |
{ |
691 |
get { return (double)GetValue(CenterYProperty); } |
692 |
set { SetValue(CenterYProperty, value); |
693 |
OnPropertyChanged("CenterY"); |
694 |
} |
695 |
} |
696 |
|
697 |
public Brush SubPathFill |
698 |
{ |
699 |
get { return (Brush)GetValue(SubPathFillProperty); } |
700 |
set |
701 |
{ |
702 |
SetValue(SubPathFillProperty, value); |
703 |
OnPropertyChanged("SubPathFill"); |
704 |
} |
705 |
} |
706 |
|
707 |
public Brush TextBoxBackground |
708 |
{ |
709 |
get { return (Brush)GetValue(TextBoxBackgroundProperty); } |
710 |
set |
711 |
{ |
712 |
SetValue(TextBoxBackgroundProperty, value); |
713 |
OnPropertyChanged("TextBoxBackground"); |
714 |
} |
715 |
} |
716 |
|
717 |
|
718 |
//강인구 추가 주석풀기 |
719 |
|
720 |
|
721 |
public bool EnableEditing |
722 |
{ |
723 |
get { return (bool)GetValue(EnableEditingProperty); } |
724 |
set |
725 |
{ |
726 |
if (this.EnableEditing != value) |
727 |
{ |
728 |
SetValue(EnableEditingProperty, value); |
729 |
OnPropertyChanged("EnableEditing"); |
730 |
} |
731 |
} |
732 |
} |
733 |
|
734 |
#endregion |
735 |
|
736 |
#region Dependency Properties |
737 |
|
738 |
public static readonly DependencyProperty BoxWidthProperty = DependencyProperty.Register( |
739 |
"BoxWidth", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20)); |
740 |
|
741 |
public static readonly DependencyProperty BoxHeightProperty = DependencyProperty.Register( |
742 |
"BoxHeight", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)20)); |
743 |
|
744 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
745 |
"UserID", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null)); |
746 |
|
747 |
public static readonly DependencyProperty ArrowTextStyleProperty = DependencyProperty.Register( |
748 |
"ArrowTextStyle", typeof(ArrowTextStyleSet), typeof(ArrowTextControl), new PropertyMetadata(ArrowTextStyleSet.Normal)); |
749 |
|
750 |
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register( |
751 |
"CenterX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
752 |
|
753 |
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register( |
754 |
"CenterY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
755 |
|
756 |
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register( |
757 |
"Angle", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(PointValueChanged))); |
758 |
|
759 |
public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register( |
760 |
"CanvasX", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
761 |
|
762 |
public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register( |
763 |
"CanvasY", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
764 |
|
765 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
766 |
"PointSet", typeof(List<Point>), typeof(ArrowTextControl), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
767 |
|
768 |
public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register( |
769 |
"TextFamily", typeof(FontFamily), typeof(ArrowTextControl), new PropertyMetadata(new FontFamily("Arial"), TextChanged)); |
770 |
|
771 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
772 |
"PathData", typeof(Geometry), typeof(ArrowTextControl), null); |
773 |
|
774 |
//강인구 추가 |
775 |
public static readonly DependencyProperty UnderLineProperty = DependencyProperty.Register( |
776 |
"UnderLine", typeof(TextDecorationCollection), typeof(ArrowTextControl), new PropertyMetadata(null, PointValueChanged)); |
777 |
|
778 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
779 |
"LineSize", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)3, PointValueChanged)); |
780 |
|
781 |
public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register( |
782 |
"TextStyle", typeof(FontStyle), typeof(ArrowTextControl), new PropertyMetadata(FontStyles.Normal)); |
783 |
|
784 |
public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register( |
785 |
"TextSize", typeof(Double), typeof(ArrowTextControl), new PropertyMetadata((Double)30, PointValueChanged)); |
786 |
|
787 |
public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register( |
788 |
"TextWeight", typeof(FontWeight), typeof(ArrowTextControl), new PropertyMetadata(FontWeights.Normal)); |
789 |
|
790 |
public static readonly DependencyProperty IsFixedProperty = DependencyProperty.Register( |
791 |
"isFixed", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged)); |
792 |
|
793 |
public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register( |
794 |
"IsSelected", typeof(bool), typeof(ArrowTextControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
795 |
|
796 |
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
797 |
"StrokeColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
798 |
|
799 |
public static readonly DependencyProperty ArcLengthProperty = DependencyProperty.Register( |
800 |
"ArcLength", typeof(double), typeof(ArrowTextControl), new PropertyMetadata((Double)10, PointValueChanged)); |
801 |
|
802 |
public static readonly DependencyProperty ControlTypeProperty = DependencyProperty.Register( |
803 |
"ControlType", typeof(ControlType), typeof(ArrowTextControl), new FrameworkPropertyMetadata(ControlType.ArrowTextControl)); |
804 |
|
805 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
806 |
"StartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
807 |
|
808 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
809 |
"EndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
810 |
|
811 |
public static readonly DependencyProperty BackInnerColorProperty = DependencyProperty.Register( |
812 |
"BackInnerColor", typeof(SolidColorBrush), typeof(ArrowTextControl), new PropertyMetadata(new SolidColorBrush(Colors.White))); |
813 |
|
814 |
public static readonly DependencyProperty PathDataInnerProperty = DependencyProperty.Register( |
815 |
"PathDataInner", typeof(Geometry), typeof(ArrowTextControl), null); |
816 |
|
817 |
public static readonly DependencyProperty isHighlightProperty = DependencyProperty.Register( |
818 |
"isHighlight", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged)); |
819 |
|
820 |
public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register( |
821 |
"MidPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
822 |
|
823 |
public static readonly DependencyProperty TransformerProperty = DependencyProperty.Register( |
824 |
"isTrans", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata(false, PointValueChanged)); |
825 |
|
826 |
public static readonly DependencyProperty BorderSizeProperty = DependencyProperty.Register( |
827 |
"BorderSize", typeof(Thickness), typeof(ArrowTextControl), new PropertyMetadata(new Thickness(0), PointValueChanged)); |
828 |
|
829 |
public static readonly DependencyProperty ArrowTextProperty = DependencyProperty.Register( |
830 |
"ArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null)); |
831 |
|
832 |
|
833 |
|
834 |
//, new PropertyChangedCallback(TextChanged) |
835 |
|
836 |
|
837 |
#region 추가 사항 |
838 |
public static readonly DependencyProperty SubPathDataProperty = DependencyProperty.Register( |
839 |
"SubPathData", typeof(Geometry), typeof(ArrowTextControl), null); |
840 |
|
841 |
|
842 |
public static readonly DependencyProperty SubPathFillProperty = DependencyProperty.Register( |
843 |
"SubPathFill", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(null)); |
844 |
|
845 |
public static readonly DependencyProperty TextBoxBackgroundProperty = DependencyProperty.Register( |
846 |
"TextBoxBackground", typeof(Brush), typeof(ArrowTextControl), new PropertyMetadata(Brushes.White)); |
847 |
|
848 |
public static readonly DependencyProperty OverViewArrowTextProperty = DependencyProperty.Register( |
849 |
"OverViewArrowText", typeof(string), typeof(ArrowTextControl), new PropertyMetadata(null, new PropertyChangedCallback(TextChanged))); |
850 |
|
851 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
852 |
"OverViewPathData", typeof(Geometry), typeof(ArrowTextControl), null); |
853 |
|
854 |
public static readonly DependencyProperty OverViewStartPointProperty = DependencyProperty.Register( |
855 |
"OverViewStartPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null)); |
856 |
|
857 |
public static readonly DependencyProperty OverViewEndPointProperty = DependencyProperty.Register( |
858 |
"OverViewEndPoint", typeof(Point), typeof(ArrowTextControl), new PropertyMetadata(null)); |
859 |
|
860 |
public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register( |
861 |
"TextBoxVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged)); |
862 |
|
863 |
//강인구 추가(주석풀기) |
864 |
public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register( |
865 |
"TextBlockVisibility", typeof(Visibility), typeof(ArrowTextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged)); |
866 |
|
867 |
public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register( |
868 |
"EnableEditing", typeof(bool), typeof(ArrowTextControl), new PropertyMetadata((true), new PropertyChangedCallback(OnIsEditingChanged))); |
869 |
|
870 |
#endregion |
871 |
|
872 |
#endregion |
873 |
|
874 |
#region CallBack Method |
875 |
|
876 |
//강인구 추가(주석풀기) |
877 |
public static void OnIsEditingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
878 |
{ |
879 |
var instance = (ArrowTextControl)sender; |
880 |
|
881 |
if (e.OldValue != e.NewValue && instance.Base_TextBlock != null) |
882 |
{ |
883 |
instance.SetValue(e.Property, e.NewValue); |
884 |
|
885 |
if (instance.EnableEditing) |
886 |
{ |
887 |
instance.EditingMode(); |
888 |
} |
889 |
else |
890 |
{ |
891 |
instance.UnEditingMode(); |
892 |
} |
893 |
} |
894 |
} |
895 |
|
896 |
public static void OnTextBoxVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
897 |
{ |
898 |
var instance = (ArrowTextControl)sender; |
899 |
|
900 |
if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null) |
901 |
{ |
902 |
instance.SetValue(e.Property, e.NewValue); |
903 |
} |
904 |
} |
905 |
|
906 |
public static void OnTextBlockVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
907 |
{ |
908 |
var instance = (ArrowTextControl)sender; |
909 |
|
910 |
if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null) |
911 |
{ |
912 |
instance.SetValue(e.Property, e.NewValue); |
913 |
} |
914 |
} |
915 |
|
916 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
917 |
{ |
918 |
var instance = (ArrowTextControl)sender; |
919 |
|
920 |
if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null) |
921 |
{ |
922 |
if (e.Property.Name == "StartPoint" || e.Property.Name == "EndPoint") |
923 |
{ |
924 |
var connections = instance.GetConnectionPointList(); |
925 |
var near = MathSet.getNearPoint(connections, instance.StartPoint); |
926 |
var BendingPoint = instance.GetBendingPoint(connections, near); |
927 |
if (BendingPoint.HasValue) instance.MidPoint = BendingPoint.Value; |
928 |
} |
929 |
instance.SetArrowTextPath(); |
930 |
} |
931 |
} |
932 |
|
933 |
|
934 |
public static void TextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
935 |
{ |
936 |
var instance = (ArrowTextControl)sender; |
937 |
|
938 |
if (e.OldValue != e.NewValue) |
939 |
{ |
940 |
instance.SetValue(e.Property, e.NewValue); |
941 |
//instance.BoxWidth = instance.Base_TextBox.ActualWidth; |
942 |
//instance.BoxHeight = instance.Base_TextBox.ActualHeight; |
943 |
} |
944 |
} |
945 |
|
946 |
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
947 |
{ |
948 |
var instance = (ArrowTextControl)sender; |
949 |
if (e.OldValue != e.NewValue && instance.Base_ArrowPath != null) |
950 |
{ |
951 |
instance.SetValue(e.Property, e.NewValue); |
952 |
instance.SetArrowTextPath(); |
953 |
} |
954 |
} |
955 |
|
956 |
public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
957 |
{ |
958 |
var instance = (ArrowTextControl)sender; |
959 |
|
960 |
if (e.OldValue != e.NewValue && instance != null) |
961 |
{ |
962 |
instance.SetValue(e.Property, e.NewValue); |
963 |
//Canvas.SetLeft(instance, instance.CanvasX); |
964 |
//Canvas.SetTop(instance, instance.CanvasY); |
965 |
} |
966 |
} |
967 |
|
968 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
969 |
{ |
970 |
//var instance = (ArrowTextControl)sender; |
971 |
|
972 |
//if (e.OldValue != e.NewValue) |
973 |
//{ |
974 |
// instance.SetValue(e.Property, e.NewValue); |
975 |
|
976 |
// if (instance.IsSelected && instance.Base_TextBox != null) |
977 |
// { |
978 |
// instance.BorderSize = new Thickness(1); |
979 |
// //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Blue); |
980 |
// //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Blue); |
981 |
// } |
982 |
// else |
983 |
// { |
984 |
// instance.BorderSize = new Thickness(0); |
985 |
// //instance.Base_TextBox.BorderBrush = new SolidColorBrush(Colors.Transparent); |
986 |
// //instance.Base_ArrowPath.Stroke = new SolidColorBrush(Colors.Transparent); |
987 |
// } |
988 |
//} |
989 |
} |
990 |
#endregion |
991 |
|
992 |
#region Internal Method |
993 |
|
994 |
//강인구 주석 풀기 |
995 |
public void EditingMode() |
996 |
{ |
997 |
TextBoxVisibility = Visibility.Visible; |
998 |
TextBlockVisibility = Visibility.Collapsed; |
999 |
|
1000 |
|
1001 |
//강인구 언더라인 추가 |
1002 |
if (UnderLine != null) |
1003 |
Base_TextBlock.TextDecorations = UnderLine; |
1004 |
} |
1005 |
//강인구 주석 풀기 |
1006 |
public void UnEditingMode() |
1007 |
{ |
1008 |
TextBoxVisibility = Visibility.Collapsed; |
1009 |
TextBlockVisibility = Visibility.Visible; |
1010 |
|
1011 |
if (Base_TextBlock != null) |
1012 |
{ |
1013 |
if (UnderLine != null) |
1014 |
Base_TextBlock.TextDecorations = UnderLine; |
1015 |
|
1016 |
Base_TextBlock.Margin = |
1017 |
new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4, |
1018 |
Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4); |
1019 |
} |
1020 |
|
1021 |
this.BaseTextbox_Caret.Visibility = Visibility.Collapsed; |
1022 |
} |
1023 |
|
1024 |
/// <summary> |
1025 |
/// 연결점 리스트를 리턴한다. |
1026 |
/// </summary> |
1027 |
/// <returns></returns> |
1028 |
private List<Point> GetConnectionPointList() |
1029 |
{ |
1030 |
List<Point> res = new List<Point>(); |
1031 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox))); //상단 |
1032 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth / 2, Canvas.GetTop(Base_TextBox) + this.BoxHeight)); // 하단 |
1033 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2)); //좌단 |
1034 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxWidth, Canvas.GetTop(Base_TextBox) + this.BoxHeight / 2)); //우단 |
1035 |
|
1036 |
if (isTrans) |
1037 |
{ |
1038 |
switch (Math.Abs(this.PageAngle).ToString()) |
1039 |
{ |
1040 |
case "90": |
1041 |
{ |
1042 |
res.Clear(); |
1043 |
|
1044 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽 |
1045 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간 |
1046 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽 |
1047 |
|
1048 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간 |
1049 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단 |
1050 |
|
1051 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); //중간 하단 |
1052 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 하단 |
1053 |
|
1054 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간 |
1055 |
} |
1056 |
break; |
1057 |
case "270": |
1058 |
{ |
1059 |
res.Clear(); |
1060 |
|
1061 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽 |
1062 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간 |
1063 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽 |
1064 |
|
1065 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간 |
1066 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단 |
1067 |
|
1068 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); //중간 하단 |
1069 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 하단 |
1070 |
|
1071 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 |
1072 |
} |
1073 |
break; |
1074 |
default: |
1075 |
break; |
1076 |
} |
1077 |
} |
1078 |
else |
1079 |
{ |
1080 |
switch (Math.Abs(this.PageAngle).ToString()) |
1081 |
{ |
1082 |
case "90": |
1083 |
{ |
1084 |
res.Clear(); |
1085 |
|
1086 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽 |
1087 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); // 위 중간 |
1088 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - this.BoxWidth)); // 위 오른쪽 |
1089 |
|
1090 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간 |
1091 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단 |
1092 |
|
1093 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth / 2)); //중간 하단 |
1094 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 하단 |
1095 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) + this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) - this.BoxWidth)); //오른쪽 중간 |
1096 |
} |
1097 |
break; |
1098 |
case "270": |
1099 |
{ |
1100 |
res.Clear(); |
1101 |
|
1102 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox))); //위 왼쪽 |
1103 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); // 위 중간 |
1104 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + this.BoxWidth)); // 위 오른쪽 |
1105 |
|
1106 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox))); //왼쪽 중간 |
1107 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox))); //왼쪽 하단 |
1108 |
|
1109 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth / 2)); //중간 하단 |
1110 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 하단 |
1111 |
|
1112 |
res.Add(new Point(Canvas.GetLeft(Base_TextBox) - this.BoxHeight / 2, Canvas.GetTop(Base_TextBox) + this.BoxWidth)); //오른쪽 중간 |
1113 |
} |
1114 |
break; |
1115 |
default: |
1116 |
break; |
1117 |
} |
1118 |
} |
1119 |
|
1120 |
return res; |
1121 |
} |
1122 |
|
1123 |
/// <summary> |
1124 |
/// connection을 이용하여 꺽인점의 위치를 구한다. |
1125 |
/// </summary> |
1126 |
/// <returns></returns> |
1127 |
private Point? GetBendingPoint(List<Point> ConnectionPointList, Point connection) |
1128 |
{ |
1129 |
Point? BendingPoint = null; |
1130 |
|
1131 |
if (isTrans) |
1132 |
{ |
1133 |
//20180910 LJY 각도에 따라. |
1134 |
switch (Math.Abs(this.PageAngle).ToString()) |
1135 |
{ |
1136 |
case "90": |
1137 |
if (isFixed) |
1138 |
{ |
1139 |
if (ConnectionPointList[0] == connection) //상단 |
1140 |
{ |
1141 |
BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength); |
1142 |
} |
1143 |
else if (ConnectionPointList[1] == connection) //하단 |
1144 |
{ |
1145 |
BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength); |
1146 |
} |
1147 |
else if (ConnectionPointList[2] == connection) //좌단 |
1148 |
{ |
1149 |
BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y); |
1150 |
} |
1151 |
else if (ConnectionPointList[3] == connection) //우단 |
1152 |
{ |
1153 |
BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y); |
1154 |
} |
1155 |
} |
1156 |
else |
1157 |
{ |
1158 |
BendingPoint = connection; |
1159 |
} |
1160 |
break; |
1161 |
case "270": |
1162 |
if (isFixed) |
1163 |
{ |
1164 |
if (ConnectionPointList[0] == connection) //상단 |
1165 |
{ |
1166 |
BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength); |
1167 |
} |
1168 |
else if (ConnectionPointList[1] == connection) //하단 |
1169 |
{ |
1170 |
BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength); |
1171 |
} |
1172 |
else if (ConnectionPointList[2] == connection) //좌단 |
1173 |
{ |
1174 |
BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y); |
1175 |
} |
1176 |
else if (ConnectionPointList[3] == connection) //우단 |
1177 |
{ |
1178 |
BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y); |
1179 |
} |
1180 |
} |
1181 |
else |
1182 |
{ |
1183 |
BendingPoint = connection; |
1184 |
} |
1185 |
break; |
1186 |
default: |
1187 |
if (isFixed) |
1188 |
{ |
1189 |
if (ConnectionPointList[0] == connection) //상단 |
1190 |
{ |
1191 |
BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength); |
1192 |
} |
1193 |
else if (ConnectionPointList[1] == connection) //하단 |
1194 |
{ |
1195 |
BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength); |
1196 |
} |
1197 |
else if (ConnectionPointList[2] == connection) //좌단 |
1198 |
{ |
1199 |
BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y); |
1200 |
} |
1201 |
else if (ConnectionPointList[3] == connection) //우단 |
1202 |
{ |
1203 |
BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y); |
1204 |
} |
1205 |
} |
1206 |
else |
1207 |
{ |
1208 |
BendingPoint = connection; |
1209 |
} |
1210 |
break; |
1211 |
} |
1212 |
} |
1213 |
else |
1214 |
{ |
1215 |
//20180910 LJY 각도에 따라. |
1216 |
switch (Math.Abs(this.PageAngle).ToString()) |
1217 |
{ |
1218 |
case "90": |
1219 |
if (isFixed) |
1220 |
{ |
1221 |
if (ConnectionPointList[0] == connection) //상단 |
1222 |
{ |
1223 |
BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y); |
1224 |
} |
1225 |
else if (ConnectionPointList[1] == connection) //하단 |
1226 |
{ |
1227 |
BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y); |
1228 |
} |
1229 |
else if (ConnectionPointList[2] == connection) //좌단 |
1230 |
{ |
1231 |
BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y); |
1232 |
} |
1233 |
else if (ConnectionPointList[3] == connection) //우단 |
1234 |
{ |
1235 |
BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y); |
1236 |
} |
1237 |
} |
1238 |
else |
1239 |
{ |
1240 |
BendingPoint = connection; |
1241 |
} |
1242 |
break; |
1243 |
case "270": |
1244 |
if (isFixed) |
1245 |
{ |
1246 |
if (ConnectionPointList[0] == connection) //상단 |
1247 |
{ |
1248 |
BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y); |
1249 |
} |
1250 |
else if (ConnectionPointList[1] == connection) //하단 |
1251 |
{ |
1252 |
BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y); |
1253 |
} |
1254 |
else if (ConnectionPointList[2] == connection) //좌단 |
1255 |
{ |
1256 |
BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y); |
1257 |
} |
1258 |
else if (ConnectionPointList[3] == connection) //우단 |
1259 |
{ |
1260 |
BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y); |
1261 |
} |
1262 |
} |
1263 |
else |
1264 |
{ |
1265 |
BendingPoint = connection; |
1266 |
} |
1267 |
break; |
1268 |
default: |
1269 |
if (isFixed) |
1270 |
{ |
1271 |
if (ConnectionPointList[0] == connection) //상단 |
1272 |
{ |
1273 |
BendingPoint = new Point(connection.X, connection.Y - _BendingLineLength); |
1274 |
} |
1275 |
else if (ConnectionPointList[1] == connection) //하단 |
1276 |
{ |
1277 |
BendingPoint = new Point(connection.X, connection.Y + _BendingLineLength); |
1278 |
} |
1279 |
else if (ConnectionPointList[2] == connection) //좌단 |
1280 |
{ |
1281 |
BendingPoint = new Point(connection.X - _BendingLineLength, connection.Y); |
1282 |
} |
1283 |
else if (ConnectionPointList[3] == connection) //우단 |
1284 |
{ |
1285 |
BendingPoint = new Point(connection.X + _BendingLineLength, connection.Y); |
1286 |
} |
1287 |
} |
1288 |
else |
1289 |
{ |
1290 |
BendingPoint = connection; |
1291 |
} |
1292 |
break; |
1293 |
} |
1294 |
} |
1295 |
|
1296 |
|
1297 |
return BendingPoint; |
1298 |
} |
1299 |
|
1300 |
private void SetArrowTextPath(bool IsInit = false) |
1301 |
{ |
1302 |
instanceGroup.Children.Clear(); |
1303 |
|
1304 |
if (Math.Abs(PageAngle).ToString() == "90") |
1305 |
{ |
1306 |
VisualPageAngle = 270; |
1307 |
} |
1308 |
else if (Math.Abs(PageAngle).ToString() == "270") |
1309 |
{ |
1310 |
VisualPageAngle = 90; |
1311 |
} |
1312 |
else |
1313 |
{ |
1314 |
VisualPageAngle = PageAngle; |
1315 |
} |
1316 |
|
1317 |
connectorSMGeometry.StartPoint = this.StartPoint; |
1318 |
connectorSMGeometry.EndPoint = this.MidPoint; |
1319 |
connectorMEGeometry.StartPoint = this.MidPoint; //핵심 |
1320 |
|
1321 |
/// 텍스트박스의 좌표 설정 |
1322 |
Canvas.SetLeft(Base_TextBox, this.EndPoint.X); |
1323 |
Canvas.SetTop(Base_TextBox, this.EndPoint.Y); |
1324 |
|
1325 |
List<Point> ps = GetConnectionPointList(); |
1326 |
if (isTrans) |
1327 |
{ |
1328 |
var ConnectionPoint = MathSet.getNearPoint(ps, this.MidPoint); |
1329 |
Point? BendingPoint = GetBendingPoint(ps, ConnectionPoint); |
1330 |
if (BendingPoint.HasValue) |
1331 |
{ |
1332 |
connectorSMGeometry.EndPoint = BendingPoint.Value; |
1333 |
connectorMEGeometry.StartPoint = BendingPoint.Value; |
1334 |
connectorMEGeometry.EndPoint = ConnectionPoint; |
1335 |
|
1336 |
//20180910 LJY 각도에 따라. |
1337 |
this.MidPoint = BendingPoint.Value; |
1338 |
instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint.Value, this.StartPoint, this.LineSize)); |
1339 |
instanceGroup.FillRule = FillRule.Nonzero; |
1340 |
this.Base_ArrowPath.Fill = this.StrokeColor; |
1341 |
this.Base_ArrowSubPath.Fill = this.StrokeColor; |
1342 |
} |
1343 |
} |
1344 |
else |
1345 |
{ |
1346 |
var ConnectionPoint = MathSet.getNearPoint(ps, this.MidPoint); |
1347 |
#region 보정치 |
1348 |
Point? BendingPoint = GetBendingPoint(ps, ConnectionPoint); |
1349 |
if (BendingPoint.HasValue) |
1350 |
{ |
1351 |
connectorSMGeometry.EndPoint = BendingPoint.Value; |
1352 |
connectorMEGeometry.StartPoint = BendingPoint.Value; |
1353 |
connectorMEGeometry.EndPoint = ConnectionPoint; |
1354 |
|
1355 |
instanceGroup.Children.Add(DrawSet.DrawArrow(BendingPoint.Value, this.StartPoint, this.LineSize)); |
1356 |
instanceGroup.FillRule = FillRule.Nonzero; |
1357 |
this.Base_ArrowPath.Fill = this.StrokeColor; |
1358 |
this.Base_ArrowSubPath.Fill = this.StrokeColor; |
1359 |
} |
1360 |
#endregion |
1361 |
} |
1362 |
|
1363 |
switch (this.ArrowTextStyle) |
1364 |
{ |
1365 |
case ArrowTextStyleSet.Normal: |
1366 |
this.BorderSize = new Thickness(0); |
1367 |
DrawingRect(); |
1368 |
break; |
1369 |
case ArrowTextStyleSet.Cloud: |
1370 |
this.BorderSize = new Thickness(0); |
1371 |
DrawingCloud(); |
1372 |
break; |
1373 |
default: |
1374 |
{ |
1375 |
this.BorderSize = new Thickness(LineSize); |
1376 |
DrawingRect(); |
1377 |
} |
1378 |
|
1379 |
break; |
1380 |
} |
1381 |
|
1382 |
if (isHighLight) |
1383 |
{ |
1384 |
SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B)); |
1385 |
BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B)); |
1386 |
|
1387 |
TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B)); |
1388 |
} |
1389 |
else |
1390 |
{ |
1391 |
BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B)); |
1392 |
SubPathFill = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), Colors.White.R, Colors.White.G, Colors.White.B)); |
1393 |
TextBoxBackground = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1), Colors.White.R, Colors.White.G, Colors.White.B)); |
1394 |
} |
1395 |
|
1396 |
instanceGroup.Children.Add(connectorSMGeometry); |
1397 |
instanceGroup.Children.Add(connectorMEGeometry); |
1398 |
|
1399 |
this.PathData = instanceGroup; |
1400 |
OverViewPathData = PathData; |
1401 |
OverViewArrowText = ArrowText; |
1402 |
OverViewEndPoint = connectorMEGeometry.EndPoint; |
1403 |
OverViewStartPoint = connectorSMGeometry.StartPoint; |
1404 |
|
1405 |
var tempAngle = Math.Abs(this.VisualPageAngle); |
1406 |
|
1407 |
if (tempAngle == Convert.ToDouble(90) || tempAngle == Convert.ToDouble(270)) |
1408 |
{ |
1409 |
this.RenderTransformOrigin = new Point(0.5, 0.5); |
1410 |
this.Base_ArrowPath.RenderTransformOrigin = new Point(0, 0); |
1411 |
this.Base_ArrowSubPath.RenderTransformOrigin = new Point(0, 0); |
1412 |
|
1413 |
Base_TextBox.RenderTransformOrigin = new Point(0, 0); |
1414 |
BaseTextbox_Caret.RenderTransformOrigin = new Point(0, 0); |
1415 |
} |
1416 |
|
1417 |
Base_TextBox.RenderTransform = new RotateTransform |
1418 |
{ |
1419 |
Angle = this.VisualPageAngle, |
1420 |
CenterX = this.CenterX, |
1421 |
CenterY = this.CenterY, |
1422 |
}; |
1423 |
|
1424 |
Base_ArrowSubPath.RenderTransform = new RotateTransform |
1425 |
{ |
1426 |
Angle = this.VisualPageAngle, |
1427 |
CenterX = this.EndPoint.X, |
1428 |
CenterY = this.EndPoint.Y, |
1429 |
}; |
1430 |
|
1431 |
if (BaseTextbox_Caret.Visibility == Visibility.Visible) |
1432 |
{ |
1433 |
BaseTextbox_Caret.RenderTransform = new RotateTransform |
1434 |
{ |
1435 |
Angle = this.VisualPageAngle, |
1436 |
CenterX = this.CenterX, |
1437 |
CenterY = this.CenterY, |
1438 |
}; |
1439 |
|
1440 |
MoveCustomCaret(); |
1441 |
} |
1442 |
} |
1443 |
|
1444 |
private void DrawingCloud() |
1445 |
{ |
1446 |
//20180906 LJY Textbox guide |
1447 |
string angle = Math.Abs(this.PageAngle).ToString(); |
1448 |
//방지 |
1449 |
if (this.ArcLength == 0) this.ArcLength = 10; |
1450 |
if (angle == "180") |
1451 |
{ |
1452 |
List<Point> pCloud = new List<Point>() |
1453 |
{ |
1454 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1455 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxHeight), //왼쪽 아래 |
1456 |
new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox) - BoxHeight), |
1457 |
new Point(Canvas.GetLeft(Base_TextBox) - BoxWidth, Canvas.GetTop(Base_TextBox)), |
1458 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1459 |
}; |
1460 |
SubPathData = Generate(pCloud, this.ArcLength); |
1461 |
PathDataInner = (GenerateInnerCloud(pCloud, angle)); |
1462 |
|
1463 |
}//20180906 LJY Textbox guide |
1464 |
else |
1465 |
{ |
1466 |
var boxWidth = BoxWidth; |
1467 |
System.Diagnostics.Debug.WriteLine("disp Width : " + BoxWidth); |
1468 |
//boxWidth = boxWidth + Base_TextBox.Margin.Left + Base_TextBox.Margin.Right + Base_TextBox.Padding.Left + Base_TextBox.Padding.Right; |
1469 |
|
1470 |
List<Point> pCloud = new List<Point>() |
1471 |
{ |
1472 |
#if SILVERLIGHT |
1473 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1474 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래 |
1475 |
new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight), |
1476 |
new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)), |
1477 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1478 |
|
1479 |
#else |
1480 |
new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize ), Canvas.GetTop(Base_TextBox) -(this.LineSize)), //위 |
1481 |
new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize ), Canvas.GetTop(Base_TextBox)+ BoxHeight+(this.LineSize)), //왼쪽 아래 |
1482 |
new Point(Canvas.GetLeft(Base_TextBox)+ boxWidth+(this.LineSize ), Canvas.GetTop(Base_TextBox) + BoxHeight+(this.LineSize)), |
1483 |
new Point(Canvas.GetLeft(Base_TextBox) + boxWidth+(this.LineSize ), Canvas.GetTop(Base_TextBox)-(this.LineSize)), |
1484 |
new Point(Canvas.GetLeft(Base_TextBox)-(this.LineSize), Canvas.GetTop(Base_TextBox)-(this.LineSize)), //위 |
1485 |
|
1486 |
//new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1487 |
//new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래 |
1488 |
//new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4), |
1489 |
//new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)), |
1490 |
//new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1491 |
#endif |
1492 |
}; |
1493 |
//instanceGroup.Children.Add(Generate(pCloud)); |
1494 |
SubPathData = Generate(pCloud, this.ArcLength); |
1495 |
PathDataInner = (GenerateInnerCloud(pCloud, angle)); |
1496 |
// } |
1497 |
} |
1498 |
|
1499 |
} |
1500 |
|
1501 |
private void DrawingRect() |
1502 |
{ |
1503 |
//20180906 LJY Textbox guide |
1504 |
if(this.ArrowTextStyle == ArrowTextStyleSet.Normal) |
1505 |
{ |
1506 |
this.Base_TextBox.BorderBrush = Brushes.Transparent; |
1507 |
} |
1508 |
|
1509 |
if (Math.Abs(this.PageAngle).ToString() == "90") |
1510 |
{ |
1511 |
List<Point> pCloud = new List<Point>() |
1512 |
{ |
1513 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1514 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) - BoxWidth), //왼쪽 아래 |
1515 |
new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox) - BoxWidth), |
1516 |
new Point(Canvas.GetLeft(Base_TextBox) + BoxHeight, Canvas.GetTop(Base_TextBox)), |
1517 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1518 |
}; |
1519 |
PathDataInner = (GenerateInner(pCloud)); |
1520 |
} |
1521 |
else if(Math.Abs(this.PageAngle).ToString() == "270") |
1522 |
{ |
1523 |
List<Point> pCloud = new List<Point>() |
1524 |
{ |
1525 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1526 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox) + BoxWidth), //왼쪽 아래 |
1527 |
new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox) + BoxWidth), |
1528 |
new Point(Canvas.GetLeft(Base_TextBox) - BoxHeight, Canvas.GetTop(Base_TextBox)), |
1529 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1530 |
}; |
1531 |
PathDataInner = (GenerateInner(pCloud)); |
1532 |
}//20180906 LJY Textbox guide |
1533 |
else |
1534 |
{ |
1535 |
List<Point> pCloud = new List<Point>() |
1536 |
{ |
1537 |
#if SILVERLIGHT |
1538 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1539 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래 |
1540 |
new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight), |
1541 |
new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)), |
1542 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1543 |
|
1544 |
#else |
1545 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1546 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight), //왼쪽 아래 |
1547 |
new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth, Canvas.GetTop(Base_TextBox) + BoxHeight), |
1548 |
new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth, Canvas.GetTop(Base_TextBox)), |
1549 |
new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1550 |
|
1551 |
//new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1552 |
//new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)+ BoxHeight-4), //왼쪽 아래 |
1553 |
//new Point(Canvas.GetLeft(Base_TextBox)+ BoxWidth-1, Canvas.GetTop(Base_TextBox) + BoxHeight-4), |
1554 |
//new Point(Canvas.GetLeft(Base_TextBox) + BoxWidth-1, Canvas.GetTop(Base_TextBox)), |
1555 |
//new Point(Canvas.GetLeft(Base_TextBox), Canvas.GetTop(Base_TextBox)), //위 |
1556 |
#endif |
1557 |
}; |
1558 |
//instanceGroup.Children.Add(Generate(pCloud)); |
1559 |
PathDataInner = (GenerateInner(pCloud)); |
1560 |
} |
1561 |
} |
1562 |
|
1563 |
public override void UpdateControl() |
1564 |
{ |
1565 |
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
1566 |
this.MidPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
1567 |
this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
1568 |
} |
1569 |
|
1570 |
public override void ApplyOverViewData() |
1571 |
{ |
1572 |
this.OverViewPathData = this.PathData; |
1573 |
if (ArrowText == "") |
1574 |
{ |
1575 |
this.OverViewArrowText = ""; |
1576 |
this.ArrowText = this.OverViewArrowText; |
1577 |
} |
1578 |
else |
1579 |
this.OverViewArrowText = this.ArrowText; |
1580 |
this.OverViewStartPoint = this.StartPoint; |
1581 |
this.OverViewEndPoint = this.EndPoint; |
1582 |
} |
1583 |
|
1584 |
#endregion |
1585 |
|
1586 |
public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse) |
1587 |
{ |
1588 |
PathFigure pathFigure = new PathFigure(); |
1589 |
pathFigure.StartPoint = p1; |
1590 |
|
1591 |
double arcLength = arcLength_; |
1592 |
/// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung |
1593 |
double dx = p2.X - p1.X; |
1594 |
double dy = p2.Y - p1.Y; |
1595 |
double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2 |
1596 |
double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI; |
1597 |
Point lastPt = new Point(p1.X, p1.Y); |
1598 |
double count = l / arcLength; |
1599 |
/// normalize |
1600 |
dx /= l; |
1601 |
dy /= l; |
1602 |
Double j = 1; |
1603 |
for (j = 1; j < (count - 1); j++) |
1604 |
{ |
1605 |
ArcSegment arcSeg = new ArcSegment(); |
1606 |
arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth); /// x size and y size of arc |
1607 |
arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength); /// end point of arc |
1608 |
lastPt = arcSeg.Point; /// save last point |
1609 |
arcSeg.RotationAngle = theta + 90; |
1610 |
if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
1611 |
pathFigure.Segments.Add(arcSeg); |
1612 |
} |
1613 |
|
1614 |
/// draw arc between last point and end point |
1615 |
if ((count > j) || (count > 0)) |
1616 |
{ |
1617 |
arcLength = MathSet.DistanceTo(lastPt, p2); |
1618 |
ArcSegment arcSeg = new ArcSegment(); |
1619 |
arcSeg.Size = new Size(arcLength * _CloudArcDepth, arcLength * _CloudArcDepth); /// x size and y size of arc |
1620 |
arcSeg.Point = new Point(p2.X, p2.Y); /// end point of arc |
1621 |
arcSeg.RotationAngle = theta; |
1622 |
if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
1623 |
pathFigure.Segments.Add(arcSeg); |
1624 |
} |
1625 |
/// up to here |
1626 |
|
1627 |
return pathFigure; |
1628 |
} |
1629 |
|
1630 |
public static PathGeometry Generate(List<Point> pData, double _ArcLength) |
1631 |
{ |
1632 |
var _pathGeometry = new PathGeometry(); |
1633 |
|
1634 |
double area = MathSet.AreaOf(pData); |
1635 |
bool reverse = (area > 0); |
1636 |
int count = pData.Count; |
1637 |
for (int i = 0; i < (count - 1); i++) |
1638 |
{ |
1639 |
PathFigure pathFigure = Polygon.CloudControl.GenerateLineWithCloud(pData[i], pData[i + 1], _ArcLength, reverse); |
1640 |
pathFigure.IsClosed = false; |
1641 |
pathFigure.IsFilled = false; |
1642 |
_pathGeometry.Figures.Add(pathFigure); |
1643 |
} |
1644 |
|
1645 |
return _pathGeometry; |
1646 |
} |
1647 |
|
1648 |
|
1649 |
public static PathGeometry GenerateInner(List<Point> pData) |
1650 |
{ |
1651 |
var _pathGeometry = new PathGeometry(); |
1652 |
double area = MathSet.AreaOf(pData); |
1653 |
bool reverse = (area > 0); |
1654 |
int count = pData.Count; |
1655 |
|
1656 |
PathFigure pathFigur2 = new PathFigure(); |
1657 |
pathFigur2.StartPoint = pData[0]; |
1658 |
|
1659 |
LineSegment lineSegment0 = new LineSegment(); |
1660 |
lineSegment0.Point = pData[0]; |
1661 |
pathFigur2.Segments.Add(lineSegment0); |
1662 |
|
1663 |
LineSegment lineSegment1 = new LineSegment(); |
1664 |
lineSegment1.Point = pData[1]; |
1665 |
pathFigur2.Segments.Add(lineSegment1); |
1666 |
|
1667 |
LineSegment lineSegment2 = new LineSegment(); |
1668 |
lineSegment2.Point = pData[2]; |
1669 |
pathFigur2.Segments.Add(lineSegment2); |
1670 |
|
1671 |
LineSegment lineSegment3 = new LineSegment(); |
1672 |
lineSegment3.Point = pData[3]; |
1673 |
pathFigur2.Segments.Add(lineSegment3); |
1674 |
|
1675 |
|
1676 |
pathFigur2.IsClosed = true; |
1677 |
pathFigur2.IsFilled = true; |
1678 |
_pathGeometry.Figures.Add(pathFigur2); |
1679 |
|
1680 |
return _pathGeometry; |
1681 |
} |
1682 |
|
1683 |
//20180910 LJY Cloud rotation 추가 |
1684 |
public static PathGeometry GenerateInnerCloud(List<Point> pData, string angle) |
1685 |
{ |
1686 |
var _pathGeometry = new PathGeometry(); |
1687 |
double area = MathSet.AreaOf(pData); |
1688 |
bool reverse = (area > 0); |
1689 |
int count = pData.Count; |
1690 |
|
1691 |
PathFigure pathFigur2 = new PathFigure(); |
1692 |
pathFigur2.StartPoint = pData[0]; |
1693 |
|
1694 |
LineSegment lineSegment0 = new LineSegment(); |
1695 |
lineSegment0.Point = pData[0]; |
1696 |
pathFigur2.Segments.Add(lineSegment0); |
1697 |
|
1698 |
LineSegment lineSegment1 = new LineSegment(); |
1699 |
lineSegment1.Point = pData[1]; |
1700 |
pathFigur2.Segments.Add(lineSegment1); |
1701 |
|
1702 |
LineSegment lineSegment2 = new LineSegment(); |
1703 |
lineSegment2.Point = pData[2]; |
1704 |
pathFigur2.Segments.Add(lineSegment2); |
1705 |
|
1706 |
LineSegment lineSegment3 = new LineSegment(); |
1707 |
lineSegment3.Point = pData[3]; |
1708 |
pathFigur2.Segments.Add(lineSegment3); |
1709 |
|
1710 |
RotateTransform transform = new RotateTransform(); |
1711 |
switch (angle) |
1712 |
{ |
1713 |
case "90": |
1714 |
transform.Angle = -90; |
1715 |
break; |
1716 |
case "180": |
1717 |
transform.Angle = -180; |
1718 |
break; |
1719 |
case "270": |
1720 |
transform.Angle = -270; |
1721 |
break; |
1722 |
} |
1723 |
transform.CenterX = pData[0].X; |
1724 |
transform.CenterY = pData[0].Y; |
1725 |
_pathGeometry.Transform = transform; |
1726 |
|
1727 |
pathFigur2.IsClosed = true; |
1728 |
pathFigur2.IsFilled = true; |
1729 |
_pathGeometry.Figures.Add(pathFigur2); |
1730 |
|
1731 |
return _pathGeometry; |
1732 |
} |
1733 |
|
1734 |
/// <summary> |
1735 |
/// call when mouse is moving while drawing control |
1736 |
/// </summary> |
1737 |
/// <author>humkyung</author> |
1738 |
/// <param name="pt"></param> |
1739 |
/// <param name="bAxisLocked"></param> |
1740 |
public override void OnCreatingMouseMove(Point pt, bool bAxisLocked) |
1741 |
{ |
1742 |
this.EndPoint = pt; |
1743 |
|
1744 |
Point tempPoint = this.EndPoint; |
1745 |
CommentAngle = MathSet.returnAngle(this.StartPoint, ref tempPoint, bAxisLocked); |
1746 |
|
1747 |
if (bAxisLocked) |
1748 |
{ |
1749 |
this.EndPoint = tempPoint; |
1750 |
} |
1751 |
|
1752 |
this.MidPoint = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint); |
1753 |
this.isFixed = (this.ControlType == ControlType.ArrowTransTextControl) || |
1754 |
(this.ControlType == ControlType.ArrowTransTextBorderControl) || (this.ControlType == ControlType.ArrowTransTextCloudControl); |
1755 |
|
1756 |
this.PointSet = new List<Point> |
1757 |
{ |
1758 |
this.StartPoint, |
1759 |
this.MidPoint, |
1760 |
this.EndPoint, |
1761 |
}; |
1762 |
} |
1763 |
|
1764 |
/// <summary> |
1765 |
/// move control point has same location of given pt along given delta |
1766 |
/// </summary> |
1767 |
/// <author>humkyung</author> |
1768 |
/// <date>2019.06.20</date> |
1769 |
/// <param name="pt"></param> |
1770 |
/// <param name="dx"></param> |
1771 |
/// <param name="dy"></param> |
1772 |
public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false) |
1773 |
{ |
1774 |
IPath path = (this as IPath); |
1775 |
|
1776 |
Point selected = MathSet.getNearPoint(path.PointSet, pt); |
1777 |
selected.X += dx; |
1778 |
selected.Y += dy; |
1779 |
|
1780 |
int i = 0; |
1781 |
for (i = 0; i < (this as IPath).PointSet.Count; i++) |
1782 |
{ |
1783 |
if (pt.Equals((this as IPath).PointSet[i])) break; |
1784 |
} |
1785 |
|
1786 |
List<Point> pts = path.PointSet; |
1787 |
#region 끝점을 이동할때 |
1788 |
if (i == 0) |
1789 |
{ |
1790 |
var connections = GetConnectionPointList(); |
1791 |
var near = MathSet.getNearPoint(connections, selected); |
1792 |
var bending = GetBendingPoint(connections, near); |
1793 |
if(bending.HasValue) path.PointSet[1] = bending.Value; |
1794 |
} |
1795 |
#endregion |
1796 |
#region 중간점을 이동할때 |
1797 |
else if (i == 1) |
1798 |
{ |
1799 |
path.PointSet[1] = selected; |
1800 |
} |
1801 |
#endregion |
1802 |
|
1803 |
if (path.PointSet.Count > i) { |
1804 |
path.PointSet[i] = selected; |
1805 |
} |
1806 |
|
1807 |
this.UpdateControl(); |
1808 |
} |
1809 |
|
1810 |
/// <summary> |
1811 |
/// return ArrowTextControl's area |
1812 |
/// </summary> |
1813 |
/// <author>humkyung</author> |
1814 |
/// <date>2019.06.13</date> |
1815 |
public override Rect ItemRect |
1816 |
{ |
1817 |
get |
1818 |
{ |
1819 |
double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X); |
1820 |
double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y); |
1821 |
double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X); |
1822 |
double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y); |
1823 |
|
1824 |
return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY)); |
1825 |
} |
1826 |
} |
1827 |
|
1828 |
/// <summary> |
1829 |
/// Serialize this |
1830 |
/// </summary> |
1831 |
/// <param name="sUserId"></param> |
1832 |
/// <returns></returns> |
1833 |
public override string Serialize() |
1834 |
{ |
1835 |
using (S_ArrowTextControl ctrl = new S_ArrowTextControl()) |
1836 |
{ |
1837 |
ctrl.TransformPoint = "0|0"; |
1838 |
ctrl.PointSet = this.PointSet; |
1839 |
ctrl.SizeSet = String.Format("{0}", this.LineSize); |
1840 |
ctrl.StrokeColor = this.StrokeColor.Color.ToString(); |
1841 |
ctrl.StartPoint = this.StartPoint; |
1842 |
ctrl.ArrowStyle = this.ArrowTextStyle; |
1843 |
ctrl.UserID = this.UserID; |
1844 |
ctrl.ArrowText = this.Base_TextBox.Text; |
1845 |
ctrl.BorderSize = this.BorderSize; |
1846 |
ctrl.isHighLight = this.isHighLight; |
1847 |
ctrl.BoxHeight = this.BoxHeight; |
1848 |
ctrl.BoxWidth = this.BoxWidth; |
1849 |
ctrl.Opac = this.Opacity; |
1850 |
ctrl.EndPoint = this.EndPoint; |
1851 |
ctrl.isFixed = this.isFixed; |
1852 |
ctrl.ControlType = this.ControlType; |
1853 |
ctrl.Name = this.GetType().Name.ToString(); |
1854 |
ctrl.isTrans = this.isTrans; |
1855 |
ctrl.MidPoint = this.MidPoint; |
1856 |
ctrl.Angle = this.PageAngle; |
1857 |
ctrl.fontConfig = new List<string>() |
1858 |
{ |
1859 |
this.TextFamily.FontName(), |
1860 |
this.TextStyle.ToString(), |
1861 |
this.TextWeight.ToString(), |
1862 |
this.TextSize.ToString(), |
1863 |
}; |
1864 |
|
1865 |
if (this.UnderLine != null) |
1866 |
{ |
1867 |
ctrl.fontConfig.Add("true"); |
1868 |
} |
1869 |
|
1870 |
ctrl.Memo = this.Memo; |
1871 |
ctrl.BorderSize = this.BorderSize; |
1872 |
ctrl.ArcLength = this.ArcLength; |
1873 |
ctrl.Index = this.Index; |
1874 |
ctrl.ZIndex = this.ZIndex; |
1875 |
ctrl.GroupID = this.GroupID; |
1876 |
|
1877 |
return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize())); |
1878 |
}; |
1879 |
} |
1880 |
|
1881 |
/// <summary> |
1882 |
/// create a arrowtextcontrol from given string |
1883 |
/// </summary> |
1884 |
/// <param name="str"></param> |
1885 |
/// <returns></returns> |
1886 |
public static ArrowTextControl FromString(string str, SolidColorBrush brush, string sProjectNo,double PageAngle) |
1887 |
{ |
1888 |
ArrowTextControl instance = null; |
1889 |
using (S_ArrowTextControl s = JsonSerializerHelper.JsonDeserialize<S_ArrowTextControl>(str)) |
1890 |
{ |
1891 |
string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
1892 |
instance = new ArrowTextControl(); |
1893 |
instance.PageAngle = s.Angle; |
1894 |
instance.LineSize = Convert.ToDouble(data2.First()); |
1895 |
instance.PointSet = s.PointSet; |
1896 |
instance.StartPoint = s.StartPoint; |
1897 |
instance.EndPoint = s.EndPoint; |
1898 |
instance.StrokeColor = brush; |
1899 |
instance.ArrowTextStyle = s.ArrowStyle; |
1900 |
instance.isHighLight = s.isHighLight; |
1901 |
instance.ArrowText = s.ArrowText; |
1902 |
instance.Opacity = s.Opac; |
1903 |
instance.BorderSize = s.BorderSize; |
1904 |
instance.BoxWidth = s.BoxWidth; |
1905 |
instance.BoxHeight = s.BoxHeight; |
1906 |
instance.isFixed = s.isFixed; |
1907 |
instance.ControlType = s.ControlType; |
1908 |
instance.UserID = s.UserID; |
1909 |
instance.isTrans = s.isTrans; |
1910 |
instance.MidPoint = s.MidPoint; |
1911 |
instance.Memo = s.Memo; |
1912 |
instance.Index = s.Index; |
1913 |
instance.ZIndex = s.ZIndex; |
1914 |
instance.GroupID = s.GroupID; |
1915 |
if (s.fontConfig == null || s.fontConfig.ToList().Count == 0) |
1916 |
{ |
1917 |
s.fontConfig = new List<string>(); |
1918 |
|
1919 |
s.fontConfig.Add("Arial"); |
1920 |
s.fontConfig.Add("Normal"); |
1921 |
s.fontConfig.Add("Normal"); |
1922 |
s.fontConfig.Add("30"); |
1923 |
} |
1924 |
instance.TextFamily = Markus.Fonts.FontHelper.GetFontFamily(s.fontConfig[0]); |
1925 |
//인구 추가(2018.04.17) |
1926 |
instance.TextStyle = StringToFont.ConFontStyle(s.fontConfig[1]); |
1927 |
instance.TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]); |
1928 |
instance.TextSize = Convert.ToDouble(s.fontConfig[3]); |
1929 |
instance.ArcLength = s.ArcLength; |
1930 |
if (s.fontConfig.Count == 5) |
1931 |
{ |
1932 |
instance.UnderLine = TextDecorations.Underline; |
1933 |
} |
1934 |
} |
1935 |
|
1936 |
return instance; |
1937 |
} |
1938 |
|
1939 |
#region Dispose |
1940 |
public void Dispose() |
1941 |
{ |
1942 |
//GC.Collect(); |
1943 |
////GC.SuppressFinalize(this); |
1944 |
this.BaseTextbox_Caret = null; |
1945 |
this.Base_ArrowPath = null; |
1946 |
this.Base_ArrowSubPath = null; |
1947 |
this.Base_TextBlock = null; |
1948 |
this.Base_TextBox = null; |
1949 |
} |
1950 |
#endregion |
1951 |
|
1952 |
#region INotifyPropertyChanged |
1953 |
private void OnPropertyChanged(string name) |
1954 |
{ |
1955 |
if (PropertyChanged != null) |
1956 |
{ |
1957 |
PropertyChanged(this, new PropertyChangedEventArgs(name)); |
1958 |
} |
1959 |
} |
1960 |
|
1961 |
public Rect GetCommentRect() |
1962 |
{ |
1963 |
Rect rect = new Rect(); |
1964 |
|
1965 |
rect.Location = new Point(); |
1966 |
rect.Size = new Size(); |
1967 |
|
1968 |
List<Point> points = new List<Point>(); |
1969 |
|
1970 |
points.AddRange(this.PointSet); |
1971 |
|
1972 |
var boxTopleft = new Point(Canvas.GetTop(Base_TextBox), Canvas.GetLeft(Base_TextBox)); |
1973 |
points.Add(boxTopleft); |
1974 |
|
1975 |
var boxBottomRight =new Point(boxTopleft.X + Base_TextBox.ActualWidth, boxTopleft.Y + Base_TextBox.ActualHeight); |
1976 |
points.Add(boxBottomRight); |
1977 |
|
1978 |
rect = CommentMath.CalculateBoundingRect(points); |
1979 |
|
1980 |
return rect; |
1981 |
} |
1982 |
|
1983 |
public event PropertyChangedEventHandler PropertyChanged; |
1984 |
#endregion |
1985 |
} |
1986 |
} |