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