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