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