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