프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Text / TextControl.cs @ 1c0c336a

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