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