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