markus / MarkupToPDF / Controls / Etc / DateControl.cs @ 0d00f9c8
이력 | 보기 | 이력해설 | 다운로드 (23.3 KB)
1 |
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 |
using MarkupToPDF.Serialize.Core; |
16 |
using MarkupToPDF.Serialize.S_Control; |
17 |
using System.Linq; |
18 |
|
19 |
namespace MarkupToPDF.Controls.Etc |
20 |
{ |
21 |
public class DateControl : CommentUserInfo, IDisposable, IPath, INotifyPropertyChanged, IViewBox, IMarkupCommonData |
22 |
{ |
23 |
private const string PART_ViewBox = "PART_ViewBox"; |
24 |
private const string PART_TextBox = "PART_TextBox"; |
25 |
public Viewbox Base_ViewBox = null; |
26 |
public TextBlock Base_TextBox = null; |
27 |
|
28 |
static DateControl() |
29 |
{ |
30 |
DefaultStyleKeyProperty.OverrideMetadata(typeof(DateControl), new FrameworkPropertyMetadata(typeof(DateControl))); |
31 |
//Application.Current.Resources.MergedDictionaries.Add(Application.LoadComponent(new Uri("/MarkupToPDF;Component/Themes/generic.xaml")) as ResourceDictionary); |
32 |
ResourceDictionary dictionary = new ResourceDictionary(); |
33 |
dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
34 |
Application.Current.Resources.MergedDictionaries.Add(dictionary); |
35 |
System.Diagnostics.Debug.WriteLine("resource Count :" + Application.Current.Resources.MergedDictionaries.Count); |
36 |
} |
37 |
|
38 |
public DateControl() |
39 |
{ |
40 |
this.DefaultStyleKey = typeof(DateControl); |
41 |
} |
42 |
|
43 |
|
44 |
#region Dependency Properties |
45 |
|
46 |
|
47 |
public static readonly DependencyProperty IsSelectedProperty = |
48 |
DependencyProperty.Register("IsSelected", typeof(bool), typeof(DateControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
49 |
|
50 |
public static readonly DependencyProperty ControlTypeProperty = |
51 |
DependencyProperty.Register("ControlType", typeof(ControlType), typeof(DateControl), new FrameworkPropertyMetadata(ControlType.Date)); |
52 |
|
53 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
54 |
"OverViewPathData", typeof(Geometry), typeof(DateControl), null); |
55 |
|
56 |
public static readonly DependencyProperty OverViewStartPointProperty = DependencyProperty.Register( |
57 |
"OverViewStartPoint", typeof(Point), typeof(DateControl), new PropertyMetadata(null)); |
58 |
|
59 |
public static readonly DependencyProperty OverViewEndPointProperty = DependencyProperty.Register( |
60 |
"OverViewEndPoint", typeof(Point), typeof(DateControl), new PropertyMetadata(null)); |
61 |
|
62 |
|
63 |
public static readonly DependencyProperty TextProperty = DependencyProperty.Register( |
64 |
"Text", typeof(string), typeof(DateControl), new PropertyMetadata(null)); |
65 |
public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
66 |
"UserID", typeof(string), typeof(DateControl), new PropertyMetadata(null)); |
67 |
public static readonly DependencyProperty FontColorProperty = DependencyProperty.Register( |
68 |
"FontColor", typeof(SolidColorBrush), typeof(DateControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
69 |
//[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] |
70 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
71 |
"StartPoint", typeof(Point), typeof(DateControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
72 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
73 |
"EndPoint", typeof(Point), typeof(DateControl), new PropertyMetadata(new Point(100, 100), PointValueChanged)); |
74 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
75 |
"LineSize", typeof(double), typeof(DateControl), new PropertyMetadata((double)3)); |
76 |
public static readonly DependencyProperty TopRightPointProperty = DependencyProperty.Register( |
77 |
"TopRightPoint", typeof(Point), typeof(DateControl), new PropertyMetadata(new Point(0, 0), TRPointValueChanged)); |
78 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
79 |
"PointSet", typeof(List<Point>), typeof(DateControl), new PropertyMetadata(new List<Point>())); |
80 |
public static readonly DependencyProperty LeftBottomPointProperty = DependencyProperty.Register( |
81 |
"LeftBottomPoint", typeof(Point), typeof(DateControl), new PropertyMetadata(new Point(0, 0), LBPointValueChanged)); |
82 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
83 |
"PathData", typeof(Geometry), typeof(DateControl), null); |
84 |
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register("Angle", typeof(double), typeof(DateControl), |
85 |
new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
86 |
|
87 |
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(DateControl), |
88 |
new PropertyMetadata((double)0, OnCenterXYChanged)); |
89 |
|
90 |
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(DateControl), |
91 |
new PropertyMetadata((double)0, OnCenterXYChanged)); |
92 |
|
93 |
#endregion |
94 |
#region PropertyChanged Method |
95 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
96 |
{ |
97 |
//var instance = (DateControl)sender; |
98 |
|
99 |
//if (e.OldValue != e.NewValue && instance.Base_ViewBox != null) |
100 |
//{ |
101 |
|
102 |
// instance.SetValue(e.Property, e.NewValue); |
103 |
|
104 |
// if (instance.IsSelected) |
105 |
// { |
106 |
// //instance.Base_ViewBox.Style. = new SolidColorBrush(Colors.Blue); |
107 |
// } |
108 |
// else |
109 |
// { |
110 |
// //instance.Base_ViewBox.Stroke = new SolidColorBrush(Colors.Red); |
111 |
// } |
112 |
//} |
113 |
} |
114 |
|
115 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
116 |
{ |
117 |
var instance = (DateControl)sender; |
118 |
if (e.OldValue != e.NewValue && instance.Base_TextBox != null) |
119 |
{ |
120 |
instance.SetValue(e.Property, e.NewValue); |
121 |
instance.SetDate(); |
122 |
} |
123 |
} |
124 |
public static void LBPointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
125 |
{ |
126 |
var instance = (DateControl)sender; |
127 |
if (e.OldValue != e.NewValue && instance.Base_TextBox != null) |
128 |
{ |
129 |
instance.SetValue(e.Property, e.NewValue); |
130 |
//instance.EndPoint = new Point(instance.EndPoint.X, ((Point)e.NewValue).Y); |
131 |
//instance.StartPoint = new Point(((Point)e.NewValue).X, instance.StartPoint.Y); |
132 |
////instance.PointSet[0] = instance.StartPoint; |
133 |
////instance.PointSet[2] = instance.EndPoint; |
134 |
instance.SetDate(); |
135 |
} |
136 |
} |
137 |
public static void TRPointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
138 |
{ |
139 |
var instance = (DateControl)sender; |
140 |
if (e.OldValue != e.NewValue && instance.Base_TextBox != null) |
141 |
{ |
142 |
instance.SetValue(e.Property, e.NewValue); |
143 |
instance.SetDate(); |
144 |
} |
145 |
} |
146 |
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
147 |
{ |
148 |
var instance = (DateControl)sender; |
149 |
if (e.OldValue != e.NewValue && instance.Base_ViewBox != null) |
150 |
{ |
151 |
instance.SetValue(e.Property, e.NewValue); |
152 |
instance.SetDate(); |
153 |
} |
154 |
} |
155 |
|
156 |
public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
157 |
{ |
158 |
var instance = (DateControl)sender; |
159 |
if (e.OldValue != e.NewValue && instance.Base_ViewBox != null) |
160 |
{ |
161 |
instance.SetValue(e.Property, e.NewValue); |
162 |
instance.SetDate(); |
163 |
} |
164 |
} |
165 |
#endregion |
166 |
#region Properties |
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 |
OnPropertyChanged("LineSize"); |
176 |
} |
177 |
} |
178 |
} |
179 |
public string UserID |
180 |
{ |
181 |
get { return (string)GetValue(UserIDProperty); } |
182 |
set |
183 |
{ |
184 |
if (this.UserID != value) |
185 |
{ |
186 |
SetValue(UserIDProperty, value); |
187 |
OnPropertyChanged("UserID"); |
188 |
} |
189 |
} |
190 |
} |
191 |
public double Angle |
192 |
{ |
193 |
get { return (double)GetValue(AngleProperty); } |
194 |
set |
195 |
{ |
196 |
if (this.Angle != value) |
197 |
{ |
198 |
SetValue(AngleProperty, value); |
199 |
} |
200 |
} |
201 |
} |
202 |
|
203 |
|
204 |
|
205 |
public override bool IsSelected |
206 |
{ |
207 |
get |
208 |
{ |
209 |
return (bool)GetValue(IsSelectedProperty); |
210 |
} |
211 |
set |
212 |
{ |
213 |
SetValue(IsSelectedProperty, value); |
214 |
OnPropertyChanged("IsSelected"); |
215 |
} |
216 |
} |
217 |
|
218 |
public override ControlType ControlType |
219 |
{ |
220 |
set |
221 |
{ |
222 |
SetValue(ControlTypeProperty, value); |
223 |
OnPropertyChanged("ControlType"); |
224 |
} |
225 |
get |
226 |
{ |
227 |
return (ControlType)GetValue(ControlTypeProperty); |
228 |
} |
229 |
} |
230 |
|
231 |
public Geometry OverViewPathData |
232 |
{ |
233 |
get { return (Geometry)GetValue(OverViewPathDataProperty); } |
234 |
set |
235 |
{ |
236 |
SetValue(OverViewPathDataProperty, value); |
237 |
OnPropertyChanged("OverViewPathData"); |
238 |
} |
239 |
} |
240 |
|
241 |
public List<Point> PointSet |
242 |
{ |
243 |
get { return (List<Point>)GetValue(PointSetProperty); } |
244 |
set { SetValue(PointSetProperty, value); } |
245 |
} |
246 |
public Point TopRightPoint |
247 |
{ |
248 |
get { return (Point)GetValue(TopRightPointProperty); } |
249 |
set |
250 |
{ |
251 |
SetValue(TopRightPointProperty, value); |
252 |
OnPropertyChanged("TopRightPoint"); |
253 |
} |
254 |
} |
255 |
public Point LeftBottomPoint |
256 |
{ |
257 |
get { return (Point)GetValue(LeftBottomPointProperty); } |
258 |
set |
259 |
{ |
260 |
SetValue(LeftBottomPointProperty, value); |
261 |
OnPropertyChanged("LeftBottomPoint"); |
262 |
} |
263 |
} |
264 |
public double CenterX |
265 |
{ |
266 |
get { return (double)GetValue(CenterXProperty); } |
267 |
set { SetValue(CenterXProperty, value); } |
268 |
} |
269 |
public double CenterY |
270 |
{ |
271 |
get { return (double)GetValue(CenterYProperty); } |
272 |
set { SetValue(CenterYProperty, value); } |
273 |
} |
274 |
public string Text |
275 |
{ |
276 |
get { return (string)GetValue(TextProperty); } |
277 |
set |
278 |
{ |
279 |
if (this.Text != value) |
280 |
{ |
281 |
SetValue(TextProperty, value); |
282 |
OnPropertyChanged("Text"); |
283 |
} |
284 |
} |
285 |
} |
286 |
public Geometry PathData |
287 |
{ |
288 |
get { return (Geometry)GetValue(PathDataProperty); } |
289 |
set |
290 |
{ |
291 |
SetValue(PathDataProperty, value); |
292 |
OnPropertyChanged("PathData"); |
293 |
} |
294 |
} |
295 |
public SolidColorBrush FontColor |
296 |
{ |
297 |
get { return (SolidColorBrush)GetValue(FontColorProperty); } |
298 |
set |
299 |
{ |
300 |
if (this.FontColor != value) |
301 |
{ |
302 |
SetValue(FontColorProperty, value); |
303 |
OnPropertyChanged("FontColor"); |
304 |
} |
305 |
|
306 |
} |
307 |
} |
308 |
public Point EndPoint |
309 |
{ |
310 |
get { return (Point)GetValue(EndPointProperty); } |
311 |
set |
312 |
{ |
313 |
if (this.EndPoint != value) |
314 |
{ |
315 |
SetValue(EndPointProperty, value); |
316 |
OnPropertyChanged("EndPoint"); |
317 |
} |
318 |
} |
319 |
} |
320 |
public Point StartPoint |
321 |
{ |
322 |
get { return (Point)GetValue(StartPointProperty); } |
323 |
set |
324 |
{ |
325 |
if (this.StartPoint != value) |
326 |
{ |
327 |
SetValue(StartPointProperty, value); |
328 |
OnPropertyChanged("StartPoint"); |
329 |
} |
330 |
} |
331 |
} |
332 |
|
333 |
public Point OverViewStartPoint |
334 |
{ |
335 |
get { return (Point)GetValue(OverViewStartPointProperty); } |
336 |
set { SetValue(OverViewStartPointProperty, value); } |
337 |
} |
338 |
|
339 |
public Point OverViewEndPoint |
340 |
{ |
341 |
get { return (Point)GetValue(OverViewEndPointProperty); } |
342 |
set { SetValue(OverViewEndPointProperty, value); } |
343 |
} |
344 |
|
345 |
//public int MyProperty { get; set; } |
346 |
|
347 |
|
348 |
#endregion |
349 |
#region Data |
350 |
LineGeometry p1 = new LineGeometry(); |
351 |
LineGeometry p2 = new LineGeometry(); |
352 |
LineGeometry p3 = new LineGeometry(); |
353 |
LineGeometry p4 = new LineGeometry(); |
354 |
GeometryGroup instanceGroup = new GeometryGroup(); |
355 |
FormattedText text; |
356 |
#endregion |
357 |
public override void OnApplyTemplate() |
358 |
{ |
359 |
base.OnApplyTemplate(); |
360 |
Base_ViewBox = GetTemplateChild(PART_ViewBox) as Viewbox; |
361 |
Base_TextBox = GetTemplateChild(PART_TextBox) as TextBlock; |
362 |
Base_TextBox.Visibility = System.Windows.Visibility.Hidden; |
363 |
SetDate(); |
364 |
} |
365 |
|
366 |
private void SetDate() |
367 |
{ |
368 |
if (Text == null) |
369 |
{ |
370 |
Text = DateTime.Now.ToString("yyyy-MM-dd"); |
371 |
} |
372 |
this.ApplyTemplate(); |
373 |
instanceGroup.Children.Clear(); |
374 |
Base_TextBox.Visibility = System.Windows.Visibility.Visible; |
375 |
Point mid = MathSet.FindCentroid(new List<Point>() |
376 |
{ |
377 |
this.StartPoint, |
378 |
this.LeftBottomPoint, |
379 |
this.EndPoint, |
380 |
this.TopRightPoint, |
381 |
}); |
382 |
|
383 |
|
384 |
double AngleData = this.Angle * -1; |
385 |
|
386 |
PathFigure pathFigure = new PathFigure(); |
387 |
pathFigure.StartPoint = MathSet.RotateAbout(mid, this.StartPoint, AngleData); |
388 |
|
389 |
LineSegment lineSegment0 = new LineSegment(); |
390 |
lineSegment0.Point = MathSet.RotateAbout(mid, this.StartPoint, AngleData); |
391 |
pathFigure.Segments.Add(lineSegment0); |
392 |
|
393 |
LineSegment lineSegment1 = new LineSegment(); |
394 |
lineSegment1.Point = MathSet.RotateAbout(mid, this.LeftBottomPoint, AngleData); |
395 |
pathFigure.Segments.Add(lineSegment1); |
396 |
|
397 |
LineSegment lineSegment2 = new LineSegment(); |
398 |
lineSegment2.Point = MathSet.RotateAbout(mid, this.EndPoint, AngleData); |
399 |
pathFigure.Segments.Add(lineSegment2); |
400 |
|
401 |
LineSegment lineSegment3 = new LineSegment(); |
402 |
lineSegment3.Point = MathSet.RotateAbout(mid, this.TopRightPoint, AngleData); |
403 |
pathFigure.Segments.Add(lineSegment3); |
404 |
|
405 |
PathGeometry pathGeometry = new PathGeometry(); |
406 |
pathGeometry.Figures = new PathFigureCollection(); |
407 |
pathFigure.IsClosed = true; |
408 |
pathGeometry.Figures.Add(pathFigure); |
409 |
this.Base_ViewBox.Width = pathGeometry.Bounds.Width; |
410 |
this.Base_ViewBox.Height = pathGeometry.Bounds.Height; |
411 |
this.Tag = pathGeometry; |
412 |
|
413 |
Canvas.SetLeft(this, MathSet.RotateAbout(mid, mid, AngleData).X - this.Base_ViewBox.Width / 2); |
414 |
Canvas.SetTop(this, MathSet.RotateAbout(mid, mid, AngleData).Y - this.Base_ViewBox.Height / 2); |
415 |
|
416 |
//CenterX = MathSet.RotateAbout(mid, mid, AngleData).X - this.Base_ViewBox.Width / 2; |
417 |
//CenterY = MathSet.RotateAbout(mid, mid, AngleData).Y - this.Base_ViewBox.Height / 2; |
418 |
|
419 |
instanceGroup.Children.Add(pathGeometry); |
420 |
|
421 |
text = new FormattedText(Text, System.Globalization.CultureInfo.CurrentCulture, |
422 |
FlowDirection.LeftToRight, new Typeface("Tahoma"), 16, Brushes.Black); |
423 |
|
424 |
instanceGroup.Children.Add(text.BuildGeometry(new Point(10,10))); |
425 |
|
426 |
PathData = instanceGroup; |
427 |
//OverViewPathData = PathData; |
428 |
|
429 |
|
430 |
} |
431 |
|
432 |
public event PropertyChangedEventHandler PropertyChanged; |
433 |
protected void OnPropertyChanged(string propName) |
434 |
{ |
435 |
if (PropertyChanged != null) |
436 |
PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
437 |
} |
438 |
|
439 |
public void Dispose() |
440 |
{ |
441 |
GC.Collect(); |
442 |
GC.SuppressFinalize(this); |
443 |
} |
444 |
|
445 |
public override void ApplyOverViewData() |
446 |
{ |
447 |
//this.OverViewPathData = this.PathData; |
448 |
this.OverViewStartPoint = this.StartPoint; |
449 |
this.OverViewEndPoint = this.EndPoint; |
450 |
} |
451 |
|
452 |
public override void UpdateControl() |
453 |
{ |
454 |
this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y); |
455 |
this.TopRightPoint = new Point(this.PointSet[3].X, this.PointSet[3].Y); |
456 |
this.LeftBottomPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y); |
457 |
this.EndPoint = new Point(this.PointSet[2].X, this.PointSet[2].Y); |
458 |
this.SetDate(); |
459 |
} |
460 |
|
461 |
/// <summary> |
462 |
/// call when mouse is moving while drawing control |
463 |
/// </summary> |
464 |
/// <author>humkyung</author> |
465 |
/// <param name="pt"></param> |
466 |
/// <param name="bAxisLocked"></param> |
467 |
public override void OnCreatingMouseMove(Point pt, bool bAxisLocked, bool bShiftKeyPressed) |
468 |
{ |
469 |
this.EndPoint = pt; |
470 |
this.LeftBottomPoint = new Point(this.StartPoint.X, this.EndPoint.Y); |
471 |
this.TopRightPoint = new Point(this.EndPoint.X, this.StartPoint.Y); |
472 |
|
473 |
this.PointSet = new List<Point> |
474 |
{ |
475 |
this.StartPoint, |
476 |
this.LeftBottomPoint, |
477 |
this.EndPoint, |
478 |
this.TopRightPoint, |
479 |
}; |
480 |
} |
481 |
|
482 |
/// <summary> |
483 |
/// move control point has same location of given pt along given delta |
484 |
/// </summary> |
485 |
/// <author>humkyung</author> |
486 |
/// <date>2019.06.20</date> |
487 |
/// <param name="pt"></param> |
488 |
/// <param name="dx"></param> |
489 |
/// <param name="dy"></param> |
490 |
public override void OnMoveCtrlPoint(Point pt, double dx, double dy) |
491 |
{ |
492 |
IPath path = (this as IPath); |
493 |
|
494 |
Point selected = MathSet.getNearPoint(path.PointSet, pt); |
495 |
selected.X += dx; |
496 |
selected.Y += dy; |
497 |
int i = 0; |
498 |
for (i = 0; i < (this as IPath).PointSet.Count; i++) |
499 |
{ |
500 |
if (pt.Equals((this as IPath).PointSet[i])) |
501 |
{ |
502 |
path.PointSet[i] = selected; |
503 |
break; |
504 |
} |
505 |
} |
506 |
|
507 |
var ReverseP = (i + path.PointSet.Count / 2) % path.PointSet.Count; |
508 |
var PreviousP = (i + (path.PointSet.Count - 1)) % path.PointSet.Count; |
509 |
var NextP = (i + 1) % path.PointSet.Count; |
510 |
|
511 |
var distance = MathSet.DistanceTo(path.PointSet[ReverseP], path.PointSet[i]); |
512 |
|
513 |
var PreviousV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[PreviousP]); |
514 |
var l = MathSet.DotProduct(PreviousV.X, PreviousV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, |
515 |
path.PointSet[i].Y - path.PointSet[ReverseP].Y); |
516 |
path.PointSet[PreviousP] = new Point(path.PointSet[ReverseP].X + PreviousV.X * l, path.PointSet[ReverseP].Y + PreviousV.Y * l); |
517 |
|
518 |
var NextV = MathSet.GetNormVectorBetween(path.PointSet[ReverseP], path.PointSet[NextP]); |
519 |
l = MathSet.DotProduct(NextV.X, NextV.Y, path.PointSet[i].X - path.PointSet[ReverseP].X, path.PointSet |
520 |
[i].Y - path.PointSet[ReverseP].Y); |
521 |
path.PointSet[NextP] = new Point(path.PointSet[ReverseP].X + NextV.X * l, path.PointSet[ReverseP].Y + NextV.Y * l); |
522 |
|
523 |
this.UpdateControl(); |
524 |
} |
525 |
|
526 |
/// <summary> |
527 |
/// return DateControl's area |
528 |
/// </summary> |
529 |
/// <author>humkyung</author> |
530 |
/// <date>2019.06.13</date> |
531 |
public override Rect ItemRect |
532 |
{ |
533 |
get |
534 |
{ |
535 |
double dMinX = Math.Min(this.StartPoint.X, this.EndPoint.X); |
536 |
double dMinY = Math.Min(this.StartPoint.Y, this.EndPoint.Y); |
537 |
double dMaxX = Math.Max(this.StartPoint.X, this.EndPoint.X); |
538 |
double dMaxY = Math.Max(this.StartPoint.Y, this.EndPoint.Y); |
539 |
|
540 |
return new Rect(new Point(dMinX, dMinY), new Point(dMaxX, dMaxY)); |
541 |
} |
542 |
} |
543 |
|
544 |
/// <summary> |
545 |
/// Serialize this |
546 |
/// </summary> |
547 |
/// <param name="sUserId"></param> |
548 |
/// <returns></returns> |
549 |
public override string Serialize() |
550 |
{ |
551 |
using (S_DateControl STemp = new S_DateControl()) |
552 |
{ |
553 |
STemp.Angle = this.Angle; |
554 |
STemp.EndPoint = this.EndPoint; |
555 |
STemp.UserID = this.UserID; |
556 |
STemp.LB = this.LeftBottomPoint; |
557 |
STemp.Name = this.GetType().Name; |
558 |
STemp.PointSet = this.PointSet; |
559 |
STemp.StartPoint = this.StartPoint; |
560 |
STemp.Opac = this.Opacity; |
561 |
STemp.TR = this.TopRightPoint; |
562 |
STemp.TransformPoint = "0|0"; |
563 |
STemp.FontColor = this.FontColor.Color.ToString(); |
564 |
//STemp.FontColor = "#FFFFFF00"; |
565 |
STemp.SizeSet = String.Format("{0}", this.LineSize); |
566 |
STemp.Text = this.Text; |
567 |
///강인구 추가(2017.11.02) |
568 |
///Memo 추가 |
569 |
STemp.Memo = this.Memo; |
570 |
|
571 |
return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize())); |
572 |
} |
573 |
} |
574 |
|
575 |
/// <summary> |
576 |
/// create a datecontrol from given string |
577 |
/// </summary> |
578 |
/// <param name="str"></param> |
579 |
/// <returns></returns> |
580 |
public static DateControl FromString(string str, SolidColorBrush brush, string sProjectNo) |
581 |
{ |
582 |
using (S_DateControl s = JsonSerializerHelper.JsonDeserialize<S_DateControl>(str)) |
583 |
{ |
584 |
string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
585 |
return new DateControl |
586 |
{ |
587 |
Angle = s.Angle, |
588 |
StartPoint = s.StartPoint, |
589 |
EndPoint = s.EndPoint, |
590 |
LeftBottomPoint = s.LB, |
591 |
TopRightPoint = s.TR, |
592 |
Opacity = s.Opac, |
593 |
FontColor = brush, |
594 |
LineSize = Convert.ToDouble(data2.First()), |
595 |
Text = s.Text, |
596 |
PointSet = s.PointSet, |
597 |
UserID = s.UserID, |
598 |
Memo = s.Memo |
599 |
}; |
600 |
} |
601 |
} |
602 |
} |
603 |
} |