프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / MarkupToPDF / Controls / Etc / DateControl.cs @ b1c2c6fe

이력 | 보기 | 이력해설 | 다운로드 (24.5 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 7b34fb3a swate0609
            }
61
        }
62
63 873011c4 humkyung
        /// <summary>
64
        /// 복사본을 생성한다.
65
        /// </summary>
66
        /// <returns></returns>
67
        public override CommentUserInfo Clone()
68
        {
69 7b34fb3a swate0609
70
            var clone = new DateControl();
71
            clone.Copy(this);
72
            return clone;
73 873011c4 humkyung
        }
74 787a4489 KangIngu
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 554aae3b humkyung
223 fa48eb85 taeseongkim
        public override double CommentAngle
224 787a4489 KangIngu
        {
225
            get { return (double)GetValue(AngleProperty); }
226
            set
227
            {
228 fa48eb85 taeseongkim
                if (this.CommentAngle != value)
229 787a4489 KangIngu
                {
230
                    SetValue(AngleProperty, value);
231
                }
232
            }
233
        }
234
235 959b3ef2 humkyung
        public override bool IsSelected
236 787a4489 KangIngu
        {
237
            get
238
            {
239
                return (bool)GetValue(IsSelectedProperty);
240
            }
241
            set
242
            {
243
                SetValue(IsSelectedProperty, value);
244
                OnPropertyChanged("IsSelected");
245
            }
246
        }
247
248 5529d2a2 humkyung
        public override ControlType ControlType
249 787a4489 KangIngu
        {
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 661b7416 humkyung
396
        private void SetDate()
397 787a4489 KangIngu
        {
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 fa48eb85 taeseongkim
            double AngleData = this.CommentAngle * -1;
415 787a4489 KangIngu
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 a6f7f9b6 djkim
            //GC.Collect();
472 24c5e56c taeseongkim
            ////GC.SuppressFinalize(this);
473 a6f7f9b6 djkim
            this.Base_TextBox = null;
474
            this.Base_ViewBox = null;
475 787a4489 KangIngu
        }
476
477 f513c215 humkyung
        public override void ApplyOverViewData()
478 787a4489 KangIngu
        {
479
            //this.OverViewPathData = this.PathData;
480
            this.OverViewStartPoint = this.StartPoint;
481
            this.OverViewEndPoint = this.EndPoint;
482
        }
483
484 0d00f9c8 humkyung
        public override void UpdateControl()
485 787a4489 KangIngu
        {
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 036650a0 humkyung
493
        /// <summary>
494 a6272c57 humkyung
        /// 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 233ef333 taeseongkim
        public override void OnCreatingMouseMove(Point pt, bool bAxisLocked)
500 a6272c57 humkyung
        {
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 d2114d3b humkyung
        /// 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 233ef333 taeseongkim
        public override void OnMoveCtrlPoint(Point pt, double dx, double dy, bool bAxisLocked = false)
523 d2114d3b humkyung
        {
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 0d00f9c8 humkyung
            this.UpdateControl();
556 d2114d3b humkyung
        }
557
558
        /// <summary>
559 91efe37a humkyung
        /// 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 036650a0 humkyung
        /// 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 fa48eb85 taeseongkim
                STemp.Angle = this.CommentAngle;
586 036650a0 humkyung
                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 661b7416 humkyung
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 fa48eb85 taeseongkim
                    CommentAngle = s.Angle,
620 661b7416 humkyung
                    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 787a4489 KangIngu
    }
635
}
클립보드 이미지 추가 (최대 크기: 500 MB)