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