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