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