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