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