markus / MarkupToPDF / Controls / Polygon / PolygonControl.cs @ 7a3b7ef3
이력 | 보기 | 이력해설 | 다운로드 (24.4 KB)
1 | 787a4489 | KangIngu | using MarkupToPDF.Common; |
---|---|---|---|
2 | using MarkupToPDF.Controls.Common; |
||
3 | 036650a0 | humkyung | using MarkupToPDF.Serialize.Core; |
4 | using MarkupToPDF.Serialize.S_Control; |
||
5 | 787a4489 | KangIngu | using System; |
6 | using System.Collections.Generic; |
||
7 | using System.ComponentModel; |
||
8 | using System.Linq; |
||
9 | using System.Text; |
||
10 | using System.Threading.Tasks; |
||
11 | using System.Windows; |
||
12 | using System.Windows.Controls; |
||
13 | 7a3b7ef3 | swate0609 | using System.Windows.Forms; |
14 | using System.Windows.Input; |
||
15 | 787a4489 | KangIngu | using System.Windows.Media; |
16 | using System.Windows.Shapes; |
||
17 | |||
18 | namespace MarkupToPDF.Controls.Polygon |
||
19 | { |
||
20 | public class PolygonControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IShapeControl, IMarkupControlData, IPath |
||
21 | { |
||
22 | #region Constructure |
||
23 | |||
24 | static PolygonControl() |
||
25 | { |
||
26 | DefaultStyleKeyProperty.OverrideMetadata(typeof(PolygonControl), new FrameworkPropertyMetadata(typeof(PolygonControl))); |
||
27 | a6f7f9b6 | djkim | //ResourceDictionary dictionary = new ResourceDictionary(); |
28 | //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
||
29 | //Application.Current.Resources.MergedDictionaries.Add(dictionary); |
||
30 | 787a4489 | KangIngu | } |
31 | |||
32 | public PolygonControl() |
||
33 | { |
||
34 | a6f7f9b6 | djkim | //this.DefaultStyleKey = typeof(PolygonControl); |
35 | 787a4489 | KangIngu | } |
36 | |||
37 | #endregion |
||
38 | |||
39 | #region Variable |
||
40 | private const string PART_PolyPath = "PART_PolyPath"; |
||
41 | |||
42 | public Path Base_PolyPath = null; |
||
43 | |||
44 | #endregion |
||
45 | |||
46 | #region Internal Method |
||
47 | public override void OnApplyTemplate() |
||
48 | { |
||
49 | base.OnApplyTemplate(); |
||
50 | |||
51 | Base_PolyPath = GetTemplateChild(PART_PolyPath) as Path; |
||
52 | |||
53 | if (Base_PolyPath == null) |
||
54 | return; |
||
55 | |||
56 | this.SetPolyPath(); |
||
57 | } |
||
58 | |||
59 | |||
60 | #endregion |
||
61 | |||
62 | #region Method |
||
63 | |||
64 | f513c215 | humkyung | public override void ApplyOverViewData() |
65 | 787a4489 | KangIngu | { |
66 | this.OverViewPathData = this.PathData; |
||
67 | } |
||
68 | |||
69 | #endregion |
||
70 | |||
71 | #region Dependency Properties |
||
72 | |||
73 | public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
||
74 | "UserID", typeof(string), typeof(PolygonControl), new PropertyMetadata(null)); |
||
75 | |||
76 | public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
||
77 | "LineSize", typeof(double), typeof(PolygonControl), new PropertyMetadata((Double)3)); |
||
78 | |||
79 | public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
||
80 | "StrokeColor", typeof(SolidColorBrush), typeof(PolygonControl), |
||
81 | new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
||
82 | |||
83 | public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
||
84 | "PathData", typeof(Geometry), typeof(PolygonControl), null); |
||
85 | |||
86 | //강인구 추가 |
||
87 | public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
||
88 | "DashSize", typeof(DoubleCollection), typeof(PolygonControl), new PropertyMetadata(new DoubleCollection { 99999999 }, PointValueChanged)); |
||
89 | |||
90 | public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
||
91 | "OverViewPathData", typeof(Geometry), typeof(PolygonControl), null); |
||
92 | //강인구 추가 |
||
93 | public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
||
94 | "Paint", typeof(PaintSet), typeof(PolygonControl), new PropertyMetadata(PaintSet.None, PointValueChanged)); |
||
95 | |||
96 | public static readonly DependencyProperty IsCompletedProperty = DependencyProperty.Register( |
||
97 | "IsCompleted", typeof(bool), typeof(PolygonControl), null); |
||
98 | |||
99 | public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
||
100 | "StartPoint", typeof(Point), typeof(PolygonControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
101 | |||
102 | public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
||
103 | "EndPoint", typeof(Point), typeof(PolygonControl), new PropertyMetadata(new Point(100, 100), PointValueChanged)); |
||
104 | |||
105 | public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
||
106 | "PointSet", typeof(List<Point>), typeof(PolygonControl), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
||
107 | |||
108 | /// <summary> |
||
109 | /// StylusPointSet을 List<Point>로 대체하면 PointValueChanged가 작동안한다. |
||
110 | /// </summary> |
||
111 | //public static readonly DependencyProperty StylusPointSetProperty = DependencyProperty.Register( |
||
112 | // "PointC", typeof(StylusPointSet), typeof(PolygonControl), new PropertyMetadata(new StylusPointSet(), PointValueChanged)); |
||
113 | |||
114 | public static readonly DependencyProperty AngleProperty = |
||
115 | DependencyProperty.Register("Angle", typeof(double), typeof(PolygonControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback |
||
116 | (AngleValueChanged))); |
||
117 | |||
118 | public static readonly DependencyProperty CenterXProperty = |
||
119 | DependencyProperty.Register("CenterX", typeof(double), typeof(PolygonControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
120 | |||
121 | public static readonly DependencyProperty CenterYProperty = |
||
122 | DependencyProperty.Register("CenterY", typeof(double), typeof(PolygonControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
123 | |||
124 | public static readonly DependencyProperty IsSelectedProperty = |
||
125 | DependencyProperty.Register("IsSelected", typeof(bool), typeof(PolygonControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
||
126 | |||
127 | public static readonly DependencyProperty ControlTypeProperty = |
||
128 | DependencyProperty.Register("ControlType", typeof(ControlType), typeof(PolygonControl), new FrameworkPropertyMetadata(ControlType.PolygonControl)); |
||
129 | |||
130 | public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register( |
||
131 | "CanvasX", typeof(double), typeof(PolygonControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
||
132 | |||
133 | public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register( |
||
134 | "CanvasY", typeof(double), typeof(PolygonControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
||
135 | |||
136 | #endregion |
||
137 | |||
138 | #region PropertyChanged Method |
||
139 | public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
140 | { |
||
141 | var instance = (PolygonControl)sender; |
||
142 | |||
143 | if (e.OldValue != e.NewValue && instance != null) |
||
144 | { |
||
145 | instance.SetValue(e.Property, e.NewValue); |
||
146 | //Canvas.SetLeft(instance, instance.CanvasX); |
||
147 | //Canvas.SetTop(instance, instance.CanvasY); |
||
148 | } |
||
149 | } |
||
150 | |||
151 | public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
152 | { |
||
153 | var instance = (PolygonControl)sender; |
||
154 | |||
155 | if (e.OldValue != e.NewValue && instance != null) |
||
156 | { |
||
157 | instance.SetValue(e.Property, e.NewValue); |
||
158 | //강인구 추가 |
||
159 | instance.SetPolyPath(); |
||
160 | //instance.SetPolyPath(); 주석처리 |
||
161 | |||
162 | } |
||
163 | } |
||
164 | public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
165 | { |
||
166 | var instance = (PolygonControl)sender; |
||
167 | |||
168 | if (e.OldValue != e.NewValue && instance != null) |
||
169 | { |
||
170 | instance.SetValue(e.Property, e.NewValue); |
||
171 | instance.SetPolyPath(); |
||
172 | } |
||
173 | } |
||
174 | public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
175 | { |
||
176 | var instance = (PolygonControl)sender; |
||
177 | if (e.OldValue != e.NewValue && instance != null) |
||
178 | { |
||
179 | instance.SetValue(e.Property, e.NewValue); |
||
180 | instance.SetPolyPath(); |
||
181 | } |
||
182 | } |
||
183 | |||
184 | public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
185 | { |
||
186 | //var instance = (PolygonControl)sender; |
||
187 | |||
188 | //if (e.OldValue != e.NewValue && instance.Base_PolyPath != null) |
||
189 | //{ |
||
190 | // instance.SetValue(e.Property, e.NewValue); |
||
191 | |||
192 | // if (instance.IsSelected) |
||
193 | // { |
||
194 | // instance.Base_PolyPath.Stroke = new SolidColorBrush(Colors.Blue); |
||
195 | // } |
||
196 | // else |
||
197 | // { |
||
198 | // instance.Base_PolyPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
199 | // } |
||
200 | //} |
||
201 | } |
||
202 | |||
203 | #endregion |
||
204 | |||
205 | #region Properties |
||
206 | |||
207 | |||
208 | public bool IsCompleted |
||
209 | { |
||
210 | get { return (bool)GetValue(IsCompletedProperty); } |
||
211 | set |
||
212 | { |
||
213 | SetValue(IsCompletedProperty, value); |
||
214 | OnPropertyChanged("IsCompleted"); |
||
215 | } |
||
216 | } |
||
217 | |||
218 | |||
219 | public Geometry OverViewPathData |
||
220 | { |
||
221 | get { return (Geometry)GetValue(OverViewPathDataProperty); } |
||
222 | set |
||
223 | { |
||
224 | SetValue(OverViewPathDataProperty, value); |
||
225 | OnPropertyChanged("OverViewPathData"); |
||
226 | } |
||
227 | } |
||
228 | |||
229 | public double CanvasX |
||
230 | { |
||
231 | get { return (double)GetValue(CanvasXProperty); } |
||
232 | set |
||
233 | { |
||
234 | if (this.CanvasX != value) |
||
235 | { |
||
236 | SetValue(CanvasXProperty, value); |
||
237 | OnPropertyChanged("CanvasX"); |
||
238 | } |
||
239 | } |
||
240 | } |
||
241 | |||
242 | public double CanvasY |
||
243 | { |
||
244 | get { return (double)GetValue(CanvasYProperty); } |
||
245 | set |
||
246 | { |
||
247 | if (this.CanvasY != value) |
||
248 | { |
||
249 | SetValue(CanvasYProperty, value); |
||
250 | OnPropertyChanged("CanvasY"); |
||
251 | } |
||
252 | } |
||
253 | } |
||
254 | |||
255 | 959b3ef2 | humkyung | public override bool IsSelected |
256 | 787a4489 | KangIngu | { |
257 | get |
||
258 | { |
||
259 | return (bool)GetValue(IsSelectedProperty); |
||
260 | } |
||
261 | set |
||
262 | { |
||
263 | SetValue(IsSelectedProperty, value); |
||
264 | OnPropertyChanged("IsSelected"); |
||
265 | } |
||
266 | } |
||
267 | |||
268 | public PaintSet Paint |
||
269 | { |
||
270 | get { return (PaintSet)GetValue(PaintProperty); } |
||
271 | set |
||
272 | { |
||
273 | if (this.Paint != value) |
||
274 | { |
||
275 | SetValue(PaintProperty, value); |
||
276 | OnPropertyChanged("Paint"); |
||
277 | } |
||
278 | } |
||
279 | } |
||
280 | |||
281 | 5529d2a2 | humkyung | public override ControlType ControlType |
282 | 787a4489 | KangIngu | { |
283 | set |
||
284 | { |
||
285 | SetValue(ControlTypeProperty, value); |
||
286 | OnPropertyChanged("ControlType"); |
||
287 | } |
||
288 | get |
||
289 | { |
||
290 | return (ControlType)GetValue(ControlTypeProperty); |
||
291 | } |
||
292 | } |
||
293 | |||
294 | public Double LineSize |
||
295 | { |
||
296 | get { return (Double)GetValue(LineSizeProperty); } |
||
297 | set |
||
298 | { |
||
299 | if (this.LineSize != value) |
||
300 | { |
||
301 | SetValue(LineSizeProperty, value); |
||
302 | OnPropertyChanged("LineSize"); |
||
303 | } |
||
304 | } |
||
305 | } |
||
306 | |||
307 | public DoubleCollection DashSize |
||
308 | { |
||
309 | get { return (DoubleCollection)GetValue(DashSizeProperty); } |
||
310 | set |
||
311 | { |
||
312 | if (this.DashSize != value) |
||
313 | { |
||
314 | SetValue(DashSizeProperty, value); |
||
315 | OnPropertyChanged("DashSize"); |
||
316 | } |
||
317 | } |
||
318 | } |
||
319 | public string UserID |
||
320 | { |
||
321 | get { return (string)GetValue(UserIDProperty); } |
||
322 | set |
||
323 | { |
||
324 | if (this.UserID != value) |
||
325 | { |
||
326 | SetValue(UserIDProperty, value); |
||
327 | OnPropertyChanged("UserID"); |
||
328 | } |
||
329 | } |
||
330 | } |
||
331 | public List<Point> PointSet |
||
332 | { |
||
333 | get { return (List<Point>)GetValue(PointSetProperty); } |
||
334 | set { SetValue(PointSetProperty, value); |
||
335 | OnPropertyChanged("PointSet"); |
||
336 | } |
||
337 | } //public StylusPointSet PointC |
||
338 | //{ |
||
339 | // get { return (StylusPointSet)GetValue(StylusPointSetProperty); } |
||
340 | // set |
||
341 | // { |
||
342 | // SetValue(StylusPointSetProperty, value); |
||
343 | // OnPropertyChanged("PointC"); |
||
344 | // } |
||
345 | //} |
||
346 | |||
347 | |||
348 | public double CenterX |
||
349 | { |
||
350 | get { return (double)GetValue(CenterXProperty); } |
||
351 | set { SetValue(CenterXProperty, value); |
||
352 | OnPropertyChanged("CenterX"); |
||
353 | } |
||
354 | } |
||
355 | public double CenterY |
||
356 | { |
||
357 | get |
||
358 | { |
||
359 | return (double)GetValue(CenterYProperty); |
||
360 | } |
||
361 | set |
||
362 | { |
||
363 | SetValue(CenterYProperty, value); |
||
364 | OnPropertyChanged("CenterY"); |
||
365 | } |
||
366 | } |
||
367 | 4913851c | humkyung | public override SolidColorBrush StrokeColor |
368 | 787a4489 | KangIngu | { |
369 | get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
||
370 | set |
||
371 | { |
||
372 | if (this.StrokeColor != value) |
||
373 | { |
||
374 | SetValue(StrokeColorProperty, value); |
||
375 | OnPropertyChanged("StrokeColor"); |
||
376 | } |
||
377 | } |
||
378 | } |
||
379 | public Geometry PathData |
||
380 | { |
||
381 | get { return (Geometry)GetValue(PathDataProperty); } |
||
382 | set |
||
383 | { |
||
384 | SetValue(PathDataProperty, value); |
||
385 | OnPropertyChanged("PathData"); |
||
386 | } |
||
387 | } |
||
388 | |||
389 | 168f8027 | taeseongkim | //public double Angle |
390 | //{ |
||
391 | // get { return (double)GetValue(AngleProperty); } |
||
392 | // set |
||
393 | // { |
||
394 | // if (this.Angle != value) |
||
395 | // { |
||
396 | // SetValue(AngleProperty, value); |
||
397 | // OnPropertyChanged("Angle"); |
||
398 | // } |
||
399 | // } |
||
400 | //} |
||
401 | 787a4489 | KangIngu | |
402 | public Point EndPoint |
||
403 | { |
||
404 | get { return (Point)GetValue(EndPointProperty); } |
||
405 | set |
||
406 | { |
||
407 | SetValue(EndPointProperty, value); |
||
408 | OnPropertyChanged("EndPoint"); |
||
409 | } |
||
410 | } |
||
411 | public Point StartPoint |
||
412 | { |
||
413 | get { return (Point)GetValue(StartPointProperty); } |
||
414 | set |
||
415 | { |
||
416 | SetValue(StartPointProperty, value); |
||
417 | OnPropertyChanged("StartPoint"); |
||
418 | } |
||
419 | } |
||
420 | #endregion |
||
421 | |||
422 | 0d00f9c8 | humkyung | public override void UpdateControl() |
423 | 787a4489 | KangIngu | { |
424 | this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
||
425 | this.EndPoint = new Point(this.PointSet[this.PointSet.Count - 1].X, this.PointSet[this.PointSet.Count - 1].Y); |
||
426 | |||
427 | SetPolyPath(); |
||
428 | } |
||
429 | |||
430 | 661b7416 | humkyung | private void SetPolyPath() |
431 | 787a4489 | KangIngu | { |
432 | if (Base_PolyPath != null) |
||
433 | { |
||
434 | Base_PolyPath.StrokeDashArray.Clear(); |
||
435 | foreach (var item in this.DashSize) |
||
436 | { |
||
437 | Base_PolyPath.StrokeDashArray.Add(item); |
||
438 | } |
||
439 | |||
440 | PathGeometry pathGeometry = new PathGeometry(); |
||
441 | PathFigure pathFigure = new PathFigure(); |
||
442 | 4804a4fb | humkyung | PolyLineSegment instance = new PolyLineSegment(this.PointSet, true); |
443 | 787a4489 | KangIngu | |
444 | StartPoint = instance.Points.First(); |
||
445 | pathFigure.StartPoint = StartPoint; |
||
446 | EndPoint = instance.Points.Last(); |
||
447 | pathFigure.Segments.Add(instance); |
||
448 | pathGeometry.Figures.Add(pathFigure); |
||
449 | |||
450 | //강인구 추가(Chain이 아닌 Polygon일때만 채우기 및 빗금 하기) |
||
451 | if (ControlType == ControlType.PolygonControl) |
||
452 | { |
||
453 | switch (this.Paint) |
||
454 | { |
||
455 | case PaintSet.None: |
||
456 | { |
||
457 | 4804a4fb | humkyung | pathFigure.IsFilled = false; |
458 | 787a4489 | KangIngu | //강인구 추가 |
459 | Base_PolyPath.Fill = null; |
||
460 | } |
||
461 | break; |
||
462 | case PaintSet.Fill: |
||
463 | { |
||
464 | Base_PolyPath.Fill = this.StrokeColor; |
||
465 | } |
||
466 | break; |
||
467 | case PaintSet.Hatch: |
||
468 | { |
||
469 | 92c9cab8 | taeseongkim | var size = this.LineSize > 5 ? 5 : this.LineSize; |
470 | Base_PolyPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor, 3 * 0.1); |
||
471 | 787a4489 | KangIngu | } |
472 | break; |
||
473 | default: |
||
474 | break; |
||
475 | } |
||
476 | } |
||
477 | |||
478 | this.PathData = pathGeometry; |
||
479 | 4804a4fb | humkyung | this.ApplyOverViewData(); |
480 | 787a4489 | KangIngu | } |
481 | } |
||
482 | |||
483 | public void ChangePaint(PaintSet state) |
||
484 | { |
||
485 | |||
486 | } |
||
487 | a6272c57 | humkyung | |
488 | /// <summary> |
||
489 | /// call when mouse is moving while drawing control |
||
490 | /// </summary> |
||
491 | /// <author>humkyung</author> |
||
492 | /// <param name="pt"></param> |
||
493 | /// <param name="bAxisLocked"></param> |
||
494 | 233ef333 | taeseongkim | public override void OnCreatingMouseMove(Point pt, bool bAxisLocked) |
495 | a6272c57 | humkyung | { |
496 | this.PointSet.RemoveAt(this.PointSet.Count - 1); |
||
497 | |||
498 | Point tmp = pt; |
||
499 | 168f8027 | taeseongkim | |
500 | 233ef333 | taeseongkim | if (bAxisLocked) |
501 | a6272c57 | humkyung | { |
502 | 233ef333 | taeseongkim | CommentAngle = MathSet.returnAngle(this.PointSet[this.PointSet.Count - 1], ref tmp, bAxisLocked); |
503 | a6272c57 | humkyung | } |
504 | 168f8027 | taeseongkim | |
505 | 7a3b7ef3 | swate0609 | if (this.PointSet.Count > 2 && StartPoint == tmp) |
506 | { |
||
507 | this.IsCompleted = true; |
||
508 | |||
509 | |||
510 | //var firstPoint = this.PointSet.First(); |
||
511 | //this.PointSet.Add(firstPoint); |
||
512 | a6272c57 | humkyung | |
513 | 7a3b7ef3 | swate0609 | //this.ApplyOverViewData(); |
514 | |||
515 | UpdateControl(); |
||
516 | } |
||
517 | else |
||
518 | { |
||
519 | |||
520 | this.PointSet.Add(tmp); |
||
521 | |||
522 | this.UpdateControl(); |
||
523 | } |
||
524 | a6272c57 | humkyung | } |
525 | d2114d3b | humkyung | |
526 | /// <summary> |
||
527 | /// move control point has same location of given pt along given delta |
||
528 | /// </summary> |
||
529 | /// <author>humkyung</author> |
||
530 | /// <date>2019.06.20</date> |
||
531 | /// <param name="pt"></param> |
||
532 | /// <param name="dx"></param> |
||
533 | /// <param name="dy"></param> |
||
534 | 233ef333 | taeseongkim | public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false) |
535 | d2114d3b | humkyung | { |
536 | 902faaea | taeseongkim | var pointSet = (this as IPath).PointSet; |
537 | 233ef333 | taeseongkim | |
538 | 902faaea | taeseongkim | Point selected = MathSet.getNearPoint(pointSet, pt); |
539 | |||
540 | Point NearStartpoint = MathSet.getNearPoint(pointSet, pt); |
||
541 | |||
542 | var tmpPointSet = pointSet.Select((x,inx)=> new { x,inx}); |
||
543 | |||
544 | var selectPoint = tmpPointSet.Where(x => x.x.Equals(pt)); |
||
545 | |||
546 | if(selectPoint.Count() > 0) |
||
547 | { |
||
548 | if (tmpPointSet.Count() > selectPoint.First().inx + 1) |
||
549 | { |
||
550 | NearStartpoint = pointSet[selectPoint.First().inx + 1]; |
||
551 | } |
||
552 | else |
||
553 | { |
||
554 | NearStartpoint = pointSet[selectPoint.First().inx - 1]; |
||
555 | } |
||
556 | } |
||
557 | 233ef333 | taeseongkim | |
558 | d2114d3b | humkyung | selected.X += dx; |
559 | selected.Y += dy; |
||
560 | 233ef333 | taeseongkim | |
561 | Point tmp = selected; |
||
562 | |||
563 | CommentAngle = MathSet.returnAngle(NearStartpoint, ref tmp, bAxisLocked); |
||
564 | |||
565 | if (bAxisLocked) |
||
566 | { |
||
567 | selected = tmp; |
||
568 | } |
||
569 | |||
570 | d2114d3b | humkyung | for (int i = 0; i < (this as IPath).PointSet.Count; i++) |
571 | { |
||
572 | if (pt.Equals((this as IPath).PointSet[i])) |
||
573 | { |
||
574 | (this as IPath).PointSet[i] = selected; |
||
575 | } |
||
576 | } |
||
577 | 0d00f9c8 | humkyung | this.UpdateControl(); |
578 | d2114d3b | humkyung | } |
579 | 787a4489 | KangIngu | |
580 | 036650a0 | humkyung | /// <summary> |
581 | 91efe37a | humkyung | /// return Polygon's area |
582 | /// </summary> |
||
583 | /// <author>humkyung</author> |
||
584 | /// <date>2019.06.13</date> |
||
585 | public override Rect ItemRect |
||
586 | { |
||
587 | get |
||
588 | { |
||
589 | double dMinX = double.MaxValue; |
||
590 | double dMinY = double.MaxValue; |
||
591 | double dMaxX = double.MinValue; |
||
592 | double dMaxY = double.MinValue; |
||
593 | foreach (Point pt in this.PointSet) |
||
594 | { |
||
595 | dMinX = Math.Min(dMinX, pt.X); |
||
596 | dMinY = Math.Min(dMinY, pt.Y); |
||
597 | dMaxX = Math.Max(dMaxX, pt.X); |
||
598 | dMaxY = Math.Max(dMaxY, pt.Y); |
||
599 | } |
||
600 | |||
601 | return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY)); |
||
602 | } |
||
603 | } |
||
604 | |||
605 | /// <summary> |
||
606 | 036650a0 | humkyung | /// Serialize this |
607 | /// </summary> |
||
608 | /// <param name="sUserId"></param> |
||
609 | /// <returns></returns> |
||
610 | public override string Serialize() |
||
611 | { |
||
612 | using (S_PolyControl STemp = new S_PolyControl()) |
||
613 | { |
||
614 | STemp.TransformPoint = "0|0"; |
||
615 | STemp.SizeSet = String.Format("{0}", this.LineSize); |
||
616 | STemp.StrokeColor = this.StrokeColor.Color.ToString(); |
||
617 | //STemp.StrokeColor = "#FF000FFF"; |
||
618 | STemp.Name = this.GetType().Name.ToString(); |
||
619 | //STemp.Toler = this.Toler; |
||
620 | STemp.PaintState = this.Paint; |
||
621 | STemp.Opac = this.Opacity; |
||
622 | STemp.UserID = this.UserID; |
||
623 | STemp.PaintState = this.Paint; |
||
624 | //강인구 추가(Chain인지 Polygon인지 구분) |
||
625 | STemp.Type = this.ControlType; |
||
626 | //STemp.IsTrans = this.isTransOn; |
||
627 | //STemp.IsChain = this.isChain; |
||
628 | STemp.PointSet = new List<Point>(); |
||
629 | STemp.DashSize = this.DashSize; |
||
630 | STemp.StartPoint = this.StartPoint; |
||
631 | STemp.EndPoint = this.EndPoint; |
||
632 | STemp.IsCompleted = this.IsCompleted; |
||
633 | foreach (var point in this.PointSet) |
||
634 | { |
||
635 | STemp.PointSet.Add(point); |
||
636 | } |
||
637 | ///강인구 추가(2017.11.02) |
||
638 | ///Memo 추가 |
||
639 | STemp.Memo = this.Memo; |
||
640 | |||
641 | return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize())); |
||
642 | } |
||
643 | } |
||
644 | |||
645 | 661b7416 | humkyung | /// <summary> |
646 | /// create a polygoncontrol from given string |
||
647 | /// </summary> |
||
648 | /// <param name="str"></param> |
||
649 | /// <returns></returns> |
||
650 | public static PolygonControl FromString(string str, SolidColorBrush brush, string sProjectNo) |
||
651 | { |
||
652 | using (S_PolyControl s = JsonSerializerHelper.JsonDeserialize<S_PolyControl>(str)) |
||
653 | { |
||
654 | string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
655 | return new PolygonControl |
||
656 | { |
||
657 | LineSize = Convert.ToDouble(data2.First()), |
||
658 | //Toler = s.Toler, |
||
659 | IsCompleted = s.IsCompleted, |
||
660 | //PointSet = new List<Point>(), |
||
661 | Opacity = s.Opac, |
||
662 | StrokeColor = brush, |
||
663 | //강인구 추가(Chain인지 Polygon인지 구분) |
||
664 | ControlType = s.Type, |
||
665 | DashSize = s.DashSize, |
||
666 | StartPoint = s.StartPoint, |
||
667 | EndPoint = s.EndPoint, |
||
668 | PointSet = s.PointSet, |
||
669 | UserID = s.UserID, |
||
670 | Paint = s.PaintState, |
||
671 | Memo = s.Memo |
||
672 | }; |
||
673 | } |
||
674 | } |
||
675 | 787a4489 | KangIngu | |
676 | |||
677 | #region Dispose |
||
678 | public void Dispose() |
||
679 | { |
||
680 | a6f7f9b6 | djkim | //GC.Collect(); |
681 | 24c5e56c | taeseongkim | ////GC.SuppressFinalize(this); |
682 | a6f7f9b6 | djkim | this.Base_PolyPath = null; |
683 | 787a4489 | KangIngu | } |
684 | #endregion |
||
685 | |||
686 | #region INotifyPropertyChanged |
||
687 | private void OnPropertyChanged(string name) |
||
688 | { |
||
689 | if (PropertyChanged != null) |
||
690 | { |
||
691 | PropertyChanged(this, new PropertyChangedEventArgs(name)); |
||
692 | } |
||
693 | } |
||
694 | |||
695 | public event PropertyChangedEventHandler PropertyChanged; |
||
696 | #endregion |
||
697 | } |
||
698 | |||
699 | public class StylusPointSet : INotifyPropertyChanged |
||
700 | { |
||
701 | public StylusPointSet() |
||
702 | { |
||
703 | if (pointSet == null) |
||
704 | pointSet = new List<Point>(); |
||
705 | } |
||
706 | |||
707 | public List<Point> _pointSet; |
||
708 | |||
709 | public List<Point> pointSet |
||
710 | { |
||
711 | get |
||
712 | { |
||
713 | return _pointSet; |
||
714 | } |
||
715 | set |
||
716 | { |
||
717 | _pointSet = value; |
||
718 | OnPropertyChanged("pointSet"); |
||
719 | } |
||
720 | } |
||
721 | |||
722 | #region INotifyPropertyChanged |
||
723 | private void OnPropertyChanged(string name) |
||
724 | { |
||
725 | if (PropertyChanged != null) |
||
726 | { |
||
727 | PropertyChanged(this, new PropertyChangedEventArgs(name)); |
||
728 | } |
||
729 | } |
||
730 | |||
731 | public event PropertyChangedEventHandler PropertyChanged; |
||
732 | #endregion |
||
733 | } |
||
734 | } |