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