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