markus / MarkupToPDF / Controls / Shape / CircleControl.cs @ 24c5e56c
이력 | 보기 | 이력해설 | 다운로드 (22.8 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, IPath, INotifyPropertyChanged, IMarkupCommonData, IShapeControl, 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 |
#region Dependency Properties |
31 |
|
32 |
public static readonly DependencyProperty IsSelectedProperty = |
33 |
DependencyProperty.Register("IsSelected", typeof(bool), typeof(CircleControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
34 |
|
35 |
public static readonly DependencyProperty ControlTypeProperty = |
36 |
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(CircleControl), new FrameworkPropertyMetadata(ControlType.Circle)); |
37 |
|
38 |
|
39 |
|
40 |
|
41 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
42 |
"OverViewPathData", typeof(Geometry), typeof(CircleControl), new PropertyMetadata(null)); |
43 |
|
44 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
45 |
"LineSize", typeof(double), typeof(CircleControl), new PropertyMetadata((Double)3)); |
46 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
47 |
"UserID", typeof(string), typeof(CircleControl), new PropertyMetadata(null)); |
48 |
|
49 |
public static readonly DependencyProperty FillColorProperty = DependencyProperty.Register( |
50 |
"FillColor", typeof(SolidColorBrush), typeof(CircleControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
51 |
|
52 |
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
53 |
"StrokeColor", typeof(SolidColorBrush), typeof(CircleControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
54 |
|
55 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
56 |
"PathData", typeof(Geometry), typeof(CircleControl), null); |
57 |
//강인구 추가 |
58 |
public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
59 |
"Paint", typeof(PaintSet), typeof(CircleControl), new PropertyMetadata(PaintSet.None, PointValueChanged)); |
60 |
|
61 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
62 |
"EndPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
63 |
|
64 |
//강인구 추가 |
65 |
public static readonly DependencyProperty DashSizeProperty = DependencyProperty.Register( |
66 |
"DashSize", typeof(DoubleCollection), typeof(CircleControl), new PropertyMetadata(new DoubleCollection { 1, 1 }, PointValueChanged)); |
67 |
|
68 |
public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register( |
69 |
"TopRightPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
70 |
|
71 |
public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register( |
72 |
"LeftBottomPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
73 |
|
74 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
75 |
"StartPoint", typeof(Point), typeof(CircleControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
76 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
77 |
"PointSet", typeof(List<Point>), typeof(CircleControl), new PropertyMetadata(new List<Point>())); |
78 |
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(CircleControl), |
79 |
new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
80 |
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(CircleControl), |
81 |
new PropertyMetadata((double)0, OnCenterXYChanged)); |
82 |
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(CircleControl), |
83 |
new PropertyMetadata((double)0, OnCenterXYChanged)); |
84 |
public static readonly DependencyProperty mousemodeProperty = |
85 |
DependencyProperty.Register("mousemode", typeof(MouseMode), typeof(CircleControl), new PropertyMetadata(MouseMode.None, PointValueChanged)); |
86 |
#endregion |
87 |
#region PropertyChanged Method |
88 |
|
89 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
90 |
{ |
91 |
//var instance = (CircleControl)sender; |
92 |
|
93 |
//if (e.OldValue != e.NewValue && instance.Base_CirclePath != null) |
94 |
//{ |
95 |
|
96 |
// instance.SetValue(e.Property, e.NewValue); |
97 |
|
98 |
// if (instance.IsSelected) |
99 |
// { |
100 |
// instance.Base_CirclePath.Stroke = new SolidColorBrush(Colors.Blue); |
101 |
// } |
102 |
// else |
103 |
// { |
104 |
// instance.Base_CirclePath.Stroke = new SolidColorBrush(Colors.Red); |
105 |
// } |
106 |
//} |
107 |
} |
108 |
|
109 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
110 |
{ |
111 |
var instance = (CircleControl)sender; |
112 |
if (e.OldValue != e.NewValue && instance.Base_CirclePath != null) |
113 |
{ |
114 |
instance.SetValue(e.Property, e.NewValue); |
115 |
instance.SetCircle(); |
116 |
} |
117 |
} |
118 |
|
119 |
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
120 |
{ |
121 |
var instance = (CircleControl)sender; |
122 |
if (e.OldValue != e.NewValue && instance.Base_CirclePath != null) |
123 |
{ |
124 |
instance.SetValue(e.Property, e.NewValue); |
125 |
instance.SetCircle(); |
126 |
} |
127 |
} |
128 |
|
129 |
|
130 |
public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
131 |
{ |
132 |
var instance = (CircleControl)sender; |
133 |
if (e.OldValue != e.NewValue && instance.Base_CirclePath != null) |
134 |
{ |
135 |
instance.SetValue(e.Property, e.NewValue); |
136 |
instance.SetCircle(); |
137 |
} |
138 |
} |
139 |
#endregion |
140 |
#region Properties |
141 |
public string UserID |
142 |
{ |
143 |
get { return (string)GetValue(UserIDProperty); } |
144 |
set |
145 |
{ |
146 |
if (this.UserID != value) |
147 |
{ |
148 |
SetValue(UserIDProperty, value); |
149 |
OnPropertyChanged("UserID"); |
150 |
} |
151 |
} |
152 |
} |
153 |
public MouseMode mousemode |
154 |
{ |
155 |
get |
156 |
{ |
157 |
return (MouseMode)GetValue(mousemodeProperty); |
158 |
} |
159 |
set |
160 |
{ |
161 |
SetValue(mousemodeProperty, value); |
162 |
OnPropertyChanged("mousemode"); |
163 |
} |
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 SolidColorBrush FillColor |
189 |
{ |
190 |
get { return (SolidColorBrush)GetValue(FillColorProperty); } |
191 |
set |
192 |
{ |
193 |
if (this.FillColor != value) |
194 |
{ |
195 |
SetValue(FillColorProperty, value); |
196 |
} |
197 |
} |
198 |
} |
199 |
public Point TopRightPoint |
200 |
{ |
201 |
get { return (Point)GetValue(TopRightPointProperty); } |
202 |
set |
203 |
{ |
204 |
SetValue(TopRightPointProperty, value); |
205 |
OnPropertyChanged("TopRightPoint"); |
206 |
} |
207 |
} |
208 |
public Point LeftBottomPoint |
209 |
{ |
210 |
get { return (Point)GetValue(LeftBottomPointProperty); } |
211 |
set |
212 |
{ |
213 |
SetValue(LeftBottomPointProperty, value); |
214 |
OnPropertyChanged("LeftBottomPoint"); |
215 |
} |
216 |
} |
217 |
public override SolidColorBrush StrokeColor |
218 |
{ |
219 |
get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
220 |
set |
221 |
{ |
222 |
if (this.StrokeColor != value) |
223 |
{ |
224 |
SetValue(StrokeColorProperty, value); |
225 |
} |
226 |
} |
227 |
} |
228 |
public Geometry PathData |
229 |
{ |
230 |
get { return (Geometry)GetValue(PathDataProperty); } |
231 |
set { SetValue(PathDataProperty, value); } |
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 |
public PaintSet Paint |
247 |
{ |
248 |
get { return (PaintSet)GetValue(PaintProperty); } |
249 |
set |
250 |
{ |
251 |
if (this.Paint != value) |
252 |
{ |
253 |
SetValue(PaintProperty, value); |
254 |
} |
255 |
} |
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 double CenterX |
268 |
//{ |
269 |
// get { return (double)GetValue(CenterXProperty); } |
270 |
// set { SetValue(CenterXProperty, value); } |
271 |
//} |
272 |
//public double CenterY |
273 |
//{ |
274 |
// get { return (double)GetValue(CenterYProperty); } |
275 |
// set { SetValue(CenterYProperty, value); } |
276 |
//} |
277 |
public double AngleValue |
278 |
{ |
279 |
get { return (double)GetValue(AngleProperty); } |
280 |
set { SetValue(AngleProperty, value); } |
281 |
} |
282 |
public double CommentAngle |
283 |
{ |
284 |
get { return (double)GetValue(AngleProperty); } |
285 |
set |
286 |
{ |
287 |
if (this.CommentAngle != value) |
288 |
{ |
289 |
SetValue(AngleProperty, value); |
290 |
} |
291 |
} |
292 |
} |
293 |
public List<Point> PointSet |
294 |
{ |
295 |
get { return (List<Point>)GetValue(PointSetProperty); } |
296 |
set { SetValue(PointSetProperty, value); } |
297 |
} |
298 |
|
299 |
public override bool IsSelected |
300 |
{ |
301 |
get |
302 |
{ |
303 |
return (bool)GetValue(IsSelectedProperty); |
304 |
} |
305 |
set |
306 |
{ |
307 |
SetValue(IsSelectedProperty, value); |
308 |
} |
309 |
} |
310 |
|
311 |
public override ControlType ControlType |
312 |
{ |
313 |
get |
314 |
{ |
315 |
return (ControlType)GetValue(ControlTypeProperty); |
316 |
} |
317 |
set |
318 |
{ |
319 |
SetValue(ControlTypeProperty, value); |
320 |
} |
321 |
} |
322 |
|
323 |
public double CenterX |
324 |
{ |
325 |
get { return (double)GetValue(CenterXProperty); } |
326 |
set { SetValue(CenterXProperty, value); } |
327 |
} |
328 |
public double CenterY |
329 |
{ |
330 |
get { return (double)GetValue(CenterYProperty); } |
331 |
set { SetValue(CenterYProperty, value); } |
332 |
} |
333 |
#endregion |
334 |
#region Object & Variable |
335 |
EllipseGeometry instance = new EllipseGeometry(); |
336 |
GeometryGroup CircleGroup = new GeometryGroup(); |
337 |
|
338 |
#endregion |
339 |
public override void OnApplyTemplate() |
340 |
{ |
341 |
base.OnApplyTemplate(); |
342 |
Base_CirclePath = GetTemplateChild(PART_CirclePath) as Path; |
343 |
|
344 |
if (Base_CirclePath == null) |
345 |
{ |
346 |
return; |
347 |
} |
348 |
this.SetCircle(); |
349 |
} |
350 |
public void Dispose() |
351 |
{ |
352 |
//GC.Collect(); |
353 |
////GC.SuppressFinalize(this); |
354 |
this.Base_CirclePath = null; |
355 |
} |
356 |
|
357 |
public event PropertyChangedEventHandler PropertyChanged; |
358 |
protected void OnPropertyChanged(string propName) |
359 |
{ |
360 |
if (PropertyChanged != null) |
361 |
PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
362 |
} |
363 |
private void SetCircle() |
364 |
{ |
365 |
Base_CirclePath.StrokeDashArray.Clear(); |
366 |
foreach (var item in this.DashSize) |
367 |
{ |
368 |
Base_CirclePath.StrokeDashArray.Add(item); |
369 |
} |
370 |
Base_CirclePath.StrokeDashCap = PenLineCap.Square; |
371 |
|
372 |
Point middle = MathSet.getMiddlePoint(this.EndPoint, this.StartPoint); |
373 |
|
374 |
instance.RadiusX = (MathSet.DistanceTo(this.LeftBottomPoint, this.EndPoint) / 2); |
375 |
instance.RadiusY = (MathSet.DistanceTo(this.EndPoint, this.TopRightPoint) / 2); |
376 |
instance.Center = middle; |
377 |
switch (this.Paint) |
378 |
{ |
379 |
case PaintSet.None: |
380 |
this.FillColor = null; |
381 |
Base_CirclePath.Fill = this.FillColor; |
382 |
break; |
383 |
case PaintSet.Fill: |
384 |
this.FillColor = this.StrokeColor; |
385 |
Base_CirclePath.Fill = this.FillColor; |
386 |
break; |
387 |
case PaintSet.Hatch: |
388 |
Base_CirclePath.Fill = HatchMake.CreateHatchBrush(this.StrokeColor); |
389 |
break; |
390 |
default: |
391 |
break; |
392 |
} |
393 |
|
394 |
|
395 |
CircleGroup.Children.Clear(); |
396 |
CircleGroup.FillRule = FillRule.Nonzero; |
397 |
CircleGroup.Children.Add(instance); |
398 |
|
399 |
try |
400 |
{ |
401 |
//강인구 수정(원 테두리가 잘리는것 방지) |
402 |
//this.Width = Math.Abs(this.CircleGroup.Bounds.Right + 2); |
403 |
//this.Height = Math.Abs(this.CircleGroup.Bounds.Bottom + 2); |
404 |
this.Width = Math.Abs(this.CircleGroup.Bounds.Right + 20); |
405 |
this.Height = Math.Abs(this.CircleGroup.Bounds.Bottom + 20); |
406 |
} |
407 |
catch (Exception) |
408 |
{ |
409 |
|
410 |
} |
411 |
CenterX = Math.Abs(this.CircleGroup.Bounds.X / 2); |
412 |
CenterY = Math.Abs(this.CircleGroup.Bounds.Y / 2); |
413 |
this.PathData = CircleGroup; |
414 |
ApplyOverViewData(); |
415 |
} |
416 |
|
417 |
public override void UpdateControl() |
418 |
{ |
419 |
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
420 |
this.LeftBottomPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
421 |
this.TopRightPoint = new Point(this.PointSet[3].X, this.PointSet[3].Y); |
422 |
this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
423 |
} |
424 |
|
425 |
public void SetCenterXY() |
426 |
{ |
427 |
CenterX = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint).X; |
428 |
CenterY = MathSet.getMiddlePoint(this.StartPoint, this.EndPoint).Y; |
429 |
} |
430 |
|
431 |
public override void ApplyOverViewData() |
432 |
{ |
433 |
this.OverViewPathData = this.PathData; |
434 |
} |
435 |
|
436 |
public void ChangePaint(PaintSet state) |
437 |
{ |
438 |
this.Paint = state; |
439 |
this.SetCircle(); |
440 |
} |
441 |
|
442 |
/// <summary> |
443 |
/// call when mouse is moving while drawing control |
444 |
/// </summary> |
445 |
/// <param name="pt"></param> |
446 |
/// <param name="bAxisLocked"></param> |
447 |
public override void OnCreatingMouseMove(Point pt, bool bAxisLocked) |
448 |
{ |
449 |
this.EndPoint = bAxisLocked ? this.GetSquareEndPoint(this.StartPoint, pt) : pt; |
450 |
this.LeftBottomPoint = new Point(this.StartPoint.X, this.EndPoint.Y); |
451 |
this.TopRightPoint = new Point(this.EndPoint.X, this.StartPoint.Y); |
452 |
|
453 |
this.PointSet = new List<Point> |
454 |
{ |
455 |
this.StartPoint, |
456 |
this.LeftBottomPoint, |
457 |
this.EndPoint, |
458 |
this.TopRightPoint, |
459 |
}; |
460 |
} |
461 |
|
462 |
/// <summary> |
463 |
/// move control point has same location of given pt along given delta |
464 |
/// </summary> |
465 |
/// <author>humkyung</author> |
466 |
/// <date>2019.06.20</date> |
467 |
/// <param name="pt"></param> |
468 |
/// <param name="dx"></param> |
469 |
/// <param name="dy"></param> |
470 |
public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false) |
471 |
{ |
472 |
IPath path = (this as IPath); |
473 |
Point selected = MathSet.getNearPoint(path.PointSet, pt); |
474 |
selected.X += dx; |
475 |
selected.Y += dy; |
476 |
int i = 0; |
477 |
for (i = 0; i < (this as IPath).PointSet.Count; i++) |
478 |
{ |
479 |
if (pt.Equals((this as IPath).PointSet[i])) |
480 |
{ |
481 |
(this as IPath).PointSet[i] = selected; |
482 |
break; |
483 |
} |
484 |
} |
485 |
|
486 |
List<Point> newPointSet = new List<Point> { }; |
487 |
Point middle = new Point(path.PathData.Bounds.X + path.PathData.Bounds.Width * 0.5, path.PathData.Bounds.Y + path.PathData.Bounds.Height * 0.5); |
488 |
foreach (Point _pt in path.PointSet) |
489 |
{ |
490 |
newPointSet.Add(_pt); |
491 |
} |
492 |
var ReverseP = (i + newPointSet.Count() / 2) % newPointSet.Count(); |
493 |
var PreviousP = (i + (newPointSet.Count() - 1)) % newPointSet.Count(); |
494 |
var NextP = (i + 1) % newPointSet.Count(); |
495 |
var distance = MathSet.DistanceTo(newPointSet[ReverseP], newPointSet[i]); |
496 |
var PreviousV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[PreviousP]); |
497 |
var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, newPointSet[i].X - newPointSet[ReverseP].X, |
498 |
newPointSet[i].Y - newPointSet[ReverseP].Y); |
499 |
newPointSet[PreviousP] = new Point(newPointSet[ReverseP].X + PreviousV.X * l, newPointSet[ReverseP].Y |
500 |
+ PreviousV.Y * l); |
501 |
|
502 |
var NextV = MathSet.GetNormVectorBetween(newPointSet[ReverseP], newPointSet[NextP]); |
503 |
l = MathSet.DotProduct(NextV.X, NextV.Y, newPointSet[i].X - newPointSet[ReverseP].X, newPointSet[i].Y |
504 |
- newPointSet[ReverseP].Y); |
505 |
newPointSet[NextP] = new Point(newPointSet[ReverseP].X + NextV.X * l, newPointSet[ReverseP].Y + NextV.Y * l); |
506 |
|
507 |
path.PointSet = newPointSet; |
508 |
this.UpdateControl(); |
509 |
} |
510 |
|
511 |
/// <summary> |
512 |
/// return circlecontrols' area |
513 |
/// </summary> |
514 |
/// <author>humkyung</author> |
515 |
/// <date>2019.06.13</date> |
516 |
public override Rect ItemRect |
517 |
{ |
518 |
get |
519 |
{ |
520 |
double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X); |
521 |
double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y); |
522 |
double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X); |
523 |
double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y); |
524 |
|
525 |
return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY)); |
526 |
} |
527 |
} |
528 |
|
529 |
/// <summary> |
530 |
/// Serialize this |
531 |
/// </summary> |
532 |
/// <param name="sUserId"></param> |
533 |
/// <returns></returns> |
534 |
public override string Serialize() |
535 |
{ |
536 |
using (S_CircleControl STemp = new S_CircleControl()) |
537 |
{ |
538 |
STemp.TransformPoint = "0|0"; |
539 |
STemp.SizeSet = String.Format("{0}", this.LineSize); |
540 |
STemp.PaintState = this.Paint; |
541 |
//STemp.StrokeColor = "#FF00FF00"; |
542 |
STemp.StrokeColor = this.StrokeColor.Color.ToString(); |
543 |
if (this.FillColor != null) |
544 |
{ |
545 |
STemp.FillColor = this.FillColor.Color.ToString(); |
546 |
} |
547 |
STemp.StartPoint = this.StartPoint; |
548 |
STemp.UserID = this.UserID; |
549 |
STemp.EndPoint = this.EndPoint; |
550 |
STemp.TRP = this.TopRightPoint; |
551 |
STemp.LBP = this.LeftBottomPoint; |
552 |
STemp.Opac = this.Opacity; |
553 |
STemp.Angle = this.CommentAngle; |
554 |
STemp.PointSet = this.PointSet; |
555 |
STemp.DashSize = this.DashSize; |
556 |
STemp.Name = this.GetType().Name.ToString(); |
557 |
///강인구 추가(2017.11.02) |
558 |
///Memo 추가 |
559 |
STemp.Memo = this.Memo; |
560 |
|
561 |
return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize())); |
562 |
}; |
563 |
} |
564 |
|
565 |
/// <summary> |
566 |
/// create a circlecontrol from given string |
567 |
/// </summary> |
568 |
/// <param name="str"></param> |
569 |
/// <returns></returns> |
570 |
public static CircleControl FromString(string str, SolidColorBrush brush, string sProjectNo) |
571 |
{ |
572 |
using (S_CircleControl s = JsonSerializerHelper.JsonDeserialize<S_CircleControl>(str)) |
573 |
{ |
574 |
string[] data2 = s.SizeSet.Split(CommentUserInfo.delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
575 |
return new CircleControl |
576 |
{ |
577 |
LineSize = Convert.ToDouble(data2.First()), |
578 |
Paint = s.PaintState, |
579 |
StartPoint = s.StartPoint, |
580 |
EndPoint = s.EndPoint, |
581 |
LeftBottomPoint = s.LBP, |
582 |
TopRightPoint = s.TRP, |
583 |
Opacity = s.Opac, |
584 |
CommentAngle = s.Angle, |
585 |
DashSize = s.DashSize, |
586 |
PointSet = s.PointSet, |
587 |
StrokeColor = brush, |
588 |
UserID = s.UserID, |
589 |
Memo = s.Memo |
590 |
}; |
591 |
} |
592 |
} |
593 |
} |
594 |
} |