markus / MarkupToPDF / Controls / Line / ArrowArcControl.cs @ fd19a116
이력 | 보기 | 이력해설 | 다운로드 (23.4 KB)
1 | 40b3ce25 | ljiyeon | 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 | 40b3ce25 | ljiyeon | |
19 | namespace MarkupToPDF.Controls.Line |
||
20 | { |
||
21 | |||
22 | 37eadd3f | humkyung | public class ArrowArcControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IDashControl |
23 | 40b3ce25 | ljiyeon | { |
24 | #region 초기선언 |
||
25 | public event PropertyChangedEventHandler PropertyChanged; |
||
26 | private const string PART_ArcPath = "PART_ArcPath"; |
||
27 | public Path Base_ArcPath = null; |
||
28 | #endregion |
||
29 | static ArrowArcControl() |
||
30 | { |
||
31 | DefaultStyleKeyProperty.OverrideMetadata(typeof(ArrowArcControl), new FrameworkPropertyMetadata(typeof(ArrowArcControl))); |
||
32 | //Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
||
33 | a6f7f9b6 | djkim | //ResourceDictionary dictionary = new ResourceDictionary(); |
34 | //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
||
35 | //Application.Current.Resources.MergedDictionaries.Add(dictionary); |
||
36 | 40b3ce25 | ljiyeon | //System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count); |
37 | } |
||
38 | |||
39 | public ArrowArcControl() |
||
40 | { |
||
41 | a6f7f9b6 | djkim | //this.DefaultStyleKey = typeof(ArrowArcControl); |
42 | 40b3ce25 | ljiyeon | } |
43 | |||
44 | 37eadd3f | humkyung | public override void Copy(CommentUserInfo lhs) |
45 | { |
||
46 | e1b36bc0 | humkyung | if (lhs is ArrowArcControl item) |
47 | 37eadd3f | humkyung | { |
48 | e1b36bc0 | humkyung | this.StartPoint = new Point(item.StartPoint.X, item.StartPoint.Y); |
49 | this.EndPoint = new Point(item.EndPoint.X, item.EndPoint.Y); |
||
50 | this.DashSize = item.DashSize; |
||
51 | this.PointSet = item.PointSet.ConvertAll(x => new Point(x.X, x.Y)); |
||
52 | this.isTransOn = item.isTransOn; |
||
53 | this.MiddlePoint = new Point(item.MiddlePoint.X, item.MiddlePoint.Y); |
||
54 | this.StrokeColor = item.StrokeColor; |
||
55 | this.Opacity = item.Opacity; |
||
56 | |||
57 | this.Clock = item.Clock; |
||
58 | this.LineSize = item.LineSize; |
||
59 | this.UserID = item.UserID; |
||
60 | this.Memo = item.Memo; |
||
61 | this.ZIndex = item.ZIndex; |
||
62 | GroupID = item.GroupID; |
||
63 | 37eadd3f | humkyung | } |
64 | } |
||
65 | |||
66 | public override CommentUserInfo Clone() |
||
67 | { |
||
68 | var clone = new ArrowArcControl(); |
||
69 | clone.Copy(this); |
||
70 | return clone; |
||
71 | } |
||
72 | |||
73 | 40b3ce25 | ljiyeon | public void Dispose() |
74 | { |
||
75 | a6f7f9b6 | djkim | //GC.Collect(); |
76 | 24c5e56c | taeseongkim | ////GC.SuppressFinalize(this); |
77 | a6f7f9b6 | djkim | //Control control = new Control(); |
78 | this.Base_ArcPath = null; |
||
79 | 40b3ce25 | ljiyeon | } |
80 | protected void OnPropertyChanged(string propName) |
||
81 | { |
||
82 | if (PropertyChanged != null) |
||
83 | PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
||
84 | } |
||
85 | |||
86 | #region Dependency Properties |
||
87 | |||
88 | |||
89 | |||
90 | public static readonly DependencyProperty IsSelectedProperty = |
||
91 | DependencyProperty.Register("IsSelected", typeof(bool), typeof(ArrowArcControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
||
92 | |||
93 | public static readonly DependencyProperty ControlTypeProperty = |
||
94 | DependencyProperty.Register("ControlType", typeof(ControlType), typeof(ArrowArcControl), new FrameworkPropertyMetadata(ControlType.ArcArrow)); |
||
95 | |||
96 | public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
||
97 | "OverViewPathData", typeof(Geometry), typeof(ArrowArcControl), new PropertyMetadata(null)); |
||
98 | |||
99 | public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
||
100 | "UserID", typeof(string), typeof(ArrowArcControl), new PropertyMetadata(null)); |
||
101 | |||
102 | public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
||
103 | "LineSize", typeof(double), typeof(ArrowArcControl), new PropertyMetadata((Double)3, PointValueChanged)); |
||
104 | |||
105 | public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
||
106 | "DashSize", typeof(DoubleCollection), typeof(ArrowArcControl), new PropertyMetadata(new DoubleCollection { 99999999 }, PointValueChanged)); |
||
107 | |||
108 | public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
||
109 | "StrokeColor", typeof(SolidColorBrush), typeof(ArrowArcControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
||
110 | |||
111 | public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
||
112 | "PathData", typeof(Geometry), typeof(ArrowArcControl), null); |
||
113 | |||
114 | //public static readonly DependencyProperty ClockProperty = DependencyProperty.Register( |
||
115 | // "Clock", typeof(SweepDirection), typeof(ArrowArcControl), new PropertyMetadata(SweepDirection.Clockwise)); |
||
116 | public static readonly DependencyProperty ClockProperty = DependencyProperty.Register( |
||
117 | "Clock", typeof(bool), typeof(ArrowArcControl), new PropertyMetadata(false)); |
||
118 | |||
119 | public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
||
120 | "StartPoint", typeof(Point), typeof(ArrowArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
121 | public static readonly DependencyProperty MidPointProperty = DependencyProperty.Register( |
||
122 | "MidPoint", typeof(Point), typeof(ArrowArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
123 | |||
124 | public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
||
125 | "EndPoint", typeof(Point), typeof(ArrowArcControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
126 | |||
127 | public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
||
128 | "PointSet", typeof(List<Point>), typeof(ArrowArcControl), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
||
129 | |||
130 | public static readonly DependencyProperty isTransOnProperty = DependencyProperty.Register( |
||
131 | "isTransOn", typeof(bool), typeof(ArrowArcControl), new PropertyMetadata(false)); |
||
132 | |||
133 | public static readonly DependencyProperty AngleProperty = |
||
134 | DependencyProperty.Register("AngleValue", typeof(double), typeof(ArrowArcControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback |
||
135 | (AngleValueChanged))); |
||
136 | |||
137 | public static readonly DependencyProperty CenterXProperty = |
||
138 | DependencyProperty.Register("CenterX", typeof(double), typeof(ArrowArcControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
139 | |||
140 | public static readonly DependencyProperty CenterYProperty = |
||
141 | DependencyProperty.Register("CenterY", typeof(double), typeof(ArrowArcControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
142 | #endregion |
||
143 | #region PropertyChanged Method |
||
144 | |||
145 | public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
146 | { |
||
147 | //var instance = (ArrowArcControl)sender; |
||
148 | |||
149 | //if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
||
150 | //{ |
||
151 | |||
152 | // instance.SetValue(e.Property, e.NewValue); |
||
153 | |||
154 | // if (instance.IsSelected) |
||
155 | // { |
||
156 | // instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Blue); |
||
157 | // } |
||
158 | // else |
||
159 | // { |
||
160 | // instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Red); |
||
161 | // } |
||
162 | //} |
||
163 | } |
||
164 | |||
165 | public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
166 | { |
||
167 | var instance = (ArrowArcControl)sender; |
||
168 | if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
||
169 | { |
||
170 | instance.SetValue(e.Property, e.NewValue); |
||
171 | instance.SetArcPath(); |
||
172 | } |
||
173 | } |
||
174 | public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
175 | { |
||
176 | var instance = (ArrowArcControl)sender; |
||
177 | if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
||
178 | { |
||
179 | instance.SetValue(e.Property, e.NewValue); |
||
180 | instance.SetArcPath(); |
||
181 | } |
||
182 | } |
||
183 | public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
184 | { |
||
185 | var instance = (ArrowArcControl)sender; |
||
186 | if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
||
187 | { |
||
188 | instance.SetValue(e.Property, e.NewValue); |
||
189 | instance.SetArcPath(); |
||
190 | } |
||
191 | } |
||
192 | |||
193 | |||
194 | |||
195 | #endregion |
||
196 | #region Properties |
||
197 | public string UserID |
||
198 | { |
||
199 | get { return (string)GetValue(UserIDProperty); } |
||
200 | set |
||
201 | { |
||
202 | if (this.UserID != value) |
||
203 | { |
||
204 | SetValue(UserIDProperty, value); |
||
205 | OnPropertyChanged("UserID"); |
||
206 | } |
||
207 | } |
||
208 | } |
||
209 | public Double LineSize |
||
210 | { |
||
211 | get { return (Double)GetValue(LineSizeProperty); } |
||
212 | set |
||
213 | { |
||
214 | if (this.LineSize != value) |
||
215 | { |
||
216 | SetValue(LineSizeProperty, value); |
||
217 | } |
||
218 | } |
||
219 | } |
||
220 | |||
221 | |||
222 | public bool Clock |
||
223 | { |
||
224 | get { return (bool)GetValue(ClockProperty); } |
||
225 | set |
||
226 | { |
||
227 | if (this.Clock != value) |
||
228 | { |
||
229 | SetValue(ClockProperty, value); |
||
230 | OnPropertyChanged("Clock"); |
||
231 | } |
||
232 | } |
||
233 | } |
||
234 | |||
235 | //public SweepDirection Clock |
||
236 | //{ |
||
237 | // get { return (SweepDirection)GetValue(ClockProperty); } |
||
238 | // set |
||
239 | // { |
||
240 | // if (this.Clock != value) |
||
241 | // { |
||
242 | // SetValue(ClockProperty, value); |
||
243 | // OnPropertyChanged("Clock"); |
||
244 | // } |
||
245 | // } |
||
246 | //} |
||
247 | public DoubleCollection DashSize |
||
248 | { |
||
249 | get { return (DoubleCollection)GetValue(DashSizeProperty); } |
||
250 | set |
||
251 | { |
||
252 | if (this.DashSize != value) |
||
253 | { |
||
254 | SetValue(DashSizeProperty, value); |
||
255 | } |
||
256 | } |
||
257 | } |
||
258 | public List<Point> PointSet |
||
259 | { |
||
260 | get { return (List<Point>)GetValue(PointSetProperty); } |
||
261 | set { SetValue(PointSetProperty, value); } |
||
262 | } |
||
263 | public double CenterX |
||
264 | { |
||
265 | get { return (double)GetValue(CenterXProperty); } |
||
266 | set { SetValue(CenterXProperty, value); } |
||
267 | } |
||
268 | public double CenterY |
||
269 | { |
||
270 | get { return (double)GetValue(CenterYProperty); } |
||
271 | set { SetValue(CenterYProperty, value); } |
||
272 | } |
||
273 | 4913851c | humkyung | public override SolidColorBrush StrokeColor |
274 | 40b3ce25 | ljiyeon | { |
275 | get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
||
276 | set |
||
277 | { |
||
278 | if (this.StrokeColor != value) |
||
279 | { |
||
280 | SetValue(StrokeColorProperty, value); |
||
281 | } |
||
282 | } |
||
283 | } |
||
284 | |||
285 | public Geometry OverViewPathData |
||
286 | { |
||
287 | get |
||
288 | { |
||
289 | return (Geometry)GetValue(OverViewPathDataProperty); |
||
290 | } |
||
291 | set |
||
292 | { |
||
293 | SetValue(OverViewPathDataProperty, value); |
||
294 | OnPropertyChanged("OverViewPathData"); |
||
295 | } |
||
296 | } |
||
297 | |||
298 | public Geometry PathData |
||
299 | { |
||
300 | get { return (Geometry)GetValue(PathDataProperty); } |
||
301 | set |
||
302 | { |
||
303 | SetValue(PathDataProperty, value); |
||
304 | OnPropertyChanged("PathData"); |
||
305 | } |
||
306 | } |
||
307 | 959b3ef2 | humkyung | public override bool IsSelected |
308 | 40b3ce25 | ljiyeon | { |
309 | get |
||
310 | { |
||
311 | return (bool)GetValue(IsSelectedProperty); |
||
312 | } |
||
313 | set |
||
314 | { |
||
315 | SetValue(IsSelectedProperty, value); |
||
316 | } |
||
317 | } |
||
318 | |||
319 | 5529d2a2 | humkyung | public override ControlType ControlType |
320 | 40b3ce25 | ljiyeon | { |
321 | get |
||
322 | { |
||
323 | return (ControlType)GetValue(ControlTypeProperty); |
||
324 | } |
||
325 | set |
||
326 | { |
||
327 | SetValue(ControlTypeProperty, value); |
||
328 | OnPropertyChanged("ControlType"); |
||
329 | } |
||
330 | } |
||
331 | public double AngleValue |
||
332 | { |
||
333 | get { return (double)GetValue(AngleProperty); } |
||
334 | set { SetValue(AngleProperty, value); } |
||
335 | } |
||
336 | 168f8027 | taeseongkim | |
337 | |||
338 | //public double Angle |
||
339 | //{ |
||
340 | // get { return (double)GetValue(AngleProperty); } |
||
341 | // set |
||
342 | // { |
||
343 | // if (this.Angle != value) |
||
344 | // { |
||
345 | // SetValue(AngleProperty, value); |
||
346 | // } |
||
347 | // } |
||
348 | //} |
||
349 | |||
350 | 40b3ce25 | ljiyeon | public Point EndPoint |
351 | { |
||
352 | get { return (Point)GetValue(EndPointProperty); } |
||
353 | set |
||
354 | { |
||
355 | SetValue(EndPointProperty, value); |
||
356 | OnPropertyChanged("EndPoint"); |
||
357 | } |
||
358 | } |
||
359 | public Point StartPoint |
||
360 | { |
||
361 | get { return (Point)GetValue(StartPointProperty); } |
||
362 | set |
||
363 | { |
||
364 | SetValue(StartPointProperty, value); |
||
365 | OnPropertyChanged("StartPoint"); |
||
366 | } |
||
367 | } |
||
368 | 24c5e56c | taeseongkim | public Point MiddlePoint |
369 | 40b3ce25 | ljiyeon | { |
370 | get { return (Point)GetValue(MidPointProperty); } |
||
371 | set |
||
372 | { |
||
373 | SetValue(MidPointProperty, value); |
||
374 | 24c5e56c | taeseongkim | OnPropertyChanged("MiddlePoint"); |
375 | 40b3ce25 | ljiyeon | } |
376 | } |
||
377 | public bool isTransOn |
||
378 | { |
||
379 | get { return (bool)GetValue(isTransOnProperty); } |
||
380 | set |
||
381 | { |
||
382 | SetValue(isTransOnProperty, value); |
||
383 | OnPropertyChanged("isTransOn"); |
||
384 | } |
||
385 | } |
||
386 | |||
387 | #endregion |
||
388 | #region Object & Variable |
||
389 | PathGeometry pathGeometry = new PathGeometry(); |
||
390 | GeometryGroup instanceGroup = new GeometryGroup(); |
||
391 | #endregion |
||
392 | public override void OnApplyTemplate() |
||
393 | { |
||
394 | base.OnApplyTemplate(); |
||
395 | Base_ArcPath = GetTemplateChild(PART_ArcPath) as Path; |
||
396 | SetArcPath(); |
||
397 | } |
||
398 | 0d00f9c8 | humkyung | |
399 | public override void UpdateControl() |
||
400 | 40b3ce25 | ljiyeon | { |
401 | this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
||
402 | 24c5e56c | taeseongkim | this.MiddlePoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
403 | 40b3ce25 | ljiyeon | this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
404 | } |
||
405 | |||
406 | public void setClock() |
||
407 | { |
||
408 | if (Clock) |
||
409 | { |
||
410 | this.Clock = false; |
||
411 | } |
||
412 | else |
||
413 | { |
||
414 | this.Clock = true; |
||
415 | } |
||
416 | } |
||
417 | |||
418 | //public void setClock() |
||
419 | //{ |
||
420 | // if(this.Clock == SweepDirection.Clockwise) |
||
421 | // { |
||
422 | // this.Clock = SweepDirection.Counterclockwise; |
||
423 | // } |
||
424 | // else |
||
425 | // { |
||
426 | // this.Clock =SweepDirection.Clockwise; |
||
427 | // } |
||
428 | //} |
||
429 | public void SetArcPath() |
||
430 | { |
||
431 | this.ApplyTemplate(); |
||
432 | |||
433 | |||
434 | //강인구 추가 |
||
435 | Base_ArcPath.StrokeDashArray.Clear(); |
||
436 | if (this.DashSize != null) |
||
437 | { |
||
438 | foreach (var item in this.DashSize) |
||
439 | { |
||
440 | Base_ArcPath.StrokeDashArray.Add(item); |
||
441 | } |
||
442 | Base_ArcPath.StrokeDashCap = PenLineCap.Square; |
||
443 | instanceGroup.Children.Clear(); |
||
444 | } |
||
445 | PathFigure pathFigure = new PathFigure(); |
||
446 | |||
447 | pathFigure.StartPoint = this.StartPoint; |
||
448 | QuadraticBezierSegment qb = new QuadraticBezierSegment(); |
||
449 | |||
450 | 24c5e56c | taeseongkim | if (MiddlePoint != null) |
451 | 40b3ce25 | ljiyeon | { |
452 | 24c5e56c | taeseongkim | if (MiddlePoint == new Point(0,0)) |
453 | 40b3ce25 | ljiyeon | { |
454 | double xSharp = 0; |
||
455 | double ySharp = 0; |
||
456 | |||
457 | //Point t_start = new Point(0, 0); |
||
458 | //Point t_end = new Point(30, 10); |
||
459 | |||
460 | var midP = MathSet.getMiddlePoint(StartPoint, EndPoint); |
||
461 | Point normalV = MathSet.GetNormVectorBetween(StartPoint, EndPoint); |
||
462 | var dis = MathSet.DistanceTo(StartPoint, EndPoint); |
||
463 | |||
464 | if (!this.Clock) |
||
465 | { |
||
466 | xSharp = -normalV.Y; |
||
467 | ySharp = normalV.X; |
||
468 | } |
||
469 | else |
||
470 | { |
||
471 | xSharp = normalV.Y; |
||
472 | ySharp = -normalV.X; |
||
473 | } |
||
474 | |||
475 | var pointN = new Point(xSharp * dis, ySharp * dis); |
||
476 | 24c5e56c | taeseongkim | MiddlePoint = new Point(pointN.X + midP.X, pointN.Y + midP.Y); |
477 | 40b3ce25 | ljiyeon | } |
478 | 24c5e56c | taeseongkim | qb.Point1 = this.MiddlePoint; |
479 | 40b3ce25 | ljiyeon | } |
480 | |||
481 | qb.Point2 = this.EndPoint; |
||
482 | pathFigure.Segments.Add(qb); |
||
483 | pathGeometry.Figures = new PathFigureCollection(); |
||
484 | pathGeometry.Figures.Add(pathFigure); |
||
485 | pathFigure.IsFilled = false; |
||
486 | pathFigure.IsClosed = false; |
||
487 | instanceGroup.Children.Add(pathGeometry); |
||
488 | |||
489 | 24c5e56c | taeseongkim | instanceGroup.Children.Add(DrawSet.DrawArrow(this.MiddlePoint, this.StartPoint, this.LineSize)); |
490 | instanceGroup.Children.Add(DrawSet.DrawArrow(this.MiddlePoint, this.EndPoint, this.LineSize)); |
||
491 | 40b3ce25 | ljiyeon | this.Base_ArcPath.Fill = this.StrokeColor; |
492 | |||
493 | instanceGroup.FillRule = FillRule.Nonzero; |
||
494 | this.PathData = instanceGroup; |
||
495 | this.OverViewPathData = PathData; |
||
496 | |||
497 | } |
||
498 | d251456f | humkyung | |
499 | f513c215 | humkyung | public override void ApplyOverViewData() |
500 | 40b3ce25 | ljiyeon | { |
501 | this.OverViewPathData = this.PathData; |
||
502 | } |
||
503 | 036650a0 | humkyung | |
504 | /// <summary> |
||
505 | a6272c57 | humkyung | /// call when mouse is moving while drawing control |
506 | /// </summary> |
||
507 | /// <author>humkyung</author> |
||
508 | /// <param name="pt"></param> |
||
509 | /// <param name="bAxisLocked"></param> |
||
510 | 233ef333 | taeseongkim | public override void OnCreatingMouseMove(Point pt, bool bAxisLocked) |
511 | a6272c57 | humkyung | { |
512 | this.isTransOn = false; |
||
513 | 24c5e56c | taeseongkim | this.MiddlePoint = new Point(0, 0); |
514 | a6272c57 | humkyung | this.EndPoint = pt; |
515 | 168f8027 | taeseongkim | |
516 | Point tmp = this.EndPoint; |
||
517 | 233ef333 | taeseongkim | CommentAngle = MathSet.returnAngle(this.StartPoint, ref tmp, bAxisLocked); |
518 | 168f8027 | taeseongkim | |
519 | 233ef333 | taeseongkim | if (bAxisLocked) |
520 | a6272c57 | humkyung | { |
521 | this.EndPoint = tmp; |
||
522 | } |
||
523 | |||
524 | this.PointSet = new List<Point> |
||
525 | { |
||
526 | this.StartPoint, |
||
527 | 24c5e56c | taeseongkim | this.MiddlePoint, |
528 | a6272c57 | humkyung | this.EndPoint, |
529 | }; |
||
530 | } |
||
531 | |||
532 | /// <summary> |
||
533 | d2114d3b | humkyung | /// move control point has same location of given pt along given delta |
534 | /// </summary> |
||
535 | /// <author>humkyung</author> |
||
536 | /// <date>2019.06.20</date> |
||
537 | /// <param name="pt"></param> |
||
538 | /// <param name="dx"></param> |
||
539 | /// <param name="dy"></param> |
||
540 | 233ef333 | taeseongkim | public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false) |
541 | d2114d3b | humkyung | { |
542 | Point selected = MathSet.getNearPoint((this as IPath).PointSet, pt); |
||
543 | 233ef333 | taeseongkim | |
544 | var tmpPointSet = (this as IPath).PointSet.Where(x => !x.Equals(selected)); |
||
545 | Point NearStartpoint = MathSet.getNearPoint(tmpPointSet.ToList(), pt); |
||
546 | |||
547 | d2114d3b | humkyung | selected.X += dx; |
548 | selected.Y += dy; |
||
549 | 233ef333 | taeseongkim | |
550 | Point tmp = selected; |
||
551 | |||
552 | CommentAngle = MathSet.returnAngle(NearStartpoint, ref tmp, bAxisLocked); |
||
553 | |||
554 | if (bAxisLocked) |
||
555 | { |
||
556 | selected = tmp; |
||
557 | } |
||
558 | |||
559 | d2114d3b | humkyung | for (int i = 0; i < (this as IPath).PointSet.Count; i++) |
560 | { |
||
561 | if (pt.Equals((this as IPath).PointSet[i])) |
||
562 | { |
||
563 | (this as IPath).PointSet[i] = selected; |
||
564 | } |
||
565 | } |
||
566 | 0d00f9c8 | humkyung | this.UpdateControl(); |
567 | d2114d3b | humkyung | } |
568 | |||
569 | 24c5e56c | taeseongkim | |
570 | /// <summary> |
||
571 | /// return ArrowControl_Multi's area |
||
572 | /// </summary> |
||
573 | /// <author>humkyung</author> |
||
574 | /// <date>2019.06.13</date> |
||
575 | public override Rect ItemRect |
||
576 | { |
||
577 | get |
||
578 | { |
||
579 | double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X); |
||
580 | dMinX = Math.Min(this.MiddlePoint.X, dMinX); |
||
581 | double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y); |
||
582 | dMinY = Math.Min(this.MiddlePoint.Y, dMinY); |
||
583 | double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X); |
||
584 | dMaxX = Math.Max(this.MiddlePoint.X, dMaxX); |
||
585 | double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y); |
||
586 | dMaxY = Math.Max(this.MiddlePoint.Y, dMaxY); |
||
587 | |||
588 | return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY)); |
||
589 | } |
||
590 | } |
||
591 | |||
592 | d2114d3b | humkyung | /// <summary> |
593 | 036650a0 | humkyung | /// Serialize this |
594 | /// </summary> |
||
595 | /// <param name="sUserId"></param> |
||
596 | /// <returns></returns> |
||
597 | public override string Serialize() |
||
598 | { |
||
599 | b2d0f316 | humkyung | using (S_ArrowArcControl ctrl = new S_ArrowArcControl()) |
600 | 036650a0 | humkyung | { |
601 | b2d0f316 | humkyung | ctrl.TransformPoint = "0|0"; |
602 | ctrl.PointSet = this.PointSet; |
||
603 | ctrl.SizeSet = String.Format("{0}", this.LineSize); |
||
604 | //ctrl.StrokeColor = "#FF000FFF"; |
||
605 | ctrl.StrokeColor = this.StrokeColor.Color.ToString(); |
||
606 | ctrl.StartPoint = this.StartPoint; |
||
607 | ctrl.UserID = this.UserID; |
||
608 | ctrl.Opac = this.Opacity; |
||
609 | ctrl.MidPoint = this.MiddlePoint; |
||
610 | ctrl.EndPoint = this.EndPoint; |
||
611 | ctrl.IsTransOn = this.isTransOn; |
||
612 | ctrl.DashSize = this.DashSize; |
||
613 | ctrl.Clock = this.Clock; |
||
614 | //ctrl.ArcStyleSet = this.ControlType; |
||
615 | ctrl.Name = this.GetType().Name.ToString(); |
||
616 | 036650a0 | humkyung | |
617 | ///강인구 추가(2017.11.02) |
||
618 | ///Memo 추가 |
||
619 | b2d0f316 | humkyung | ctrl.Memo = this.Memo; |
620 | fd19a116 | humkyung | ctrl.Index = this.Index; |
621 | b2d0f316 | humkyung | ctrl.ZIndex = this.ZIndex; |
622 | e1b36bc0 | humkyung | ctrl.GroupID = this.GroupID; |
623 | b2d0f316 | humkyung | |
624 | return "|DZ|" + JsonSerializerHelper.CompressString((ctrl.JsonSerialize())); |
||
625 | 036650a0 | humkyung | } |
626 | } |
||
627 | 661b7416 | humkyung | |
628 | /// <summary> |
||
629 | /// create a arrowarccontrol from given string |
||
630 | /// </summary> |
||
631 | /// <param name="str"></param> |
||
632 | /// <returns></returns> |
||
633 | public static ArrowArcControl FromString(string str, SolidColorBrush brush, string sProjectNo) |
||
634 | { |
||
635 | ArrowArcControl instance = null; |
||
636 | using (S_ArrowArcControl s = JsonSerializerHelper.JsonDeserialize<S_ArrowArcControl>(str)) |
||
637 | { |
||
638 | string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
639 | instance = new ArrowArcControl() |
||
640 | { |
||
641 | StartPoint = s.StartPoint, |
||
642 | EndPoint = s.EndPoint, |
||
643 | DashSize = s.DashSize, |
||
644 | PointSet = s.PointSet, |
||
645 | isTransOn = s.IsTransOn, |
||
646 | ef22793a | taeseongkim | MiddlePoint = s.MidPoint, |
647 | 661b7416 | humkyung | StrokeColor = brush, |
648 | Opacity = s.Opac, |
||
649 | |||
650 | Clock = s.Clock, |
||
651 | LineSize = Convert.ToDouble(data2.First()), |
||
652 | UserID = s.UserID, |
||
653 | b2d0f316 | humkyung | Memo = s.Memo, |
654 | fd19a116 | humkyung | Index = s.Index, |
655 | e1b36bc0 | humkyung | ZIndex = s.ZIndex, |
656 | GroupID = s.GroupID |
||
657 | 661b7416 | humkyung | }; |
658 | } |
||
659 | |||
660 | return instance; |
||
661 | } |
||
662 | 40b3ce25 | ljiyeon | } |
663 | } |