markus / MarkupToPDF / Controls / Shape / RectCloudControl.cs @ 5a9353a9
이력 | 보기 | 이력해설 | 다운로드 (22.7 KB)
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.ComponentModel; |
12 |
using System.Collections.Generic; |
13 |
using MarkupToPDF.Controls.Common; |
14 |
using MarkupToPDF.Common; |
15 |
|
16 |
namespace MarkupToPDF.Controls.Shape |
17 |
{ |
18 |
public class RectCloudControl : CommentUserInfo, IDisposable, IPath, INotifyPropertyChanged, IMarkupCommonData, IShapeControl, IDashControl |
19 |
{ |
20 |
#region 초기 선언 |
21 |
private const string PART_ArcPath = "PART_ArcPath"; |
22 |
private const string PART_BodyPath = "PART_BodyPath"; |
23 |
public event PropertyChangedEventHandler PropertyChanged; |
24 |
|
25 |
public Path Base_ArcPath = null; |
26 |
public Path Base_BodyPath = null; |
27 |
|
28 |
private const double _CloudArcDepth = 0.55; /// 2018.05.14 added by humkyung |
29 |
|
30 |
#endregion |
31 |
|
32 |
static RectCloudControl() |
33 |
{ |
34 |
DefaultStyleKeyProperty.OverrideMetadata(typeof(RectCloudControl), new FrameworkPropertyMetadata(typeof(RectCloudControl))); |
35 |
//Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
36 |
ResourceDictionary dictionary = new ResourceDictionary(); |
37 |
dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
38 |
Application.Current.Resources.MergedDictionaries.Add(dictionary); |
39 |
} |
40 |
|
41 |
#region Dependency Properties |
42 |
|
43 |
public static readonly DependencyProperty mousemodeProperty = |
44 |
DependencyProperty.Register("mousemode", typeof(MouseMode), typeof(RectangleControl), new PropertyMetadata(MouseMode.None, PointValueChanged)); |
45 |
public static readonly DependencyProperty IsSelectedProperty = |
46 |
DependencyProperty.Register("IsSelected", typeof(bool), typeof(RectCloudControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
47 |
|
48 |
public static readonly DependencyProperty ControlTypeProperty = |
49 |
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(RectCloudControl), new FrameworkPropertyMetadata(ControlType.RectCloud)); |
50 |
|
51 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
52 |
"OverViewPathData", typeof(Geometry), typeof(RectCloudControl), new PropertyMetadata(null)); |
53 |
|
54 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
55 |
"LineSize", typeof(double), typeof(RectCloudControl), new PropertyMetadata((Double)3)); |
56 |
|
57 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
58 |
"UserID", typeof(string), typeof(RectCloudControl), new PropertyMetadata(null)); |
59 |
|
60 |
//강인구 추가 |
61 |
public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
62 |
"DashSize", typeof(DoubleCollection), typeof(RectCloudControl), new PropertyMetadata(new DoubleCollection { 99999999 }, PointValueChanged)); |
63 |
|
64 |
public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register( |
65 |
"FillColor", typeof(SolidColorBrush), typeof(RectCloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
66 |
//강인구 추가 |
67 |
public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
68 |
"Paint", typeof(PaintSet), typeof(RectCloudControl), new PropertyMetadata(PaintSet.None, PointValueChanged)); |
69 |
|
70 |
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
71 |
"StrokeColor", typeof(SolidColorBrush), typeof(RectCloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
72 |
|
73 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
74 |
"PathData", typeof(Geometry), typeof(RectCloudControl), null); |
75 |
|
76 |
public static readonly DependencyProperty PathSubDataProperty = DependencyProperty.Register( |
77 |
"PathSubData", typeof(Geometry), typeof(RectCloudControl), null); |
78 |
|
79 |
public static readonly DependencyProperty ArcLengthProperty = DependencyProperty.Register( |
80 |
"ArcLength", typeof(double), typeof(RectCloudControl), new PropertyMetadata((Double)10, PointValueChanged)); |
81 |
|
82 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
83 |
"EndPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
84 |
|
85 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
86 |
"StartPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
87 |
|
88 |
public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register( |
89 |
"TopRightPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
90 |
|
91 |
public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register( |
92 |
"LeftBottomPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
93 |
|
94 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
95 |
"PointSet", typeof(List<Point>), typeof(RectCloudControl), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
96 |
|
97 |
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("AngleValue", typeof(double), typeof(RectCloudControl), |
98 |
new PropertyMetadata((double)0.0, new PropertyChangedCallback(PointValueChanged))); |
99 |
|
100 |
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(RectCloudControl), |
101 |
new PropertyMetadata((double)0, PointValueChanged)); |
102 |
|
103 |
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(RectCloudControl), |
104 |
new PropertyMetadata((double)0, PointValueChanged)); |
105 |
|
106 |
#endregion |
107 |
|
108 |
#region PropertyChanged Method |
109 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
110 |
{ |
111 |
var instance = (RectCloudControl)sender; |
112 |
if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
113 |
{ |
114 |
instance.SetValue(e.Property, e.NewValue); |
115 |
instance.SetRectCloud(); |
116 |
} |
117 |
} |
118 |
#endregion |
119 |
|
120 |
#region Properties |
121 |
|
122 |
public MouseMode mousemode |
123 |
{ |
124 |
get |
125 |
{ |
126 |
return (MouseMode)GetValue(mousemodeProperty); |
127 |
} |
128 |
set |
129 |
{ |
130 |
SetValue(mousemodeProperty, value); |
131 |
OnPropertyChanged("mousemode"); |
132 |
} |
133 |
} |
134 |
public Double LineSize |
135 |
{ |
136 |
get { return (Double)GetValue(LineSizeProperty); } |
137 |
set |
138 |
{ |
139 |
if (this.LineSize != value) |
140 |
{ |
141 |
SetValue(LineSizeProperty, value); |
142 |
} |
143 |
} |
144 |
} |
145 |
public DoubleCollection DashSize |
146 |
{ |
147 |
get { return (DoubleCollection)GetValue(DashSizeProperty); } |
148 |
set |
149 |
{ |
150 |
if (this.DashSize != value) |
151 |
{ |
152 |
SetValue(DashSizeProperty, value); |
153 |
} |
154 |
} |
155 |
} |
156 |
public string UserID |
157 |
{ |
158 |
get { return (string)GetValue(UserIDProperty); } |
159 |
set |
160 |
{ |
161 |
if (this.UserID != value) |
162 |
{ |
163 |
SetValue(UserIDProperty, value); |
164 |
OnPropertyChanged("UserID"); |
165 |
} |
166 |
} |
167 |
} |
168 |
public PaintSet Paint |
169 |
{ |
170 |
get { return (PaintSet)GetValue(PaintProperty); } |
171 |
set |
172 |
{ |
173 |
if (this.Paint != value) |
174 |
{ |
175 |
SetValue(PaintProperty, value); |
176 |
} |
177 |
} |
178 |
} |
179 |
public SolidColorBrush FillColor |
180 |
{ |
181 |
get { return (SolidColorBrush)GetValue(FillColorProperty); } |
182 |
set |
183 |
{ |
184 |
if (this.FillColor != value) |
185 |
{ |
186 |
SetValue(FillColorProperty, value); |
187 |
} |
188 |
} |
189 |
} |
190 |
public SolidColorBrush StrokeColor |
191 |
{ |
192 |
get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
193 |
set |
194 |
{ |
195 |
if (this.StrokeColor != value) |
196 |
{ |
197 |
SetValue(StrokeColorProperty, value); |
198 |
} |
199 |
} |
200 |
} |
201 |
|
202 |
public Geometry OverViewPathData |
203 |
{ |
204 |
get |
205 |
{ |
206 |
return (Geometry)GetValue(OverViewPathDataProperty); |
207 |
} |
208 |
set |
209 |
{ |
210 |
SetValue(OverViewPathDataProperty, value); |
211 |
OnPropertyChanged("OverViewPathData"); |
212 |
} |
213 |
} |
214 |
|
215 |
public Geometry PathData |
216 |
{ |
217 |
get { return (Geometry)GetValue(PathDataProperty); } |
218 |
set { SetValue(PathDataProperty, value); } |
219 |
} |
220 |
public Geometry PathSubData |
221 |
{ |
222 |
get { return (Geometry)GetValue(PathSubDataProperty); } |
223 |
set { SetValue(PathSubDataProperty, value); } |
224 |
} |
225 |
public Point EndPoint |
226 |
{ |
227 |
get { return (Point)GetValue(EndPointProperty); } |
228 |
set { SetValue(EndPointProperty, value); } |
229 |
} |
230 |
public Point StartPoint |
231 |
{ |
232 |
get { return (Point)GetValue(StartPointProperty); } |
233 |
set { SetValue(StartPointProperty, value); } |
234 |
} |
235 |
public List<Point> PointSet |
236 |
{ |
237 |
get { return (List<Point>)GetValue(PointSetProperty); } |
238 |
set { SetValue(PointSetProperty, value); } |
239 |
} |
240 |
public bool IsSelected |
241 |
{ |
242 |
get |
243 |
{ |
244 |
return (bool)GetValue(IsSelectedProperty); |
245 |
} |
246 |
set |
247 |
{ |
248 |
SetValue(IsSelectedProperty, value); |
249 |
} |
250 |
} |
251 |
public ControlType ControlType |
252 |
{ |
253 |
get |
254 |
{ |
255 |
return (ControlType)GetValue(ControlTypeProperty); |
256 |
} |
257 |
set |
258 |
{ |
259 |
SetValue(ControlTypeProperty, value); |
260 |
} |
261 |
} |
262 |
|
263 |
public Double ArcLength |
264 |
{ |
265 |
get { return (Double)GetValue(ArcLengthProperty); } |
266 |
set |
267 |
{ |
268 |
if (this.ArcLength != value) |
269 |
{ |
270 |
SetValue(ArcLengthProperty, value); |
271 |
OnPropertyChanged("ArcLength"); |
272 |
} |
273 |
} |
274 |
} |
275 |
|
276 |
|
277 |
private double _toler = 1; |
278 |
public double Toler |
279 |
{ |
280 |
get { return _toler; } |
281 |
set { _toler = value; } |
282 |
} |
283 |
//private double _arcLength = 30; |
284 |
//public double ArcLength |
285 |
//{ |
286 |
// get { return _arcLength; } |
287 |
// set { _arcLength = value; } |
288 |
//} |
289 |
|
290 |
private bool _fill = false; |
291 |
public bool Fill |
292 |
{ |
293 |
get { return _fill; } |
294 |
set { _fill = value; } |
295 |
} |
296 |
public double Angle |
297 |
{ |
298 |
get { return (double)GetValue(AngleProperty); } |
299 |
set |
300 |
{ |
301 |
if (this.Angle != value) |
302 |
{ |
303 |
SetValue(AngleProperty, value); |
304 |
} |
305 |
} |
306 |
} |
307 |
public double CenterX |
308 |
{ |
309 |
get { return (double)GetValue(CenterXProperty); } |
310 |
set { SetValue(CenterXProperty, value); } |
311 |
} |
312 |
public double CenterY |
313 |
{ |
314 |
get { return (double)GetValue(CenterYProperty); } |
315 |
set { SetValue(CenterYProperty, value); } |
316 |
} |
317 |
public Point LeftBottomPoint |
318 |
{ |
319 |
get { return (Point)GetValue(LeftBottomPointProperty); } |
320 |
set |
321 |
{ |
322 |
SetValue(LeftBottomPointProperty, value); |
323 |
OnPropertyChanged("LeftBottomPoint"); |
324 |
} |
325 |
} |
326 |
public Point TopRightPoint |
327 |
{ |
328 |
get { return (Point)GetValue(TopRightPointProperty); } |
329 |
set |
330 |
{ |
331 |
SetValue(TopRightPointProperty, value); |
332 |
OnPropertyChanged("TopRightPoint"); |
333 |
} |
334 |
} |
335 |
#endregion |
336 |
|
337 |
#region Data |
338 |
private PathGeometry _pathGeometry = new PathGeometry(); |
339 |
#endregion |
340 |
|
341 |
public override void OnApplyTemplate() |
342 |
{ |
343 |
base.OnApplyTemplate(); |
344 |
Base_ArcPath = GetTemplateChild(PART_ArcPath) as Path; |
345 |
Base_BodyPath = GetTemplateChild(PART_BodyPath) as Path; |
346 |
|
347 |
this.SetRectCloud(); |
348 |
|
349 |
} |
350 |
protected void OnPropertyChanged(string propName) |
351 |
{ |
352 |
if (PropertyChanged != null) |
353 |
PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
354 |
} |
355 |
public void Dispose() |
356 |
{ |
357 |
GC.Collect(); |
358 |
GC.SuppressFinalize(this); |
359 |
} |
360 |
|
361 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
362 |
{ |
363 |
//var instance = (RectCloudControl)sender; |
364 |
|
365 |
//if (e.OldValue != e.NewValue && instance.Base_BodyPath != null) |
366 |
//{ |
367 |
|
368 |
// instance.SetValue(e.Property, e.NewValue); |
369 |
|
370 |
// if (instance.IsSelected) |
371 |
// { |
372 |
// instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Blue); |
373 |
// } |
374 |
// else |
375 |
// { |
376 |
// instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Red); |
377 |
// } |
378 |
//} |
379 |
} |
380 |
|
381 |
public void SetRectCloud() |
382 |
{ |
383 |
this.ApplyTemplate(); |
384 |
PathFigure pathFigure = new PathFigure(); |
385 |
|
386 |
Base_ArcPath.StrokeDashArray.Clear(); |
387 |
Base_BodyPath.StrokeDashArray.Clear(); |
388 |
|
389 |
foreach (var item in this.DashSize) |
390 |
{ |
391 |
Base_ArcPath.StrokeDashArray.Add(item); |
392 |
Base_BodyPath.StrokeDashArray.Add(item); |
393 |
} |
394 |
|
395 |
switch (this.Paint) |
396 |
{ |
397 |
case PaintSet.None: |
398 |
//강인구 추가 |
399 |
pathFigure.IsFilled = false; |
400 |
Base_BodyPath.Fill = null; |
401 |
Base_BodyPath.Stroke = null; |
402 |
break; |
403 |
case PaintSet.Fill: |
404 |
{ |
405 |
Base_BodyPath.Stroke = this.StrokeColor; |
406 |
Base_BodyPath.StrokeThickness = 0.5; |
407 |
Base_ArcPath.Stroke = this.StrokeColor; |
408 |
|
409 |
Base_ArcPath.Fill = this.FillColor; |
410 |
Base_BodyPath.Fill = this.FillColor; |
411 |
} |
412 |
//this.FillColor = this.StrokeColor; |
413 |
//Base_BodyPath.Fill = this.FillColor; |
414 |
//Base_ArcPath.Fill = this.FillColor; |
415 |
//Base_BodyPath.Stroke = this.StrokeColor; |
416 |
//Base_BodyPath.StrokeThickness = 2; |
417 |
//Base_ArcPath.Stroke = this.StrokeColor; |
418 |
//Base_ArcPath.StrokeThickness = 2; |
419 |
//pathFigure.IsFilled = true; |
420 |
break; |
421 |
case PaintSet.Hatch: |
422 |
Base_BodyPath.Stroke = new SolidColorBrush(Colors.Transparent); |
423 |
Base_BodyPath.StrokeThickness = 2; |
424 |
Base_BodyPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor); |
425 |
Base_ArcPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor); |
426 |
pathFigure.IsFilled = true; |
427 |
break; |
428 |
default: |
429 |
break; |
430 |
} |
431 |
|
432 |
#region 사각형 만들기 |
433 |
if (this.Paint != PaintSet.None) |
434 |
{ |
435 |
|
436 |
|
437 |
pathFigure.StartPoint = this.StartPoint; |
438 |
|
439 |
LineSegment lineSegment0 = new LineSegment(); |
440 |
lineSegment0.Point = this.StartPoint; |
441 |
pathFigure.Segments.Add(lineSegment0); |
442 |
|
443 |
LineSegment lineSegment1 = new LineSegment(); |
444 |
lineSegment1.Point = this.LeftBottomPoint; |
445 |
pathFigure.Segments.Add(lineSegment1); |
446 |
|
447 |
LineSegment lineSegment2 = new LineSegment(); |
448 |
lineSegment2.Point = this.EndPoint; |
449 |
pathFigure.Segments.Add(lineSegment2); |
450 |
|
451 |
LineSegment lineSegment3 = new LineSegment(); |
452 |
lineSegment3.Point = this.TopRightPoint; |
453 |
pathFigure.Segments.Add(lineSegment3); |
454 |
|
455 |
PathGeometry pathGeometry = new PathGeometry(); |
456 |
pathGeometry.Figures = new PathFigureCollection(); |
457 |
pathFigure.IsClosed = true; |
458 |
pathGeometry.Figures.Add(pathFigure); |
459 |
//this.FillColor = new SolidColorBrush(Colors.Red); |
460 |
this.PathSubData = pathGeometry; |
461 |
} |
462 |
|
463 |
|
464 |
#endregion |
465 |
#region Cloud 만들기 |
466 |
/// set reverse if area is greater 0 - 2012.07.04 added by humkyung |
467 |
/// |
468 |
|
469 |
//double size = MathSet.DistanceTo(this.StartPoint, this.EndPoint); |
470 |
//ArcLength = (size * 0.05); |
471 |
|
472 |
//if (ArcLength <= 10) |
473 |
//{ |
474 |
// ArcLength = 10; |
475 |
//} |
476 |
//강인구 수정(클라우드 사이즈) |
477 |
//if (ArcLength <= 3) |
478 |
//{ |
479 |
// ArcLength = 10; |
480 |
//} |
481 |
//else if (ArcLength <= 10) |
482 |
//{ |
483 |
// ArcLength = 20; |
484 |
//} |
485 |
//else if (ArcLength <= 30) |
486 |
//{ |
487 |
// ArcLength = 30; |
488 |
//} |
489 |
|
490 |
//ArcLength = 10; |
491 |
|
492 |
System.Diagnostics.Debug.WriteLine(ArcLength); |
493 |
double area = MathSet.AreaOf(new List<Point>() { this.StartPoint, this.LeftBottomPoint, this.EndPoint, this.TopRightPoint }); |
494 |
bool reverse = (area > 0); |
495 |
/// up to here |
496 |
this._pathGeometry = new PathGeometry(); |
497 |
int count = this.PointSet.Count; |
498 |
PathFigure pathSubFigure = RectCloudControl.GenerateLineWithCloud(this.StartPoint, this.LeftBottomPoint, this.ArcLength, reverse); |
499 |
_pathGeometry.Figures.Add(pathSubFigure); |
500 |
|
501 |
pathSubFigure = RectCloudControl.GenerateLineWithCloud(this.LeftBottomPoint, this.EndPoint, this.ArcLength, reverse); |
502 |
_pathGeometry.Figures.Add(pathSubFigure); |
503 |
|
504 |
pathSubFigure = RectCloudControl.GenerateLineWithCloud(this.EndPoint, this.TopRightPoint, this.ArcLength, reverse); |
505 |
_pathGeometry.Figures.Add(pathSubFigure); |
506 |
|
507 |
pathSubFigure = RectCloudControl.GenerateLineWithCloud(this.TopRightPoint, this.StartPoint, this.ArcLength, reverse); |
508 |
_pathGeometry.Figures.Add(pathSubFigure); |
509 |
|
510 |
if (this.Paint != PaintSet.None) |
511 |
{ |
512 |
foreach (var item in _pathGeometry.Figures) |
513 |
{ |
514 |
item.IsFilled = true; |
515 |
} |
516 |
} |
517 |
|
518 |
|
519 |
//for (int i = 0; i < (count - 1); i++) |
520 |
//{ |
521 |
// PathFigure pathSubFigure = CloudControl.GenerateLineWithCloud(this.PointSet[i], this.PointSet[i + 1], this.ArcLength, reverse); |
522 |
// _pathGeometry.Figures.Add(pathSubFigure); |
523 |
//} |
524 |
|
525 |
//Base_ArcPath.StrokeThickness = 3; |
526 |
//Base_BodyPath.StrokeThickness = 3; |
527 |
|
528 |
this.PathData = _pathGeometry; |
529 |
ApplyOverViewData(); |
530 |
#endregion |
531 |
} |
532 |
|
533 |
public void ChangePaint(PaintSet state) |
534 |
{ |
535 |
this.Paint = state; |
536 |
this.SetRectCloud(); |
537 |
} |
538 |
|
539 |
public void CloseSettingPoint() |
540 |
{ |
541 |
this.PointSet[0] = this.StartPoint; |
542 |
this.PointSet[1] = this.LeftBottomPoint; |
543 |
this.PointSet[2] = this.EndPoint; |
544 |
this.PointSet[3] = this.TopRightPoint; |
545 |
} |
546 |
|
547 |
public void ApplyOverViewData() |
548 |
{ |
549 |
this.OverViewPathData = this.PathData; |
550 |
} |
551 |
|
552 |
public void updateControl() |
553 |
{ |
554 |
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
555 |
this.LeftBottomPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
556 |
this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
557 |
this.TopRightPoint = new Point(this.PointSet[3].X, this.PointSet[3].Y); |
558 |
} |
559 |
|
560 |
public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse) |
561 |
{ |
562 |
PathFigure pathFigure = new PathFigure(); |
563 |
pathFigure.StartPoint = p1; |
564 |
|
565 |
double arcLength = arcLength_; |
566 |
/// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung |
567 |
double dx = p2.X - p1.X; |
568 |
double dy = p2.Y - p1.Y; |
569 |
double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2 |
570 |
double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI; |
571 |
Point lastPt = new Point(p1.X, p1.Y); |
572 |
double count = l / arcLength; |
573 |
/// normalize |
574 |
dx /= l; |
575 |
dy /= l; |
576 |
Double j = 1; |
577 |
for (j = 1; j < (count - 1); j++) |
578 |
{ |
579 |
ArcSegment arcSeg = new ArcSegment(); |
580 |
arcSeg.Size = new Size(arcLength * RectCloudControl._CloudArcDepth, arcLength * RectCloudControl._CloudArcDepth); /// x size and y size of arc |
581 |
arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength); /// end point of arc |
582 |
lastPt = arcSeg.Point; /// save last point |
583 |
arcSeg.RotationAngle = theta + 90; |
584 |
if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
585 |
pathFigure.Segments.Add(arcSeg); |
586 |
} |
587 |
|
588 |
/// draw arc between last point and end point |
589 |
if ((count > j) || (count > 0)) |
590 |
{ |
591 |
arcLength = MathSet.DistanceTo(lastPt, p2); |
592 |
ArcSegment arcSeg = new ArcSegment(); |
593 |
arcSeg.Size = new Size(arcLength * RectCloudControl._CloudArcDepth, arcLength * RectCloudControl._CloudArcDepth); /// x size and y size of arc |
594 |
arcSeg.Point = new Point(p2.X, p2.Y); /// end point of arc |
595 |
arcSeg.RotationAngle = theta; |
596 |
if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
597 |
pathFigure.Segments.Add(arcSeg); |
598 |
} |
599 |
pathFigure.IsClosed = false; |
600 |
pathFigure.IsFilled = false; |
601 |
/// up to here |
602 |
//pathFigure.IsFilled = true; |
603 |
return pathFigure; |
604 |
} |
605 |
} |
606 |
} |