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