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