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