markus / MarkupToPDF / Controls / Etc / SymControl.cs @ 31e0b8c1
이력 | 보기 | 이력해설 | 다운로드 (20.9 KB)
1 | 787a4489 | KangIngu | using System; |
---|---|---|---|
2 | using System.Net; |
||
3 | using System.Windows; |
||
4 | using System.Windows.Controls; |
||
5 | using System.Windows.Documents; |
||
6 | using System.Windows.Ink; |
||
7 | using System.Windows.Input; |
||
8 | using System.Windows.Media; |
||
9 | using System.Windows.Media.Animation; |
||
10 | using System.Windows.Shapes; |
||
11 | using System.ComponentModel; |
||
12 | using System.Collections.Generic; |
||
13 | using MarkupToPDF.Controls.Common; |
||
14 | using MarkupToPDF.Common; |
||
15 | 036650a0 | humkyung | using MarkupToPDF.Serialize.Core; |
16 | using MarkupToPDF.Serialize.S_Control; |
||
17 | 661b7416 | humkyung | using System.Linq; |
18 | 787a4489 | KangIngu | |
19 | namespace MarkupToPDF.Controls.Etc |
||
20 | { |
||
21 | [TemplatePart(Name = "PART_SymPath", Type = typeof(Path))] |
||
22 | [TemplatePart(Name = "PART_ViewBox", Type = typeof(Viewbox))] |
||
23 | |||
24 | public class SymControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IPath, IViewBox, IMarkupCommonData |
||
25 | { |
||
26 | #region 초기선언 |
||
27 | public enum SymStyleSet { None, Fill }; |
||
28 | private const string PART_ViewBox = "PART_ViewBox"; |
||
29 | private const string PART_SymPath = "PART_SymPath"; |
||
30 | public Viewbox Base_ViewBox = null; |
||
31 | public Path Base_SymPath = null; |
||
32 | #endregion |
||
33 | |||
34 | static SymControl() |
||
35 | { |
||
36 | DefaultStyleKeyProperty.OverrideMetadata(typeof(SymControl), new FrameworkPropertyMetadata(typeof(SymControl))); |
||
37 | //Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
||
38 | ResourceDictionary dictionary = new ResourceDictionary(); |
||
39 | dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
||
40 | Application.Current.Resources.MergedDictionaries.Add(dictionary); |
||
41 | System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count); |
||
42 | } |
||
43 | |||
44 | public void Dispose() |
||
45 | { |
||
46 | GC.Collect(); |
||
47 | GC.SuppressFinalize(this); |
||
48 | } |
||
49 | public event PropertyChangedEventHandler PropertyChanged; |
||
50 | protected void RaisePropertyChanged(string propName) |
||
51 | { |
||
52 | if (PropertyChanged != null) |
||
53 | PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
||
54 | } |
||
55 | #region Dependency Properties |
||
56 | public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
||
57 | "UserID", typeof(string), typeof(SymControl), new PropertyMetadata(null)); |
||
58 | public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
||
59 | "LineSize", typeof(double), typeof(SymControl), new PropertyMetadata((Double)1)); |
||
60 | public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
||
61 | "StrokeColor", typeof(SolidColorBrush), typeof(SymControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
||
62 | public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
||
63 | "PathData", typeof(Geometry), typeof(SymControl), null); |
||
64 | public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
||
65 | "EndPoint", typeof(Point), typeof(SymControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
66 | public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
||
67 | "StartPoint", typeof(Point), typeof(SymControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
68 | public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register( |
||
69 | "TopRightPoint", typeof(Point), typeof(SymControl), new PropertyMetadata(new Point(0, 0), TRPointValueChanged)); |
||
70 | public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register( |
||
71 | "LeftBottomPoint", typeof(Point), typeof(SymControl), new PropertyMetadata(new Point(0, 0), LBPointValueChanged)); |
||
72 | public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
||
73 | "PointSet", typeof(List<Point>), typeof(SymControl), new PropertyMetadata(new List<Point>())); |
||
74 | public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(SymControl), |
||
75 | new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
||
76 | public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(SymControl), |
||
77 | new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
78 | public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(SymControl), |
||
79 | new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
80 | public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
||
81 | "Paint", typeof(PaintSet), typeof(SymControl), new PropertyMetadata(PaintSet.None)); |
||
82 | |||
83 | public static readonly DependencyProperty IsSelectedProperty = |
||
84 | DependencyProperty.Register("IsSelected", typeof(bool), typeof(SymControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
||
85 | |||
86 | public static readonly DependencyProperty ControlTypeProperty = |
||
87 | DependencyProperty.Register("ControlType", typeof(ControlType), typeof(SymControl), new FrameworkPropertyMetadata(ControlType.Symbol)); |
||
88 | #endregion |
||
89 | #region PropertyChanged Method |
||
90 | public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
91 | { |
||
92 | var instance = (SymControl)sender; |
||
93 | if (e.OldValue != e.NewValue && instance.Base_SymPath != null) |
||
94 | { |
||
95 | instance.SetValue(e.Property, e.NewValue); |
||
96 | instance.SetSymPath(); |
||
97 | } |
||
98 | } |
||
99 | |||
100 | public static void TRPointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
101 | { |
||
102 | var instance = (SymControl)sender; |
||
103 | if (e.OldValue != e.NewValue && instance.Base_SymPath != null) |
||
104 | { |
||
105 | instance.SetValue(e.Property, e.NewValue); |
||
106 | instance.SetSymPath(); |
||
107 | } |
||
108 | } |
||
109 | public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
110 | { |
||
111 | |||
112 | } |
||
113 | public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
114 | { |
||
115 | var instance = (SymControl)sender; |
||
116 | if (e.OldValue != e.NewValue && instance.Base_SymPath != null) |
||
117 | { |
||
118 | instance.SetValue(e.Property, e.NewValue); |
||
119 | instance.SetSymPath(); |
||
120 | } |
||
121 | } |
||
122 | |||
123 | public static void LBPointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
124 | { |
||
125 | var instance = (SymControl)sender; |
||
126 | if (e.OldValue != e.NewValue && instance.Base_SymPath != null) |
||
127 | { |
||
128 | instance.SetValue(e.Property, e.NewValue); |
||
129 | //instance.EndPoint = new Point(instance.EndPoint.X, ((Point)e.NewValue).Y); |
||
130 | //instance.StartPoint = new Point(((Point)e.NewValue).X, instance.StartPoint.Y); |
||
131 | ////instance.PointSet[0] = instance.StartPoint; |
||
132 | ////instance.PointSet[2] = instance.EndPoint; |
||
133 | instance.SetSymPath(); |
||
134 | } |
||
135 | } |
||
136 | |||
137 | public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
138 | { |
||
139 | var instance = (SymControl)sender; |
||
140 | if (e.OldValue != e.NewValue && instance.Base_SymPath != null) |
||
141 | { |
||
142 | instance.SetValue(e.Property, e.NewValue); |
||
143 | instance.SetSymPath(); |
||
144 | } |
||
145 | } |
||
146 | #endregion |
||
147 | #region Properties |
||
148 | public string UserID |
||
149 | { |
||
150 | get { return (string)GetValue(UserIDProperty); } |
||
151 | set |
||
152 | { |
||
153 | if (this.UserID != value) |
||
154 | { |
||
155 | SetValue(UserIDProperty, value); |
||
156 | RaisePropertyChanged("UserID"); |
||
157 | } |
||
158 | } |
||
159 | } |
||
160 | public Double LineSize |
||
161 | { |
||
162 | get { return (Double)GetValue(LineSizeProperty); } |
||
163 | set |
||
164 | { |
||
165 | if (this.LineSize != value) |
||
166 | { |
||
167 | SetValue(LineSizeProperty, value); |
||
168 | } |
||
169 | } |
||
170 | } |
||
171 | public PaintSet Paint |
||
172 | { |
||
173 | get { return (PaintSet)GetValue(PaintProperty); } |
||
174 | set |
||
175 | { |
||
176 | if (this.Paint != value) |
||
177 | { |
||
178 | SetValue(PaintProperty, value); |
||
179 | } |
||
180 | } |
||
181 | } |
||
182 | public List<Point> PointSet |
||
183 | { |
||
184 | get { return (List<Point>)GetValue(PointSetProperty); } |
||
185 | set { SetValue(PointSetProperty, value); } |
||
186 | } |
||
187 | 554aae3b | humkyung | |
188 | public override double Angle |
||
189 | 787a4489 | KangIngu | { |
190 | get { return (double)GetValue(AngleProperty); } |
||
191 | set |
||
192 | { |
||
193 | if (this.Angle != value) |
||
194 | { |
||
195 | SetValue(AngleProperty, value); |
||
196 | } |
||
197 | } |
||
198 | } |
||
199 | public SolidColorBrush StrokeColor |
||
200 | { |
||
201 | get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
||
202 | set |
||
203 | { |
||
204 | if (this.StrokeColor != value) |
||
205 | { |
||
206 | SetValue(StrokeColorProperty, value); |
||
207 | } |
||
208 | } |
||
209 | } |
||
210 | public Geometry PathData |
||
211 | { |
||
212 | get { return (Geometry)GetValue(PathDataProperty); } |
||
213 | set |
||
214 | { |
||
215 | SetValue(PathDataProperty, value); |
||
216 | RaisePropertyChanged("PathData"); |
||
217 | } |
||
218 | } |
||
219 | public Point TopRightPoint |
||
220 | { |
||
221 | get { return (Point)GetValue(TopRightPointProperty); } |
||
222 | set |
||
223 | { |
||
224 | SetValue(TopRightPointProperty, value); |
||
225 | RaisePropertyChanged("TopRightPoint"); |
||
226 | } |
||
227 | } |
||
228 | public Point LeftBottomPoint |
||
229 | { |
||
230 | get { return (Point)GetValue(LeftBottomPointProperty); } |
||
231 | set |
||
232 | { |
||
233 | SetValue(LeftBottomPointProperty, value); |
||
234 | RaisePropertyChanged("LeftBottomPoint"); |
||
235 | } |
||
236 | } |
||
237 | public Point EndPoint |
||
238 | { |
||
239 | get { return (Point)GetValue(EndPointProperty); } |
||
240 | set |
||
241 | { |
||
242 | SetValue(EndPointProperty, value); |
||
243 | RaisePropertyChanged("EndPoint"); |
||
244 | } |
||
245 | } |
||
246 | public Point StartPoint |
||
247 | { |
||
248 | get { return (Point)GetValue(StartPointProperty); } |
||
249 | set |
||
250 | { |
||
251 | SetValue(StartPointProperty, value); |
||
252 | RaisePropertyChanged("StartPoint"); |
||
253 | } |
||
254 | } |
||
255 | public double CenterX |
||
256 | { |
||
257 | get { return (double)GetValue(CenterXProperty); } |
||
258 | set { SetValue(CenterXProperty, value); } |
||
259 | } |
||
260 | public double CenterY |
||
261 | { |
||
262 | get { return (double)GetValue(CenterYProperty); } |
||
263 | set { SetValue(CenterYProperty, value); } |
||
264 | } |
||
265 | public double AngleValue |
||
266 | { |
||
267 | get { return (double)GetValue(AngleProperty); } |
||
268 | set { SetValue(AngleProperty, value); } |
||
269 | } |
||
270 | 959b3ef2 | humkyung | public override bool IsSelected |
271 | 787a4489 | KangIngu | { |
272 | get |
||
273 | { |
||
274 | return (bool)GetValue(IsSelectedProperty); |
||
275 | } |
||
276 | set |
||
277 | { |
||
278 | SetValue(IsSelectedProperty, value); |
||
279 | } |
||
280 | } |
||
281 | |||
282 | 5529d2a2 | humkyung | public override ControlType ControlType |
283 | 787a4489 | KangIngu | { |
284 | set |
||
285 | { |
||
286 | SetValue(ControlTypeProperty, value); |
||
287 | } |
||
288 | get |
||
289 | { |
||
290 | return (ControlType)GetValue(ControlTypeProperty); |
||
291 | } |
||
292 | } |
||
293 | |||
294 | #endregion |
||
295 | public override void OnApplyTemplate() |
||
296 | { |
||
297 | base.OnApplyTemplate(); |
||
298 | Base_ViewBox = GetTemplateChild(PART_ViewBox) as Viewbox; |
||
299 | Base_SymPath = GetTemplateChild(PART_SymPath) as Path; |
||
300 | SetSymPath(); |
||
301 | } |
||
302 | 661b7416 | humkyung | |
303 | private void SetSymPath() |
||
304 | 787a4489 | KangIngu | { |
305 | this.ApplyTemplate(); |
||
306 | switch (this.Paint) |
||
307 | { |
||
308 | case PaintSet.None: |
||
309 | Base_SymPath.Fill = null; |
||
310 | break; |
||
311 | case PaintSet.Fill: |
||
312 | Base_SymPath.Fill = this.StrokeColor; |
||
313 | break; |
||
314 | default: |
||
315 | break; |
||
316 | } |
||
317 | |||
318 | Point mid = MathSet.FindCentroid(new List<Point>() |
||
319 | { |
||
320 | this.StartPoint, |
||
321 | this.LeftBottomPoint, |
||
322 | this.EndPoint, |
||
323 | this.TopRightPoint, |
||
324 | }); |
||
325 | |||
326 | double AngleData = this.Angle * -1; |
||
327 | |||
328 | PathFigure pathFigure = new PathFigure(); |
||
329 | pathFigure.StartPoint = MathSet.RotateAbout(mid, this.StartPoint, AngleData); |
||
330 | |||
331 | LineSegment lineSegment0 = new LineSegment(); |
||
332 | lineSegment0.Point = MathSet.RotateAbout(mid, this.StartPoint, AngleData); |
||
333 | pathFigure.Segments.Add(lineSegment0); |
||
334 | |||
335 | LineSegment lineSegment1 = new LineSegment(); |
||
336 | lineSegment1.Point = MathSet.RotateAbout(mid, this.LeftBottomPoint, AngleData); |
||
337 | pathFigure.Segments.Add(lineSegment1); |
||
338 | |||
339 | LineSegment lineSegment2 = new LineSegment(); |
||
340 | lineSegment2.Point = MathSet.RotateAbout(mid, this.EndPoint, AngleData); |
||
341 | pathFigure.Segments.Add(lineSegment2); |
||
342 | |||
343 | LineSegment lineSegment3 = new LineSegment(); |
||
344 | lineSegment3.Point = MathSet.RotateAbout(mid, this.TopRightPoint, AngleData); |
||
345 | pathFigure.Segments.Add(lineSegment3); |
||
346 | |||
347 | PathGeometry pathGeometry = new PathGeometry(); |
||
348 | pathGeometry.Figures = new PathFigureCollection(); |
||
349 | pathFigure.IsClosed = true; |
||
350 | pathGeometry.Figures.Add(pathFigure); |
||
351 | this.Base_ViewBox.Width = pathGeometry.Bounds.Width; |
||
352 | this.Base_ViewBox.Height = pathGeometry.Bounds.Height; ; |
||
353 | this.Tag = pathGeometry; |
||
354 | |||
355 | Canvas.SetLeft(this, MathSet.RotateAbout(mid, mid, AngleData).X - this.Base_ViewBox.Width / 2); |
||
356 | Canvas.SetTop(this, MathSet.RotateAbout(mid, mid, AngleData).Y - this.Base_ViewBox.Height / 2); |
||
357 | |||
358 | } |
||
359 | 0d00f9c8 | humkyung | |
360 | public override void UpdateControl() |
||
361 | 787a4489 | KangIngu | { |
362 | this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
||
363 | this.LeftBottomPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
||
364 | this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
||
365 | this.TopRightPoint = new Point(this.PointSet[3].X, this.PointSet[3].Y); |
||
366 | this.SetSymPath(); |
||
367 | } |
||
368 | |||
369 | |||
370 | public void ChangePaint(PaintSet state) |
||
371 | { |
||
372 | this.Paint = state; |
||
373 | this.SetSymPath(); |
||
374 | } |
||
375 | 036650a0 | humkyung | |
376 | /// <summary> |
||
377 | a6272c57 | humkyung | /// call when mouse is moving while drawing control |
378 | /// </summary> |
||
379 | /// <author>humkyung</author> |
||
380 | /// <param name="pt"></param> |
||
381 | /// <param name="bAxisLocked"></param> |
||
382 | public override void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed) |
||
383 | { |
||
384 | this.EndPoint = pt; |
||
385 | this.LeftBottomPoint = new Point(this.StartPoint.X, this.EndPoint.Y); |
||
386 | this.TopRightPoint = new Point(this.EndPoint.X, this.StartPoint.Y); |
||
387 | |||
388 | this.StrokeColor = new SolidColorBrush(Colors.Red); |
||
389 | |||
390 | if (this.StartPoint != this.EndPoint) |
||
391 | { |
||
392 | if (this.PathData == null) |
||
393 | { |
||
394 | using (StringToPathConverter Convert = new StringToPathConverter()) |
||
395 | { |
||
396 | this.PathData = Convert.Convert("M-5,5L0,0L20,30L40,-20 "); |
||
397 | } |
||
398 | } |
||
399 | } |
||
400 | |||
401 | this.PointSet = new List<Point> |
||
402 | { |
||
403 | this.StartPoint, |
||
404 | this.LeftBottomPoint, |
||
405 | this.EndPoint, |
||
406 | this.TopRightPoint, |
||
407 | }; |
||
408 | } |
||
409 | |||
410 | /// <summary> |
||
411 | d2114d3b | humkyung | /// move control point has same location of given pt along given delta |
412 | /// </summary> |
||
413 | /// <author>humkyung</author> |
||
414 | /// <date>2019.06.20</date> |
||
415 | /// <param name="pt"></param> |
||
416 | /// <param name="dx"></param> |
||
417 | /// <param name="dy"></param> |
||
418 | public override void OnMoveCtrlPoint(Point pt, double dx, double dy) |
||
419 | { |
||
420 | IPath path = (this as IPath); |
||
421 | |||
422 | Point selected = MathSet.getNearPoint(path.PointSet, pt); |
||
423 | selected.X += dx; |
||
424 | selected.Y += dy; |
||
425 | int i = 0; |
||
426 | for (i = 0; i < (this as IPath).PointSet.Count; i++) |
||
427 | { |
||
428 | if (pt.Equals((this as IPath).PointSet[i])) |
||
429 | { |
||
430 | path.PointSet[i] = selected; |
||
431 | break; |
||
432 | } |
||
433 | } |
||
434 | |||
435 | var ReverseP = (i + path.PointSet.Count / 2) % path.PointSet.Count; |
||
436 | var PreviousP = (i + (path.PointSet.Count - 1)) % path.PointSet.Count; |
||
437 | var NextP = (i + 1) % path.PointSet.Count; |
||
438 | |||
439 | var distance = MathSet.DistanceTo(path.PointSet[ReverseP], path.PointSet[i]); |
||
440 | |||
441 | var PreviousV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[PreviousP]); |
||
442 | var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, |
||
443 | path.PointSet[i].Y - path.PointSet[ReverseP].Y); |
||
444 | path.PointSet[PreviousP] = new Point(path.PointSet[ReverseP].X + PreviousV.X * l, path.PointSet[ReverseP].Y + PreviousV.Y * l); |
||
445 | |||
446 | var NextV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[NextP]); |
||
447 | l = MathSet.DotProduct(NextV.X, NextV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, path.PointSet |
||
448 | [i].Y - path.PointSet[ReverseP].Y); |
||
449 | path.PointSet[NextP] = new Point(path.PointSet[ReverseP].X + NextV.X * l, path.PointSet[ReverseP].Y + NextV.Y * l); |
||
450 | |||
451 | 0d00f9c8 | humkyung | this.UpdateControl(); |
452 | d2114d3b | humkyung | } |
453 | |||
454 | /// <summary> |
||
455 | 91efe37a | humkyung | /// return SymControl's area |
456 | /// </summary> |
||
457 | /// <author>humkyung</author> |
||
458 | /// <date>2019.06.13</date> |
||
459 | public override Rect ItemRect |
||
460 | { |
||
461 | get |
||
462 | { |
||
463 | double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X); |
||
464 | double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y); |
||
465 | double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X); |
||
466 | double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y); |
||
467 | |||
468 | return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY)); |
||
469 | } |
||
470 | } |
||
471 | |||
472 | /// <summary> |
||
473 | 036650a0 | humkyung | /// Serialize this |
474 | /// </summary> |
||
475 | /// <param name="sUserId"></param> |
||
476 | /// <returns></returns> |
||
477 | public override string Serialize() |
||
478 | { |
||
479 | using (S_SymControl STemp = new S_SymControl()) |
||
480 | { |
||
481 | STemp.TransformPoint = "0|0"; |
||
482 | STemp.PointSet = this.PointSet; |
||
483 | STemp.UserID = this.UserID; |
||
484 | STemp.SizeSet = String.Format("{0}", this.LineSize.ToString()); |
||
485 | STemp.PaintState = this.Paint; |
||
486 | STemp.PathInfo = this.PathData.ToString(); |
||
487 | STemp.StrokeColor = this.StrokeColor.Color.ToString(); |
||
488 | STemp.StartPoint = this.StartPoint; |
||
489 | STemp.Angle = this.Angle; |
||
490 | STemp.EndPoint = this.EndPoint; |
||
491 | STemp.LB = this.LeftBottomPoint; |
||
492 | STemp.TR = this.TopRightPoint; |
||
493 | STemp.Opac = this.Opacity; |
||
494 | STemp.Name = this.GetType().Name.ToString(); |
||
495 | |||
496 | return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize())); |
||
497 | } |
||
498 | } |
||
499 | 661b7416 | humkyung | |
500 | /// <summary> |
||
501 | /// create a symcontrol from given string |
||
502 | /// </summary> |
||
503 | /// <param name="str"></param> |
||
504 | /// <returns></returns> |
||
505 | public static SymControl FromString(string str, SolidColorBrush brush, string sProjectNo) |
||
506 | { |
||
507 | SymControl instance = null; |
||
508 | using (S_SymControl s = JsonSerializerHelper.JsonDeserialize<S_SymControl>(str)) |
||
509 | { |
||
510 | string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
511 | Common.StringToPathConverter sm = new Common.StringToPathConverter(); |
||
512 | instance = new SymControl |
||
513 | { |
||
514 | LineSize = Convert.ToDouble(data2.First()), |
||
515 | PointSet = s.PointSet, |
||
516 | Paint = s.PaintState, |
||
517 | StartPoint = s.StartPoint, |
||
518 | StrokeColor = brush, |
||
519 | EndPoint = s.EndPoint, |
||
520 | Angle = s.Angle, |
||
521 | UserID = s.UserID, |
||
522 | LeftBottomPoint = s.LB, |
||
523 | TopRightPoint = s.TR, |
||
524 | PathData = sm.Convert(s.PathInfo.ToString()), |
||
525 | Opacity = s.Opac, |
||
526 | Memo = s.Memo |
||
527 | }; |
||
528 | } |
||
529 | |||
530 | return instance; |
||
531 | } |
||
532 | 787a4489 | KangIngu | } |
533 | } |