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