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