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