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