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