프로젝트

일반

사용자정보

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

markus / MarkupToPDF / Controls / Text / TextControl.cs @ fd19a116

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