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