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