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