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