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