프로젝트

일반

사용자정보

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

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

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

1
using MarkupToPDF.Common;
2
using MarkupToPDF.Controls.Common;
3
using System;
4
using System.Collections.Generic;
5
using System.ComponentModel;
6
using System.Linq;
7
using System.Text;
8
using System.Threading.Tasks;
9
using System.Windows;
10
using System.Windows.Controls;
11
using System.Windows.Media;
12
using System.Windows.Shapes;
13

    
14
namespace MarkupToPDF.Controls.Text
15
{
16
    [TemplatePart(Name = "PART_TextBox", Type = typeof(TextBox))]
17
    [TemplatePart(Name = "PART_TextBlock", Type = typeof(TextBlock))]
18
    [TemplatePart(Name = "PART_TextPath", Type = typeof(Path))]
19
    [TemplatePart(Name = "PART_Border", Type = typeof(Border))]
20
    [TemplatePart(Name = "PART_Grid", Type = typeof(Grid))]
21
    public class TextControl : CommentUserInfo, INotifyPropertyChanged, IMarkupControlData, IPath
22
    {
23
        public event PropertyChangedEventHandler PropertyChanged;
24

    
25
        private const string PART_Grid = "PART_Grid";
26
        private const string PART_Border = "PART_Border";
27
        private const string PART_TextBox = "PART_TextBox";
28
        private const string PART_TextPath = "PART_TextPath";
29
        private const string PART_TextBlock = "PART_TextBlock";
30
        //private const string PART_TextPrefix = "PART_TextPrefix";
31

    
32
        public Path Base_TextPath = null;
33
        public Grid Base_Grid = null;
34
        public Border Base_Border = null;
35
        //public TextBlock Base_TextPrefixBlock = null;
36
        public TextBlock Base_TextBlock = null;
37
        public TextBox Base_TextBox = null;
38

    
39
        public RotateTransform _rotation = null;
40
        public TranslateTransform _translation = null;
41
        public ScaleTransform _scale = null;
42

    
43
        private const double _CloudArcDepth = 0.8;  /// 2018.05.14 added by humkyung
44

    
45
        public bool IsSelected
46
        {
47
            get
48
            {
49
                return (bool)GetValue(IsSelectedProperty);
50
            }
51
            set
52
            {
53
                SetValue(IsSelectedProperty, value);
54
                OnPropertyChanged("IsSelected");
55
            }
56
        }
57

    
58
        #region Internal Method
59

    
60
        public TextControl()
61
        {
62
            this.DefaultStyleKey = typeof(TextControl);
63
        }
64

    
65
        static TextControl()
66
        {
67
            DefaultStyleKeyProperty.OverrideMetadata(typeof(TextControl), new FrameworkPropertyMetadata(typeof(TextControl)));
68
            ResourceDictionary dictionary = new ResourceDictionary();
69
            dictionary.Source = new Uri("/MarkupToPDF;component/Themes/generic.xaml", UriKind.RelativeOrAbsolute);
70
            Application.Current.Resources.MergedDictionaries.Add(dictionary);
71
        }
72

    
73
        public override void OnApplyTemplate()
74
        {
75
            base.OnApplyTemplate();
76
            
77

    
78
            Base_TextPath = GetTemplateChild(PART_TextPath) as Path;
79
            Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox;
80
            Base_TextBlock = GetTemplateChild(PART_TextBlock) as TextBlock;
81
            Base_Grid = GetTemplateChild(PART_Grid) as Grid;
82
            Base_Border = GetTemplateChild(PART_Border) as Border;
83

    
84

    
85
            //Base_TextPrefixBlock = GetTemplateChild(PART_TextPrefix) as TextBlock;
86

    
87
            //Canvas.SetLeft(this, this.StartPoint.X);
88
            //Canvas.SetTop(this, this.StartPoint.Y);
89

    
90
            //CanvasX = StartPoint.X;
91
            //CanvasY = StartPoint.Y;
92

    
93
            //this.LostFocus += new RoutedEventHandler(TextControl_LostFocus);
94
            //this.GotFocus += new RoutedEventHandler(TextControl_GotFocus);
95
            this.Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged);
96
            this.Base_TextBlock.SizeChanged += Base_TextBlock_SizeChanged;
97

    
98
            this.Base_TextBox.LostFocus += Base_TextBox_LostFocus;
99
            //this.MouseDown += TextControl_MouseDown;
100

    
101

    
102

    
103
            SetText();
104
            Base_TextBox.Focus();
105

    
106
            this.Focusable = false;
107
            if (!String.IsNullOrEmpty(this.Text))
108
            {
109
                Base_TextBlock.Visibility = Visibility.Visible;
110
                Base_TextBox.Visibility = Visibility.Collapsed;
111
            }
112
        }
113

    
114
        private void Base_TextBox_LostFocus(object sender, EventArgs e)
115
        {
116
            IsEditing = false;
117
            UnEditingMode();
118
            ApplyOverViewData();
119
        }
120

    
121
        public void ApplyOverViewData()
122
        {
123
            this.OverViewPathData = this.PathData;
124
            this.OverViewText = this.Text;
125
            this.OverViewPaint = this.Paint;
126

    
127
        }
128

    
129
        void Base_TextBlock_SizeChanged(object sender, SizeChangedEventArgs e)
130
        {
131
            this.Text = Base_TextBox.Text;
132

    
133
            BoxWidth = e.NewSize.Width;
134
            BoxHeight = e.NewSize.Height;
135

    
136
            this.ApplyTemplate();
137

    
138
            DrawingCloud();
139
        }
140

    
141
        //void TextControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
142
        //{
143
        //    this.Focus();
144
        //}
145

    
146
        void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e)
147
        {
148
            if (Base_TextBox.Text.Contains("|OR||DZ|"))
149
            {
150
                Base_TextBox.Text = this.Text;
151
            }
152

    
153
            this.Text = Base_TextBox.Text;
154
            BoxWidth = e.NewSize.Width;
155
            BoxHeight = e.NewSize.Height;
156
            this.ApplyTemplate();
157
            DrawingCloud();           
158
        }
159

    
160
        void TextControl_GotFocus(object sender, RoutedEventArgs e)
161
        {
162
            if (EnableEditing)
163
            {
164
                IsEditing = true;
165
                EditingMode();
166
            }
167
            else
168
            {
169
                IsEditing = false;
170
                UnEditingMode();
171
            }
172
        }
173

    
174
        void TextControl_LostFocus(object sender, RoutedEventArgs e)
175
        {
176
            IsEditing = false;
177
            UnEditingMode();
178
            ApplyOverViewData();
179
        }
180

    
181
        //void TextControl_GotFocus(object sender, RoutedEventArgs e)
182
        //{
183
        //    Base_TextBox.Visibility = Visibility.Visible;
184
        //    Base_TextBlock.Visibility = Visibility.Collapsed;
185
        //    this.Base_TextBox.BorderThickness = new Thickness(1);
186
        //    if (UnderLine != null)
187
        //    {
188
        //        Base_TextBlock.TextDecorations = UnderLine;
189
        //    }
190
        //    if (this.Text != null)
191
        //    {
192
        //        Base_TextBox.Text = this.Text;
193
        //    }
194
        //    IsEditing = true;
195
        //}
196
        //void TextControl_LostFocus(object sender, RoutedEventArgs e)
197
        //{
198
        //    Base_TextBox.Visibility = Visibility.Collapsed;
199
        //    Base_TextBlock.Visibility = Visibility.Visible;
200
        //    this.Text = Base_TextBox.Text;
201
        //    if (UnderLine != null)
202
        //    {
203
        //        Base_TextBlock.TextDecorations = UnderLine;
204
        //    }
205
        //    Base_TextBlock.Margin =
206
        //       new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4, Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4);
207
        //    IsEditing = false;
208
        //}
209

    
210
        public void EditingMode()
211
        {
212
            //System.Diagnostics.Debug.WriteLine(DateTime.Now.ToLongTimeString());
213
            TextBoxVisibility = Visibility.Visible;
214
            //Base_TextBox.Visibility = System.Windows.Visibility.Visible;
215

    
216
            TextBlockVisibility = Visibility.Collapsed;
217
            //Base_TextBlock.Visibility = System.Windows.Visibility.Collapsed;
218

    
219

    
220
            //this.Base_TextBox.BorderThickness = new Thickness(1);
221

    
222
            if (UnderLine != null)
223
                Base_TextBlock.TextDecorations = UnderLine;
224

    
225
            if (this.Text != null)
226
                Base_TextBox.Text = this.Text;
227

    
228
            //            Base_TextBox.Margin =
229
            //new Thickness(Base_TextBlock.Margin.Left + -2, Base_TextBlock.Margin.Top + 0,
230
            //Base_TextBlock.Margin.Right + 0, Base_TextBlock.Margin.Bottom + -2);
231
        }
232

    
233
        public void UnEditingMode()
234
        {
235
            if (EnableEditing)
236
                this.Text = Base_TextBox.Text;
237

    
238
            TextBoxVisibility = Visibility.Collapsed;
239
            //Base_TextBox.Visibility = System.Windows.Visibility.Collapsed;
240

    
241
            TextBlockVisibility = Visibility.Visible;
242
            //Base_TextBlock.Visibility = System.Windows.Visibility.Visible;
243

    
244
            if (UnderLine != null)
245
                Base_TextBlock.TextDecorations = UnderLine;
246

    
247
            //Base_TextBox.Focusable = false;
248

    
249
            //Base_TextBlock.Margin =
250
            //     new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4,
251
            //         Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4);
252

    
253
            //       Base_TextBlock.Margin =
254
            //new Thickness(Base_TextBox.Margin.Left + 2, Base_TextBox.Margin.Top + 2,
255
            //    Base_TextBox.Margin.Right + 2, Base_TextBox.Margin.Bottom + 2);
256

    
257
            //            Base_TextBlock.Margin =
258
            //new Thickness(Base_TextBox.Margin.Left + 5, Base_TextBox.Margin.Top + 0,
259
            //Base_TextBox.Margin.Right + 0, Base_TextBox.Margin.Bottom + 2);
260
        }
261

    
262
        public void SetText()
263
        {
264
            this.ApplyTemplate();
265
            if (IsHighLight)
266
            {
267
                this.BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6),
268
                    Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
269
                this.BackColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1),
270
                    Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B));
271
            }
272
            else
273
            {
274
                this.BackInnerColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6),
275
                    Colors.White.R, Colors.White.G, Colors.White.B));
276

    
277
                this.BackColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.1),
278
                    Colors.White.R, Colors.White.G, Colors.White.B));
279

    
280

    
281
                //this.BackColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6),
282
                //        Colors.White.R, Colors.White.G, Colors.White.B));
283
                //this.BackColor = null;
284
            }
285
            if (Base_TextPath != null)
286
            {
287
                Base_TextPath.StrokeThickness = LineSize.Left;
288
            }
289

    
290
            OverViewPathData = PathData;
291
            OverViewText = Text;
292
        }
293

    
294
        public void DrawingCloud()
295
        {
296
            this.ApplyTemplate();
297

    
298
            //pathGeometry = new PathGeometry();
299

    
300
            List<Point> pCloud = new List<Point>
301
            {
302
                //new Point(0, 0),
303
                //new Point(0, 0 + BoxHeight + 2),
304
                //new Point(0 + BoxWidth + 4, 0 + BoxHeight + 2),
305
                //new Point(0 + BoxWidth + 4 ,0),
306
                //new Point(0, 0)
307

    
308
                new Point(0, 0),
309
                new Point(0, 0 + BoxHeight + 0),
310
                new Point(0 + BoxWidth + 2, 0 + BoxHeight + 0),
311
                new Point(0 + BoxWidth + 2 ,0),
312
                new Point(0, 0)
313
            };
314

    
315
            if (Base_TextPath != null)
316
            {
317
                switch (ControlType_No)
318
                {
319
                    case 0:
320
                        {
321
                            PathData = new PathGeometry();
322
                            PathDataInner = (GenerateInner(pCloud));
323
                        }
324
                        break;
325
                    case 1:
326
                        {
327
                            PathData = (Generate_Rect(pCloud));
328

    
329
                            List<Point> pCloud2 = new List<Point>
330
                            {
331
                                //new Point(0, 0),
332
                                //new Point(0, 0 + BoxHeight + 2),
333
                                //new Point(0 + BoxWidth + 4, 0 + BoxHeight + 2),
334
                                //new Point(0 + BoxWidth + 4 ,0),
335
                                //new Point(0, 0)
336

    
337
                                new Point(0, 0),
338
                                new Point(0, 0 + BoxHeight + 0),
339
                                new Point(0 + BoxWidth + 10, 0 + BoxHeight + 0),
340
                                new Point(0 + BoxWidth + 10 ,0),
341
                                new Point(0, 0)
342
                            };
343

    
344
                            PathDataInner = (GenerateInner(pCloud));
345
                        }
346
                        break;
347
                    case 2:
348
                        {
349
                            PathData = (Generate(pCloud));
350
                            PathDataInner = (GenerateInner(pCloud));
351
                        }
352
                        break;
353
                }
354
            }
355

    
356
            SetText();
357
        }
358
        #endregion Internal Method
359

    
360
        public void Dispose()
361
        {
362
            GC.Collect();
363
            GC.SuppressFinalize(this);
364
        }
365
        public void updateControl()
366
        {
367
            this.StartPoint = new Point(this.PointSet[0].X, this.PointSet[0].Y);
368
            this.EndPoint = new Point(this.PointSet[1].X, this.PointSet[1].Y);
369
        }
370

    
371
        #region Drawing Cloud Method
372
        public static PathGeometry Generate_Rect(List<Point> pData)
373
        {
374
            //this.StartPoint;
375

    
376
            PathFigure pathFigure = new PathFigure();
377
            pathFigure.StartPoint = pData[0];
378

    
379
            LineSegment lineSegment0 = new LineSegment();
380
            lineSegment0.Point = pData[0];
381
            pathFigure.Segments.Add(lineSegment0);
382

    
383
            LineSegment lineSegment1 = new LineSegment();
384
            lineSegment1.Point = pData[1];
385
            pathFigure.Segments.Add(lineSegment1);
386

    
387
            LineSegment lineSegment2 = new LineSegment();
388
            lineSegment2.Point = pData[2];
389
            pathFigure.Segments.Add(lineSegment2);
390

    
391
            LineSegment lineSegment3 = new LineSegment();
392
            lineSegment3.Point = pData[3];
393
            pathFigure.Segments.Add(lineSegment3);
394

    
395
            PathGeometry rectPathGeometry = new PathGeometry();
396
            rectPathGeometry.Figures = new PathFigureCollection();
397
            pathFigure.IsClosed = true;
398
            pathFigure.IsFilled = false;
399
            rectPathGeometry.Figures.Add(pathFigure);
400

    
401

    
402
            return rectPathGeometry;
403
        }
404

    
405
        public static PathGeometry Generate(List<Point> pData)
406
        {
407
            var _pathGeometry = new PathGeometry();
408
            double area = MathSet.AreaOf(pData);
409
            bool reverse = (area > 0);
410
            int count = pData.Count;
411
            for (int i = 0; i < (count - 1); i++)
412
            {
413
                PathFigure pathFigure = GenerateLineWithCloud(pData[i], pData[i + 1], 20, reverse);
414
                pathFigure.IsClosed = false;
415
                pathFigure.IsFilled = true;
416
                _pathGeometry.Figures.Add(pathFigure);
417
            }
418

    
419
            //    PathFigure pathFigur2= new PathFigure();
420
            //pathFigur2.StartPoint = pData[0];
421

    
422
            //    LineSegment lineSegment0 = new LineSegment();
423
            //    lineSegment0.Point = pData[0];
424
            //pathFigur2.Segments.Add(lineSegment0);
425

    
426
            //    LineSegment lineSegment1 = new LineSegment();
427
            //    lineSegment1.Point = pData[1];
428
            //pathFigur2.Segments.Add(lineSegment1);
429

    
430
            //    LineSegment lineSegment2 = new LineSegment();
431
            //    lineSegment2.Point = pData[2];
432
            //pathFigur2.Segments.Add(lineSegment2);
433

    
434
            //    LineSegment lineSegment3 = new LineSegment();
435
            //    lineSegment3.Point = pData[3];
436
            //pathFigur2.Segments.Add(lineSegment3);
437

    
438

    
439
            //pathFigur2.IsClosed = true;
440
            //pathFigur2.IsFilled = true;
441
            //_pathGeometry.Figures.Add(pathFigur2);
442

    
443
            return _pathGeometry;
444
        }
445

    
446

    
447
        public static PathGeometry GenerateInner(List<Point> pData)
448
        {
449
            var _pathGeometry = new PathGeometry();
450
            double area = MathSet.AreaOf(pData);
451
            bool reverse = (area > 0);
452
            int count = pData.Count;
453

    
454
            PathFigure pathFigur2 = new PathFigure();
455
            pathFigur2.StartPoint = pData[0];
456

    
457
            LineSegment lineSegment0 = new LineSegment();
458
            lineSegment0.Point = pData[0];
459
            pathFigur2.Segments.Add(lineSegment0);
460

    
461
            LineSegment lineSegment1 = new LineSegment();
462
            lineSegment1.Point = pData[1];
463
            pathFigur2.Segments.Add(lineSegment1);
464

    
465
            LineSegment lineSegment2 = new LineSegment();
466
            lineSegment2.Point = pData[2];
467
            pathFigur2.Segments.Add(lineSegment2);
468

    
469
            LineSegment lineSegment3 = new LineSegment();
470
            lineSegment3.Point = pData[3];
471
            pathFigur2.Segments.Add(lineSegment3);
472

    
473

    
474
            pathFigur2.IsClosed = true;
475
            pathFigur2.IsFilled = true;
476
            _pathGeometry.Figures.Add(pathFigur2);
477

    
478
            return _pathGeometry;
479
        }
480

    
481

    
482

    
483
        public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double _arcLength, bool reverse)
484
        {
485
            PathFigure pathFigure = new PathFigure();
486
            pathFigure.StartPoint = p1;
487

    
488
            double arcLength = _arcLength;
489
            double dx = p2.X - p1.X;
490
            double dy = p2.Y - p1.Y;
491
            double l = MathSet.DistanceTo(p1, p2);
492
            double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI;
493
            Point lastPt = new Point(p1.X, p1.Y);
494
            double count = l / _arcLength;
495

    
496
            dx /= l;
497
            dy /= l;
498

    
499
            Double j = 1;
500
            for (j = 1; j < (count - 1); j++)
501
            {
502
                ArcSegment arcSeg = new ArcSegment();
503
                arcSeg.Size = new Size(arcLength * TextControl._CloudArcDepth, arcLength * TextControl._CloudArcDepth);
504
                arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength);
505
                lastPt = arcSeg.Point;
506
                arcSeg.RotationAngle = theta + 90;
507
                if (true == reverse)
508
                    arcSeg.SweepDirection = SweepDirection.Clockwise;
509
                pathFigure.Segments.Add(arcSeg);
510
            }
511

    
512
            if ((count > j) || count > 0)
513
            {
514
                arcLength = MathSet.DistanceTo(lastPt, p2);
515
                ArcSegment arcSeg = new ArcSegment();
516
                arcSeg.Size = new Size(arcLength * TextControl._CloudArcDepth, arcLength * TextControl._CloudArcDepth);
517
                arcSeg.Point = new Point(p2.X, p2.Y);
518
                arcSeg.RotationAngle = theta;
519

    
520
                if (true == reverse)
521
                    arcSeg.SweepDirection = SweepDirection.Clockwise;
522

    
523
                pathFigure.Segments.Add(arcSeg);
524

    
525
            }
526
            return pathFigure;
527
        }
528
        #endregion
529

    
530
        #region Dependency Properties
531
        public static readonly DependencyProperty ControlTypeProperty =
532
        DependencyProperty.Register("ControlType", typeof(ControlType), typeof(TextControl), new FrameworkPropertyMetadata(ControlType.TextControl));
533

    
534
        public static readonly DependencyProperty ControlType_NoProperty =
535
        DependencyProperty.Register("ControlType_No", typeof(int), typeof(TextControl), new FrameworkPropertyMetadata(0));
536

    
537
        public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(
538
            "IsSelected", typeof(bool), typeof(TextControl), new FrameworkPropertyMetadata(false, IsSelectedChanged));
539

    
540
        public static readonly DependencyProperty PathGeometryProperty = DependencyProperty.Register(
541
            "PathGeometry", typeof(PathGeometry), typeof(TextControl), new PropertyMetadata(null, SetPathGeometryChanged));
542

    
543
        public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
544
            "Text", typeof(string), typeof(TextControl), new PropertyMetadata(null));
545

    
546
        public static readonly DependencyProperty OverViewTextProperty = DependencyProperty.Register(
547
            "OverViewText", typeof(string), typeof(TextControl), new PropertyMetadata(null));
548

    
549
        public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register(
550
            "UserID", typeof(string), typeof(TextControl), new PropertyMetadata(null));
551

    
552
        public static readonly DependencyProperty FontColorProperty = DependencyProperty.Register(
553
            "FontColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red)));
554

    
555
        //강인구 추가
556
        public static readonly DependencyProperty IsHighlightProperty = DependencyProperty.Register(
557
            "IsHighLight", typeof(bool), typeof(TextControl), new PropertyMetadata(false, PointValueChanged));
558

    
559
        public static readonly DependencyProperty BackColorProperty = DependencyProperty.Register(
560
            "BackColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.White)));
561

    
562
        public static readonly DependencyProperty BackInnerColorProperty = DependencyProperty.Register(
563
            "BackInnerColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.White)));
564

    
565
        public static readonly DependencyProperty UnderLineProperty = DependencyProperty.Register(
566
            "UnderLine", typeof(TextDecorationCollection), typeof(TextControl), new PropertyMetadata(null));
567

    
568
        public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register(
569
            "LineSize", typeof(Thickness), typeof(TextControl), new PropertyMetadata(new Thickness(4), PointValueChanged)); //여기만 4인지 모르겠지만 4 그대로 두겠음
570

    
571
        public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register(
572
            "PointSet", typeof(List<Point>), typeof(TextControl), new PropertyMetadata(new List<Point>()));
573

    
574
        public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register(
575
            "PathData", typeof(Geometry), typeof(TextControl), null);
576

    
577
        public static readonly DependencyProperty PathDataInnerProperty = DependencyProperty.Register(
578
    "PathDataInner", typeof(Geometry), typeof(TextControl), null);
579

    
580
        public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register(
581
            "OverViewPathDataProperty", typeof(Geometry), typeof(TextControl), null);
582

    
583
        public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register(
584
            "TextStyle", typeof(FontStyle), typeof(TextControl), new PropertyMetadata(FontStyles.Normal));
585

    
586
        public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register(
587
            "TextFamily", typeof(FontFamily), typeof(TextControl), new PropertyMetadata(new FontFamily("Arial")));
588

    
589
        public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register(
590
            "TextWeight", typeof(FontWeight), typeof(TextControl), new PropertyMetadata(FontWeights.Normal));
591

    
592
        public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register(
593
            "CenterX", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
594

    
595
        public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register(
596
            "CenterY", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnCenterXYChanged));
597

    
598
        public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register(
599
           "CanvasX", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
600

    
601
        public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register(
602
            "CanvasY", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnSetCansvasChanged));
603

    
604
        public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register(
605
              "StartPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged));
606

    
607
        public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register(
608
             "EndPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(100, 100), PointValueChanged));
609

    
610
        public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register(
611
               "TextSize", typeof(Double), typeof(TextControl), new PropertyMetadata((Double)30, PointValueChanged));
612

    
613
        public static readonly DependencyProperty PaintProperty = DependencyProperty.Register(
614
                "Paint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged));
615

    
616
        public static readonly DependencyProperty OverViewPaintProperty = DependencyProperty.Register(
617
                "OverViewPaint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged));
618

    
619
        public static readonly DependencyProperty AngleProperty = DependencyProperty.Register(
620
            "Angle", typeof(double), typeof(TextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged)));
621

    
622
        public static readonly DependencyProperty IsEditingProperty = DependencyProperty.Register(
623
           "IsEditing", typeof(bool), typeof(TextControl), new PropertyMetadata((false), new PropertyChangedCallback(OnIsEditingChanged)));
624

    
625
        public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register(
626
           "EnableEditing", typeof(bool), typeof(TextControl), new PropertyMetadata((true)));
627

    
628
        public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register(
629
        "TextBoxVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged));
630

    
631
        public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register(
632
        "TextBlockVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged));
633

    
634
        #endregion Dependency Properties
635

    
636
        #region dp Properties
637

    
638
        public bool IsEditing
639
        {
640
            get { return (bool)GetValue(IsEditingProperty); }
641
            set
642
            {
643
                if (this.IsEditing != value)
644
                {
645
                    SetValue(IsEditingProperty, value);
646

    
647
                    OnPropertyChanged("IsEditing");
648

    
649
                }
650
            }
651
        }
652

    
653
        public bool EnableEditing
654
        {
655
            get { return (bool)GetValue(EnableEditingProperty); }
656
            set
657
            {
658
                if (this.EnableEditing != value)
659
                {
660
                    SetValue(EnableEditingProperty, value);
661
                    OnPropertyChanged("EnableEditing");
662
                }
663
            }
664
        }
665

    
666
        public Thickness LineSize
667
        {
668
            get
669
            {
670
                return (Thickness)GetValue(LineSizeProperty);
671
            }
672
            set
673
            {
674
                if (this.LineSize != value)
675
                {
676
                    SetValue(LineSizeProperty, value);
677
                    OnPropertyChanged("LineSize");
678
                }
679
            }
680
        }
681

    
682

    
683

    
684

    
685
        public ControlType ControlType
686
        {
687
            get
688
            {
689
                return (ControlType)GetValue(ControlTypeProperty);
690
            }
691
            set
692
            {
693
                SetValue(ControlTypeProperty, value);
694
            }
695
        }
696
        public int ControlType_No
697
        {
698
            get
699
            {
700
                return (int)GetValue(ControlType_NoProperty);
701
            }
702
            set
703
            {
704
                SetValue(ControlType_NoProperty, value);
705
            }
706
        }
707

    
708
        public string UserID
709
        {
710
            get { return (string)GetValue(UserIDProperty); }
711
            set
712
            {
713
                if (this.UserID != value)
714
                {
715
                    SetValue(UserIDProperty, value);
716
                    OnPropertyChanged("UserID");
717
                }
718
            }
719
        }
720

    
721
        public double CenterX
722
        {
723
            get { return (double)GetValue(CenterXProperty); }
724
            set { SetValue(CenterXProperty, value);
725
            OnPropertyChanged("CenterX");
726
            
727
            }
728
        }
729

    
730
        public double CenterY
731
        {
732
            get { return (double)GetValue(CenterYProperty); }
733
            set { SetValue(CenterYProperty, value);
734
            OnPropertyChanged("CenterY");
735
            }
736
        }
737

    
738
        public string Text
739
        {
740
            get { return (string)GetValue(TextProperty); }
741
            set
742
            {
743
                if (this.Text != value)
744
                {
745
                    SetValue(TextProperty, value);
746
                    OnPropertyChanged("Text");
747
                }
748
            }
749
        }
750

    
751
        public string OverViewText
752
        {
753
            get { return (string)GetValue(OverViewTextProperty); }
754
            set
755
            {
756
                if (this.OverViewText != value)
757
                {
758
                    SetValue(OverViewTextProperty, value);
759
                    OnPropertyChanged("OverViewText");
760
                }
761
            }
762
        }
763

    
764
        public Geometry OverViewPathData
765
        {
766
            get { return (Geometry)GetValue(OverViewPathDataProperty); }
767
            set
768
            {
769
                if (this.OverViewPathData != value)
770
                {
771
                    SetValue(OverViewPathDataProperty, value);
772
                    OnPropertyChanged("OverViewPathData");
773
                }
774
            }
775
        }
776

    
777
        public Visibility TextBoxVisibility
778
        {
779
            get { return (Visibility)GetValue(TextBoxVisibilityProperty); }
780
            set
781
            {
782
                if (this.TextBoxVisibility != value)
783
                {
784
                    SetValue(TextBoxVisibilityProperty, value);
785
                    OnPropertyChanged("TextBoxVisibility");
786
                }
787
            }
788
        }
789

    
790

    
791
        public Visibility TextBlockVisibility
792
        {
793
            get { return (Visibility)GetValue(TextBlockVisibilityProperty); }
794
            set
795
            {
796
                if (this.TextBlockVisibility != value)
797
                {
798
                    SetValue(TextBlockVisibilityProperty, value);
799
                    OnPropertyChanged("TextBlockVisibility");
800
                }
801
            }
802
        }
803

    
804

    
805

    
806
        public Double TextSize
807
        {
808
            get { return (Double)GetValue(TextSizeProperty); }
809
            set
810
            {
811
                if (this.TextSize != value)
812
                {
813
                    SetValue(TextSizeProperty, value);
814
                    OnPropertyChanged("TextSize");
815
                }
816
            }
817
        }
818

    
819
        public SolidColorBrush FontColor
820
        {
821
            get { return (SolidColorBrush)GetValue(FontColorProperty); }
822
            set
823
            {
824
                if (this.FontColor != value)
825
                {
826
                    SetValue(FontColorProperty, value);
827
                    OnPropertyChanged("FontColor");
828
                }
829
            }
830
        }
831

    
832
        public SolidColorBrush BackColor
833
        {
834
            get { return (SolidColorBrush)GetValue(BackColorProperty); }
835
            set
836
            {
837
                if (this.BackColor != value)
838
                {
839
                    SetValue(BackColorProperty, value);
840
                    OnPropertyChanged("BackColor");
841
                }
842
            }
843
        }
844

    
845
        public SolidColorBrush BackInnerColor
846
        {
847
            get { return (SolidColorBrush)GetValue(BackInnerColorProperty); }
848
            set
849
            {
850
                if (this.BackInnerColor != value)
851
                {
852
                    SetValue(BackInnerColorProperty, value);
853
                    OnPropertyChanged("BackInnerColor");
854
                }
855
            }
856
        }
857

    
858
        
859

    
860
        public TextDecorationCollection UnderLine
861
        {
862
            get
863
            {
864
                return (TextDecorationCollection)GetValue(UnderLineProperty);
865
            }
866
            set
867
            {
868
                if (this.UnderLine != value)
869
                {
870
                    SetValue(UnderLineProperty, value);
871
                    OnPropertyChanged("UnderLine");
872
                }
873
            }
874
        }
875

    
876
        public double CanvasX
877
        {
878
            get { return (double)GetValue(CanvasXProperty); }
879
            set
880
            {
881
                if (this.CanvasX != value)
882
                {
883
                    SetValue(CanvasXProperty, value);
884
                    OnPropertyChanged("CanvasX");
885
                }
886
            }
887
        }
888

    
889
        public double CanvasY
890
        {
891
            get { return (double)GetValue(CanvasYProperty); }
892
            set
893
            {
894
                if (this.CanvasY != value)
895
                {
896
                    SetValue(CanvasYProperty, value);
897
                    OnPropertyChanged("CanvasY");
898
                }
899
            }
900
        }
901

    
902
        public Point EndPoint
903
        {
904
            get { return (Point)GetValue(EndPointProperty); }
905
            set
906
            {
907
                if (this.EndPoint != value)
908
                {
909
                    SetValue(EndPointProperty, value);
910
                    OnPropertyChanged("EndPoint");
911
                }
912
            }
913
        }
914

    
915
        public Point StartPoint
916
        {
917
            get { return (Point)GetValue(StartPointProperty); }
918
            set
919
            {
920
                if (this.StartPoint != value)
921
                {
922
                    SetValue(StartPointProperty, value);
923
                    OnPropertyChanged("StartPoint");
924
                }
925
            }
926
        }
927

    
928
        public FontStyle TextStyle
929
        {
930
            get { return (FontStyle)GetValue(TextStyleProperty); }
931
            set
932
            {
933
                if (this.TextStyle != value)
934
                {
935
                    SetValue(TextStyleProperty, value);
936
                    OnPropertyChanged("TextStyle");
937
                }
938
            }
939
        }
940

    
941
        public FontFamily TextFamily
942
        {
943
            get { return (FontFamily)GetValue(TextFamilyProperty); }
944
            set
945
            {
946
                if (this.TextFamily != value)
947
                {
948
                    SetValue(TextFamilyProperty, value);
949
                    OnPropertyChanged("TextFamily");
950
                }
951
            }
952
        }
953

    
954
        public FontWeight TextWeight
955
        {
956
            get { return (FontWeight)GetValue(TextWeightProperty); }
957
            set
958
            {
959
                if (this.TextWeight != value)
960
                {
961
                    SetValue(TextWeightProperty, value);
962
                    OnPropertyChanged("TextWeight");
963
                }
964
            }
965
        }
966

    
967
        public PaintSet Paint
968
        {
969
            get { return (PaintSet)GetValue(PaintProperty); }
970
            set
971
            {
972
                if (this.Paint != value)
973
                {
974
                    SetValue(PaintProperty, value);
975
                    OnPropertyChanged("Paint");
976
                }
977
            }
978
        }
979

    
980
        public PaintSet OverViewPaint
981
        {
982
            get { return (PaintSet)GetValue(OverViewPaintProperty); }
983
            set
984
            {
985
                if (this.OverViewPaint != value)
986
                {
987
                    SetValue(OverViewPaintProperty, value);
988
                    OnPropertyChanged("OverViewPaint");
989
                }
990
            }
991
        }
992

    
993
        double IPath.LineSize
994
        {
995
            get
996
            {
997
                return this.LineSize.Left;
998
            }
999
            set
1000
            {
1001
                this.LineSize = new Thickness(value);
1002
                OnPropertyChanged("LineSize");
1003
            }
1004
        }
1005

    
1006

    
1007
        public Geometry PathData
1008
        {
1009
            get { return (Geometry)GetValue(PathDataProperty); }
1010
            set { SetValue(PathDataProperty, value);
1011
            OnPropertyChanged("PathData");
1012
            }
1013
        }
1014

    
1015
        public Geometry PathDataInner
1016
        {
1017
            get { return (Geometry)GetValue(PathDataInnerProperty); }
1018
            set
1019
            {
1020
                SetValue(PathDataInnerProperty, value);
1021
                OnPropertyChanged("PathDataInner");
1022
            }
1023
        }
1024

    
1025
        public double Angle
1026
        {
1027
            get { return (double)GetValue(AngleProperty); }
1028
            set
1029
            {
1030
                if (this.Angle != value)
1031
                {
1032
                    SetValue(AngleProperty, value);
1033

    
1034
                    OnPropertyChanged("Angle");
1035
                    UpdateLayout();
1036
                }
1037
            }
1038
        }
1039

    
1040
        public bool IsHighLight
1041
        {
1042
            get { return (bool)GetValue(IsHighlightProperty); }
1043
            set
1044
            {
1045
                if (this.IsHighLight != value)
1046
                {
1047
                    SetValue(IsHighlightProperty, value);
1048
                    OnPropertyChanged("IsHighLight");
1049
                }
1050
            }
1051
        }
1052

    
1053
        public List<Point> PointSet
1054
        {
1055
            get { return (List<Point>)GetValue(PointSetProperty); }
1056
            set { SetValue(PointSetProperty, value);
1057
            OnPropertyChanged("PointSet");
1058
            }
1059
        }
1060

    
1061
        #endregion Properties
1062

    
1063
        #region Properties
1064

    
1065

    
1066

    
1067
        public PathGeometry PathGeometry 
1068
        {
1069
            get { return (PathGeometry)GetValue(PathGeometryProperty); }
1070
            set
1071
            {
1072
                SetValue(PathGeometryProperty, value);
1073
                OnPropertyChanged("PathGeometry");
1074
            }
1075
        }
1076

    
1077
        private double _BoxWidth;
1078
        public double BoxWidth
1079
        {
1080
            get
1081
            {
1082
                return _BoxWidth;
1083
            }
1084
            set
1085
            {
1086
                _BoxWidth = value;
1087
                OnPropertyChanged("BoxWidth");
1088
            }
1089
        }
1090

    
1091
        private double _BoxHeight;
1092
        public double BoxHeight
1093
        {
1094
            get
1095
            {
1096
                return _BoxHeight;
1097
            }
1098
            set
1099
            {
1100
                _BoxHeight = value;
1101
                OnPropertyChanged("BoxHeight");
1102
            }
1103
        }
1104

    
1105
        #endregion
1106

    
1107
        #region CallBack Method
1108
        public static void SetPathGeometryChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1109
        {
1110
            var instance = (TextControl)sender;
1111

    
1112
            if (e.OldValue != e.NewValue && instance.Base_TextPath != null)
1113
            {
1114
                instance.SetValue(e.Property, e.NewValue);
1115
            }
1116
        }
1117

    
1118

    
1119
        public static void OnTextBoxVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1120
        {
1121
            var instance = (TextControl)sender;
1122

    
1123
            if (e.OldValue != e.NewValue && instance.Base_TextPath != null)
1124
            {
1125
                instance.SetValue(e.Property, e.NewValue);
1126
            }
1127
        }
1128

    
1129
        public static void OnTextBlockVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1130
        {
1131
            var instance = (TextControl)sender;
1132

    
1133
            if (e.OldValue != e.NewValue && instance.Base_TextPath != null)
1134
            {
1135
                instance.SetValue(e.Property, e.NewValue);
1136
            }
1137
        }
1138

    
1139
        public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1140
        {
1141
            var instance = (TextControl)sender;
1142

    
1143
            if (e.OldValue != e.NewValue && instance.Base_Border != null)
1144
            {
1145
                instance.SetValue(e.Property, e.NewValue);
1146

    
1147
                if (instance.IsSelected)
1148
                {
1149
                    instance.FontColor = new SolidColorBrush(Colors.Blue);
1150
                    //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Blue);
1151
                }
1152
                else
1153
                {
1154
                    instance.FontColor = new SolidColorBrush(Colors.Red);
1155
                    //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Red);
1156
                    //instance.FontColor = new SolidColorBrush(Colors.Transparent);
1157
                    //instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Transparent);
1158
                }
1159

    
1160
            }
1161
        }
1162

    
1163
        public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1164
        {
1165
            var instance = (TextControl)sender;
1166

    
1167
            if (e.OldValue != e.NewValue && instance != null)
1168
            {
1169
                instance.SetValue(e.Property, e.NewValue);
1170

    
1171
                Canvas.SetLeft(instance, instance.CanvasX);
1172

    
1173
                Canvas.SetTop(instance, instance.CanvasY);
1174
            }
1175
        }
1176

    
1177
        public static void OnIsEditingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1178
        {
1179
            var instance = (TextControl)sender;
1180

    
1181
            if (e.OldValue != e.NewValue && instance.Base_TextBlock != null)
1182
            {
1183
                instance.SetValue(e.Property, e.NewValue);
1184

    
1185
                if (instance.EnableEditing)
1186
                {
1187
                    if (instance.IsEditing)
1188
                    {
1189
                        instance.EditingMode();
1190
                    }
1191
                    else
1192
                    {
1193
                        instance.UnEditingMode();
1194
                    }
1195
                }
1196
                else
1197
                {
1198
                    instance.UnEditingMode();
1199
                }
1200
            }
1201
        }
1202

    
1203
        public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1204
        {
1205
            var instance = (TextControl)sender;
1206

    
1207
            if (e.OldValue != e.NewValue && instance.Base_TextBlock != null)
1208
            {
1209
                instance.SetValue(e.Property, e.NewValue);
1210
                instance.SetText();
1211
            }
1212
        }
1213

    
1214
        public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1215
        {
1216
            var instance = (TextControl)sender;
1217
            if (e.OldValue != e.NewValue && instance.Base_TextBlock != null)
1218
            {
1219
                instance.SetValue(e.Property, e.NewValue);
1220
                instance.SetText();
1221
            }
1222
        }
1223

    
1224
        public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
1225
        {
1226
            var instance = (TextControl)sender;
1227
            if (e.OldValue != e.NewValue && instance!= null)
1228
            {
1229
                instance.SetValue(e.Property, e.NewValue);
1230
                instance.SetText();
1231
            }
1232
        }
1233
            
1234
        #endregion CallBack Method
1235

    
1236
        protected void OnPropertyChanged(string propName)
1237
        {
1238
            if (PropertyChanged != null)
1239
                PropertyChanged(this, new PropertyChangedEventArgs(propName));
1240
        }
1241
    }
1242
}
클립보드 이미지 추가 (최대 크기: 500 MB)