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