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