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