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