markus / MarkupToPDF / Controls / Text / TextControl.cs @ 05009a0e
이력 | 보기 | 이력해설 | 다운로드 (44.9 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 |
public static readonly DependencyProperty StrokeColorProperty = DependencyProperty.Register( |
454 |
"StrokeColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
455 |
|
456 |
//강인구 추가 |
457 |
public static readonly DependencyProperty IsHighlightProperty = DependencyProperty.Register( |
458 |
"IsHighLight", typeof(bool), typeof(TextControl), new PropertyMetadata(false, PointValueChanged)); |
459 |
|
460 |
public static readonly DependencyProperty BackColorProperty = DependencyProperty.Register( |
461 |
"BackColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.White))); |
462 |
|
463 |
public static readonly DependencyProperty BackInnerColorProperty = DependencyProperty.Register( |
464 |
"BackInnerColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.White))); |
465 |
|
466 |
public static readonly DependencyProperty UnderLineProperty = DependencyProperty.Register( |
467 |
"UnderLine", typeof(TextDecorationCollection), typeof(TextControl), new PropertyMetadata(null)); |
468 |
|
469 |
public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
470 |
"LineSize", typeof(Thickness), typeof(TextControl), new PropertyMetadata(new Thickness(4), PointValueChanged)); //여기만 4인지 모르겠지만 4 그대로 두겠음 |
471 |
|
472 |
public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
473 |
"PointSet", typeof(List<Point>), typeof(TextControl), new PropertyMetadata(new List<Point>())); |
474 |
|
475 |
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
476 |
"PathData", typeof(Geometry), typeof(TextControl), null); |
477 |
|
478 |
|
479 |
|
480 |
public static readonly DependencyProperty PathDataInnerProperty = DependencyProperty.Register( |
481 |
"PathDataInner", typeof(Geometry), typeof(TextControl), null); |
482 |
|
483 |
public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
484 |
"OverViewPathDataProperty", typeof(Geometry), typeof(TextControl), null); |
485 |
|
486 |
public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register( |
487 |
"TextStyle", typeof(FontStyle), typeof(TextControl), new PropertyMetadata(FontStyles.Normal)); |
488 |
|
489 |
public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register( |
490 |
"TextFamily", typeof(FontFamily), typeof(TextControl), new PropertyMetadata(new FontFamily("Arial"))); |
491 |
|
492 |
public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register( |
493 |
"TextWeight", typeof(FontWeight), typeof(TextControl), new PropertyMetadata(FontWeights.Normal)); |
494 |
|
495 |
public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register( |
496 |
"CenterX", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
497 |
|
498 |
public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register( |
499 |
"CenterY", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
500 |
|
501 |
public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register( |
502 |
"CanvasX", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
503 |
|
504 |
public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register( |
505 |
"CanvasY", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
506 |
|
507 |
public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
508 |
"StartPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
509 |
|
510 |
public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
511 |
"EndPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(100, 100), PointValueChanged)); |
512 |
|
513 |
public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register( |
514 |
"TextSize", typeof(Double), typeof(TextControl), new PropertyMetadata((Double)30, PointValueChanged)); |
515 |
|
516 |
public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
517 |
"Paint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged)); |
518 |
|
519 |
public static readonly DependencyProperty OverViewPaintProperty = DependencyProperty.Register( |
520 |
"OverViewPaint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged)); |
521 |
|
522 |
public static readonly DependencyProperty AngleProperty = DependencyProperty.Register( |
523 |
"Angle", typeof(double), typeof(TextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
524 |
|
525 |
public static readonly DependencyProperty IsEditingProperty = DependencyProperty.Register( |
526 |
"IsEditing", typeof(bool), typeof(TextControl), new PropertyMetadata((false), new PropertyChangedCallback(OnIsEditingChanged))); |
527 |
|
528 |
public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register( |
529 |
"EnableEditing", typeof(bool), typeof(TextControl), new PropertyMetadata((true))); |
530 |
|
531 |
public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register( |
532 |
"TextBoxVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged)); |
533 |
|
534 |
public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register( |
535 |
"TextBlockVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged)); |
536 |
|
537 |
#endregion Dependency Properties |
538 |
|
539 |
#region dp Properties |
540 |
|
541 |
|
542 |
public override SolidColorBrush StrokeColor |
543 |
{ |
544 |
get { return (SolidColorBrush)GetValue(StrokeColorProperty); } |
545 |
set |
546 |
{ |
547 |
if (this.StrokeColor != value) |
548 |
{ |
549 |
SetValue(StrokeColorProperty, value); |
550 |
} |
551 |
} |
552 |
} |
553 |
|
554 |
public bool IsEditing |
555 |
{ |
556 |
get { return (bool)GetValue(IsEditingProperty); } |
557 |
set |
558 |
{ |
559 |
if (this.IsEditing != value) |
560 |
{ |
561 |
SetValue(IsEditingProperty, value); |
562 |
|
563 |
OnPropertyChanged("IsEditing"); |
564 |
|
565 |
} |
566 |
} |
567 |
} |
568 |
|
569 |
public bool EnableEditing |
570 |
{ |
571 |
get { return (bool)GetValue(EnableEditingProperty); } |
572 |
set |
573 |
{ |
574 |
if (this.EnableEditing != value) |
575 |
{ |
576 |
SetValue(EnableEditingProperty, value); |
577 |
OnPropertyChanged("EnableEditing"); |
578 |
} |
579 |
} |
580 |
} |
581 |
|
582 |
public Thickness LineSize |
583 |
{ |
584 |
get |
585 |
{ |
586 |
return (Thickness)GetValue(LineSizeProperty); |
587 |
} |
588 |
set |
589 |
{ |
590 |
if (this.LineSize != value) |
591 |
{ |
592 |
SetValue(LineSizeProperty, value); |
593 |
OnPropertyChanged("LineSize"); |
594 |
} |
595 |
} |
596 |
} |
597 |
|
598 |
public override ControlType ControlType |
599 |
{ |
600 |
get |
601 |
{ |
602 |
return (ControlType)GetValue(ControlTypeProperty); |
603 |
} |
604 |
set |
605 |
{ |
606 |
SetValue(ControlTypeProperty, value); |
607 |
} |
608 |
} |
609 |
public int ControlType_No |
610 |
{ |
611 |
get |
612 |
{ |
613 |
return (int)GetValue(ControlType_NoProperty); |
614 |
} |
615 |
set |
616 |
{ |
617 |
SetValue(ControlType_NoProperty, value); |
618 |
} |
619 |
} |
620 |
|
621 |
public string UserID |
622 |
{ |
623 |
get { return (string)GetValue(UserIDProperty); } |
624 |
set |
625 |
{ |
626 |
if (this.UserID != value) |
627 |
{ |
628 |
SetValue(UserIDProperty, value); |
629 |
OnPropertyChanged("UserID"); |
630 |
} |
631 |
} |
632 |
} |
633 |
|
634 |
public double CenterX |
635 |
{ |
636 |
get { return (double)GetValue(CenterXProperty); } |
637 |
set { SetValue(CenterXProperty, value); |
638 |
OnPropertyChanged("CenterX"); |
639 |
|
640 |
} |
641 |
} |
642 |
|
643 |
public double CenterY |
644 |
{ |
645 |
get { return (double)GetValue(CenterYProperty); } |
646 |
set { SetValue(CenterYProperty, value); |
647 |
OnPropertyChanged("CenterY"); |
648 |
} |
649 |
} |
650 |
|
651 |
public string Text |
652 |
{ |
653 |
get { return (string)GetValue(TextProperty); } |
654 |
set |
655 |
{ |
656 |
if (this.Text != value) |
657 |
{ |
658 |
SetValue(TextProperty, value); |
659 |
OnPropertyChanged("Text"); |
660 |
} |
661 |
} |
662 |
} |
663 |
|
664 |
public string OverViewText |
665 |
{ |
666 |
get { return (string)GetValue(OverViewTextProperty); } |
667 |
set |
668 |
{ |
669 |
if (this.OverViewText != value) |
670 |
{ |
671 |
SetValue(OverViewTextProperty, value); |
672 |
OnPropertyChanged("OverViewText"); |
673 |
} |
674 |
} |
675 |
} |
676 |
|
677 |
public Geometry OverViewPathData |
678 |
{ |
679 |
get { return (Geometry)GetValue(OverViewPathDataProperty); } |
680 |
set |
681 |
{ |
682 |
if (this.OverViewPathData != value) |
683 |
{ |
684 |
SetValue(OverViewPathDataProperty, value); |
685 |
OnPropertyChanged("OverViewPathData"); |
686 |
} |
687 |
} |
688 |
} |
689 |
|
690 |
public Visibility TextBoxVisibility |
691 |
{ |
692 |
get { return (Visibility)GetValue(TextBoxVisibilityProperty); } |
693 |
set |
694 |
{ |
695 |
if (this.TextBoxVisibility != value) |
696 |
{ |
697 |
SetValue(TextBoxVisibilityProperty, value); |
698 |
OnPropertyChanged("TextBoxVisibility"); |
699 |
} |
700 |
} |
701 |
} |
702 |
|
703 |
|
704 |
public Visibility TextBlockVisibility |
705 |
{ |
706 |
get { return (Visibility)GetValue(TextBlockVisibilityProperty); } |
707 |
set |
708 |
{ |
709 |
if (this.TextBlockVisibility != value) |
710 |
{ |
711 |
SetValue(TextBlockVisibilityProperty, value); |
712 |
OnPropertyChanged("TextBlockVisibility"); |
713 |
} |
714 |
} |
715 |
} |
716 |
|
717 |
|
718 |
|
719 |
public Double TextSize |
720 |
{ |
721 |
get { return (Double)GetValue(TextSizeProperty); } |
722 |
set |
723 |
{ |
724 |
if (this.TextSize != value) |
725 |
{ |
726 |
SetValue(TextSizeProperty, value); |
727 |
OnPropertyChanged("TextSize"); |
728 |
} |
729 |
} |
730 |
} |
731 |
/* |
732 |
public SolidColorBrush FontColor |
733 |
{ |
734 |
get { return (SolidColorBrush)GetValue(FontColorProperty); } |
735 |
set |
736 |
{ |
737 |
if (this.FontColor != value) |
738 |
{ |
739 |
SetValue(FontColorProperty, value); |
740 |
OnPropertyChanged("FontColor"); |
741 |
} |
742 |
} |
743 |
}*/ |
744 |
|
745 |
public SolidColorBrush BackColor |
746 |
{ |
747 |
get { return (SolidColorBrush)GetValue(BackColorProperty); } |
748 |
set |
749 |
{ |
750 |
if (this.BackColor != value) |
751 |
{ |
752 |
SetValue(BackColorProperty, value); |
753 |
OnPropertyChanged("BackColor"); |
754 |
} |
755 |
} |
756 |
} |
757 |
|
758 |
public SolidColorBrush BackInnerColor |
759 |
{ |
760 |
get { return (SolidColorBrush)GetValue(BackInnerColorProperty); } |
761 |
set |
762 |
{ |
763 |
if (this.BackInnerColor != value) |
764 |
{ |
765 |
SetValue(BackInnerColorProperty, value); |
766 |
OnPropertyChanged("BackInnerColor"); |
767 |
} |
768 |
} |
769 |
} |
770 |
|
771 |
|
772 |
|
773 |
public TextDecorationCollection UnderLine |
774 |
{ |
775 |
get |
776 |
{ |
777 |
return (TextDecorationCollection)GetValue(UnderLineProperty); |
778 |
} |
779 |
set |
780 |
{ |
781 |
if (this.UnderLine != value) |
782 |
{ |
783 |
SetValue(UnderLineProperty, value); |
784 |
OnPropertyChanged("UnderLine"); |
785 |
} |
786 |
} |
787 |
} |
788 |
|
789 |
public double CanvasX |
790 |
{ |
791 |
get { return (double)GetValue(CanvasXProperty); } |
792 |
set |
793 |
{ |
794 |
if (this.CanvasX != value) |
795 |
{ |
796 |
SetValue(CanvasXProperty, value); |
797 |
OnPropertyChanged("CanvasX"); |
798 |
} |
799 |
} |
800 |
} |
801 |
|
802 |
public double CanvasY |
803 |
{ |
804 |
get { return (double)GetValue(CanvasYProperty); } |
805 |
set |
806 |
{ |
807 |
if (this.CanvasY != value) |
808 |
{ |
809 |
SetValue(CanvasYProperty, value); |
810 |
OnPropertyChanged("CanvasY"); |
811 |
} |
812 |
} |
813 |
} |
814 |
|
815 |
public Point EndPoint |
816 |
{ |
817 |
get { return (Point)GetValue(EndPointProperty); } |
818 |
set |
819 |
{ |
820 |
if (this.EndPoint != value) |
821 |
{ |
822 |
SetValue(EndPointProperty, value); |
823 |
OnPropertyChanged("EndPoint"); |
824 |
} |
825 |
} |
826 |
} |
827 |
|
828 |
public Point StartPoint |
829 |
{ |
830 |
get { return (Point)GetValue(StartPointProperty); } |
831 |
set |
832 |
{ |
833 |
if (this.StartPoint != value) |
834 |
{ |
835 |
SetValue(StartPointProperty, value); |
836 |
OnPropertyChanged("StartPoint"); |
837 |
} |
838 |
} |
839 |
} |
840 |
|
841 |
public FontStyle TextStyle |
842 |
{ |
843 |
get { return (FontStyle)GetValue(TextStyleProperty); } |
844 |
set |
845 |
{ |
846 |
if (this.TextStyle != value) |
847 |
{ |
848 |
SetValue(TextStyleProperty, value); |
849 |
OnPropertyChanged("TextStyle"); |
850 |
} |
851 |
} |
852 |
} |
853 |
|
854 |
public FontFamily TextFamily |
855 |
{ |
856 |
get { return (FontFamily)GetValue(TextFamilyProperty); } |
857 |
set |
858 |
{ |
859 |
if (this.TextFamily != value) |
860 |
{ |
861 |
SetValue(TextFamilyProperty, value); |
862 |
OnPropertyChanged("TextFamily"); |
863 |
} |
864 |
} |
865 |
} |
866 |
|
867 |
public FontWeight TextWeight |
868 |
{ |
869 |
get { return (FontWeight)GetValue(TextWeightProperty); } |
870 |
set |
871 |
{ |
872 |
if (this.TextWeight != value) |
873 |
{ |
874 |
SetValue(TextWeightProperty, value); |
875 |
OnPropertyChanged("TextWeight"); |
876 |
} |
877 |
} |
878 |
} |
879 |
|
880 |
public PaintSet Paint |
881 |
{ |
882 |
get { return (PaintSet)GetValue(PaintProperty); } |
883 |
set |
884 |
{ |
885 |
if (this.Paint != value) |
886 |
{ |
887 |
SetValue(PaintProperty, value); |
888 |
OnPropertyChanged("Paint"); |
889 |
} |
890 |
} |
891 |
} |
892 |
|
893 |
public PaintSet OverViewPaint |
894 |
{ |
895 |
get { return (PaintSet)GetValue(OverViewPaintProperty); } |
896 |
set |
897 |
{ |
898 |
if (this.OverViewPaint != value) |
899 |
{ |
900 |
SetValue(OverViewPaintProperty, value); |
901 |
OnPropertyChanged("OverViewPaint"); |
902 |
} |
903 |
} |
904 |
} |
905 |
|
906 |
double IPath.LineSize |
907 |
{ |
908 |
get |
909 |
{ |
910 |
return this.LineSize.Left; |
911 |
} |
912 |
set |
913 |
{ |
914 |
this.LineSize = new Thickness(value); |
915 |
OnPropertyChanged("LineSize"); |
916 |
} |
917 |
} |
918 |
|
919 |
|
920 |
public Geometry PathData |
921 |
{ |
922 |
get { return (Geometry)GetValue(PathDataProperty); } |
923 |
set { SetValue(PathDataProperty, value); |
924 |
OnPropertyChanged("PathData"); |
925 |
} |
926 |
} |
927 |
|
928 |
public Geometry PathDataInner |
929 |
{ |
930 |
get { return (Geometry)GetValue(PathDataInnerProperty); } |
931 |
set |
932 |
{ |
933 |
SetValue(PathDataInnerProperty, value); |
934 |
OnPropertyChanged("PathDataInner"); |
935 |
} |
936 |
} |
937 |
|
938 |
public double Angle |
939 |
{ |
940 |
get { return (double)GetValue(AngleProperty); } |
941 |
set |
942 |
{ |
943 |
if (this.Angle != value) |
944 |
{ |
945 |
SetValue(AngleProperty, value); |
946 |
|
947 |
OnPropertyChanged("Angle"); |
948 |
UpdateLayout(); |
949 |
} |
950 |
} |
951 |
} |
952 |
|
953 |
public bool IsHighLight |
954 |
{ |
955 |
get { return (bool)GetValue(IsHighlightProperty); } |
956 |
set |
957 |
{ |
958 |
if (this.IsHighLight != value) |
959 |
{ |
960 |
SetValue(IsHighlightProperty, value); |
961 |
OnPropertyChanged("IsHighLight"); |
962 |
} |
963 |
} |
964 |
} |
965 |
|
966 |
public List<Point> PointSet |
967 |
{ |
968 |
get { return (List<Point>)GetValue(PointSetProperty); } |
969 |
set { SetValue(PointSetProperty, value); |
970 |
OnPropertyChanged("PointSet"); |
971 |
} |
972 |
} |
973 |
|
974 |
#endregion Properties |
975 |
|
976 |
#region Properties |
977 |
|
978 |
|
979 |
|
980 |
public PathGeometry PathGeometry |
981 |
{ |
982 |
get { return (PathGeometry)GetValue(PathGeometryProperty); } |
983 |
set |
984 |
{ |
985 |
SetValue(PathGeometryProperty, value); |
986 |
OnPropertyChanged("PathGeometry"); |
987 |
} |
988 |
} |
989 |
|
990 |
private double _BoxWidth; |
991 |
public double BoxWidth |
992 |
{ |
993 |
get |
994 |
{ |
995 |
return _BoxWidth; |
996 |
} |
997 |
set |
998 |
{ |
999 |
_BoxWidth = value; |
1000 |
OnPropertyChanged("BoxWidth"); |
1001 |
} |
1002 |
} |
1003 |
|
1004 |
private double _BoxHeight; |
1005 |
public double BoxHeight |
1006 |
{ |
1007 |
get |
1008 |
{ |
1009 |
return _BoxHeight; |
1010 |
} |
1011 |
set |
1012 |
{ |
1013 |
_BoxHeight = value; |
1014 |
OnPropertyChanged("BoxHeight"); |
1015 |
} |
1016 |
} |
1017 |
|
1018 |
#endregion |
1019 |
|
1020 |
#region CallBack Method |
1021 |
public static void SetPathGeometryChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1022 |
{ |
1023 |
var instance = (TextControl)sender; |
1024 |
|
1025 |
if (e.OldValue != e.NewValue && instance.Base_TextPath != null) |
1026 |
{ |
1027 |
instance.SetValue(e.Property, e.NewValue); |
1028 |
} |
1029 |
} |
1030 |
|
1031 |
|
1032 |
public static void OnTextBoxVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1033 |
{ |
1034 |
var instance = (TextControl)sender; |
1035 |
|
1036 |
if (e.OldValue != e.NewValue && instance.Base_TextPath != null) |
1037 |
{ |
1038 |
instance.SetValue(e.Property, e.NewValue); |
1039 |
} |
1040 |
} |
1041 |
|
1042 |
public static void OnTextBlockVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1043 |
{ |
1044 |
var instance = (TextControl)sender; |
1045 |
|
1046 |
if (e.OldValue != e.NewValue && instance.Base_TextPath != null) |
1047 |
{ |
1048 |
instance.SetValue(e.Property, e.NewValue); |
1049 |
} |
1050 |
} |
1051 |
|
1052 |
public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1053 |
{ |
1054 |
var instance = (TextControl)sender; |
1055 |
|
1056 |
if (e.OldValue != e.NewValue && instance.Base_Border != null) |
1057 |
{ |
1058 |
instance.SetValue(e.Property, e.NewValue); |
1059 |
|
1060 |
if (instance.IsSelected) |
1061 |
{ |
1062 |
instance.StrokeColor = new SolidColorBrush(Colors.Blue); |
1063 |
//instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Blue); |
1064 |
} |
1065 |
else |
1066 |
{ |
1067 |
instance.StrokeColor = new SolidColorBrush(Colors.Red); |
1068 |
//instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Red); |
1069 |
//instance.FontColor = new SolidColorBrush(Colors.Transparent); |
1070 |
//instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Transparent); |
1071 |
} |
1072 |
|
1073 |
} |
1074 |
} |
1075 |
|
1076 |
public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1077 |
{ |
1078 |
var instance = (TextControl)sender; |
1079 |
|
1080 |
if (e.OldValue != e.NewValue && instance != null) |
1081 |
{ |
1082 |
instance.SetValue(e.Property, e.NewValue); |
1083 |
|
1084 |
Canvas.SetLeft(instance, instance.CanvasX); |
1085 |
|
1086 |
Canvas.SetTop(instance, instance.CanvasY); |
1087 |
} |
1088 |
} |
1089 |
|
1090 |
public static void OnIsEditingChanged(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 |
|
1098 |
if (instance.EnableEditing) |
1099 |
{ |
1100 |
if (instance.IsEditing) |
1101 |
{ |
1102 |
instance.EditingMode(); |
1103 |
} |
1104 |
else |
1105 |
{ |
1106 |
instance.UnEditingMode(); |
1107 |
} |
1108 |
} |
1109 |
else |
1110 |
{ |
1111 |
instance.UnEditingMode(); |
1112 |
} |
1113 |
} |
1114 |
} |
1115 |
|
1116 |
public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1117 |
{ |
1118 |
var instance = (TextControl)sender; |
1119 |
|
1120 |
if (e.OldValue != e.NewValue && instance.Base_TextBlock != null) |
1121 |
{ |
1122 |
instance.SetValue(e.Property, e.NewValue); |
1123 |
//instance.DrawingCloud(); |
1124 |
} |
1125 |
} |
1126 |
|
1127 |
public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1128 |
{ |
1129 |
var instance = (TextControl)sender; |
1130 |
if (e.OldValue != e.NewValue && instance.Base_TextBlock != null) |
1131 |
{ |
1132 |
instance.SetValue(e.Property, e.NewValue); |
1133 |
//instance.DrawingCloud(); |
1134 |
} |
1135 |
} |
1136 |
|
1137 |
public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
1138 |
{ |
1139 |
var instance = (TextControl)sender; |
1140 |
if (e.OldValue != e.NewValue && instance!= null) |
1141 |
{ |
1142 |
instance.SetValue(e.Property, e.NewValue); |
1143 |
//instance.DrawingCloud(); |
1144 |
} |
1145 |
} |
1146 |
|
1147 |
#endregion CallBack Method |
1148 |
|
1149 |
protected void OnPropertyChanged(string propName) |
1150 |
{ |
1151 |
if (PropertyChanged != null) |
1152 |
PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
1153 |
} |
1154 |
|
1155 |
/// <summary> |
1156 |
/// return textcontrols' area |
1157 |
/// </summary> |
1158 |
public override Rect ItemRect |
1159 |
{ |
1160 |
get |
1161 |
{ |
1162 |
Point start = new Point(this.CanvasX, this.CanvasY); |
1163 |
|
1164 |
Point length = new Point(); |
1165 |
double angle = this.Angle * Math.PI / 180; |
1166 |
|
1167 |
length.X = this.BoxWidth * Math.Cos(angle) - this.BoxHeight * Math.Sin(angle); |
1168 |
length.Y = this.BoxWidth * Math.Sin(angle) + this.BoxHeight * Math.Cos(angle); |
1169 |
|
1170 |
Point end = new Point(start.X + length.X, start.Y + length.Y); |
1171 |
return new Rect(start, end); |
1172 |
} |
1173 |
} |
1174 |
|
1175 |
/// <summary> |
1176 |
/// translate TextControl by given dx, dy |
1177 |
/// </summary> |
1178 |
/// <param name="dx"></param> |
1179 |
/// <param name="dy"></param> |
1180 |
public override void Move(double dx, double dy) |
1181 |
{ |
1182 |
//Canvas.SetLeft(this, Canvas.GetLeft(this) + dx); |
1183 |
//Canvas.SetTop(this, Canvas.GetTop(this) + dy); |
1184 |
this.SetValue(TextControl.CanvasXProperty, Canvas.GetLeft(this) + dx); |
1185 |
this.SetValue(TextControl.CanvasYProperty, Canvas.GetTop(this) + dy); |
1186 |
//System.Diagnostics.Debug.WriteLine("Left :" + Canvas.GetLeft(this) + dx); |
1187 |
//System.Diagnostics.Debug.WriteLine("Top :" + Canvas.GetTop(this) + dy); |
1188 |
|
1189 |
//this.CanvasX = Canvas.GetLeft(this) + dx; |
1190 |
//this.CanvasY = Canvas.GetTop(this) + dy; |
1191 |
|
1192 |
//System.Diagnostics.Debug.WriteLine("X :" + this.CanvasX); |
1193 |
//System.Diagnostics.Debug.WriteLine("Y :" + this.CanvasY); |
1194 |
//this.SetValue(TextControl.CanvasXProperty, Canvas.GetLeft(this) + dx); |
1195 |
//this.SetValue(TextControl.CanvasYProperty, Canvas.GetTop(this) + dy); |
1196 |
this.StartPoint = new Point(this.StartPoint.X + dx, this.StartPoint.Y + dy); |
1197 |
this.EndPoint = new Point(this.EndPoint.X + dx, this.EndPoint.Y + dy); |
1198 |
} |
1199 |
|
1200 |
/// <summary> |
1201 |
/// Serialize this |
1202 |
/// </summary> |
1203 |
/// <param name="sUserId"></param> |
1204 |
/// <returns></returns> |
1205 |
public override string Serialize() |
1206 |
{ |
1207 |
using (S_TextControl STemp = new S_TextControl()) |
1208 |
{ |
1209 |
STemp.TransformPoint = "0|0"; |
1210 |
STemp.SizeSet = String.Format("{0}|{1}", this.LineSize.Left.ToString(), this.TextSize.ToString()); |
1211 |
STemp.Text = this.Text; |
1212 |
STemp.UserID = this.UserID; |
1213 |
STemp.FontColor = this.StrokeColor.Color.ToString(); |
1214 |
//STemp.FontColor = "#FFFFFF00"; |
1215 |
|
1216 |
if (this.StartPoint == new Point()) |
1217 |
STemp.StartPoint = new Point(this.CanvasX, this.CanvasY); |
1218 |
else |
1219 |
STemp.StartPoint = this.StartPoint; |
1220 |
|
1221 |
STemp.EndPoint = this.EndPoint; |
1222 |
STemp.Opac = this.Opacity; |
1223 |
STemp.PointSet = this.PointSet; |
1224 |
STemp.Angle = this.Angle; |
1225 |
STemp.paintMethod = this.ControlType_No; |
1226 |
STemp.BoxW = this.BoxWidth; |
1227 |
STemp.BoxH = this.BoxHeight; |
1228 |
STemp.isHighLight = this.IsHighLight; |
1229 |
STemp.Name = this.GetType().Name.ToString(); |
1230 |
STemp.fontConfig = new List<string>() |
1231 |
{ |
1232 |
this.TextFamily.ToString(), |
1233 |
this.TextStyle.ToString(), |
1234 |
this.TextWeight.ToString(), |
1235 |
}; |
1236 |
|
1237 |
|
1238 |
|
1239 |
if (this.UnderLine != null) |
1240 |
{ |
1241 |
STemp.fontConfig.Add("true"); |
1242 |
} |
1243 |
|
1244 |
///강인구 추가(2017.11.02) |
1245 |
///Memo 추가 |
1246 |
STemp.Memo = this.Memo; |
1247 |
|
1248 |
return "|DZ|" + JsonSerializerHelper.CompressString((STemp.JsonSerialize())); |
1249 |
} |
1250 |
} |
1251 |
|
1252 |
/// <summary> |
1253 |
/// create a textcontrol from given string |
1254 |
/// </summary> |
1255 |
/// <param name="str"></param> |
1256 |
/// <returns></returns> |
1257 |
public static TextControl FromString(string str, SolidColorBrush brush, string sProjectNo) |
1258 |
{ |
1259 |
using (S_TextControl s = JsonSerializerHelper.JsonDeserialize<S_TextControl>(str)) |
1260 |
{ |
1261 |
string[] data2 = s.SizeSet.Split(delimiterChars2, StringSplitOptions.RemoveEmptyEntries); |
1262 |
TextControl instance = new TextControl() |
1263 |
{ |
1264 |
Text = s.Text, |
1265 |
StartPoint = s.StartPoint, |
1266 |
EndPoint = s.EndPoint, |
1267 |
CanvasX = s.StartPoint.X, |
1268 |
CanvasY = s.StartPoint.Y, |
1269 |
BoxWidth = s.BoxW, |
1270 |
BoxHeight = s.BoxH, |
1271 |
ControlType_No = s.paintMethod, |
1272 |
LineSize = new Thickness(Convert.ToDouble(data2.First())), |
1273 |
TextSize = Convert.ToDouble(data2[1]), |
1274 |
StrokeColor = brush, |
1275 |
FontSize = 10, |
1276 |
UserID = s.UserID, |
1277 |
IsHighLight = s.isHighLight, |
1278 |
Angle = s.Angle, |
1279 |
PointSet = s.PointSet, |
1280 |
Opacity = s.Opac, |
1281 |
TextFamily = new FontFamily(s.fontConfig[0]), |
1282 |
//인구 추가(2018.04.17) |
1283 |
TextStyle = StringToFont.ConFontStyle(s.fontConfig[1]), |
1284 |
TextWeight = StringToFont.ConFontWeight(s.fontConfig[2]), |
1285 |
}; |
1286 |
|
1287 |
if (s.fontConfig.Count() == 4) |
1288 |
{ |
1289 |
instance.UnderLine = TextDecorations.Underline; |
1290 |
} |
1291 |
|
1292 |
return instance; |
1293 |
} |
1294 |
} |
1295 |
} |
1296 |
} |