markus / MarkupToPDF / Controls / Shape / RectCloudControl.cs @ efd9be38
이력 | 보기 | 이력해설 | 다운로드 (28.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 | 787a4489 | KangIngu | |
19 | namespace MarkupToPDF.Controls.Shape |
||
20 | { |
||
21 | public class RectCloudControl : CommentUserInfo, IDisposable, IPath, INotifyPropertyChanged, IMarkupCommonData, IShapeControl, IDashControl |
||
22 | { |
||
23 | #region 초기 선언 |
||
24 | private const string PART_ArcPath = "PART_ArcPath"; |
||
25 | private const string PART_BodyPath = "PART_BodyPath"; |
||
26 | public event PropertyChangedEventHandler PropertyChanged; |
||
27 | |||
28 | public Path Base_ArcPath = null; |
||
29 | public Path Base_BodyPath = null; |
||
30 | |||
31 | 53393bae | KangIngu | private const double _CloudArcDepth = 0.8; /// 2018.05.14 added by humkyung |
32 | 5a9353a9 | humkyung | |
33 | 787a4489 | KangIngu | #endregion |
34 | |||
35 | static RectCloudControl() |
||
36 | { |
||
37 | DefaultStyleKeyProperty.OverrideMetadata(typeof(RectCloudControl), new FrameworkPropertyMetadata(typeof(RectCloudControl))); |
||
38 | //Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
||
39 | a6f7f9b6 | djkim | //ResourceDictionary dictionary = new ResourceDictionary(); |
40 | //dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
||
41 | //Application.Current.Resources.MergedDictionaries.Add(dictionary); |
||
42 | 787a4489 | KangIngu | } |
43 | |||
44 | #region Dependency Properties |
||
45 | |||
46 | public static readonly DependencyProperty mousemodeProperty = |
||
47 | DependencyProperty.Register("mousemode", typeof(MouseMode), typeof(RectangleControl), new PropertyMetadata(MouseMode.None, PointValueChanged)); |
||
48 | public static readonly DependencyProperty IsSelectedProperty = |
||
49 | DependencyProperty.Register("IsSelected", typeof(bool), typeof(RectCloudControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
||
50 | |||
51 | public static readonly DependencyProperty ControlTypeProperty = |
||
52 | DependencyProperty.Register("ControlType", typeof(ControlType), typeof(RectCloudControl), new FrameworkPropertyMetadata(ControlType.RectCloud)); |
||
53 | |||
54 | public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
||
55 | "OverViewPathData", typeof(Geometry), typeof(RectCloudControl), new PropertyMetadata(null)); |
||
56 | |||
57 | public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
||
58 | "LineSize", typeof(double), typeof(RectCloudControl), new PropertyMetadata((Double)3)); |
||
59 | |||
60 | public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
||
61 | "UserID", typeof(string), typeof(RectCloudControl), new PropertyMetadata(null)); |
||
62 | |||
63 | //강인구 추가 |
||
64 | public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
||
65 | "DashSize", typeof(DoubleCollection), typeof(RectCloudControl), new PropertyMetadata(new DoubleCollection { 99999999 }, PointValueChanged)); |
||
66 | |||
67 | public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register( |
||
68 | "FillColor", typeof(SolidColorBrush), typeof(RectCloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
||
69 | //강인구 추가 |
||
70 | public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
||
71 | "Paint", typeof(PaintSet), typeof(RectCloudControl), new PropertyMetadata(PaintSet.None, PointValueChanged)); |
||
72 | |||
73 | public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
||
74 | "StrokeColor", typeof(SolidColorBrush), typeof(RectCloudControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
||
75 | |||
76 | public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
||
77 | "PathData", typeof(Geometry), typeof(RectCloudControl), null); |
||
78 | |||
79 | public static readonly DependencyProperty PathSubDataProperty = DependencyProperty.Register( |
||
80 | "PathSubData", typeof(Geometry), typeof(RectCloudControl), null); |
||
81 | |||
82 | 9f473fb7 | KangIngu | public static readonly DependencyProperty ArcLengthProperty = DependencyProperty.Register( |
83 | "ArcLength", typeof(double), typeof(RectCloudControl), new PropertyMetadata((Double)10, PointValueChanged)); |
||
84 | |||
85 | 787a4489 | KangIngu | public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
86 | "EndPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
87 | |||
88 | public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
||
89 | "StartPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
90 | |||
91 | public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register( |
||
92 | "TopRightPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
93 | |||
94 | public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register( |
||
95 | "LeftBottomPoint", typeof(Point), typeof(RectCloudControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
96 | |||
97 | public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
||
98 | "PointSet", typeof(List<Point>), typeof(RectCloudControl), new PropertyMetadata(new List<Point>(), PointValueChanged)); |
||
99 | |||
100 | public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("AngleValue", typeof(double), typeof(RectCloudControl), |
||
101 | new PropertyMetadata((double)0.0, new PropertyChangedCallback(PointValueChanged))); |
||
102 | |||
103 | public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(RectCloudControl), |
||
104 | new PropertyMetadata((double)0, PointValueChanged)); |
||
105 | |||
106 | public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(RectCloudControl), |
||
107 | new PropertyMetadata((double)0, PointValueChanged)); |
||
108 | |||
109 | #endregion |
||
110 | |||
111 | #region PropertyChanged Method |
||
112 | public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
113 | { |
||
114 | var instance = (RectCloudControl)sender; |
||
115 | if (e.OldValue != e.NewValue && instance.Base_ArcPath != null) |
||
116 | { |
||
117 | instance.SetValue(e.Property, e.NewValue); |
||
118 | instance.SetRectCloud(); |
||
119 | } |
||
120 | } |
||
121 | #endregion |
||
122 | |||
123 | #region Properties |
||
124 | |||
125 | public MouseMode mousemode |
||
126 | { |
||
127 | get |
||
128 | { |
||
129 | return (MouseMode)GetValue(mousemodeProperty); |
||
130 | } |
||
131 | set |
||
132 | { |
||
133 | SetValue(mousemodeProperty, value); |
||
134 | OnPropertyChanged("mousemode"); |
||
135 | } |
||
136 | } |
||
137 | public Double LineSize |
||
138 | { |
||
139 | get { return (Double)GetValue(LineSizeProperty); } |
||
140 | set |
||
141 | { |
||
142 | if (this.LineSize != value) |
||
143 | { |
||
144 | SetValue(LineSizeProperty, value); |
||
145 | } |
||
146 | } |
||
147 | } |
||
148 | public DoubleCollection DashSize |
||
149 | { |
||
150 | get { return (DoubleCollection)GetValue(DashSizeProperty); } |
||
151 | set |
||
152 | { |
||
153 | if (this.DashSize != value) |
||
154 | { |
||
155 | SetValue(DashSizeProperty, value); |
||
156 | } |
||
157 | } |
||
158 | } |
||
159 | public string UserID |
||
160 | { |
||
161 | get { return (string)GetValue(UserIDProperty); } |
||
162 | set |
||
163 | { |
||
164 | if (this.UserID != value) |
||
165 | { |
||
166 | SetValue(UserIDProperty, value); |
||
167 | OnPropertyChanged("UserID"); |
||
168 | } |
||
169 | } |
||
170 | } |
||
171 | public PaintSet Paint |
||
172 | { |
||
173 | get { return (PaintSet)GetValue(PaintProperty); } |
||
174 | set |
||
175 | { |
||
176 | if (this.Paint != value) |
||
177 | { |
||
178 | SetValue(PaintProperty, value); |
||
179 | } |
||
180 | } |
||
181 | } |
||
182 | public SolidColorBrush FillColor |
||
183 | { |
||
184 | get { return (SolidColorBrush)GetValue(FillColorProperty); } |
||
185 | set |
||
186 | { |
||
187 | if (this.FillColor != value) |
||
188 | { |
||
189 | SetValue(FillColorProperty, value); |
||
190 | } |
||
191 | } |
||
192 | } |
||
193 | 4913851c | humkyung | public override SolidColorBrush StrokeColor |
194 | 787a4489 | KangIngu | { |
195 | get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
||
196 | set |
||
197 | { |
||
198 | if (this.StrokeColor != value) |
||
199 | { |
||
200 | SetValue(StrokeColorProperty, value); |
||
201 | } |
||
202 | } |
||
203 | } |
||
204 | |||
205 | public Geometry OverViewPathData |
||
206 | { |
||
207 | get |
||
208 | { |
||
209 | return (Geometry)GetValue(OverViewPathDataProperty); |
||
210 | } |
||
211 | set |
||
212 | { |
||
213 | SetValue(OverViewPathDataProperty, value); |
||
214 | OnPropertyChanged("OverViewPathData"); |
||
215 | } |
||
216 | } |
||
217 | |||
218 | public Geometry PathData |
||
219 | { |
||
220 | get { return (Geometry)GetValue(PathDataProperty); } |
||
221 | set { SetValue(PathDataProperty, value); } |
||
222 | } |
||
223 | public Geometry PathSubData |
||
224 | { |
||
225 | get { return (Geometry)GetValue(PathSubDataProperty); } |
||
226 | set { SetValue(PathSubDataProperty, value); } |
||
227 | } |
||
228 | public Point EndPoint |
||
229 | { |
||
230 | get { return (Point)GetValue(EndPointProperty); } |
||
231 | set { SetValue(EndPointProperty, value); } |
||
232 | } |
||
233 | public Point StartPoint |
||
234 | { |
||
235 | get { return (Point)GetValue(StartPointProperty); } |
||
236 | set { SetValue(StartPointProperty, value); } |
||
237 | } |
||
238 | public List<Point> PointSet |
||
239 | { |
||
240 | get { return (List<Point>)GetValue(PointSetProperty); } |
||
241 | set { SetValue(PointSetProperty, value); } |
||
242 | } |
||
243 | 959b3ef2 | humkyung | public override bool IsSelected |
244 | 787a4489 | KangIngu | { |
245 | get |
||
246 | { |
||
247 | return (bool)GetValue(IsSelectedProperty); |
||
248 | } |
||
249 | set |
||
250 | { |
||
251 | SetValue(IsSelectedProperty, value); |
||
252 | } |
||
253 | } |
||
254 | 036650a0 | humkyung | |
255 | 5529d2a2 | humkyung | public override ControlType ControlType |
256 | 787a4489 | KangIngu | { |
257 | get |
||
258 | { |
||
259 | return (ControlType)GetValue(ControlTypeProperty); |
||
260 | } |
||
261 | set |
||
262 | { |
||
263 | SetValue(ControlTypeProperty, value); |
||
264 | } |
||
265 | } |
||
266 | |||
267 | 9f473fb7 | KangIngu | public Double ArcLength |
268 | { |
||
269 | get { return (Double)GetValue(ArcLengthProperty); } |
||
270 | set |
||
271 | { |
||
272 | if (this.ArcLength != value) |
||
273 | { |
||
274 | SetValue(ArcLengthProperty, value); |
||
275 | OnPropertyChanged("ArcLength"); |
||
276 | } |
||
277 | } |
||
278 | } |
||
279 | |||
280 | 787a4489 | KangIngu | |
281 | private double _toler = 1; |
||
282 | public double Toler |
||
283 | { |
||
284 | get { return _toler; } |
||
285 | set { _toler = value; } |
||
286 | } |
||
287 | 9f473fb7 | KangIngu | //private double _arcLength = 30; |
288 | //public double ArcLength |
||
289 | //{ |
||
290 | // get { return _arcLength; } |
||
291 | // set { _arcLength = value; } |
||
292 | //} |
||
293 | 787a4489 | KangIngu | |
294 | private bool _fill = false; |
||
295 | public bool Fill |
||
296 | { |
||
297 | get { return _fill; } |
||
298 | set { _fill = value; } |
||
299 | } |
||
300 | fa48eb85 | taeseongkim | public double CommentAngle |
301 | 787a4489 | KangIngu | { |
302 | get { return (double)GetValue(AngleProperty); } |
||
303 | set |
||
304 | { |
||
305 | fa48eb85 | taeseongkim | if (this.CommentAngle != value) |
306 | 787a4489 | KangIngu | { |
307 | SetValue(AngleProperty, value); |
||
308 | } |
||
309 | } |
||
310 | } |
||
311 | public double CenterX |
||
312 | { |
||
313 | get { return (double)GetValue(CenterXProperty); } |
||
314 | set { SetValue(CenterXProperty, value); } |
||
315 | } |
||
316 | public double CenterY |
||
317 | { |
||
318 | get { return (double)GetValue(CenterYProperty); } |
||
319 | set { SetValue(CenterYProperty, value); } |
||
320 | } |
||
321 | public Point LeftBottomPoint |
||
322 | { |
||
323 | get { return (Point)GetValue(LeftBottomPointProperty); } |
||
324 | set |
||
325 | { |
||
326 | SetValue(LeftBottomPointProperty, value); |
||
327 | OnPropertyChanged("LeftBottomPoint"); |
||
328 | } |
||
329 | } |
||
330 | public Point TopRightPoint |
||
331 | { |
||
332 | get { return (Point)GetValue(TopRightPointProperty); } |
||
333 | set |
||
334 | { |
||
335 | SetValue(TopRightPointProperty, value); |
||
336 | OnPropertyChanged("TopRightPoint"); |
||
337 | } |
||
338 | } |
||
339 | #endregion |
||
340 | |||
341 | #region Data |
||
342 | private PathGeometry _pathGeometry = new PathGeometry(); |
||
343 | #endregion |
||
344 | |||
345 | public override void OnApplyTemplate() |
||
346 | { |
||
347 | base.OnApplyTemplate(); |
||
348 | Base_ArcPath = GetTemplateChild(PART_ArcPath) as Path; |
||
349 | Base_BodyPath = GetTemplateChild(PART_BodyPath) as Path; |
||
350 | |||
351 | this.SetRectCloud(); |
||
352 | |||
353 | } |
||
354 | protected void OnPropertyChanged(string propName) |
||
355 | { |
||
356 | if (PropertyChanged != null) |
||
357 | PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
||
358 | } |
||
359 | public void Dispose() |
||
360 | { |
||
361 | a6f7f9b6 | djkim | //GC.Collect(); |
362 | 24c5e56c | taeseongkim | ////GC.SuppressFinalize(this); |
363 | a6f7f9b6 | djkim | this.Base_ArcPath = null; |
364 | this.Base_BodyPath = null; |
||
365 | 787a4489 | KangIngu | } |
366 | |||
367 | public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
368 | { |
||
369 | //var instance = (RectCloudControl)sender; |
||
370 | |||
371 | //if (e.OldValue != e.NewValue && instance.Base_BodyPath != null) |
||
372 | //{ |
||
373 | |||
374 | // instance.SetValue(e.Property, e.NewValue); |
||
375 | |||
376 | // if (instance.IsSelected) |
||
377 | // { |
||
378 | // instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Blue); |
||
379 | // } |
||
380 | // else |
||
381 | // { |
||
382 | // instance.Base_ArcPath.Stroke = new SolidColorBrush(Colors.Red); |
||
383 | // } |
||
384 | //} |
||
385 | } |
||
386 | |||
387 | 661b7416 | humkyung | private void SetRectCloud() |
388 | 787a4489 | KangIngu | { |
389 | this.ApplyTemplate(); |
||
390 | PathFigure pathFigure = new PathFigure(); |
||
391 | |||
392 | Base_ArcPath.StrokeDashArray.Clear(); |
||
393 | Base_BodyPath.StrokeDashArray.Clear(); |
||
394 | |||
395 | foreach (var item in this.DashSize) |
||
396 | { |
||
397 | Base_ArcPath.StrokeDashArray.Add(item); |
||
398 | Base_BodyPath.StrokeDashArray.Add(item); |
||
399 | } |
||
400 | |||
401 | switch (this.Paint) |
||
402 | { |
||
403 | case PaintSet.None: |
||
404 | //강인구 추가 |
||
405 | pathFigure.IsFilled = false; |
||
406 | Base_BodyPath.Fill = null; |
||
407 | Base_BodyPath.Stroke = null; |
||
408 | break; |
||
409 | case PaintSet.Fill: |
||
410 | { |
||
411 | Base_BodyPath.Stroke = this.StrokeColor; |
||
412 | Base_BodyPath.StrokeThickness = 0.5; |
||
413 | Base_ArcPath.Stroke = this.StrokeColor; |
||
414 | |||
415 | Base_ArcPath.Fill = this.FillColor; |
||
416 | Base_BodyPath.Fill = this.FillColor; |
||
417 | } |
||
418 | //this.FillColor = this.StrokeColor; |
||
419 | //Base_BodyPath.Fill = this.FillColor; |
||
420 | //Base_ArcPath.Fill = this.FillColor; |
||
421 | //Base_BodyPath.Stroke = this.StrokeColor; |
||
422 | //Base_BodyPath.StrokeThickness = 2; |
||
423 | //Base_ArcPath.Stroke = this.StrokeColor; |
||
424 | //Base_ArcPath.StrokeThickness = 2; |
||
425 | //pathFigure.IsFilled = true; |
||
426 | break; |
||
427 | case PaintSet.Hatch: |
||
428 | Base_BodyPath.Stroke = new SolidColorBrush(Colors.Transparent); |
||
429 | Base_BodyPath.StrokeThickness = 2; |
||
430 | Base_BodyPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor); |
||
431 | Base_ArcPath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor); |
||
432 | pathFigure.IsFilled = true; |
||
433 | break; |
||
434 | default: |
||
435 | break; |
||
436 | } |
||
437 | |||
438 | #region 사각형 만들기 |
||
439 | if (this.Paint != PaintSet.None) |
||
440 | { |
||
441 | pathFigure.StartPoint = this.StartPoint; |
||
442 | |||
443 | 6d1a8228 | humkyung | List<Point> points = new List<Point>() { this.StartPoint, this.LeftBottomPoint, this.EndPoint, this.TopRightPoint }; |
444 | PolyLineSegment polyline = new PolyLineSegment(points, true); |
||
445 | pathFigure.Segments.Add(polyline); |
||
446 | |||
447 | 787a4489 | KangIngu | PathGeometry pathGeometry = new PathGeometry(); |
448 | pathGeometry.Figures = new PathFigureCollection(); |
||
449 | pathFigure.IsClosed = true; |
||
450 | pathGeometry.Figures.Add(pathFigure); |
||
451 | //this.FillColor = new SolidColorBrush(Colors.Red); |
||
452 | this.PathSubData = pathGeometry; |
||
453 | } |
||
454 | 53393bae | KangIngu | ArcLength = ArcLength == 0 ? 10 : ArcLength; |
455 | 787a4489 | KangIngu | |
456 | #endregion |
||
457 | #region Cloud 만들기 |
||
458 | /// set reverse if area is greater 0 - 2012.07.04 added by humkyung |
||
459 | /// |
||
460 | |||
461 | System.Diagnostics.Debug.WriteLine(ArcLength); |
||
462 | double area = MathSet.AreaOf(new List<Point>() { this.StartPoint, this.LeftBottomPoint, this.EndPoint, this.TopRightPoint }); |
||
463 | bool reverse = (area > 0); |
||
464 | /// up to here |
||
465 | this._pathGeometry = new PathGeometry(); |
||
466 | int count = this.PointSet.Count; |
||
467 | 43e1d368 | taeseongkim | PathFigure pathSubFigure = Polygon.CloudControl.GenerateLineWithCloud(this.StartPoint, this.LeftBottomPoint, this.ArcLength, reverse); |
468 | 787a4489 | KangIngu | _pathGeometry.Figures.Add(pathSubFigure); |
469 | |||
470 | 43e1d368 | taeseongkim | pathSubFigure = Polygon.CloudControl.GenerateLineWithCloud(this.LeftBottomPoint, this.EndPoint, this.ArcLength, reverse); |
471 | 787a4489 | KangIngu | _pathGeometry.Figures.Add(pathSubFigure); |
472 | |||
473 | 43e1d368 | taeseongkim | pathSubFigure = Polygon.CloudControl.GenerateLineWithCloud(this.EndPoint, this.TopRightPoint, this.ArcLength, reverse); |
474 | 787a4489 | KangIngu | _pathGeometry.Figures.Add(pathSubFigure); |
475 | |||
476 | 43e1d368 | taeseongkim | pathSubFigure = Polygon.CloudControl.GenerateLineWithCloud(this.TopRightPoint, this.StartPoint, this.ArcLength, reverse); |
477 | 787a4489 | KangIngu | _pathGeometry.Figures.Add(pathSubFigure); |
478 | |||
479 | if (this.Paint != PaintSet.None) |
||
480 | { |
||
481 | foreach (var item in _pathGeometry.Figures) |
||
482 | { |
||
483 | item.IsFilled = true; |
||
484 | } |
||
485 | } |
||
486 | |||
487 | this.PathData = _pathGeometry; |
||
488 | ApplyOverViewData(); |
||
489 | #endregion |
||
490 | } |
||
491 | |||
492 | public void ChangePaint(PaintSet state) |
||
493 | { |
||
494 | this.Paint = state; |
||
495 | this.SetRectCloud(); |
||
496 | } |
||
497 | |||
498 | public void CloseSettingPoint() |
||
499 | { |
||
500 | this.PointSet[0] = this.StartPoint; |
||
501 | this.PointSet[1] = this.LeftBottomPoint; |
||
502 | this.PointSet[2] = this.EndPoint; |
||
503 | this.PointSet[3] = this.TopRightPoint; |
||
504 | } |
||
505 | |||
506 | f513c215 | humkyung | public override void ApplyOverViewData() |
507 | 787a4489 | KangIngu | { |
508 | this.OverViewPathData = this.PathData; |
||
509 | } |
||
510 | |||
511 | 0d00f9c8 | humkyung | public override void UpdateControl() |
512 | 787a4489 | KangIngu | { |
513 | this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
||
514 | this.LeftBottomPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
||
515 | this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
||
516 | this.TopRightPoint = new Point(this.PointSet[3].X, this.PointSet[3].Y); |
||
517 | } |
||
518 | |||
519 | 43e1d368 | taeseongkim | //public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double arcLength_, bool reverse) |
520 | //{ |
||
521 | // PathFigure pathFigure = new PathFigure(); |
||
522 | // pathFigure.StartPoint = p1; |
||
523 | |||
524 | // double arcLength = arcLength_; |
||
525 | // /// draw arcs which has arcLength between p1 and p2 - 2012.06.21 added by humkyung |
||
526 | // double dx = p2.X - p1.X; |
||
527 | // double dy = p2.Y - p1.Y; |
||
528 | // double l = MathSet.DistanceTo(p1, p2); /// distance between p1 and p2 |
||
529 | // double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI; |
||
530 | // Point lastPt = new Point(p1.X, p1.Y); |
||
531 | // double count = l / arcLength; |
||
532 | // /// normalize |
||
533 | // dx /= l; |
||
534 | // dy /= l; |
||
535 | // Double j = 1; |
||
536 | // for (j = 1; j < (count - 1); j++) |
||
537 | // { |
||
538 | // ArcSegment arcSeg = new ArcSegment(); |
||
539 | // arcSeg.Size = new Size(arcLength * RectCloudControl._CloudArcDepth, arcLength * RectCloudControl._CloudArcDepth); /// x size and y size of arc |
||
540 | // arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength); /// end point of arc |
||
541 | // lastPt = arcSeg.Point; /// save last point |
||
542 | // arcSeg.RotationAngle = theta + 90; |
||
543 | // if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
||
544 | // pathFigure.Segments.Add(arcSeg); |
||
545 | // } |
||
546 | |||
547 | // /// draw arc between last point and end point |
||
548 | // if ((count > j) || (count > 0)) |
||
549 | // { |
||
550 | // arcLength = MathSet.DistanceTo(lastPt, p2); |
||
551 | // ArcSegment arcSeg = new ArcSegment(); |
||
552 | // arcSeg.Size = new Size(arcLength * RectCloudControl._CloudArcDepth, arcLength * RectCloudControl._CloudArcDepth); /// x size and y size of arc |
||
553 | // arcSeg.Point = new Point(p2.X, p2.Y); /// end point of arc |
||
554 | // arcSeg.RotationAngle = theta; |
||
555 | // if (true == reverse) arcSeg.SweepDirection = SweepDirection.Clockwise; |
||
556 | // pathFigure.Segments.Add(arcSeg); |
||
557 | // } |
||
558 | // pathFigure.IsClosed = false; |
||
559 | // pathFigure.IsFilled = false; |
||
560 | // /// up to here |
||
561 | // //pathFigure.IsFilled = true; |
||
562 | // return pathFigure; |
||
563 | //} |
||
564 | 036650a0 | humkyung | |
565 | /// <summary> |
||
566 | a6272c57 | humkyung | /// call when mouse is moving while drawing control |
567 | /// </summary> |
||
568 | /// <author>humkyung</author> |
||
569 | /// <param name="pt"></param> |
||
570 | /// <param name="bAxisLocked"></param> |
||
571 | 233ef333 | taeseongkim | public override void OnCreatingMouseMove(Point pt, bool bAxisLocked) |
572 | a6272c57 | humkyung | { |
573 | 233ef333 | taeseongkim | this.EndPoint = bAxisLocked ? this.GetSquareEndPoint(this.StartPoint, pt) : pt; |
574 | a6272c57 | humkyung | this.LeftBottomPoint = new Point(this.StartPoint.X, this.EndPoint.Y); |
575 | this.TopRightPoint = new Point(this.EndPoint.X, this.StartPoint.Y); |
||
576 | |||
577 | this.PointSet = new List<Point> |
||
578 | { |
||
579 | this.StartPoint, |
||
580 | this.LeftBottomPoint, |
||
581 | this.EndPoint, |
||
582 | this.TopRightPoint, |
||
583 | }; |
||
584 | } |
||
585 | |||
586 | /// <summary> |
||
587 | d2114d3b | humkyung | /// move control point has same location of given pt along given delta |
588 | /// </summary> |
||
589 | /// <author>humkyung</author> |
||
590 | /// <date>2019.06.20</date> |
||
591 | /// <param name="pt"></param> |
||
592 | /// <param name="dx"></param> |
||
593 | /// <param name="dy"></param> |
||
594 | 233ef333 | taeseongkim | public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false) |
595 | d2114d3b | humkyung | { |
596 | IPath path = (this as IPath); |
||
597 | |||
598 | Point selected = MathSet.getNearPoint(path.PointSet, pt); |
||
599 | selected.X += dx; |
||
600 | selected.Y += dy; |
||
601 | int i = 0; |
||
602 | for (i = 0; i < (this as IPath).PointSet.Count; i++) |
||
603 | { |
||
604 | if (pt.Equals((this as IPath).PointSet[i])) |
||
605 | { |
||
606 | (this as IPath).PointSet[i] = selected; |
||
607 | break; |
||
608 | } |
||
609 | } |
||
610 | |||
611 | ca7b7b56 | humkyung | var OppositeP = (i + path.PointSet.Count / 2) % path.PointSet.Count; |
612 | var PreviousP = (i + (path.PointSet.Count - 1)) % path.PointSet.Count; |
||
613 | var NextP = (i + 1) % path.PointSet.Count; |
||
614 | |||
615 | if (bAxisLocked) |
||
616 | { |
||
617 | double _dx = path.PointSet[i].X - path.PointSet[OppositeP].X; |
||
618 | double _dy = path.PointSet[i].Y - path.PointSet[OppositeP].Y; |
||
619 | double distance = Math.Max(Math.Abs(_dx), Math.Abs(_dy)); |
||
620 | |||
621 | var PreviousV = path.PointSet[PreviousP] - path.PointSet[OppositeP]; |
||
622 | PreviousV.Normalize(); |
||
623 | path.PointSet[PreviousP] = path.PointSet[OppositeP] + PreviousV * distance; |
||
624 | |||
625 | var NextV = path.PointSet[NextP] - path.PointSet[OppositeP]; |
||
626 | NextV.Normalize(); |
||
627 | path.PointSet[NextP] = path.PointSet[OppositeP] + NextV * distance; |
||
628 | |||
629 | path.PointSet[i] = path.PointSet[OppositeP] + PreviousV * distance + NextV * distance; |
||
630 | } |
||
631 | else |
||
632 | { |
||
633 | var PreviousV = MathSet.GetNormVectorBetween(path.PointSet[OppositeP], path.PointSet[PreviousP]); |
||
634 | var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, path.PointSet[i].X - path.PointSet[OppositeP].X, |
||
635 | path.PointSet[i].Y - path.PointSet[OppositeP].Y); |
||
636 | path.PointSet[PreviousP] = new Point(path.PointSet[OppositeP].X + PreviousV.X * l, path.PointSet |
||
637 | [OppositeP].Y + PreviousV.Y * l); |
||
638 | |||
639 | var NextV = MathSet.GetNormVectorBetween(path.PointSet[OppositeP], path.PointSet[NextP]); |
||
640 | l = MathSet.DotProduct(NextV.X, NextV.Y, path.PointSet[i].X - path.PointSet[OppositeP].X, path.PointSet |
||
641 | [i].Y - path.PointSet[OppositeP].Y); |
||
642 | path.PointSet[NextP] = new Point(path.PointSet[OppositeP].X + NextV.X * l, path.PointSet[OppositeP].Y + NextV.Y * l); |
||
643 | } |
||
644 | d2114d3b | humkyung | |
645 | 0d00f9c8 | humkyung | this.UpdateControl(); |
646 | d2114d3b | humkyung | } |
647 | |||
648 | /// <summary> |
||
649 | 91efe37a | humkyung | /// return rectcloudcontrols' area |
650 | /// </summary> |
||
651 | /// <author>humkyung</author> |
||
652 | /// <date>2019.06.13</date> |
||
653 | public override Rect ItemRect |
||
654 | { |
||
655 | get |
||
656 | { |
||
657 | double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X); |
||
658 | double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y); |
||
659 | double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X); |
||
660 | double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y); |
||
661 | |||
662 | return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY)); |
||
663 | } |
||
664 | } |
||
665 | |||
666 | /// <summary> |
||
667 | 036650a0 | humkyung | /// Serialize this |
668 | /// </summary> |
||
669 | /// <param name="sUserId"></param> |
||
670 | /// <returns></returns> |
||
671 | public override string Serialize() |
||
672 | { |
||
673 | using (S_RectCloudControl STemp = new S_RectCloudControl()) |
||
674 | { |
||
675 | STemp.TransformPoint = "0|0"; |
||
676 | STemp.PointSet = this.PointSet; |
||
677 | STemp.SizeSet = String.Format("{0}", this.LineSize); |
||
678 | //STemp.StrokeColor = "#FF00FF00"; |
||
679 | STemp.StrokeColor = this.StrokeColor.Color.ToString(); |
||
680 | STemp.StartPoint = this.StartPoint; |
||
681 | STemp.UserID = this.UserID; |
||
682 | STemp.Opac = this.Opacity; |
||
683 | STemp.TR = this.TopRightPoint; |
||
684 | STemp.LB = this.LeftBottomPoint; |
||
685 | STemp.EndPoint = this.EndPoint; |
||
686 | STemp.PaintState = this.Paint; |
||
687 | STemp.DashSize = this.DashSize; |
||
688 | STemp.ArcLength = this.ArcLength; |
||
689 | STemp.Name = this.GetType().Name.ToString(); |
||
690 | ///강인구 추가(2017.11.02) |
||
691 | ///Memo 추가 |
||
692 | STemp.Memo = this.Memo; |
||
693 | |||
694 | return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize())); |
||
695 | } |
||
696 | } |
||
697 | 661b7416 | humkyung | |
698 | /// <summary> |
||
699 | /// create a rectcloudcontrol from given string |
||
700 | /// </summary> |
||
701 | /// <param name="str"></param> |
||
702 | /// <returns></returns> |
||
703 | public static RectCloudControl FromString(string str, SolidColorBrush brush, string sProjectNo) |
||
704 | { |
||
705 | using (S_RectCloudControl s = JsonSerializerHelper.JsonDeserialize<S_RectCloudControl>(str)) |
||
706 | { |
||
707 | string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
||
708 | return new RectCloudControl() |
||
709 | { |
||
710 | StartPoint = s.StartPoint, |
||
711 | EndPoint = s.EndPoint, |
||
712 | LeftBottomPoint = s.LB, |
||
713 | Paint = s.PaintState, |
||
714 | Opacity = s.Opac, |
||
715 | DashSize = s.DashSize, |
||
716 | TopRightPoint = s.TR, |
||
717 | PointSet = s.PointSet, |
||
718 | StrokeColor = brush, |
||
719 | ArcLength = s.ArcLength, |
||
720 | LineSize = Convert.ToDouble(data2.First()), |
||
721 | UserID = s.UserID, |
||
722 | Memo = s.Memo |
||
723 | }; |
||
724 | } |
||
725 | } |
||
726 | 787a4489 | KangIngu | } |
727 | } |