1
|
using System;
|
2
|
using System.Net;
|
3
|
using System.Windows;
|
4
|
using System.Windows.Controls;
|
5
|
using System.Windows.Documents;
|
6
|
using System.Windows.Ink;
|
7
|
using System.Windows.Input;
|
8
|
using System.Windows.Media;
|
9
|
using System.Windows.Media.Animation;
|
10
|
using System.Windows.Shapes;
|
11
|
using System.Collections.Generic;
|
12
|
using System.ComponentModel;
|
13
|
using MarkupToPDF.Controls.Common;
|
14
|
|
15
|
namespace MarkupToPDF.Controls.Polygon
|
16
|
{
|
17
|
public class CloudControl : Control, IDisposable, INotifyPropertyChanged, IPath, IShapeControl, ICloudControl, IDashControl
|
18
|
{
|
19
|
private const string PART_CloudPath = "PART_CloudPath";
|
20
|
private const string PART_CloudSubPath = "PART_CloudSubPath";
|
21
|
|
22
|
public Path Base_CloudPath = null;
|
23
|
public Path Base_CloudSubPath = null;
|
24
|
|
25
|
static CloudControl()
|
26
|
{
|
27
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(CloudControl), new FrameworkPropertyMetadata(typeof(CloudControl)));
|
28
|
//Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary);
|
29
|
ResourceDictionary dictionary = new ResourceDictionary();
|
30
|
dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute);
|
31
|
Application.Current.Resources.MergedDictionaries.Add(dictionary);
|
32
|
}
|
33
|
public CloudControl()
|
34
|
{
|
35
|
this.DefaultStyleKey = typeof(CloudControl);
|
36
|
}
|
37
|
|
38
|
#region Dependency Properties
|
39
|
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
|
40
|
"UserID", typeof(string), typeof(CloudControl), new PropertyMetadata(null));
|
41
|
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
|
42
|
"LineSize", typeof(double), typeof(CloudControl), new PropertyMetadata((Double)1));
|
43
|
public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register(
|
44
|
"DashSize", typeof(DoubleCollection), typeof(CloudControl), new PropertyMetadata(new DoubleCollection {7,7,1,7 }));
|
45
|
public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register(
|
46
|
"FillColor", typeof(SolidColorBrush), typeof(CloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
|
47
|
|
48
|
public static readonly DependencyProperty IsCompletedProperty = DependencyProperty.Register(
|
49
|
"IsCompleted", typeof(bool), typeof(CloudControl), null);
|
50
|
|
51
|
public static readonly DependencyProperty PaintProperty = DependencyProperty.Register(
|
52
|
"Paint", typeof(PaintSet), typeof(CloudControl), new PropertyMetadata(PaintSet.None));
|
53
|
|
54
|
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
|
55
|
"StrokeColor", typeof(SolidColorBrush), typeof(CloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
|
56
|
|
57
|
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
|
58
|
"PathData", typeof(Geometry), typeof(CloudControl), null);
|
59
|
|
60
|
public static readonly DependencyProperty PathSubDataProperty = DependencyProperty.Register(
|
61
|
"PathSubData", typeof(Geometry), typeof(CloudControl), null);
|
62
|
|
63
|
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
|
64
|
"EndPoint", typeof(Point), typeof(CloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
|
65
|
|
66
|
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
|
67
|
"StartPoint", typeof(Point), typeof(CloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
|
68
|
|
69
|
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
|
70
|
"PointSet", typeof(List<Point>), typeof(CloudControl), new PropertyMetadata(new List<Point>(), PointValueChanged));
|
71
|
public static readonly DependencyProperty isTransOnProperty = DependencyProperty.Register(
|
72
|
"isTransOn", typeof(bool), typeof(CloudControl), new PropertyMetadata(false));
|
73
|
public static readonly DependencyProperty isChainProperty = DependencyProperty.Register(
|
74
|
"isChain", typeof(bool), typeof(CloudControl), new PropertyMetadata(false));
|
75
|
|
76
|
/// <summary>
|
77
|
/// StylusPointSet을 List<Point>로 대체하면 PointValueChanged가 작동안한다.
|
78
|
/// </summary>
|
79
|
public static readonly DependencyProperty StylusPointSetProperty = DependencyProperty.Register(
|
80
|
"PointC", typeof(StylusPointSet), typeof(CloudControl), new PropertyMetadata(new StylusPointSet(), PointValueChanged));
|
81
|
|
82
|
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("AngleValue", typeof(double), typeof(CloudControl),
|
83
|
new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged)));
|
84
|
|
85
|
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(CloudControl),
|
86
|
new PropertyMetadata((double)0, OnCenterXYChanged));
|
87
|
|
88
|
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(CloudControl),
|
89
|
new PropertyMetadata((double)0, OnCenterXYChanged));
|
90
|
|
91
|
public static readonly DependencyProperty IsSelectedProperty =
|
92
|
DependencyProperty.Register("IsSelected", typeof(bool), typeof(CloudControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
|
93
|
|
94
|
public static readonly DependencyProperty ControlTypeProperty =
|
95
|
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(CloudControl), new FrameworkPropertyMetadata(ControlType.PolygonCloud));
|
96
|
|
97
|
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
|
98
|
"OverViewPathData", typeof(Geometry), typeof(ControlType), null);
|
99
|
|
100
|
|
101
|
public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
|
102
|
"CanvasX", typeof(double), typeof(CloudControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
|
103
|
|
104
|
public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
|
105
|
"CanvasY", typeof(double), typeof(CloudControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
|
106
|
|
107
|
|
108
|
#endregion
|
109
|
#region PropertyChanged Method
|
110
|
|
111
|
public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
112
|
{
|
113
|
var instance = (CloudControl)sender;
|
114
|
|
115
|
if (e.OldValue != e.NewValue && instance != null)
|
116
|
{
|
117
|
instance.SetValue(e.Property, e.NewValue);
|
118
|
}
|
119
|
}
|
120
|
|
121
|
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
122
|
{
|
123
|
var instance = (CloudControl)sender;
|
124
|
if (e.OldValue != e.NewValue && instance.Base_CloudPath != null)
|
125
|
{
|
126
|
instance.SetValue(e.Property, e.NewValue);
|
127
|
instance.SetCloud();
|
128
|
}
|
129
|
}
|
130
|
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
131
|
{
|
132
|
var instance = (CloudControl)sender;
|
133
|
|
134
|
if (e.OldValue != e.NewValue && instance.Base_CloudPath != null)
|
135
|
{
|
136
|
|
137
|
instance.SetValue(e.Property, e.NewValue);
|
138
|
|
139
|
if (instance.IsSelected)
|
140
|
{
|
141
|
instance.Base_CloudPath.Stroke = new SolidColorBrush(Colors.Blue);
|
142
|
}
|
143
|
else
|
144
|
{
|
145
|
instance.Base_CloudPath.Stroke = new SolidColorBrush(Colors.Red);
|
146
|
}
|
147
|
}
|
148
|
}
|
149
|
|
150
|
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
151
|
{
|
152
|
var instance = (CloudControl)sender;
|
153
|
if (e.OldValue != e.NewValue && instance.Base_CloudPath != null)
|
154
|
{
|
155
|
instance.SetValue(e.Property, e.NewValue);
|
156
|
instance.DrawingCloud();
|
157
|
}
|
158
|
}
|
159
|
public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
|
160
|
{
|
161
|
var instance = (CloudControl)sender;
|
162
|
if (e.OldValue != e.NewValue && instance.Base_CloudPath != null)
|
163
|
{
|
164
|
instance.SetValue(e.Property, e.NewValue);
|
165
|
instance.DrawingCloud();
|
166
|
}
|
167
|
}
|
168
|
#endregion
|
169
|
#region Properties
|
170
|
|
171
|
|
172
|
public bool IsCompleted
|
173
|
{
|
174
|
get { return (bool)GetValue(IsCompletedProperty); }
|
175
|
set
|
176
|
{
|
177
|
SetValue(IsCompletedProperty, value);
|
178
|
}
|
179
|
}
|
180
|
|
181
|
public Geometry OverViewPathData
|
182
|
{
|
183
|
get { return (Geometry)GetValue(OverViewPathDataProperty); }
|
184
|
set
|
185
|
{
|
186
|
SetValue(OverViewPathDataProperty, value);
|
187
|
OnPropertyChanged("OverViewPathData");
|
188
|
}
|
189
|
}
|
190
|
|
191
|
public double CanvasX
|
192
|
{
|
193
|
get { return (double)GetValue(CanvasXProperty); }
|
194
|
set
|
195
|
{
|
196
|
if (this.CanvasX != value)
|
197
|
{
|
198
|
SetValue(CanvasXProperty, value);
|
199
|
}
|
200
|
}
|
201
|
}
|
202
|
|
203
|
public double CanvasY
|
204
|
{
|
205
|
get { return (double)GetValue(CanvasYProperty); }
|
206
|
set
|
207
|
{
|
208
|
if (this.CanvasY != value)
|
209
|
{
|
210
|
SetValue(CanvasYProperty, value);
|
211
|
}
|
212
|
}
|
213
|
}
|
214
|
|
215
|
public bool IsSelected
|
216
|
{
|
217
|
get
|
218
|
{
|
219
|
return (bool)GetValue(IsSelectedProperty);
|
220
|
}
|
221
|
set
|
222
|
{
|
223
|
SetValue(IsSelectedProperty, value);
|
224
|
}
|
225
|
}
|
226
|
|
227
|
public ControlType ControlType
|
228
|
{
|
229
|
set
|
230
|
{
|
231
|
SetValue(ControlTypeProperty, value);
|
232
|
}
|
233
|
get
|
234
|
{
|
235
|
return (ControlType)GetValue(ControlTypeProperty);
|
236
|
}
|
237
|
}
|
238
|
|
239
|
public Double LineSize
|
240
|
{
|
241
|
get { return (Double)GetValue(LineSizeProperty); }
|
242
|
set
|
243
|
{
|
244
|
if (this.LineSize != value)
|
245
|
{
|
246
|
SetValue(LineSizeProperty, value);
|
247
|
}
|
248
|
}
|
249
|
}
|
250
|
public bool isChain
|
251
|
{
|
252
|
get { return (bool)GetValue(isChainProperty); }
|
253
|
set
|
254
|
{
|
255
|
SetValue(isChainProperty, value);
|
256
|
OnPropertyChanged("isChain");
|
257
|
}
|
258
|
}
|
259
|
public bool isTransOn
|
260
|
{
|
261
|
get { return (bool)GetValue(isTransOnProperty); }
|
262
|
set
|
263
|
{
|
264
|
SetValue(isTransOnProperty, value);
|
265
|
OnPropertyChanged("isTransOn");
|
266
|
}
|
267
|
}
|
268
|
public DoubleCollection DashSize
|
269
|
{
|
270
|
get { return (DoubleCollection)GetValue(DashSizeProperty); }
|
271
|
set
|
272
|
{
|
273
|
if (this.DashSize != value)
|
274
|
{
|
275
|
SetValue(DashSizeProperty, value);
|
276
|
OnPropertyChanged("DashSize");
|
277
|
}
|
278
|
}
|
279
|
}
|
280
|
public string UserID
|
281
|
{
|
282
|
get { return (string)GetValue(UserIDProperty); }
|
283
|
set
|
284
|
{
|
285
|
if (this.UserID != value)
|
286
|
{
|
287
|
SetValue(UserIDProperty, value);
|
288
|
OnPropertyChanged("UserID");
|
289
|
}
|
290
|
}
|
291
|
}
|
292
|
public PaintSet Paint
|
293
|
{
|
294
|
get { return (PaintSet)GetValue(PaintProperty); }
|
295
|
set
|
296
|
{
|
297
|
if (this.Paint != value)
|
298
|
{
|
299
|
SetValue(PaintProperty, value);
|
300
|
OnPropertyChanged("Paint");
|
301
|
}
|
302
|
}
|
303
|
}
|
304
|
|
305
|
public SolidColorBrush FillColor
|
306
|
{
|
307
|
get { return (SolidColorBrush)GetValue(FillColorProperty); }
|
308
|
set
|
309
|
{
|
310
|
if (this.FillColor != value)
|
311
|
{
|
312
|
SetValue(FillColorProperty, value);
|
313
|
OnPropertyChanged("FillColor");
|
314
|
}
|
315
|
}
|
316
|
}
|
317
|
public SolidColorBrush StrokeColor
|
318
|
{
|
319
|
get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
|
320
|
set
|
321
|
{
|
322
|
if (this.StrokeColor != value)
|
323
|
{
|
324
|
SetValue(StrokeColorProperty, value);
|
325
|
OnPropertyChanged("StrokeColor");
|
326
|
}
|
327
|
}
|
328
|
}
|
329
|
public Geometry PathData
|
330
|
{
|
331
|
get
|
332
|
{
|
333
|
return (Geometry)GetValue(PathDataProperty);
|
334
|
}
|
335
|
set
|
336
|
{
|
337
|
SetValue(PathDataProperty, value);
|
338
|
OnPropertyChanged("PathData");
|
339
|
}
|
340
|
}
|
341
|
public Geometry PathSubData
|
342
|
{
|
343
|
get
|
344
|
{
|
345
|
return (Geometry)GetValue(PathSubDataProperty);
|
346
|
}
|
347
|
set
|
348
|
{
|
349
|
SetValue(PathSubDataProperty, value);
|
350
|
OnPropertyChanged("PathSubData");
|
351
|
}
|
352
|
}
|
353
|
public Point EndPoint
|
354
|
{
|
355
|
get
|
356
|
{
|
357
|
return (Point)GetValue(EndPointProperty);
|
358
|
}
|
359
|
set
|
360
|
{
|
361
|
SetValue(EndPointProperty, value);
|
362
|
OnPropertyChanged("EndPoint");
|
363
|
}
|
364
|
}
|
365
|
public Point StartPoint
|
366
|
{
|
367
|
get
|
368
|
{
|
369
|
return (Point)GetValue(StartPointProperty);
|
370
|
}
|
371
|
set
|
372
|
{
|
373
|
SetValue(StartPointProperty, value);
|
374
|
OnPropertyChanged("StartPoint");
|
375
|
}
|
376
|
}
|
377
|
public List<Point> _pointSet;
|
378
|
|
379
|
public List<Point> PointSet
|
380
|
{
|
381
|
get
|
382
|
{
|
383
|
return (List<Point>)GetValue(PointSetProperty);
|
384
|
}
|
385
|
set
|
386
|
{
|
387
|
SetValue(PointSetProperty, value);
|
388
|
OnPropertyChanged("PointSet");
|
389
|
}
|
390
|
}
|
391
|
|
392
|
public List<Point> pointSet
|
393
|
{
|
394
|
get
|
395
|
{
|
396
|
return _pointSet;
|
397
|
}
|
398
|
set
|
399
|
{
|
400
|
_pointSet = value;
|
401
|
OnPropertyChanged("pointSet");
|
402
|
}
|
403
|
}
|
404
|
|
405
|
private double _toler = 1;
|
406
|
public double Toler
|
407
|
{
|
408
|
get { return _toler; }
|
409
|
set { _toler = value; }
|
410
|
}
|
411
|
private double _arcLength = 10;
|
412
|
public double ArcLength
|
413
|
{
|
414
|
get { return _arcLength; }
|
415
|
set { _arcLength = value; }
|
416
|
}
|
417
|
private bool _fill = false;
|
418
|
public bool Fill
|
419
|
{
|
420
|
get { return _fill; }
|
421
|
set { _fill = value; }
|
422
|
}
|
423
|
public double Angle
|
424
|
{
|
425
|
get { return (double)GetValue(AngleProperty); }
|
426
|
set
|
427
|
{
|
428
|
if (this.Angle != value)
|
429
|
{
|
430
|
SetValue(AngleProperty, value);
|
431
|
OnPropertyChanged("Angle");
|
432
|
}
|
433
|
}
|
434
|
}
|
435
|
public StylusPointSet PointC
|
436
|
{
|
437
|
get { return (StylusPointSet)GetValue(StylusPointSetProperty); }
|
438
|
set
|
439
|
{
|
440
|
SetValue(StylusPointSetProperty, value);
|
441
|
OnPropertyChanged("PointC");
|
442
|
}
|
443
|
}
|
444
|
public double CenterX
|
445
|
{
|
446
|
get
|
447
|
{
|
448
|
return (double)GetValue(CenterXProperty);
|
449
|
}
|
450
|
set
|
451
|
{
|
452
|
SetValue(CenterXProperty, value);
|
453
|
OnPropertyChanged("CenterX");
|
454
|
}
|
455
|
}
|
456
|
public double CenterY
|
457
|
{
|
458
|
get
|
459
|
{
|
460
|
return (double)GetValue(CenterYProperty);
|
461
|
}
|
462
|
set
|
463
|
{
|
464
|
SetValue(CenterYProperty, value);
|
465
|
OnPropertyChanged("CenterY");
|
466
|
}
|
467
|
}
|
468
|
public double AngleValue
|
469
|
{
|
470
|
get
|
471
|
{
|
472
|
return (double)GetValue(AngleProperty);
|
473
|
}
|
474
|
set
|
475
|
{
|
476
|
SetValue(AngleProperty, value);
|
477
|
OnPropertyChanged("AngleValue");
|
478
|
}
|
479
|
}
|
480
|
#endregion
|
481
|
#region Data
|
482
|
private PathGeometry _pathGeometry = new PathGeometry();
|
483
|
private PathGeometry _pathSubGeometry = new PathGeometry();
|
484
|
#endregion
|
485
|
|
486
|
public override void OnApplyTemplate()
|
487
|
{
|
488
|
base.OnApplyTemplate();
|
489
|
Base_CloudPath = GetTemplateChild(PART_CloudPath) as Path;
|
490
|
Base_CloudSubPath = GetTemplateChild(PART_CloudSubPath) as Path;
|
491
|
}
|
492
|
public void SetCloud()
|
493
|
{
|
494
|
//this.Width = this.Base_CloudPath.Width;
|
495
|
//this.Height = this.Base_CloudPath.Height;
|
496
|
|
497
|
this.ApplyTemplate();
|
498
|
|
499
|
Generate();
|
500
|
|
501
|
if (!isChain)
|
502
|
{
|
503
|
//ClosePath();
|
504
|
}
|
505
|
}
|
506
|
public int Generate()
|
507
|
{
|
508
|
this._pathGeometry = null;
|
509
|
this._pathSubGeometry = null;
|
510
|
switch (this.Paint)
|
511
|
{
|
512
|
case PaintSet.None:
|
513
|
this.FillColor = null;
|
514
|
if (Base_CloudSubPath != null)
|
515
|
{
|
516
|
Base_CloudPath.Fill = null;
|
517
|
Base_CloudSubPath.Fill = null;
|
518
|
Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent);
|
519
|
Base_CloudSubPath.StrokeThickness = 0;
|
520
|
}
|
521
|
break;
|
522
|
case PaintSet.Rect:
|
523
|
this.FillColor = this.StrokeColor;
|
524
|
if (Base_CloudSubPath != null)
|
525
|
{
|
526
|
if (isChain)
|
527
|
{
|
528
|
Base_CloudPath.Fill = null;
|
529
|
Base_CloudSubPath.Fill = null;
|
530
|
Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent);
|
531
|
Base_CloudSubPath.StrokeThickness = 0;
|
532
|
}
|
533
|
else
|
534
|
{
|
535
|
Base_CloudSubPath.Stroke = this.StrokeColor;
|
536
|
Base_CloudSubPath.StrokeThickness = 2;
|
537
|
|
538
|
Base_CloudPath.Stroke = this.StrokeColor;
|
539
|
Base_CloudPath.StrokeThickness = 2;
|
540
|
Base_CloudPath.Fill = this.FillColor;
|
541
|
Base_CloudSubPath.Fill = this.FillColor;
|
542
|
}
|
543
|
}
|
544
|
break;
|
545
|
case PaintSet.Cloud:
|
546
|
if (Base_CloudSubPath != null && !isChain)
|
547
|
{
|
548
|
if (isChain)
|
549
|
{
|
550
|
Base_CloudPath.Fill = null;
|
551
|
Base_CloudSubPath.Fill = null;
|
552
|
Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent);
|
553
|
Base_CloudSubPath.StrokeThickness = 0;
|
554
|
}
|
555
|
else
|
556
|
{
|
557
|
Base_CloudPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor);
|
558
|
Base_CloudSubPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor);
|
559
|
Base_CloudSubPath.Stroke = new SolidColorBrush(Colors.Transparent);
|
560
|
Base_CloudSubPath.StrokeThickness = 0;
|
561
|
}
|
562
|
}
|
563
|
break;
|
564
|
default:
|
565
|
break;
|
566
|
}
|
567
|
|
568
|
//if (Base_CloudPath != null)
|
569
|
//{
|
570
|
// Base_CloudPath.StrokeDashArray.Clear();
|
571
|
// Base_CloudSubPath.StrokeDashArray.Clear();
|
572
|
// foreach (var item in this.DashSize)
|
573
|
// {
|
574
|
// Base_CloudPath.StrokeDashArray.Add(item);
|
575
|
// Base_CloudSubPath.StrokeDashArray.Add(item);
|
576
|
// }
|
577
|
//}
|
578
|
|
579
|
|
580
|
/// set reverse if area is greater 0 - 2012.07.04 added by humkyung
|
581
|
double area = MathSet.AreaOf(this.PointSet);
|
582
|
bool reverse = (area > 0);
|
583
|
/// up to here
|
584
|
|
585
|
this._pathGeometry = new PathGeometry();
|
586
|
this._pathSubGeometry = new PathGeometry();
|
587
|
int count = this.PointSet.Count;
|
588
|
|
589
|
if (isTransOn) // true라면 클라우드 컨트롤
|
590
|
{
|
591
|
for (int i = 0; i < (count - 1); i++)
|
592
|
{
|
593
|
PathFigure pathFigure = CloudControl.GenerateLineWithCloud(this.PointSet[i], this.PointSet[i + 1], this.ArcLength, reverse);
|
594
|
_pathGeometry.Figures.Add(pathFigure);
|
595
|
}
|
596
|
}
|
597
|
else
|
598
|
{
|
599
|
PathFigure fm = new PathFigure();
|
600
|
fm.StartPoint = this.PointSet[0];
|
601
|
for (int i = 0; i < (count - 1); i++)
|
602
|
{
|
603
|
fm.Segments.Add(new LineSegment { Point = this.PointSet[i] });
|
604
|
}
|
605
|
_pathGeometry.Figures.Add(fm);
|
606
|
}
|
607
|
|
608
|
if (this.Paint == PaintSet.Rect || this.Paint == PaintSet.Cloud)
|
609
|
{
|
610
|
PointCollection pd = new PointCollection();
|
611
|
foreach (var item in this.PointSet)
|
612
|
{
|
613
|
pd.Add(item);
|
614
|
}
|
615
|
_pathSubGeometry.Figures.Add(new PathFigure()
|
616
|
{
|
617
|
Segments = new PathSegmentCollection()
|
618
|
{
|
619
|
new PolyLineSegment()
|
620
|
{
|
621
|
Points = pd,
|
622
|
},
|
623
|
},
|
624
|
StartPoint = this.PointSet[0]
|
625
|
});
|
626
|
|
627
|
//this.PathSubData = _pathSubGeometry;
|
628
|
}
|
629
|
|
630
|
|
631
|
StartPoint = PointSet[0];
|
632
|
|
633
|
this.PathData = this._pathGeometry;
|
634
|
this.OverViewPathData = PathData;
|
635
|
this.StrokeColor = StrokeColor;
|
636
|
this.LineSize = LineSize;
|
637
|
|
638
|
return 0;
|
639
|
}
|
640
|
|
641
|
/// <summary>
|
642
|
/// draw arcs between p1 and p2
|
643
|
/// </summary>
|
644
|
/// <author>humkyung</author>
|
645
|
/// <param name="p1"></param>
|
646
|
/// <param name="p2"></param>
|
647
|
/// <param name="reverse"></param>
|
648
|
/// <returns></returns>
|
649
|
public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse)
|
650
|
{
|
651
|
PathFigure pathFigure = new PathFigure();
|
652
|
pathFigure.StartPoint = p1;
|
653
|
|
654
|
double arcLength = arcLength_;
|
655
|
/// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung
|
656
|
double dx = p2.X - p1.X;
|
657
|
double dy = p2.Y - p1.Y;
|
658
|
double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2
|
659
|
double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
|
660
|
Point lastPt = new Point(p1.X, p1.Y);
|
661
|
double count = l / arcLength;
|
662
|
/// normalize
|
663
|
dx /= l;
|
664
|
dy /= l;
|
665
|
Double j = 1;
|
666
|
for (j = 1; j < (count - 1); j++)
|
667
|
{
|
668
|
ArcSegment arcSeg = new ArcSegment();
|
669
|
arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8); /// x size and y size of arc
|
670
|
arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength); /// end point of arc
|
671
|
lastPt = arcSeg.Point; /// save last point
|
672
|
arcSeg.RotationAngle = theta + 90;
|
673
|
if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
|
674
|
pathFigure.Segments.Add(arcSeg);
|
675
|
}
|
676
|
|
677
|
/// draw arc between last point and end point
|
678
|
if ((count > j) || (count > 0))
|
679
|
{
|
680
|
arcLength = MathSet.DistanceTo(lastPt, p2);
|
681
|
ArcSegment arcSeg = new ArcSegment();
|
682
|
arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8); /// x size and y size of arc
|
683
|
arcSeg.Point = new Point(p2.X, p2.Y); /// end point of arc
|
684
|
arcSeg.RotationAngle = theta;
|
685
|
if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise;
|
686
|
pathFigure.Segments.Add(arcSeg);
|
687
|
|
688
|
}
|
689
|
|
690
|
pathFigure.IsFilled = true;
|
691
|
return pathFigure;
|
692
|
}
|
693
|
|
694
|
/// <summary>
|
695
|
/// close path if it's open
|
696
|
/// </summary>
|
697
|
/// <author>humkyung</author>
|
698
|
/// <returns></returns>
|
699
|
public int ClosePath()
|
700
|
{
|
701
|
if (this.PointSet.Count > 1)
|
702
|
{
|
703
|
double d = MathSet.DistanceTo(this.PointSet[0], this.PointSet[this.PointSet.Count - 1]);
|
704
|
if (d > _toler)
|
705
|
{
|
706
|
/// set reverse if area is greater 0 - 2012.07.04 added by humkyung
|
707
|
double area = MathSet.AreaOf(this.PointSet);
|
708
|
bool reverse = (area > 0);
|
709
|
/// up to here
|
710
|
|
711
|
int count = this.PointSet.Count;
|
712
|
|
713
|
|
714
|
|
715
|
if (isTransOn) // true라면 클라우드 컨트롤
|
716
|
{
|
717
|
PathFigure pathFigure = CloudControl.GenerateLineWithCloud(this.PointSet[count - 1], this.PointSet[0], this.ArcLength - 5, reverse);
|
718
|
|
719
|
if (this.Paint == PaintSet.Rect)
|
720
|
{
|
721
|
pathFigure.IsClosed = true;
|
722
|
}
|
723
|
|
724
|
|
725
|
_pathGeometry.Figures.Add(pathFigure);
|
726
|
|
727
|
}
|
728
|
else
|
729
|
{
|
730
|
|
731
|
PathFigure fm = new PathFigure();
|
732
|
fm.StartPoint = this.PointSet[count - 1];
|
733
|
|
734
|
//for (int i = 0; i < (count - 1); i++)
|
735
|
//{
|
736
|
_pathGeometry.Figures[_pathGeometry.Figures.Count - 1].Segments.Add(new LineSegment { Point = this.PointSet[0] });
|
737
|
_pathGeometry.Figures[_pathGeometry.Figures.Count - 1].Segments.Add(new LineSegment { Point = this.PointSet[1] });
|
738
|
//fm.Segments.Add(new LineSegment { Point = this.PointSet[0] });
|
739
|
//}
|
740
|
}
|
741
|
}
|
742
|
}
|
743
|
|
744
|
return 0;
|
745
|
}
|
746
|
public void DrawingCloud()
|
747
|
{
|
748
|
AnotherSetCloud();
|
749
|
if (!isChain)
|
750
|
{
|
751
|
//ClosePath();
|
752
|
}
|
753
|
}
|
754
|
public void AnotherSetCloud()
|
755
|
{
|
756
|
this.StrokeColor = StrokeColor;
|
757
|
this.LineSize = LineSize;
|
758
|
this.SetCloud();
|
759
|
//Generate();
|
760
|
this.Width = this.Base_CloudPath.Width;
|
761
|
this.Height = this.Base_CloudPath.Height;
|
762
|
}
|
763
|
public void Dispose()
|
764
|
{
|
765
|
GC.Collect();
|
766
|
GC.SuppressFinalize(this);
|
767
|
}
|
768
|
public event PropertyChangedEventHandler PropertyChanged;
|
769
|
protected void OnPropertyChanged(string propName)
|
770
|
{
|
771
|
if (PropertyChanged != null)
|
772
|
PropertyChanged(this, new PropertyChangedEventArgs(propName));
|
773
|
}
|
774
|
public void updateControl()
|
775
|
{
|
776
|
|
777
|
var lastIndex = this.PointSet.Count - 1;
|
778
|
//this.StartPoint = this.PointSet[0];
|
779
|
//this.EndPoint = this.PointSet[lastIndex];
|
780
|
CenterX = MathSet.getMiddlePoint(this.PointSet[0], this.PointSet[lastIndex]).X;
|
781
|
CenterY = MathSet.getMiddlePoint(this.PointSet[0], this.PointSet[lastIndex]).Y;
|
782
|
}
|
783
|
public void ChangePaint(PaintSet state)
|
784
|
{
|
785
|
this.Paint = state;
|
786
|
this.SetCloud();
|
787
|
|
788
|
}
|
789
|
#region Method
|
790
|
public void ApplyOverViewData()
|
791
|
{
|
792
|
this.OverViewPathData = this.PathData;
|
793
|
}
|
794
|
#endregion
|
795
|
}
|
796
|
|
797
|
}
|