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