markus / MarkupToPDF / Controls / Line / ArrowArcControl.cs @ 08be599f
이력 | 보기 | 이력해설 | 다운로드 (23.2 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.Line |
20 |
{ |
21 |
|
22 |
public class ArrowArcControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IDashControl |
23 |
{ |
24 |
#region 초기선언 |
25 |
public event PropertyChangedEventHandler PropertyChanged; |
26 |
private const string PART_ArcPath = "PART_ArcPath"; |
27 |
public Path Base_ArcPath = null; |
28 |
#endregion |
29 |
static ArrowArcControl() |
30 |
{ |
31 |
DefaultStyleKeyProperty.OverrideMetadata(typeof(ArrowArcControl), new FrameworkPropertyMetadata(typeof(ArrowArcControl))); |
32 |
//Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
33 |
//ResourceDictionary dictionary = new ResourceDictionary(); |
34 |
//dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
35 |
//Application.Current.Resources.MergedDictionaries.Add(dictionary); |
36 |
//System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count); |
37 |
} |
38 |
|
39 |
public ArrowArcControl() |
40 |
{ |
41 |
//this.DefaultStyleKey = typeof(ArrowArcControl); |
42 |
} |
43 |
|
44 |
public override void Copy(CommentUserInfo lhs) |
45 |
{ |
46 |
if (lhs is ArrowArcControl ArrowArcCtrl) |
47 |
{ |
48 |
this.StartPoint = new Point(ArrowArcCtrl.StartPoint.X, ArrowArcCtrl.StartPoint.Y); |
49 |
this.EndPoint = new Point(ArrowArcCtrl.EndPoint.X, ArrowArcCtrl.EndPoint.Y); |
50 |
this.DashSize = ArrowArcCtrl.DashSize; |
51 |
this.PointSet = ArrowArcCtrl.PointSet.ConvertAll(x => new Point(x.X, x.Y)); |
52 |
this.isTransOn = ArrowArcCtrl.isTransOn; |
53 |
this.MiddlePoint = new Point(ArrowArcCtrl.MiddlePoint.X, ArrowArcCtrl.MiddlePoint.Y); |
54 |
this.StrokeColor = ArrowArcCtrl.StrokeColor; |
55 |
this.Opacity = ArrowArcCtrl.Opacity; |
56 |
|
57 |
this.Clock = ArrowArcCtrl.Clock; |
58 |
this.LineSize = ArrowArcCtrl.LineSize; |
59 |
this.UserID = ArrowArcCtrl.UserID; |
60 |
this.Memo = ArrowArcCtrl.Memo; |
61 |
} |
62 |
} |
63 |
|
64 |
public override CommentUserInfo Clone() |
65 |
{ |
66 |
var clone = new ArrowArcControl(); |
67 |
clone.Copy(this); |
68 |
return clone; |
69 |
} |
70 |
|
71 |
public void Dispose() |
72 |
{ |
73 |
//GC.Collect(); |
74 |
////GC.SuppressFinalize(this); |
75 |
//Control control = new Control(); |
76 |
this.Base_ArcPath = null; |
77 |
} |
78 |
protected void OnPropertyChanged(string propName) |
79 |
{ |
80 |
if (PropertyChanged != null) |
81 |
PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
82 |
} |
83 |
|
84 |
#region Dependency Properties |
85 |
|
86 |
|
87 |
|
88 |
public static readonly DependencyProperty IsSelectedProperty = |
89 |
DependencyProperty.Register("IsSelected", typeof(bool), typeof(ArrowArcControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
90 |
|
91 |
public static readonly DependencyProperty ControlTypeProperty = |
92 |
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(ArrowArcControl), new FrameworkPropertyMetadata(ControlType.ArcArrow)); |
93 |
|
94 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
95 |
"OverViewPathData", typeof(Geometry), typeof(ArrowArcControl), new PropertyMetadata(null)); |
96 |
|
97 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
98 |
"UserID", typeof(string), typeof(ArrowArcControl), new PropertyMetadata(null)); |
99 |
|
100 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
101 |
"LineSize", typeof(double), typeof(ArrowArcControl), new PropertyMetadata((Double)3, PointValueChanged)); |
102 |
|
103 |
public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
104 |
"DashSize", typeof(DoubleCollection), typeof(ArrowArcControl), new PropertyMetadata(new DoubleCollection { 99999999 }, PointValueChanged)); |
105 |
|
106 |
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
107 |
"StrokeColor", typeof(SolidColorBrush), typeof(ArrowArcControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
108 |
|
109 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
110 |
"PathData", typeof(Geometry), typeof(ArrowArcControl), null); |
111 |
|
112 |
//public static readonly DependencyProperty ClockProperty = DependencyProperty.Register( |
113 |
// "Clock", typeof(SweepDirection), typeof(ArrowArcControl), new PropertyMetadata(SweepDirection.Clockwise)); |
114 |
public static readonly DependencyProperty ClockProperty = DependencyProperty.Register( |
115 |
"Clock", typeof(bool), typeof(ArrowArcControl), new PropertyMetadata(false)); |
116 |
|
117 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
118 |
"StartPoint", typeof(Point), typeof(ArrowArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
119 |
public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register( |
120 |
"MidPoint", typeof(Point), typeof(ArrowArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
121 |
|
122 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
123 |
"EndPoint", typeof(Point), typeof(ArrowArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
124 |
|
125 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
126 |
"PointSet", typeof(List<Point>), typeof(ArrowArcControl), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
127 |
|
128 |
public static readonly DependencyProperty isTransOnProperty = DependencyProperty.Register( |
129 |
"isTransOn", typeof(bool), typeof(ArrowArcControl), new PropertyMetadata(false)); |
130 |
|
131 |
public static readonly DependencyProperty AngleProperty = |
132 |
DependencyProperty.Register("AngleValue", typeof(double), typeof(ArrowArcControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback |
133 |
(AngleValueChanged))); |
134 |
|
135 |
public static readonly DependencyProperty CenterXProperty = |
136 |
DependencyProperty.Register("CenterX", typeof(double), typeof(ArrowArcControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
137 |
|
138 |
public static readonly DependencyProperty CenterYProperty = |
139 |
DependencyProperty.Register("CenterY", typeof(double), typeof(ArrowArcControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
140 |
#endregion |
141 |
#region PropertyChanged Method |
142 |
|
143 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
144 |
{ |
145 |
//var instance = (ArrowArcControl)sender; |
146 |
|
147 |
//if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
148 |
//{ |
149 |
|
150 |
// instance.SetValue(e.Property, e.NewValue); |
151 |
|
152 |
// if (instance.IsSelected) |
153 |
// { |
154 |
// instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Blue); |
155 |
// } |
156 |
// else |
157 |
// { |
158 |
// instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Red); |
159 |
// } |
160 |
//} |
161 |
} |
162 |
|
163 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
164 |
{ |
165 |
var instance = (ArrowArcControl)sender; |
166 |
if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
167 |
{ |
168 |
instance.SetValue(e.Property, e.NewValue); |
169 |
instance.SetArcPath(); |
170 |
} |
171 |
} |
172 |
public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
173 |
{ |
174 |
var instance = (ArrowArcControl)sender; |
175 |
if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
176 |
{ |
177 |
instance.SetValue(e.Property, e.NewValue); |
178 |
instance.SetArcPath(); |
179 |
} |
180 |
} |
181 |
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
182 |
{ |
183 |
var instance = (ArrowArcControl)sender; |
184 |
if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
185 |
{ |
186 |
instance.SetValue(e.Property, e.NewValue); |
187 |
instance.SetArcPath(); |
188 |
} |
189 |
} |
190 |
|
191 |
|
192 |
|
193 |
#endregion |
194 |
#region Properties |
195 |
public string UserID |
196 |
{ |
197 |
get { return (string)GetValue(UserIDProperty); } |
198 |
set |
199 |
{ |
200 |
if (this.UserID != value) |
201 |
{ |
202 |
SetValue(UserIDProperty, value); |
203 |
OnPropertyChanged("UserID"); |
204 |
} |
205 |
} |
206 |
} |
207 |
public Double LineSize |
208 |
{ |
209 |
get { return (Double)GetValue(LineSizeProperty); } |
210 |
set |
211 |
{ |
212 |
if (this.LineSize != value) |
213 |
{ |
214 |
SetValue(LineSizeProperty, value); |
215 |
} |
216 |
} |
217 |
} |
218 |
|
219 |
|
220 |
public bool Clock |
221 |
{ |
222 |
get { return (bool)GetValue(ClockProperty); } |
223 |
set |
224 |
{ |
225 |
if (this.Clock != value) |
226 |
{ |
227 |
SetValue(ClockProperty, value); |
228 |
OnPropertyChanged("Clock"); |
229 |
} |
230 |
} |
231 |
} |
232 |
|
233 |
//public SweepDirection Clock |
234 |
//{ |
235 |
// get { return (SweepDirection)GetValue(ClockProperty); } |
236 |
// set |
237 |
// { |
238 |
// if (this.Clock != value) |
239 |
// { |
240 |
// SetValue(ClockProperty, value); |
241 |
// OnPropertyChanged("Clock"); |
242 |
// } |
243 |
// } |
244 |
//} |
245 |
public DoubleCollection DashSize |
246 |
{ |
247 |
get { return (DoubleCollection)GetValue(DashSizeProperty); } |
248 |
set |
249 |
{ |
250 |
if (this.DashSize != value) |
251 |
{ |
252 |
SetValue(DashSizeProperty, value); |
253 |
} |
254 |
} |
255 |
} |
256 |
public List<Point> PointSet |
257 |
{ |
258 |
get { return (List<Point>)GetValue(PointSetProperty); } |
259 |
set { SetValue(PointSetProperty, value); } |
260 |
} |
261 |
public double CenterX |
262 |
{ |
263 |
get { return (double)GetValue(CenterXProperty); } |
264 |
set { SetValue(CenterXProperty, value); } |
265 |
} |
266 |
public double CenterY |
267 |
{ |
268 |
get { return (double)GetValue(CenterYProperty); } |
269 |
set { SetValue(CenterYProperty, value); } |
270 |
} |
271 |
public override SolidColorBrush StrokeColor |
272 |
{ |
273 |
get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
274 |
set |
275 |
{ |
276 |
if (this.StrokeColor != value) |
277 |
{ |
278 |
SetValue(StrokeColorProperty, value); |
279 |
} |
280 |
} |
281 |
} |
282 |
|
283 |
public Geometry OverViewPathData |
284 |
{ |
285 |
get |
286 |
{ |
287 |
return (Geometry)GetValue(OverViewPathDataProperty); |
288 |
} |
289 |
set |
290 |
{ |
291 |
SetValue(OverViewPathDataProperty, value); |
292 |
OnPropertyChanged("OverViewPathData"); |
293 |
} |
294 |
} |
295 |
|
296 |
public Geometry PathData |
297 |
{ |
298 |
get { return (Geometry)GetValue(PathDataProperty); } |
299 |
set |
300 |
{ |
301 |
SetValue(PathDataProperty, value); |
302 |
OnPropertyChanged("PathData"); |
303 |
} |
304 |
} |
305 |
public override bool IsSelected |
306 |
{ |
307 |
get |
308 |
{ |
309 |
return (bool)GetValue(IsSelectedProperty); |
310 |
} |
311 |
set |
312 |
{ |
313 |
SetValue(IsSelectedProperty, value); |
314 |
} |
315 |
} |
316 |
|
317 |
public override ControlType ControlType |
318 |
{ |
319 |
get |
320 |
{ |
321 |
return (ControlType)GetValue(ControlTypeProperty); |
322 |
} |
323 |
set |
324 |
{ |
325 |
SetValue(ControlTypeProperty, value); |
326 |
OnPropertyChanged("ControlType"); |
327 |
} |
328 |
} |
329 |
public double AngleValue |
330 |
{ |
331 |
get { return (double)GetValue(AngleProperty); } |
332 |
set { SetValue(AngleProperty, value); } |
333 |
} |
334 |
|
335 |
|
336 |
//public double Angle |
337 |
//{ |
338 |
// get { return (double)GetValue(AngleProperty); } |
339 |
// set |
340 |
// { |
341 |
// if (this.Angle != value) |
342 |
// { |
343 |
// SetValue(AngleProperty, value); |
344 |
// } |
345 |
// } |
346 |
//} |
347 |
|
348 |
public Point EndPoint |
349 |
{ |
350 |
get { return (Point)GetValue(EndPointProperty); } |
351 |
set |
352 |
{ |
353 |
SetValue(EndPointProperty, value); |
354 |
OnPropertyChanged("EndPoint"); |
355 |
} |
356 |
} |
357 |
public Point StartPoint |
358 |
{ |
359 |
get { return (Point)GetValue(StartPointProperty); } |
360 |
set |
361 |
{ |
362 |
SetValue(StartPointProperty, value); |
363 |
OnPropertyChanged("StartPoint"); |
364 |
} |
365 |
} |
366 |
public Point MiddlePoint |
367 |
{ |
368 |
get { return (Point)GetValue(MidPointProperty); } |
369 |
set |
370 |
{ |
371 |
SetValue(MidPointProperty, value); |
372 |
OnPropertyChanged("MiddlePoint"); |
373 |
} |
374 |
} |
375 |
public bool isTransOn |
376 |
{ |
377 |
get { return (bool)GetValue(isTransOnProperty); } |
378 |
set |
379 |
{ |
380 |
SetValue(isTransOnProperty, value); |
381 |
OnPropertyChanged("isTransOn"); |
382 |
} |
383 |
} |
384 |
|
385 |
#endregion |
386 |
#region Object & Variable |
387 |
PathGeometry pathGeometry = new PathGeometry(); |
388 |
GeometryGroup instanceGroup = new GeometryGroup(); |
389 |
#endregion |
390 |
public override void OnApplyTemplate() |
391 |
{ |
392 |
base.OnApplyTemplate(); |
393 |
Base_ArcPath = GetTemplateChild(PART_ArcPath) as Path; |
394 |
SetArcPath(); |
395 |
} |
396 |
|
397 |
public override void UpdateControl() |
398 |
{ |
399 |
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
400 |
this.MiddlePoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
401 |
this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
402 |
} |
403 |
|
404 |
public void setClock() |
405 |
{ |
406 |
if (Clock) |
407 |
{ |
408 |
this.Clock = false; |
409 |
} |
410 |
else |
411 |
{ |
412 |
this.Clock = true; |
413 |
} |
414 |
} |
415 |
|
416 |
//public void setClock() |
417 |
//{ |
418 |
// if(this.Clock == SweepDirection.Clockwise) |
419 |
// { |
420 |
// this.Clock = SweepDirection.Counterclockwise; |
421 |
// } |
422 |
// else |
423 |
// { |
424 |
// this.Clock =SweepDirection.Clockwise; |
425 |
// } |
426 |
//} |
427 |
public void SetArcPath() |
428 |
{ |
429 |
this.ApplyTemplate(); |
430 |
|
431 |
|
432 |
//강인구 추가 |
433 |
Base_ArcPath.StrokeDashArray.Clear(); |
434 |
if (this.DashSize != null) |
435 |
{ |
436 |
foreach (var item in this.DashSize) |
437 |
{ |
438 |
Base_ArcPath.StrokeDashArray.Add(item); |
439 |
} |
440 |
Base_ArcPath.StrokeDashCap = PenLineCap.Square; |
441 |
instanceGroup.Children.Clear(); |
442 |
} |
443 |
PathFigure pathFigure = new PathFigure(); |
444 |
|
445 |
pathFigure.StartPoint = this.StartPoint; |
446 |
QuadraticBezierSegment qb = new QuadraticBezierSegment(); |
447 |
|
448 |
if (MiddlePoint != null) |
449 |
{ |
450 |
if (MiddlePoint == new Point(0,0)) |
451 |
{ |
452 |
double xSharp = 0; |
453 |
double ySharp = 0; |
454 |
|
455 |
//Point t_start = new Point(0, 0); |
456 |
//Point t_end = new Point(30, 10); |
457 |
|
458 |
var midP = MathSet.getMiddlePoint(StartPoint, EndPoint); |
459 |
Point normalV = MathSet.GetNormVectorBetween(StartPoint, EndPoint); |
460 |
var dis = MathSet.DistanceTo(StartPoint, EndPoint); |
461 |
|
462 |
if (!this.Clock) |
463 |
{ |
464 |
xSharp = -normalV.Y; |
465 |
ySharp = normalV.X; |
466 |
} |
467 |
else |
468 |
{ |
469 |
xSharp = normalV.Y; |
470 |
ySharp = -normalV.X; |
471 |
} |
472 |
|
473 |
var pointN = new Point(xSharp * dis, ySharp * dis); |
474 |
MiddlePoint = new Point(pointN.X + midP.X, pointN.Y + midP.Y); |
475 |
} |
476 |
qb.Point1 = this.MiddlePoint; |
477 |
} |
478 |
|
479 |
qb.Point2 = this.EndPoint; |
480 |
pathFigure.Segments.Add(qb); |
481 |
pathGeometry.Figures = new PathFigureCollection(); |
482 |
pathGeometry.Figures.Add(pathFigure); |
483 |
pathFigure.IsFilled = false; |
484 |
pathFigure.IsClosed = false; |
485 |
instanceGroup.Children.Add(pathGeometry); |
486 |
|
487 |
instanceGroup.Children.Add(DrawSet.DrawArrow(this.MiddlePoint, this.StartPoint, this.LineSize)); |
488 |
instanceGroup.Children.Add(DrawSet.DrawArrow(this.MiddlePoint, this.EndPoint, this.LineSize)); |
489 |
this.Base_ArcPath.Fill = this.StrokeColor; |
490 |
|
491 |
instanceGroup.FillRule = FillRule.Nonzero; |
492 |
this.PathData = instanceGroup; |
493 |
this.OverViewPathData = PathData; |
494 |
|
495 |
} |
496 |
|
497 |
public override void ApplyOverViewData() |
498 |
{ |
499 |
this.OverViewPathData = this.PathData; |
500 |
} |
501 |
|
502 |
/// <summary> |
503 |
/// call when mouse is moving while drawing control |
504 |
/// </summary> |
505 |
/// <author>humkyung</author> |
506 |
/// <param name="pt"></param> |
507 |
/// <param name="bAxisLocked"></param> |
508 |
public override void OnCreatingMouseMove(Point pt, bool bAxisLocked) |
509 |
{ |
510 |
this.isTransOn = false; |
511 |
this.MiddlePoint = new Point(0, 0); |
512 |
this.EndPoint = pt; |
513 |
|
514 |
Point tmp = this.EndPoint; |
515 |
CommentAngle = MathSet.returnAngle(this.StartPoint, ref tmp, bAxisLocked); |
516 |
|
517 |
if (bAxisLocked) |
518 |
{ |
519 |
this.EndPoint = tmp; |
520 |
} |
521 |
|
522 |
this.PointSet = new List<Point> |
523 |
{ |
524 |
this.StartPoint, |
525 |
this.MiddlePoint, |
526 |
this.EndPoint, |
527 |
}; |
528 |
} |
529 |
|
530 |
/// <summary> |
531 |
/// move control point has same location of given pt along given delta |
532 |
/// </summary> |
533 |
/// <author>humkyung</author> |
534 |
/// <date>2019.06.20</date> |
535 |
/// <param name="pt"></param> |
536 |
/// <param name="dx"></param> |
537 |
/// <param name="dy"></param> |
538 |
public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false) |
539 |
{ |
540 |
Point selected = MathSet.getNearPoint((this as IPath).PointSet, pt); |
541 |
|
542 |
var tmpPointSet = (this as IPath).PointSet.Where(x => !x.Equals(selected)); |
543 |
Point NearStartpoint = MathSet.getNearPoint(tmpPointSet.ToList(), pt); |
544 |
|
545 |
selected.X += dx; |
546 |
selected.Y += dy; |
547 |
|
548 |
Point tmp = selected; |
549 |
|
550 |
CommentAngle = MathSet.returnAngle(NearStartpoint, ref tmp, bAxisLocked); |
551 |
|
552 |
if (bAxisLocked) |
553 |
{ |
554 |
selected = tmp; |
555 |
} |
556 |
|
557 |
for (int i = 0; i < (this as IPath).PointSet.Count; i++) |
558 |
{ |
559 |
if (pt.Equals((this as IPath).PointSet[i])) |
560 |
{ |
561 |
(this as IPath).PointSet[i] = selected; |
562 |
} |
563 |
} |
564 |
this.UpdateControl(); |
565 |
} |
566 |
|
567 |
|
568 |
/// <summary> |
569 |
/// return ArrowControl_Multi's area |
570 |
/// </summary> |
571 |
/// <author>humkyung</author> |
572 |
/// <date>2019.06.13</date> |
573 |
public override Rect ItemRect |
574 |
{ |
575 |
get |
576 |
{ |
577 |
double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X); |
578 |
dMinX = Math.Min(this.MiddlePoint.X, dMinX); |
579 |
double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y); |
580 |
dMinY = Math.Min(this.MiddlePoint.Y, dMinY); |
581 |
double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X); |
582 |
dMaxX = Math.Max(this.MiddlePoint.X, dMaxX); |
583 |
double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y); |
584 |
dMaxY = Math.Max(this.MiddlePoint.Y, dMaxY); |
585 |
|
586 |
return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY)); |
587 |
} |
588 |
} |
589 |
|
590 |
/// <summary> |
591 |
/// Serialize this |
592 |
/// </summary> |
593 |
/// <param name="sUserId"></param> |
594 |
/// <returns></returns> |
595 |
public override string Serialize() |
596 |
{ |
597 |
using (S_ArrowArcControl STemp = new S_ArrowArcControl()) |
598 |
{ |
599 |
STemp.TransformPoint = "0|0"; |
600 |
STemp.PointSet = this.PointSet; |
601 |
STemp.SizeSet = String.Format("{0}", this.LineSize); |
602 |
//STemp.StrokeColor = "#FF000FFF"; |
603 |
STemp.StrokeColor = this.StrokeColor.Color.ToString(); |
604 |
STemp.StartPoint = this.StartPoint; |
605 |
STemp.UserID = this.UserID; |
606 |
STemp.Opac = this.Opacity; |
607 |
STemp.MidPoint = this.MiddlePoint; |
608 |
STemp.EndPoint = this.EndPoint; |
609 |
STemp.IsTransOn = this.isTransOn; |
610 |
STemp.DashSize = this.DashSize; |
611 |
STemp.Clock = this.Clock; |
612 |
//STemp.ArcStyleSet = this.ControlType; |
613 |
STemp.Name = this.GetType().Name.ToString(); |
614 |
|
615 |
///강인구 추가(2017.11.02) |
616 |
///Memo 추가 |
617 |
STemp.Memo = this.Memo; |
618 |
|
619 |
return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize())); |
620 |
} |
621 |
} |
622 |
|
623 |
/// <summary> |
624 |
/// create a arrowarccontrol from given string |
625 |
/// </summary> |
626 |
/// <param name="str"></param> |
627 |
/// <returns></returns> |
628 |
public static ArrowArcControl FromString(string str, SolidColorBrush brush, string sProjectNo) |
629 |
{ |
630 |
ArrowArcControl instance = null; |
631 |
using (S_ArrowArcControl s = JsonSerializerHelper.JsonDeserialize<S_ArrowArcControl>(str)) |
632 |
{ |
633 |
string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
634 |
instance = new ArrowArcControl() |
635 |
{ |
636 |
StartPoint = s.StartPoint, |
637 |
EndPoint = s.EndPoint, |
638 |
DashSize = s.DashSize, |
639 |
PointSet = s.PointSet, |
640 |
isTransOn = s.IsTransOn, |
641 |
MiddlePoint = s.MidPoint, |
642 |
StrokeColor = brush, |
643 |
Opacity = s.Opac, |
644 |
|
645 |
Clock = s.Clock, |
646 |
LineSize = Convert.ToDouble(data2.First()), |
647 |
UserID = s.UserID, |
648 |
Memo = s.Memo |
649 |
}; |
650 |
} |
651 |
|
652 |
return instance; |
653 |
} |
654 |
} |
655 |
} |