프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Text / TextControl.cs @ 056e4dfd

이력 | 보기 | 이력해설 | 다운로드 (44.6 KB)

1 787a4489 KangIngu
using MarkupToPDF.Common;
2
using MarkupToPDF.Controls.Common;
3 036650a0 humkyung
using MarkupToPDF.Serialize.Core;
4
using MarkupToPDF.Serialize.S_Control;
5 787a4489 KangIngu
using System;
6
using System.Collections.Generic;
7
using System.ComponentModel;
8
using System.Linq;
9
using System.Text;
10
using System.Threading.Tasks;
11
using System.Windows;
12
using System.Windows.Controls;
13
using System.Windows.Media;
14
using System.Windows.Shapes;
15
16
namespace MarkupToPDF.Controls.Text
17 8898253f djkim
{    
18
    public class TextControl : CommentUserInfo, IDisposable, INotifyPropertyChanged, IPath, ITextControl, IMarkupControlData
19 787a4489 KangIngu
    {
20
        public event PropertyChangedEventHandler PropertyChanged;
21
22
        private const string PART_Grid = "PART_Grid";
23
        private const string PART_Border = "PART_Border";
24
        private const string PART_TextBox = "PART_TextBox";
25
        private const string PART_TextPath = "PART_TextPath";
26
        private const string PART_TextBlock = "PART_TextBlock";
27 0d00f9c8 humkyung
        private const string PART_Canvas = "PART_TextControlCanvas";
28 3074202c 송근호
        private const string PART_BaseTextbox_Caret = "Caret";
29
        
30 787a4489 KangIngu
        //private const string PART_TextPrefix = "PART_TextPrefix";
31 3074202c 송근호
      
32 787a4489 KangIngu
        public Path Base_TextPath = null;
33
        public Grid Base_Grid = null;
34
        public Border Base_Border = null;
35 0d00f9c8 humkyung
        public Canvas Base_Canvas = null;
36 787a4489 KangIngu
        //public TextBlock Base_TextPrefixBlock = null;
37
        public TextBlock Base_TextBlock = null;
38
        public TextBox Base_TextBox = null;
39 3074202c 송근호
        public Border BaseTextbox_Caret = null;
40 787a4489 KangIngu
41
        public RotateTransform _rotation = null;
42
        public TranslateTransform _translation = null;
43
        public ScaleTransform _scale = null;
44
45 53393bae KangIngu
        private const double _CloudArcDepth = 0.8;  /// 2018.05.14 added by humkyung
46 5a9353a9 humkyung
47 959b3ef2 humkyung
        public override bool IsSelected
48 787a4489 KangIngu
        {
49
            get
50
            {
51
                return (bool)GetValue(IsSelectedProperty);
52
            }
53
            set
54
            {
55
                SetValue(IsSelectedProperty, value);
56
                OnPropertyChanged("IsSelected");
57
            }
58
        }
59
60
        #region Internal Method
61
62
        public TextControl()
63
        {
64 a6f7f9b6 djkim
            //this.DefaultStyleKey = typeof(TextControl);
65 787a4489 KangIngu
        }
66
67
        static TextControl()
68
        {
69
            DefaultStyleKeyProperty.OverrideMetadata(typeof(TextControl), new FrameworkPropertyMetadata(typeof(TextControl)));
70 a6f7f9b6 djkim
            //ResourceDictionary dictionary = new ResourceDictionary();
71
            //dictionary.Source = new Uri("/MarkupToPDF;component/Themes/generic.xaml", UriKind.RelativeOrAbsolute);
72
            //if (!Application.Current.Resources.MergedDictionaries.Any(x => x.Source == dictionary.Source))
73
            //    Application.Current.Resources.MergedDictionaries.Add(dictionary);
74 90db87f6 송근호
75 787a4489 KangIngu
        }
76 90db87f6 송근호
77
78 787a4489 KangIngu
        public override void OnApplyTemplate()
79
        {
80 90db87f6 송근호
            base.OnApplyTemplate();
81 787a4489 KangIngu
82
            Base_TextPath = GetTemplateChild(PART_TextPath) as Path;
83
            Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox;
84
            Base_TextBlock = GetTemplateChild(PART_TextBlock) as TextBlock;
85
            Base_Grid = GetTemplateChild(PART_Grid) as Grid;
86
            Base_Border = GetTemplateChild(PART_Border) as Border;
87 0d00f9c8 humkyung
            Base_Canvas = GetTemplateChild(PART_Canvas) as Canvas;
88 3074202c 송근호
            BaseTextbox_Caret = GetTemplateChild(PART_BaseTextbox_Caret) as Border;
89
            this.Base_TextBox.Text = this.Text;
90
            this.Base_TextBox.CaretIndex = this.Base_TextBox.Text.Length;
91
            this.Base_TextBox.CaretBrush = new SolidColorBrush(Colors.Transparent);
92
            this.Base_TextBox.ApplyTemplate();
93
            MoveCustomCaret();
94
95 8898253f djkim
            this.Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged);
96
            this.Base_TextBox.TextChanged += new TextChangedEventHandler(Base_TextBox_TextChanged);
97
            this.Base_TextBlock.SizeChanged += new SizeChangedEventHandler(Base_TextBlock_SizeChanged);
98 3c71b3a5 taeseongkim
            this.Base_TextBox.GotFocus += new RoutedEventHandler(Base_TextBox_GotFocus);
99
            this.Base_TextBox.LostFocus += new RoutedEventHandler(Base_TextBox_LostFocus);            
100 3074202c 송근호
            this.Base_TextBox.SelectionChanged += (sender, e) => MoveCustomCaret();
101 b1ec47cb 송근호
            
102 8898253f djkim
            
103 787a4489 KangIngu
            SetText();
104 8898253f djkim
            DrawingCloud();
105
106 3074202c 송근호
107
108
        }
109 8898253f djkim
110
        
111
112
113
114 3074202c 송근호
        /// <summary>
115
        /// Moves the custom caret on the canvas.
116
        /// </summary>
117
        public void MoveCustomCaret()
118
        {
119
120
            var caretLocation = this.Base_TextBox.GetRectFromCharacterIndex(this.Base_TextBox.CaretIndex).Location;
121
122
            if (!double.IsInfinity(caretLocation.X)) {
123
                Canvas.SetLeft(this.BaseTextbox_Caret, caretLocation.X);
124
            }
125
126
            if (!double.IsInfinity(caretLocation.Y)) {
127
                Canvas.SetTop(this.BaseTextbox_Caret, caretLocation.Y);
128
            }
129 787a4489 KangIngu
        }
130
131 3c71b3a5 taeseongkim
        
132 414aaec1 송근호
133 f513c215 humkyung
        public override void ApplyOverViewData()
134 787a4489 KangIngu
        {
135
            this.OverViewPathData = this.PathData;
136 8898253f djkim
            if (Text == "")
137
                this.Text = this.OverViewText;
138
            else
139
                this.OverViewText = this.Text;
140
            
141 787a4489 KangIngu
            this.OverViewPaint = this.Paint;
142
143 3c71b3a5 taeseongkim
        }        
144 787a4489 KangIngu
145
        void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e)
146 8898253f djkim
        {
147
            BoxWidth = e.NewSize.Width;
148
            BoxHeight = e.NewSize.Height;
149
150
            DrawingCloud();
151
        }
152
        private void Base_TextBlock_SizeChanged(object sender, SizeChangedEventArgs e)
153
        {
154
            BoxWidth = e.NewSize.Width;
155
            BoxHeight = e.NewSize.Height;
156
157
            DrawingCloud();
158
        }
159
        private void Base_TextBox_TextChanged(object sender, TextChangedEventArgs e)
160
        {
161
            if (IsEditingMode)
162 3c71b3a5 taeseongkim
            {
163
                if (Base_TextBox.Text.Contains("|OR||DZ|"))
164
                {
165
                    Base_TextBox.Text = this.Text;
166
                }
167 90db87f6 송근호
168 3c71b3a5 taeseongkim
                this.Text = Base_TextBox.Text;
169 8898253f djkim
170 3c71b3a5 taeseongkim
            }            
171 8898253f djkim
            DrawingCloud();
172 787a4489 KangIngu
        }
173 3c71b3a5 taeseongkim
        void Base_TextBox_GotFocus(object sender, RoutedEventArgs e)
174 787a4489 KangIngu
        {
175 3c71b3a5 taeseongkim
            this.BaseTextbox_Caret.Visibility = Visibility.Visible;
176
            this.IsEditingMode = true;
177 787a4489 KangIngu
        }
178
179 3c71b3a5 taeseongkim
        void Base_TextBox_LostFocus(object sender, RoutedEventArgs e)
180 787a4489 KangIngu
        {
181 3c71b3a5 taeseongkim
            this.Text = Base_TextBox.Text;
182
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
183
            this.IsEditingMode = false;
184 787a4489 KangIngu
            ApplyOverViewData();
185
        }
186
187
        //void TextControl_GotFocus(object sender, RoutedEventArgs e)
188
        //{
189
        //    Base_TextBox.Visibility = Visibility.Visible;
190
        //    Base_TextBlock.Visibility = Visibility.Collapsed;
191
        //    this.Base_TextBox.BorderThickness = new Thickness(1);
192
        //    if (UnderLine != null)
193
        //    {
194
        //        Base_TextBlock.TextDecorations = UnderLine;
195
        //    }
196
        //    if (this.Text != null)
197
        //    {
198
        //        Base_TextBox.Text = this.Text;
199
        //    }
200
        //    IsEditing = true;
201
        //}
202
        //void TextControl_LostFocus(object sender, RoutedEventArgs e)
203
        //{
204
        //    Base_TextBox.Visibility = Visibility.Collapsed;
205
        //    Base_TextBlock.Visibility = Visibility.Visible;
206
        //    this.Text = Base_TextBox.Text;
207
        //    if (UnderLine != null)
208
        //    {
209
        //        Base_TextBlock.TextDecorations = UnderLine;
210
        //    }
211
        //    Base_TextBlock.Margin =
212
        //       new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4, Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4);
213
        //    IsEditing = false;
214
        //}
215
        public void EditingMode()
216 3c71b3a5 taeseongkim
        {            
217 787a4489 KangIngu
            TextBoxVisibility = Visibility.Visible;
218
            TextBlockVisibility = Visibility.Collapsed;
219 3c71b3a5 taeseongkim
            this.BaseTextbox_Caret.Visibility = Visibility.Visible;
220 787a4489 KangIngu
221
            if (UnderLine != null)
222
                Base_TextBlock.TextDecorations = UnderLine;
223
224
        }
225
226
        public void UnEditingMode()
227 3c71b3a5 taeseongkim
        {            
228
            TextBoxVisibility = Visibility.Collapsed;         
229
            TextBlockVisibility = Visibility.Visible; 
230 3074202c 송근호
            this.BaseTextbox_Caret.Visibility = Visibility.Collapsed;
231
232 787a4489 KangIngu
            if (UnderLine != null)
233
                Base_TextBlock.TextDecorations = UnderLine;
234
235 3c71b3a5 taeseongkim
            
236 787a4489 KangIngu
        }
237
        public void SetText()
238
        {
239
            if (IsHighLight)
240
            {
241
                this.BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6),
242
                    Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
243
                this.BackColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1),
244
                    Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
245
            }
246
            else
247
            {
248
                this.BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6),
249
                    Colors.White.R, Colors.White.G, Colors.White.B));
250
251
                this.BackColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1),
252
                    Colors.White.R, Colors.White.G, Colors.White.B));
253
            }
254
            if (Base_TextPath != null)
255
            {
256
                Base_TextPath.StrokeThickness = LineSize.Left;
257
            }
258 8898253f djkim
            
259 787a4489 KangIngu
        }
260
261
        public void DrawingCloud()
262
        {
263 8898253f djkim
            
264 787a4489 KangIngu
            List<Point> pCloud = new List<Point>
265
            {
266
                new Point(0, 0),
267
                new Point(0, 0 + BoxHeight + 0),
268
                new Point(0 + BoxWidth + 2, 0 + BoxHeight + 0),
269 8898253f djkim
                new Point(0 + BoxWidth + 2 ,0)
270 787a4489 KangIngu
            };
271 3074202c 송근호
            //this.Base_TextBox.Select(Base_TextBox.Text.Length, 0);
272 787a4489 KangIngu
            if (Base_TextPath != null)
273
            {
274
                switch (ControlType_No)
275
                {
276
                    case 0:
277
                        {
278
                            PathData = new PathGeometry();
279
                            PathDataInner = (GenerateInner(pCloud));
280
                        }
281
                        break;
282
                    case 1:
283
                        {
284
                            PathData = (Generate_Rect(pCloud));
285
                            List<Point> pCloud2 = new List<Point>
286
                            {
287
                                new Point(0, 0),
288
                                new Point(0, 0 + BoxHeight + 0),
289
                                new Point(0 + BoxWidth + 10, 0 + BoxHeight + 0),
290 8898253f djkim
                                new Point(0 + BoxWidth + 10 ,0)
291 787a4489 KangIngu
                            };
292
                            PathDataInner = (GenerateInner(pCloud));
293
                        }
294
                        break;
295
                    case 2:
296
                        {
297
                            PathData = (Generate(pCloud));
298
                            PathDataInner = (GenerateInner(pCloud));
299
                        }
300
                        break;
301
                }
302
            }
303
304 6b5d33c6 djkim
            //SetText();
305 787a4489 KangIngu
        }
306
        #endregion Internal Method
307
308
        public void Dispose()
309
        {
310 a6f7f9b6 djkim
            //GC.Collect();
311
            //GC.SuppressFinalize(this);
312
            this.Base_Border = null;
313
            this.Base_Canvas = null;
314
            this.Base_Grid = null;
315
            this.Base_TextBlock = null;
316
            this.Base_TextBox = null;
317 787a4489 KangIngu
        }
318 0d00f9c8 humkyung
319
        public override void UpdateControl()
320 787a4489 KangIngu
        {
321 0d00f9c8 humkyung
            if (this.PointSet.Count > 1)
322
            {
323
                this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
324
                this.EndPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
325
            }
326 787a4489 KangIngu
        }
327
328
        #region Drawing Cloud Method
329
        public static PathGeometry Generate_Rect(List<Point> pData)
330
        {
331
            PathFigure pathFigure = new PathFigure();
332
            pathFigure.StartPoint = pData[0];
333
334 10df01b4 humkyung
            PolyLineSegment polyline = new PolyLineSegment(pData, true);
335
            pathFigure.Segments.Add(polyline);
336 787a4489 KangIngu
337
            PathGeometry rectPathGeometry = new PathGeometry();
338
            rectPathGeometry.Figures = new PathFigureCollection();
339
            pathFigure.IsClosed = true;
340
            pathFigure.IsFilled = false;
341
            rectPathGeometry.Figures.Add(pathFigure);
342
343
344
            return rectPathGeometry;
345
        }
346
347
        public static PathGeometry Generate(List<Point> pData)
348
        {
349
            var _pathGeometry = new PathGeometry();
350
            double area = MathSet.AreaOf(pData);
351
            bool reverse = (area > 0);
352
            int count = pData.Count;
353 10df01b4 humkyung
            for (int i = 0; i < count; i++)
354 787a4489 KangIngu
            {
355 90db87f6 송근호
                PathFigure pathFigure = GenerateLineWithCloud(pData[i % count], pData[(i + 1) % count], 20, reverse);
356 787a4489 KangIngu
                pathFigure.IsClosed = false;
357
                pathFigure.IsFilled = true;
358
                _pathGeometry.Figures.Add(pathFigure);
359
            }
360
361
            return _pathGeometry;
362
        }
363
364
365
        public static PathGeometry GenerateInner(List<Point> pData)
366
        {
367
            var _pathGeometry = new PathGeometry();
368
            double area = MathSet.AreaOf(pData);
369
            bool reverse = (area > 0);
370
            int count = pData.Count;
371
372
            PathFigure pathFigur2 = new PathFigure();
373
            pathFigur2.StartPoint = pData[0];
374
375 10df01b4 humkyung
            PolyLineSegment polyline = new PolyLineSegment(pData, true);
376
            pathFigur2.Segments.Add(polyline);
377 787a4489 KangIngu
378
            pathFigur2.IsClosed = true;
379
            pathFigur2.IsFilled = true;
380
            _pathGeometry.Figures.Add(pathFigur2);
381
382
            return _pathGeometry;
383
        }
384
385
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double _arcLength, bool reverse)
386
        {
387
            PathFigure pathFigure = new PathFigure();
388
            pathFigure.StartPoint = p1;
389
390
            double arcLength = _arcLength;
391
            double dx = p2.X - p1.X;
392
            double dy = p2.Y - p1.Y;
393
            double l = MathSet.DistanceTo(p1, p2);
394
            double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
395
            Point lastPt = new Point(p1.X, p1.Y);
396
            double count = l / _arcLength;
397
398
            dx /= l;
399
            dy /= l;
400
401
            Double j = 1;
402
            for (j = 1; j < (count - 1); j++)
403
            {
404
                ArcSegment arcSeg = new ArcSegment();
405 5a9353a9 humkyung
                arcSeg.Size = new Size(arcLength * TextControl._CloudArcDepth, arcLength * TextControl._CloudArcDepth);
406 787a4489 KangIngu
                arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);
407
                lastPt = arcSeg.Point;
408
                arcSeg.RotationAngle = theta + 90;
409
                if (true == reverse)
410
                    arcSeg.SweepDirection = SweepDirection.Clockwise;
411
                pathFigure.Segments.Add(arcSeg);
412
            }
413
414
            if ((count > j) || count > 0)
415
            {
416
                arcLength = MathSet.DistanceTo(lastPt, p2);
417
                ArcSegment arcSeg = new ArcSegment();
418 5a9353a9 humkyung
                arcSeg.Size = new Size(arcLength * TextControl._CloudArcDepth, arcLength * TextControl._CloudArcDepth);
419 787a4489 KangIngu
                arcSeg.Point = new Point(p2.X, p2.Y);
420
                arcSeg.RotationAngle = theta;
421
422
                if (true == reverse)
423
                    arcSeg.SweepDirection = SweepDirection.Clockwise;
424
425
                pathFigure.Segments.Add(arcSeg);
426
427
            }
428
            return pathFigure;
429
        }
430
        #endregion
431
432
        #region Dependency Properties
433
        public static readonly DependencyProperty ControlTypeProperty =
434
        DependencyProperty.Register("ControlType", typeof(ControlType), typeof(TextControl), new FrameworkPropertyMetadata(ControlType.TextControl));
435
436
        public static readonly DependencyProperty ControlType_NoProperty =
437
        DependencyProperty.Register("ControlType_No", typeof(int), typeof(TextControl), new FrameworkPropertyMetadata(0));
438
439
        public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
440
            "IsSelected", typeof(bool), typeof(TextControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
441
442
        public static readonly DependencyProperty PathGeometryProperty = DependencyProperty.Register(
443
            "PathGeometry", typeof(PathGeometry), typeof(TextControl), new PropertyMetadata(null, SetPathGeometryChanged));
444
445
        public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
446
            "Text", typeof(string), typeof(TextControl), new PropertyMetadata(null));
447
448
        public static readonly DependencyProperty OverViewTextProperty = DependencyProperty.Register(
449 8898253f djkim
            "OverViewText", typeof(string), typeof(TextControl), new PropertyMetadata(null, new PropertyChangedCallback(TextChanged)));
450 787a4489 KangIngu
451
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
452
            "UserID", typeof(string), typeof(TextControl), new PropertyMetadata(null));
453
454 05009a0e ljiyeon
        /*public static readonly DependencyProperty FontColorProperty = DependencyProperty.Register(
455
            "FontColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));*/
456
457
        public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register(
458
            "StrokeColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
459 787a4489 KangIngu
460
        //강인구 추가
461
        public static readonly DependencyProperty IsHighlightProperty = DependencyProperty.Register(
462
            "IsHighLight", typeof(bool), typeof(TextControl), new PropertyMetadata(false, PointValueChanged));
463
464
        public static readonly DependencyProperty BackColorProperty = DependencyProperty.Register(
465
            "BackColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.White)));
466
467
        public static readonly DependencyProperty BackInnerColorProperty = DependencyProperty.Register(
468
            "BackInnerColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.White)));
469
470
        public static readonly DependencyProperty UnderLineProperty = DependencyProperty.Register(
471
            "UnderLine", typeof(TextDecorationCollection), typeof(TextControl), new PropertyMetadata(null));
472
473
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
474 f8769f8a ljiyeon
            "LineSize", typeof(Thickness), typeof(TextControl), new PropertyMetadata(new Thickness(4), PointValueChanged)); //여기만 4인지 모르겠지만 4 그대로 두겠음
475 787a4489 KangIngu
476
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
477
            "PointSet", typeof(List<Point>), typeof(TextControl), new PropertyMetadata(new List<Point>()));
478
479
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
480
            "PathData", typeof(Geometry), typeof(TextControl), null);
481
482 05009a0e ljiyeon
483
484 787a4489 KangIngu
        public static readonly DependencyProperty PathDataInnerProperty = DependencyProperty.Register(
485
    "PathDataInner", typeof(Geometry), typeof(TextControl), null);
486
487
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
488
            "OverViewPathDataProperty", typeof(Geometry), typeof(TextControl), null);
489
490
        public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register(
491
            "TextStyle", typeof(FontStyle), typeof(TextControl), new PropertyMetadata(FontStyles.Normal));
492
493
        public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register(
494
            "TextFamily", typeof(FontFamily), typeof(TextControl), new PropertyMetadata(new FontFamily("Arial")));
495
496
        public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register(
497
            "TextWeight", typeof(FontWeight), typeof(TextControl), new PropertyMetadata(FontWeights.Normal));
498
499
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register(
500
            "CenterX", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
501
502
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register(
503
            "CenterY", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
504
505
        public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
506
           "CanvasX", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
507
508
        public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
509
            "CanvasY", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
510
511
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
512
              "StartPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
513
514
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
515
             "EndPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(100, 100), PointValueChanged));
516
517
        public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register(
518
               "TextSize", typeof(Double), typeof(TextControl), new PropertyMetadata((Double)30, PointValueChanged));
519
520
        public static readonly DependencyProperty PaintProperty = DependencyProperty.Register(
521
                "Paint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged));
522
523
        public static readonly DependencyProperty OverViewPaintProperty = DependencyProperty.Register(
524
                "OverViewPaint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged));
525
526
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register(
527
            "Angle", typeof(double), typeof(TextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged)));
528
529
        public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register(
530 71d7e0bf 송근호
           "EnableEditing", typeof(bool), typeof(TextControl), new PropertyMetadata((true), new PropertyChangedCallback(OnIsEditingChanged)));
531 787a4489 KangIngu
532
        public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register(
533
        "TextBoxVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged));
534
535
        public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register(
536
        "TextBlockVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged));
537
538
        #endregion Dependency Properties
539
540
        #region dp Properties
541
542 05009a0e ljiyeon
543
        public override SolidColorBrush StrokeColor
544
        {
545
            get { return (SolidColorBrush)GetValue(StrokeColorProperty); }
546
            set
547
            {
548
                if (this.StrokeColor != value)
549
                {
550
                    SetValue(StrokeColorProperty, value);
551
                }
552
            }
553
        }
554
555 90db87f6 송근호
556 787a4489 KangIngu
557
        public bool EnableEditing
558
        {
559
            get { return (bool)GetValue(EnableEditingProperty); }
560
            set
561
            {
562
                if (this.EnableEditing != value)
563
                {
564
                    SetValue(EnableEditingProperty, value);
565
                    OnPropertyChanged("EnableEditing");
566
                }
567
            }
568
        }
569
570
        public Thickness LineSize
571
        {
572
            get
573
            {
574
                return (Thickness)GetValue(LineSizeProperty);
575
            }
576
            set
577
            {
578
                if (this.LineSize != value)
579
                {
580
                    SetValue(LineSizeProperty, value);
581
                    OnPropertyChanged("LineSize");
582
                }
583
            }
584
        }
585
586 5529d2a2 humkyung
        public override ControlType ControlType
587 787a4489 KangIngu
        {
588
            get
589
            {
590
                return (ControlType)GetValue(ControlTypeProperty);
591
            }
592
            set
593
            {
594
                SetValue(ControlTypeProperty, value);
595
            }
596
        }
597
        public int ControlType_No
598
        {
599
            get
600
            {
601
                return (int)GetValue(ControlType_NoProperty);
602
            }
603
            set
604
            {
605
                SetValue(ControlType_NoProperty, value);
606
            }
607
        }
608
609
        public string UserID
610
        {
611
            get { return (string)GetValue(UserIDProperty); }
612
            set
613
            {
614
                if (this.UserID != value)
615
                {
616
                    SetValue(UserIDProperty, value);
617
                    OnPropertyChanged("UserID");
618
                }
619
            }
620
        }
621
622
        public double CenterX
623
        {
624
            get { return (double)GetValue(CenterXProperty); }
625 90db87f6 송근호
            set
626
            {
627
                SetValue(CenterXProperty, value);
628
                OnPropertyChanged("CenterX");
629
630 787a4489 KangIngu
            }
631
        }
632
633
        public double CenterY
634
        {
635
            get { return (double)GetValue(CenterYProperty); }
636 90db87f6 송근호
            set
637
            {
638
                SetValue(CenterYProperty, value);
639
                OnPropertyChanged("CenterY");
640 787a4489 KangIngu
            }
641
        }
642
643
        public string Text
644
        {
645
            get { return (string)GetValue(TextProperty); }
646
            set
647
            {
648
                if (this.Text != value)
649
                {
650
                    SetValue(TextProperty, value);
651
                    OnPropertyChanged("Text");
652
                }
653
            }
654
        }
655
656
        public string OverViewText
657
        {
658
            get { return (string)GetValue(OverViewTextProperty); }
659
            set
660
            {
661
                if (this.OverViewText != value)
662
                {
663
                    SetValue(OverViewTextProperty, value);
664
                    OnPropertyChanged("OverViewText");
665
                }
666
            }
667
        }
668
669
        public Geometry OverViewPathData
670
        {
671
            get { return (Geometry)GetValue(OverViewPathDataProperty); }
672
            set
673
            {
674
                if (this.OverViewPathData != value)
675
                {
676
                    SetValue(OverViewPathDataProperty, value);
677
                    OnPropertyChanged("OverViewPathData");
678
                }
679
            }
680
        }
681
682
        public Visibility TextBoxVisibility
683
        {
684
            get { return (Visibility)GetValue(TextBoxVisibilityProperty); }
685
            set
686
            {
687
                if (this.TextBoxVisibility != value)
688
                {
689
                    SetValue(TextBoxVisibilityProperty, value);
690
                    OnPropertyChanged("TextBoxVisibility");
691
                }
692
            }
693
        }
694
695
696
        public Visibility TextBlockVisibility
697
        {
698
            get { return (Visibility)GetValue(TextBlockVisibilityProperty); }
699
            set
700
            {
701
                if (this.TextBlockVisibility != value)
702
                {
703
                    SetValue(TextBlockVisibilityProperty, value);
704
                    OnPropertyChanged("TextBlockVisibility");
705
                }
706
            }
707
        }
708
709
710
711
        public Double TextSize
712
        {
713
            get { return (Double)GetValue(TextSizeProperty); }
714
            set
715
            {
716
                if (this.TextSize != value)
717
                {
718
                    SetValue(TextSizeProperty, value);
719
                    OnPropertyChanged("TextSize");
720
                }
721
            }
722
        }
723 05009a0e ljiyeon
        /*
724 787a4489 KangIngu
        public SolidColorBrush FontColor
725
        {
726
            get { return (SolidColorBrush)GetValue(FontColorProperty); }
727
            set
728
            {
729
                if (this.FontColor != value)
730
                {
731
                    SetValue(FontColorProperty, value);
732
                    OnPropertyChanged("FontColor");
733
                }
734
            }
735 05009a0e ljiyeon
        }*/
736 787a4489 KangIngu
737
        public SolidColorBrush BackColor
738
        {
739
            get { return (SolidColorBrush)GetValue(BackColorProperty); }
740
            set
741
            {
742
                if (this.BackColor != value)
743
                {
744
                    SetValue(BackColorProperty, value);
745
                    OnPropertyChanged("BackColor");
746
                }
747
            }
748
        }
749
750
        public SolidColorBrush BackInnerColor
751
        {
752
            get { return (SolidColorBrush)GetValue(BackInnerColorProperty); }
753
            set
754
            {
755
                if (this.BackInnerColor != value)
756
                {
757
                    SetValue(BackInnerColorProperty, value);
758
                    OnPropertyChanged("BackInnerColor");
759
                }
760
            }
761
        }
762
763 90db87f6 송근호
764 787a4489 KangIngu
765
        public TextDecorationCollection UnderLine
766
        {
767
            get
768
            {
769
                return (TextDecorationCollection)GetValue(UnderLineProperty);
770
            }
771
            set
772
            {
773
                if (this.UnderLine != value)
774
                {
775
                    SetValue(UnderLineProperty, value);
776
                    OnPropertyChanged("UnderLine");
777
                }
778
            }
779
        }
780
781
        public double CanvasX
782
        {
783
            get { return (double)GetValue(CanvasXProperty); }
784
            set
785
            {
786
                if (this.CanvasX != value)
787
                {
788
                    SetValue(CanvasXProperty, value);
789
                    OnPropertyChanged("CanvasX");
790
                }
791
            }
792
        }
793
794
        public double CanvasY
795
        {
796
            get { return (double)GetValue(CanvasYProperty); }
797
            set
798
            {
799
                if (this.CanvasY != value)
800
                {
801
                    SetValue(CanvasYProperty, value);
802
                    OnPropertyChanged("CanvasY");
803
                }
804
            }
805
        }
806
807
        public Point EndPoint
808
        {
809
            get { return (Point)GetValue(EndPointProperty); }
810
            set
811
            {
812
                if (this.EndPoint != value)
813
                {
814
                    SetValue(EndPointProperty, value);
815
                    OnPropertyChanged("EndPoint");
816
                }
817
            }
818
        }
819
820
        public Point StartPoint
821
        {
822
            get { return (Point)GetValue(StartPointProperty); }
823
            set
824
            {
825
                if (this.StartPoint != value)
826
                {
827
                    SetValue(StartPointProperty, value);
828
                    OnPropertyChanged("StartPoint");
829
                }
830
            }
831
        }
832
833
        public FontStyle TextStyle
834
        {
835
            get { return (FontStyle)GetValue(TextStyleProperty); }
836
            set
837
            {
838
                if (this.TextStyle != value)
839
                {
840
                    SetValue(TextStyleProperty, value);
841
                    OnPropertyChanged("TextStyle");
842
                }
843
            }
844
        }
845
846
        public FontFamily TextFamily
847
        {
848
            get { return (FontFamily)GetValue(TextFamilyProperty); }
849
            set
850
            {
851
                if (this.TextFamily != value)
852
                {
853
                    SetValue(TextFamilyProperty, value);
854
                    OnPropertyChanged("TextFamily");
855
                }
856
            }
857
        }
858
859
        public FontWeight TextWeight
860
        {
861
            get { return (FontWeight)GetValue(TextWeightProperty); }
862
            set
863
            {
864
                if (this.TextWeight != value)
865
                {
866
                    SetValue(TextWeightProperty, value);
867
                    OnPropertyChanged("TextWeight");
868
                }
869
            }
870
        }
871
872
        public PaintSet Paint
873
        {
874
            get { return (PaintSet)GetValue(PaintProperty); }
875
            set
876
            {
877
                if (this.Paint != value)
878
                {
879
                    SetValue(PaintProperty, value);
880
                    OnPropertyChanged("Paint");
881
                }
882
            }
883
        }
884
885
        public PaintSet OverViewPaint
886
        {
887
            get { return (PaintSet)GetValue(OverViewPaintProperty); }
888
            set
889
            {
890
                if (this.OverViewPaint != value)
891
                {
892
                    SetValue(OverViewPaintProperty, value);
893
                    OnPropertyChanged("OverViewPaint");
894
                }
895
            }
896
        }
897
898
        double IPath.LineSize
899
        {
900
            get
901
            {
902
                return this.LineSize.Left;
903
            }
904
            set
905
            {
906
                this.LineSize = new Thickness(value);
907
                OnPropertyChanged("LineSize");
908
            }
909
        }
910
911
912
        public Geometry PathData
913
        {
914
            get { return (Geometry)GetValue(PathDataProperty); }
915 90db87f6 송근호
            set
916
            {
917
                SetValue(PathDataProperty, value);
918
                OnPropertyChanged("PathData");
919 787a4489 KangIngu
            }
920
        }
921
922
        public Geometry PathDataInner
923
        {
924
            get { return (Geometry)GetValue(PathDataInnerProperty); }
925
            set
926
            {
927
                SetValue(PathDataInnerProperty, value);
928
                OnPropertyChanged("PathDataInner");
929
            }
930
        }
931
932 54e35b39 송근호
        public override double Angle
933 787a4489 KangIngu
        {
934
            get { return (double)GetValue(AngleProperty); }
935
            set
936
            {
937
                if (this.Angle != value)
938
                {
939
                    SetValue(AngleProperty, value);
940
941
                    OnPropertyChanged("Angle");
942
                    UpdateLayout();
943
                }
944
            }
945
        }
946
947
        public bool IsHighLight
948
        {
949
            get { return (bool)GetValue(IsHighlightProperty); }
950
            set
951
            {
952
                if (this.IsHighLight != value)
953
                {
954
                    SetValue(IsHighlightProperty, value);
955
                    OnPropertyChanged("IsHighLight");
956
                }
957
            }
958
        }
959
960
        public List<Point> PointSet
961
        {
962
            get { return (List<Point>)GetValue(PointSetProperty); }
963 90db87f6 송근호
            set
964
            {
965
                SetValue(PointSetProperty, value);
966
                OnPropertyChanged("PointSet");
967 787a4489 KangIngu
            }
968
        }
969
970
        #endregion Properties
971
972
        #region Properties
973
974 3c71b3a5 taeseongkim
        private bool _IsEditingMode;
975
        public bool IsEditingMode
976
        {
977
            get
978
            {
979
                return _IsEditingMode;
980
            }
981
            set
982
            {
983
                _IsEditingMode = value;
984
                OnPropertyChanged("IsEditingMode");
985
            }
986
        }
987 787a4489 KangIngu
988 90db87f6 송근호
        public PathGeometry PathGeometry
989 787a4489 KangIngu
        {
990
            get { return (PathGeometry)GetValue(PathGeometryProperty); }
991
            set
992
            {
993
                SetValue(PathGeometryProperty, value);
994
                OnPropertyChanged("PathGeometry");
995
            }
996
        }
997
998
        private double _BoxWidth;
999
        public double BoxWidth
1000
        {
1001
            get
1002
            {
1003
                return _BoxWidth;
1004
            }
1005
            set
1006
            {
1007
                _BoxWidth = value;
1008
                OnPropertyChanged("BoxWidth");
1009
            }
1010
        }
1011
1012
        private double _BoxHeight;
1013
        public double BoxHeight
1014
        {
1015
            get
1016
            {
1017
                return _BoxHeight;
1018
            }
1019
            set
1020
            {
1021
                _BoxHeight = value;
1022
                OnPropertyChanged("BoxHeight");
1023
            }
1024
        }
1025
1026
        #endregion
1027
1028
        #region CallBack Method
1029
        public static void SetPathGeometryChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1030
        {
1031
            var instance = (TextControl)sender;
1032
1033
            if (e.OldValue != e.NewValue && instance.Base_TextPath != null)
1034
            {
1035
                instance.SetValue(e.Property, e.NewValue);
1036
            }
1037
        }
1038
1039
1040
        public static void OnTextBoxVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1041
        {
1042
            var instance = (TextControl)sender;
1043
1044
            if (e.OldValue != e.NewValue && instance.Base_TextPath != null)
1045
            {
1046
                instance.SetValue(e.Property, e.NewValue);
1047
            }
1048
        }
1049
1050
        public static void OnTextBlockVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1051
        {
1052
            var instance = (TextControl)sender;
1053
1054
            if (e.OldValue != e.NewValue && instance.Base_TextPath != null)
1055
            {
1056
                instance.SetValue(e.Property, e.NewValue);
1057
            }
1058
        }
1059
1060
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1061
        {
1062 8898253f djkim
            //var instance = (TextControl)sender;
1063 787a4489 KangIngu
1064 8898253f djkim
            //if (e.OldValue != e.NewValue && instance.Base_Border != null)
1065
            //{
1066
            //    instance.SetValue(e.Property, e.NewValue);
1067 787a4489 KangIngu
1068 8898253f djkim
            //    if (instance.IsSelected)
1069
            //    {
1070
            //        instance.StrokeColor = new SolidColorBrush(Colors.Blue);
1071
            //        //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Blue);
1072
            //    }
1073
            //    else
1074
            //    {
1075
            //        instance.StrokeColor = new SolidColorBrush(Colors.Red);
1076
            //        //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Red);
1077
            //        //instance.FontColor = new SolidColorBrush(Colors.Transparent);
1078
            //        //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Transparent);
1079
            //    }
1080 787a4489 KangIngu
1081 8898253f djkim
            //}
1082 787a4489 KangIngu
        }
1083
1084
        public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1085
        {
1086
            var instance = (TextControl)sender;
1087
1088
            if (e.OldValue != e.NewValue && instance != null)
1089
            {
1090
                instance.SetValue(e.Property, e.NewValue);
1091
1092
                Canvas.SetLeft(instance, instance.CanvasX);
1093
                Canvas.SetTop(instance, instance.CanvasY);
1094
            }
1095
        }
1096
1097
        public static void OnIsEditingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1098
        {
1099
            var instance = (TextControl)sender;
1100
1101
            if (e.OldValue != e.NewValue && instance.Base_TextBlock != null)
1102
            {
1103
                instance.SetValue(e.Property, e.NewValue);
1104
1105 3c71b3a5 taeseongkim
                if (instance.EnableEditing)
1106
                {
1107
                    instance.EditingMode();
1108
                }
1109
                else
1110
                {
1111
                    instance.UnEditingMode();
1112
                }
1113 787a4489 KangIngu
            }
1114
        }
1115 8898253f djkim
        public static void TextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1116
        {
1117
            var instance = (TextControl)sender;
1118
1119
            if (e.OldValue != e.NewValue)
1120
            {
1121
                instance.SetValue(e.Property, e.NewValue);
1122
            }
1123
        }
1124 787a4489 KangIngu
1125
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1126
        {
1127
            var instance = (TextControl)sender;
1128
1129
            if (e.OldValue != e.NewValue && instance.Base_TextBlock != null)
1130
            {
1131
                instance.SetValue(e.Property, e.NewValue);
1132 6b5d33c6 djkim
                //instance.DrawingCloud();
1133 787a4489 KangIngu
            }
1134
        }
1135
1136
        public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1137
        {
1138
            var instance = (TextControl)sender;
1139
            if (e.OldValue != e.NewValue && instance.Base_TextBlock != null)
1140
            {
1141
                instance.SetValue(e.Property, e.NewValue);
1142 05009a0e ljiyeon
                //instance.DrawingCloud();
1143 787a4489 KangIngu
            }
1144
        }
1145
1146
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1147
        {
1148
            var instance = (TextControl)sender;
1149 8898253f djkim
            
1150
            if (e.OldValue != e.NewValue && instance.Base_TextBox != null)
1151
            {                       
1152
                instance.SetText();
1153
                instance.DrawingCloud();
1154 787a4489 KangIngu
            }
1155 8898253f djkim
1156 787a4489 KangIngu
        }
1157 90db87f6 송근호
1158 787a4489 KangIngu
        #endregion CallBack Method
1159
1160
        protected void OnPropertyChanged(string propName)
1161
        {
1162
            if (PropertyChanged != null)
1163
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
1164
        }
1165 036650a0 humkyung
1166
        /// <summary>
1167 91efe37a humkyung
        /// return textcontrols' area
1168 036650a0 humkyung
        /// </summary>
1169 91efe37a humkyung
        public override Rect ItemRect
1170
        {
1171
            get
1172
            {
1173 e6a9ddaf humkyung
                Point start = new Point(this.CanvasX, this.CanvasY);
1174 91efe37a humkyung
1175
                Point length = new Point();
1176
                double angle = this.Angle * Math.PI / 180;
1177
1178
                length.X = this.BoxWidth * Math.Cos(angle) - this.BoxHeight * Math.Sin(angle);
1179
                length.Y = this.BoxWidth * Math.Sin(angle) + this.BoxHeight * Math.Cos(angle);
1180
1181
                Point end = new Point(start.X + length.X, start.Y + length.Y);
1182
                return new Rect(start, end);
1183
            }
1184
        }
1185
1186 e6a9ddaf humkyung
        /// <summary>
1187 0d00f9c8 humkyung
        /// translate control along given dx,dy
1188 e6a9ddaf humkyung
        /// </summary>
1189
        /// <param name="dx"></param>
1190
        /// <param name="dy"></param>
1191 0d00f9c8 humkyung
        public override void OnTranslate(double dx, double dy)
1192 e6a9ddaf humkyung
        {
1193 0d00f9c8 humkyung
            //this.CanvasX = Canvas.GetLeft(this) + dx;
1194
            //this.CanvasY = Canvas.GetTop(this) + dy;
1195 359bfdbe 송근호
            this.StartPoint = new Point(this.StartPoint.X + dx, this.StartPoint.Y + dy);
1196
            this.EndPoint = new Point(this.EndPoint.X + dx, this.EndPoint.Y + dy);
1197 0d00f9c8 humkyung
1198 54e35b39 송근호
            this.SetValue(TextControl.CanvasXProperty, Canvas.GetLeft(this) + dx);
1199
            this.SetValue(TextControl.CanvasYProperty, Canvas.GetTop(this) + dy);
1200
1201 0d00f9c8 humkyung
1202 90db87f6 송근호
1203
1204 54e35b39 송근호
            //Canvas.SetLeft(this, Canvas.GetLeft(this) + dx);
1205
            //Canvas.SetTop(this, Canvas.GetTop(this) + dy);
1206 e6a9ddaf humkyung
        }
1207
1208
        /// <summary>
1209
        /// Serialize this
1210
        /// </summary>
1211
        /// <param name="sUserId"></param>
1212
        /// <returns></returns>
1213
        public override string Serialize()
1214 036650a0 humkyung
        {
1215
            using (S_TextControl STemp = new S_TextControl())
1216
            {
1217
                STemp.TransformPoint = "0|0";
1218
                STemp.SizeSet = String.Format("{0}|{1}", this.LineSize.Left.ToString(), this.TextSize.ToString());
1219
                STemp.Text = this.Text;
1220
                STemp.UserID = this.UserID;
1221 05009a0e ljiyeon
                STemp.FontColor = this.StrokeColor.Color.ToString();
1222 036650a0 humkyung
                //STemp.FontColor = "#FFFFFF00";
1223
1224
                if (this.StartPoint == new Point())
1225
                    STemp.StartPoint = new Point(this.CanvasX, this.CanvasY);
1226
                else
1227
                    STemp.StartPoint = this.StartPoint;
1228
1229
                STemp.EndPoint = this.EndPoint;
1230
                STemp.Opac = this.Opacity;
1231
                STemp.PointSet = this.PointSet;
1232
                STemp.Angle = this.Angle;
1233
                STemp.paintMethod = this.ControlType_No;
1234
                STemp.BoxW = this.BoxWidth;
1235
                STemp.BoxH = this.BoxHeight;
1236
                STemp.isHighLight = this.IsHighLight;
1237
                STemp.Name = this.GetType().Name.ToString();
1238
                STemp.fontConfig = new List<string>()
1239
                            {
1240
                                this.TextFamily.ToString(),
1241
                                this.TextStyle.ToString(),
1242
                                this.TextWeight.ToString(),
1243
                            };
1244
1245
1246
1247
                if (this.UnderLine != null)
1248
                {
1249
                    STemp.fontConfig.Add("true");
1250
                }
1251
1252
                ///강인구 추가(2017.11.02)
1253
                ///Memo 추가
1254
                STemp.Memo = this.Memo;
1255
1256
                return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize()));
1257
            }
1258
        }
1259 661b7416 humkyung
1260
        /// <summary>
1261
        /// create a textcontrol from given string
1262
        /// </summary>
1263
        /// <param name="str"></param>
1264
        /// <returns></returns>
1265
        public static TextControl FromString(string str, SolidColorBrush brush, string sProjectNo)
1266
        {
1267
            using (S_TextControl s = JsonSerializerHelper.JsonDeserialize<S_TextControl>(str))
1268
            {
1269
                string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries);
1270
                TextControl instance = new TextControl()
1271
                {
1272
                    Text = s.Text,
1273
                    StartPoint = s.StartPoint,
1274
                    EndPoint = s.EndPoint,
1275
                    CanvasX = s.StartPoint.X,
1276
                    CanvasY = s.StartPoint.Y,
1277
                    BoxWidth = s.BoxW,
1278
                    BoxHeight = s.BoxH,
1279
                    ControlType_No = s.paintMethod,
1280
                    LineSize = new Thickness(Convert.ToDouble(data2.First())),
1281
                    TextSize = Convert.ToDouble(data2[1]),
1282 05009a0e ljiyeon
                    StrokeColor = brush,
1283 661b7416 humkyung
                    FontSize = 10,
1284
                    UserID = s.UserID,
1285
                    IsHighLight = s.isHighLight,
1286
                    Angle = s.Angle,
1287
                    PointSet = s.PointSet,
1288
                    Opacity = s.Opac,
1289
                    TextFamily = new FontFamily(s.fontConfig[0]),
1290
                    //인구 추가(2018.04.17)
1291
                    TextStyle = StringToFont.ConFontStyle(s.fontConfig[1]),
1292
                    TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]),
1293
                };
1294
1295
                if (s.fontConfig.Count() == 4)
1296
                {
1297
                    instance.UnderLine = TextDecorations.Underline;
1298
                }
1299
1300
                return instance;
1301
            }
1302
        }
1303 787a4489 KangIngu
    }
1304
}
클립보드 이미지 추가 (최대 크기: 500 MB)