markus / MarkupToPDF_Old / Controls / Text / TextControl.cs @ b3fb7321
이력 | 보기 | 이력해설 | 다운로드 (32.8 KB)
1 | 787a4489 | KangIngu | using MarkupToPDF.Controls.Common; |
---|---|---|---|
2 | using System; |
||
3 | using System.Collections.Generic; |
||
4 | using System.ComponentModel; |
||
5 | using System.Linq; |
||
6 | using System.Text; |
||
7 | using System.Threading.Tasks; |
||
8 | using System.Windows; |
||
9 | using System.Windows.Controls; |
||
10 | using System.Windows.Media; |
||
11 | using System.Windows.Shapes; |
||
12 | |||
13 | namespace MarkupToPDF.Controls.Text |
||
14 | { |
||
15 | public class TextControl : Control, INotifyPropertyChanged, IMarkupControlData |
||
16 | { |
||
17 | public event PropertyChangedEventHandler PropertyChanged; |
||
18 | |||
19 | private const string PART_Grid = "PART_Grid"; |
||
20 | private const string PART_Border = "PART_Border"; |
||
21 | private const string PART_TextBox = "PART_TextBox"; |
||
22 | private const string PART_TextPath = "PART_TextPath"; |
||
23 | private const string PART_TextBlock = "PART_TextBlock"; |
||
24 | //private const string PART_TextPrefix = "PART_TextPrefix"; |
||
25 | |||
26 | public Path Base_TextPath = null; |
||
27 | public Grid Base_Grid = null; |
||
28 | public Border Base_Border = null; |
||
29 | //public TextBlock Base_TextPrefixBlock = null; |
||
30 | public TextBlock Base_TextBlock = null; |
||
31 | public TextBox Base_TextBox = null; |
||
32 | |||
33 | public RotateTransform _rotation = null; |
||
34 | public TranslateTransform _translation = null; |
||
35 | public ScaleTransform _scale = null; |
||
36 | |||
37 | public bool IsSelected |
||
38 | { |
||
39 | get |
||
40 | { |
||
41 | return (bool)GetValue(IsSelectedProperty); |
||
42 | } |
||
43 | set |
||
44 | { |
||
45 | SetValue(IsSelectedProperty, value); |
||
46 | OnPropertyChanged("IsSelected"); |
||
47 | } |
||
48 | } |
||
49 | |||
50 | #region Internal Method |
||
51 | |||
52 | public TextControl() |
||
53 | { |
||
54 | this.DefaultStyleKey = typeof(TextControl); |
||
55 | } |
||
56 | |||
57 | static TextControl() |
||
58 | { |
||
59 | DefaultStyleKeyProperty.OverrideMetadata(typeof(TextControl), new FrameworkPropertyMetadata(typeof(TextControl))); |
||
60 | ResourceDictionary dictionary = new ResourceDictionary(); |
||
61 | dictionary.Source = new Uri("/MarkupToPDF;component/themes/generic.xaml", UriKind.RelativeOrAbsolute); |
||
62 | Application.Current.Resources.MergedDictionaries.Add(dictionary); |
||
63 | } |
||
64 | |||
65 | public override void OnApplyTemplate() |
||
66 | { |
||
67 | base.OnApplyTemplate(); |
||
68 | |||
69 | Base_TextPath = GetTemplateChild(PART_TextPath) as Path; |
||
70 | Base_TextBox = GetTemplateChild(PART_TextBox) as TextBox; |
||
71 | Base_TextBlock = GetTemplateChild(PART_TextBlock) as TextBlock; |
||
72 | Base_Grid = GetTemplateChild(PART_Grid) as Grid; |
||
73 | Base_Border = GetTemplateChild(PART_Border) as Border; |
||
74 | //Base_TextPrefixBlock = GetTemplateChild(PART_TextPrefix) as TextBlock; |
||
75 | |||
76 | //Canvas.SetLeft(this, this.StartPoint.X); |
||
77 | //Canvas.SetTop(this, this.StartPoint.Y); |
||
78 | |||
79 | //CanvasX = StartPoint.X; |
||
80 | //CanvasY = StartPoint.Y; |
||
81 | |||
82 | this.LostFocus += new RoutedEventHandler(TextControl_LostFocus); |
||
83 | this.GotFocus += new RoutedEventHandler(TextControl_GotFocus); |
||
84 | this.Base_TextBox.SizeChanged += new SizeChangedEventHandler(Base_TextBox_SizeChanged); |
||
85 | this.Base_TextBlock.SizeChanged += Base_TextBlock_SizeChanged; |
||
86 | this.MouseDown += TextControl_MouseDown; |
||
87 | |||
88 | SetText(); |
||
89 | |||
90 | Base_TextBox.Focus(); |
||
91 | } |
||
92 | |||
93 | public void ApplyOverViewData() |
||
94 | { |
||
95 | this.OverViewPathData = this.PathData; |
||
96 | this.OverViewText = this.Text; |
||
97 | this.OverViewPaint = this.Paint; |
||
98 | |||
99 | } |
||
100 | |||
101 | void Base_TextBlock_SizeChanged(object sender, SizeChangedEventArgs e) |
||
102 | { |
||
103 | this.Text = Base_TextBox.Text; |
||
104 | |||
105 | BoxWidth = e.NewSize.Width; |
||
106 | BoxHeight = e.NewSize.Height; |
||
107 | |||
108 | this.ApplyTemplate(); |
||
109 | |||
110 | DrawingCloud(); |
||
111 | } |
||
112 | |||
113 | void TextControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) |
||
114 | { |
||
115 | this.Focus(); |
||
116 | } |
||
117 | |||
118 | void Base_TextBox_SizeChanged(object sender, SizeChangedEventArgs e) |
||
119 | { |
||
120 | this.Text = Base_TextBox.Text; |
||
121 | |||
122 | BoxWidth = e.NewSize.Width; |
||
123 | BoxHeight = e.NewSize.Height; |
||
124 | |||
125 | this.ApplyTemplate(); |
||
126 | |||
127 | DrawingCloud(); |
||
128 | } |
||
129 | |||
130 | void TextControl_GotFocus(object sender, RoutedEventArgs e) |
||
131 | { |
||
132 | if (EnableEditing) |
||
133 | { |
||
134 | IsEditing = true; |
||
135 | EditingMode(); |
||
136 | } |
||
137 | else |
||
138 | { |
||
139 | IsEditing = false; |
||
140 | UnEditingMode(); |
||
141 | } |
||
142 | } |
||
143 | |||
144 | void TextControl_LostFocus(object sender, RoutedEventArgs e) |
||
145 | { |
||
146 | IsEditing = false; |
||
147 | UnEditingMode(); |
||
148 | ApplyOverViewData(); |
||
149 | } |
||
150 | |||
151 | public void EditingMode() |
||
152 | { |
||
153 | TextBoxVisibility = Visibility.Visible; |
||
154 | //Base_TextBox.Visibility = System.Windows.Visibility.Visible; |
||
155 | |||
156 | TextBlockVisibility = Visibility.Collapsed; |
||
157 | //Base_TextBlock.Visibility = System.Windows.Visibility.Collapsed; |
||
158 | |||
159 | |||
160 | this.Base_TextBox.BorderThickness = new Thickness(1); |
||
161 | |||
162 | if (UnderLine != null) |
||
163 | Base_TextBlock.TextDecorations = UnderLine; |
||
164 | |||
165 | if (this.Text != null) |
||
166 | Base_TextBox.Text = this.Text; |
||
167 | } |
||
168 | |||
169 | public void UnEditingMode() |
||
170 | { |
||
171 | if (EnableEditing) |
||
172 | this.Text = Base_TextBox.Text; |
||
173 | |||
174 | TextBoxVisibility = Visibility.Collapsed; |
||
175 | //Base_TextBox.Visibility = System.Windows.Visibility.Collapsed; |
||
176 | |||
177 | TextBlockVisibility = Visibility.Visible; |
||
178 | //Base_TextBlock.Visibility = System.Windows.Visibility.Visible; |
||
179 | |||
180 | if (UnderLine != null) |
||
181 | Base_TextBlock.TextDecorations = UnderLine; |
||
182 | |||
183 | Base_TextBlock.Margin = |
||
184 | new Thickness(Base_TextBox.Margin.Left + 4, Base_TextBox.Margin.Top + 4, |
||
185 | Base_TextBox.Margin.Right + 4, Base_TextBox.Margin.Bottom + 4); |
||
186 | } |
||
187 | |||
188 | public void SetText() |
||
189 | { |
||
190 | this.ApplyTemplate(); |
||
191 | |||
192 | if (IsHighLight) |
||
193 | { |
||
194 | this.BackColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), |
||
195 | Colors.Yellow.R, Colors.Yellow.G, Colors.Yellow.B)); |
||
196 | } |
||
197 | else |
||
198 | { |
||
199 | this.BackColor = new SolidColorBrush(Color.FromArgb(Convert.ToByte(255 * 0.6), |
||
200 | Colors.White.R, Colors.White.G, Colors.White.B)); |
||
201 | } |
||
202 | |||
203 | OverViewPathData = PathData; |
||
204 | OverViewText = Text; |
||
205 | } |
||
206 | |||
207 | public void DrawingCloud() |
||
208 | { |
||
209 | this.ApplyTemplate(); |
||
210 | |||
211 | //pathGeometry = new PathGeometry(); |
||
212 | |||
213 | List<Point> pCloud = new List<Point> |
||
214 | { |
||
215 | new Point(0, 0), |
||
216 | new Point(0, 0 + BoxHeight + 2), |
||
217 | new Point(0 + BoxWidth + 4, 0 + BoxHeight + 2), |
||
218 | new Point(0 + BoxWidth + 4 ,0), |
||
219 | new Point(0, 0) |
||
220 | }; |
||
221 | |||
222 | if (Base_TextPath != null) |
||
223 | { |
||
224 | switch (ControlType_No) |
||
225 | { |
||
226 | case 1: |
||
227 | { |
||
228 | PathData = (Generate_Rect(pCloud)); |
||
229 | } |
||
230 | break; |
||
231 | case 2: |
||
232 | { |
||
233 | PathData = (Generate(pCloud)); |
||
234 | } |
||
235 | break; |
||
236 | } |
||
237 | } |
||
238 | |||
239 | SetText(); |
||
240 | } |
||
241 | |||
242 | #endregion Internal Method |
||
243 | |||
244 | #region Drawing Cloud Method |
||
245 | public static PathGeometry Generate_Rect(List<Point> pData) |
||
246 | { |
||
247 | PathFigure pathFigure = new PathFigure(); |
||
248 | pathFigure.StartPoint = pData[0]; |
||
249 | |||
250 | LineSegment lineSegment0 = new LineSegment(); |
||
251 | lineSegment0.Point = pData[0]; |
||
252 | pathFigure.Segments.Add(lineSegment0); |
||
253 | |||
254 | LineSegment lineSegment1 = new LineSegment(); |
||
255 | lineSegment1.Point = pData[1]; |
||
256 | pathFigure.Segments.Add(lineSegment1); |
||
257 | |||
258 | LineSegment lineSegment2 = new LineSegment(); |
||
259 | lineSegment2.Point = pData[2]; |
||
260 | pathFigure.Segments.Add(lineSegment2); |
||
261 | |||
262 | LineSegment lineSegment3 = new LineSegment(); |
||
263 | lineSegment3.Point = pData[3]; |
||
264 | pathFigure.Segments.Add(lineSegment3); |
||
265 | |||
266 | PathGeometry rectPathGeometry = new PathGeometry(); |
||
267 | rectPathGeometry.Figures = new PathFigureCollection(); |
||
268 | pathFigure.IsClosed = true; |
||
269 | pathFigure.IsFilled = false; |
||
270 | rectPathGeometry.Figures.Add(pathFigure); |
||
271 | |||
272 | return rectPathGeometry; |
||
273 | } |
||
274 | |||
275 | public static PathGeometry Generate(List<Point> pData) |
||
276 | { |
||
277 | var _pathGeometry = new PathGeometry(); |
||
278 | double area = MathSet.AreaOf(pData); |
||
279 | bool reverse = (area > 0); |
||
280 | int count = pData.Count; |
||
281 | |||
282 | for (int i = 0; i < (count - 1); i++) |
||
283 | { |
||
284 | PathFigure pathFigure = GenerateLineWithCloud(pData[i], pData[i + 1], 20, reverse); |
||
285 | pathFigure.IsClosed = false; |
||
286 | pathFigure.IsFilled = true; |
||
287 | _pathGeometry.Figures.Add(pathFigure); |
||
288 | } |
||
289 | |||
290 | return _pathGeometry; |
||
291 | } |
||
292 | |||
293 | public static PathFigure GenerateLineWithCloud(Point p1, Point p2, double _arcLength, bool reverse) |
||
294 | { |
||
295 | PathFigure pathFigure = new PathFigure(); |
||
296 | pathFigure.StartPoint = p1; |
||
297 | |||
298 | double arcLength = _arcLength; |
||
299 | double dx = p2.X - p1.X; |
||
300 | double dy = p2.Y - p1.Y; |
||
301 | double l = MathSet.DistanceTo(p1, p2); |
||
302 | double theta = Math.Atan2(Math.Abs(dy), Math.Abs(dx)) * 180 / Math.PI; |
||
303 | Point lastPt = new Point(p1.X, p1.Y); |
||
304 | double count = l / _arcLength; |
||
305 | |||
306 | dx /= l; |
||
307 | dy /= l; |
||
308 | |||
309 | Double j = 1; |
||
310 | for (j = 1; j < (count - 1); j++) |
||
311 | { |
||
312 | ArcSegment arcSeg = new ArcSegment(); |
||
313 | arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8); |
||
314 | |||
315 | arcSeg.Point = new Point(p1.X + j * dx * arcLength, p1.Y + j * dy * arcLength); |
||
316 | lastPt = arcSeg.Point; |
||
317 | arcSeg.RotationAngle = theta + 90; |
||
318 | if (true == reverse) |
||
319 | arcSeg.SweepDirection = SweepDirection.Clockwise; |
||
320 | pathFigure.Segments.Add(arcSeg); |
||
321 | } |
||
322 | |||
323 | if ((count > j) || count > 0) |
||
324 | { |
||
325 | arcLength = MathSet.DistanceTo(lastPt, p2); |
||
326 | ArcSegment arcSeg = new ArcSegment(); |
||
327 | arcSeg.Size = new Size(arcLength * 0.8, arcLength * 0.8); |
||
328 | arcSeg.Point = new Point(p2.X, p2.Y); |
||
329 | arcSeg.RotationAngle = theta; |
||
330 | |||
331 | if (true == reverse) |
||
332 | arcSeg.SweepDirection = SweepDirection.Clockwise; |
||
333 | |||
334 | pathFigure.Segments.Add(arcSeg); |
||
335 | |||
336 | } |
||
337 | return pathFigure; |
||
338 | } |
||
339 | #endregion |
||
340 | |||
341 | #region Dependency Properties |
||
342 | public static readonly DependencyProperty ControlTypeProperty = |
||
343 | DependencyProperty.Register("ControlType", typeof(ControlType), typeof(TextControl), new FrameworkPropertyMetadata(ControlType.TextControl)); |
||
344 | |||
345 | public static readonly DependencyProperty ControlType_NoProperty = |
||
346 | DependencyProperty.Register("ControlType_No", typeof(int), typeof(TextControl), new FrameworkPropertyMetadata(0)); |
||
347 | |||
348 | public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register( |
||
349 | "IsSelected", typeof(bool), typeof(TextControl), new FrameworkPropertyMetadata(false, IsSelectedChanged)); |
||
350 | |||
351 | public static readonly DependencyProperty PathGeometryProperty = DependencyProperty.Register( |
||
352 | "PathGeometry", typeof(PathGeometry), typeof(TextControl), new PropertyMetadata(null, SetPathGeometryChanged)); |
||
353 | |||
354 | public static readonly DependencyProperty TextProperty = DependencyProperty.Register( |
||
355 | "Text", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
||
356 | |||
357 | public static readonly DependencyProperty OverViewTextProperty = DependencyProperty.Register( |
||
358 | "OverViewText", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
||
359 | |||
360 | public static readonly DependencyProperty UserIDProperty = DependencyProperty.Register( |
||
361 | "UserID", typeof(string), typeof(TextControl), new PropertyMetadata(null)); |
||
362 | |||
363 | public static readonly DependencyProperty FontColorProperty = DependencyProperty.Register( |
||
364 | "FontColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.Red))); |
||
365 | |||
366 | public static readonly DependencyProperty IsHighlightProperty = DependencyProperty.Register( |
||
367 | "IsHighLight", typeof(bool), typeof(TextControl), new PropertyMetadata(false)); |
||
368 | |||
369 | public static readonly DependencyProperty BackColorProperty = DependencyProperty.Register( |
||
370 | "BackColor", typeof(SolidColorBrush), typeof(TextControl), new PropertyMetadata(new SolidColorBrush(Colors.White))); |
||
371 | |||
372 | public static readonly DependencyProperty UnderLineProperty = DependencyProperty.Register( |
||
373 | "UnderLine", typeof(TextDecorationCollection), typeof(TextControl), new PropertyMetadata(null)); |
||
374 | |||
375 | public static readonly DependencyProperty LineSizeProperty = DependencyProperty.Register( |
||
376 | "LineSize", typeof(Thickness), typeof(TextControl), new PropertyMetadata(new Thickness(4))); |
||
377 | |||
378 | public static readonly DependencyProperty PointSetProperty = DependencyProperty.Register( |
||
379 | "PointSet", typeof(List<Point>), typeof(TextControl), new PropertyMetadata(new List<Point>())); |
||
380 | |||
381 | public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register( |
||
382 | "PathData", typeof(Geometry), typeof(TextControl), null); |
||
383 | |||
384 | public static readonly DependencyProperty OverViewPathDataProperty = DependencyProperty.Register( |
||
385 | "OverViewPathDataProperty", typeof(Geometry), typeof(TextControl), null); |
||
386 | |||
387 | public static readonly DependencyProperty TextStyleProperty = DependencyProperty.Register( |
||
388 | "TextStyle", typeof(FontStyle), typeof(TextControl), new PropertyMetadata(FontStyles.Normal)); |
||
389 | |||
390 | public static readonly DependencyProperty TextFamilyProperty = DependencyProperty.Register( |
||
391 | "TextFamily",typeof(FontFamily), typeof(TextControl), new PropertyMetadata(new FontFamily("Arial"))); |
||
392 | |||
393 | public static readonly DependencyProperty TextWeightProperty = DependencyProperty.Register( |
||
394 | "TextWeight", typeof(FontWeight), typeof(TextControl), new PropertyMetadata(FontWeights.Normal)); |
||
395 | |||
396 | public static readonly DependencyProperty CenterXProperty = DependencyProperty.Register( |
||
397 | "CenterX", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
398 | |||
399 | public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register( |
||
400 | "CenterY", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnCenterXYChanged)); |
||
401 | |||
402 | public static readonly DependencyProperty CanvasXProperty = DependencyProperty.Register( |
||
403 | "CanvasX", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
||
404 | |||
405 | public static readonly DependencyProperty CanvasYProperty = DependencyProperty.Register( |
||
406 | "CanvasY", typeof(double), typeof(TextControl), new PropertyMetadata((double)0, OnSetCansvasChanged)); |
||
407 | |||
408 | public static readonly DependencyProperty StartPointProperty = DependencyProperty.Register( |
||
409 | "StartPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(0, 0), PointValueChanged)); |
||
410 | |||
411 | public static readonly DependencyProperty EndPointProperty = DependencyProperty.Register( |
||
412 | "EndPoint", typeof(Point), typeof(TextControl), new PropertyMetadata(new Point(100, 100), PointValueChanged)); |
||
413 | |||
414 | public static readonly DependencyProperty TextSizeProperty = DependencyProperty.Register( |
||
415 | "TextSize", typeof(Double), typeof(TextControl), new PropertyMetadata((Double)20, PointValueChanged)); |
||
416 | |||
417 | public static readonly DependencyProperty PaintProperty = DependencyProperty.Register( |
||
418 | "Paint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged)); |
||
419 | |||
420 | public static readonly DependencyProperty OverViewPaintProperty = DependencyProperty.Register( |
||
421 | "OverViewPaint", typeof(PaintSet), typeof(TextControl), new PropertyMetadata((PaintSet.None), PointValueChanged)); |
||
422 | |||
423 | public static readonly DependencyProperty AngleProperty = DependencyProperty.Register( |
||
424 | "Angle", typeof(double), typeof(TextControl), new PropertyMetadata((double)0.0, new PropertyChangedCallback(AngleValueChanged))); |
||
425 | |||
426 | public static readonly DependencyProperty IsEditingProperty = DependencyProperty.Register( |
||
427 | "IsEditing", typeof(bool), typeof(TextControl), new PropertyMetadata((false), new PropertyChangedCallback(OnIsEditingChanged))); |
||
428 | |||
429 | public static readonly DependencyProperty EnableEditingProperty = DependencyProperty.Register( |
||
430 | "EnableEditing", typeof(bool), typeof(TextControl), new PropertyMetadata((true))); |
||
431 | |||
432 | public static readonly DependencyProperty TextBoxVisibilityProperty = DependencyProperty.Register( |
||
433 | "TextBoxVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Visible), OnTextBoxVisibilityChanged)); |
||
434 | |||
435 | public static readonly DependencyProperty TextBlockVisibilityProperty = DependencyProperty.Register( |
||
436 | "TextBlockVisibility", typeof(Visibility), typeof(TextControl), new PropertyMetadata((Visibility.Collapsed), OnTextBlockVisibilityChanged)); |
||
437 | |||
438 | #endregion Dependency Properties |
||
439 | |||
440 | #region dp Properties |
||
441 | |||
442 | public bool IsEditing |
||
443 | { |
||
444 | get { return (bool)GetValue(IsEditingProperty); } |
||
445 | set |
||
446 | { |
||
447 | if (this.IsEditing != value) |
||
448 | { |
||
449 | SetValue(IsEditingProperty, value); |
||
450 | |||
451 | OnPropertyChanged("IsEditing"); |
||
452 | |||
453 | } |
||
454 | } |
||
455 | } |
||
456 | |||
457 | public bool EnableEditing |
||
458 | { |
||
459 | get { return (bool)GetValue(EnableEditingProperty); } |
||
460 | set |
||
461 | { |
||
462 | if (this.EnableEditing != value) |
||
463 | { |
||
464 | SetValue(EnableEditingProperty, value); |
||
465 | OnPropertyChanged("EnableEditing"); |
||
466 | } |
||
467 | } |
||
468 | } |
||
469 | |||
470 | public Thickness LineSize |
||
471 | { |
||
472 | get { return (Thickness)GetValue(LineSizeProperty); } |
||
473 | set |
||
474 | { |
||
475 | if (this.LineSize != value) |
||
476 | { |
||
477 | SetValue(LineSizeProperty, value); |
||
478 | OnPropertyChanged("LineSize"); |
||
479 | } |
||
480 | } |
||
481 | } |
||
482 | |||
483 | public ControlType ControlType |
||
484 | { |
||
485 | get |
||
486 | { |
||
487 | return (ControlType)GetValue(ControlTypeProperty); |
||
488 | } |
||
489 | set |
||
490 | { |
||
491 | SetValue(ControlTypeProperty, value); |
||
492 | } |
||
493 | } |
||
494 | public int ControlType_No |
||
495 | { |
||
496 | get |
||
497 | { |
||
498 | return (int)GetValue(ControlType_NoProperty); |
||
499 | } |
||
500 | set |
||
501 | { |
||
502 | SetValue(ControlType_NoProperty, value); |
||
503 | } |
||
504 | } |
||
505 | |||
506 | public string UserID |
||
507 | { |
||
508 | get { return (string)GetValue(UserIDProperty); } |
||
509 | set |
||
510 | { |
||
511 | if (this.UserID != value) |
||
512 | { |
||
513 | SetValue(UserIDProperty, value); |
||
514 | OnPropertyChanged("UserID"); |
||
515 | } |
||
516 | } |
||
517 | } |
||
518 | |||
519 | public double CenterX |
||
520 | { |
||
521 | get { return (double)GetValue(CenterXProperty); } |
||
522 | set { SetValue(CenterXProperty, value); |
||
523 | OnPropertyChanged("CenterX"); |
||
524 | |||
525 | } |
||
526 | } |
||
527 | |||
528 | public double CenterY |
||
529 | { |
||
530 | get { return (double)GetValue(CenterYProperty); } |
||
531 | set { SetValue(CenterYProperty, value); |
||
532 | OnPropertyChanged("CenterY"); |
||
533 | } |
||
534 | } |
||
535 | |||
536 | public string Text |
||
537 | { |
||
538 | get { return (string)GetValue(TextProperty); } |
||
539 | set |
||
540 | { |
||
541 | if (this.Text != value) |
||
542 | { |
||
543 | SetValue(TextProperty, value); |
||
544 | OnPropertyChanged("Text"); |
||
545 | } |
||
546 | } |
||
547 | } |
||
548 | |||
549 | public string OverViewText |
||
550 | { |
||
551 | get { return (string)GetValue(OverViewTextProperty); } |
||
552 | set |
||
553 | { |
||
554 | if (this.OverViewText != value) |
||
555 | { |
||
556 | SetValue(OverViewTextProperty, value); |
||
557 | OnPropertyChanged("OverViewText"); |
||
558 | } |
||
559 | } |
||
560 | } |
||
561 | |||
562 | public Geometry OverViewPathData |
||
563 | { |
||
564 | get { return (Geometry)GetValue(OverViewPathDataProperty); } |
||
565 | set |
||
566 | { |
||
567 | if (this.OverViewPathData != value) |
||
568 | { |
||
569 | SetValue(OverViewPathDataProperty, value); |
||
570 | OnPropertyChanged("OverViewPathData"); |
||
571 | } |
||
572 | } |
||
573 | } |
||
574 | |||
575 | public Visibility TextBoxVisibility |
||
576 | { |
||
577 | get { return (Visibility)GetValue(TextBoxVisibilityProperty); } |
||
578 | set |
||
579 | { |
||
580 | if (this.TextBoxVisibility != value) |
||
581 | { |
||
582 | SetValue(TextBoxVisibilityProperty, value); |
||
583 | OnPropertyChanged("TextBoxVisibility"); |
||
584 | } |
||
585 | } |
||
586 | } |
||
587 | |||
588 | |||
589 | public Visibility TextBlockVisibility |
||
590 | { |
||
591 | get { return (Visibility)GetValue(TextBlockVisibilityProperty); } |
||
592 | set |
||
593 | { |
||
594 | if (this.TextBlockVisibility != value) |
||
595 | { |
||
596 | SetValue(TextBlockVisibilityProperty, value); |
||
597 | OnPropertyChanged("TextBlockVisibility"); |
||
598 | } |
||
599 | } |
||
600 | } |
||
601 | |||
602 | |||
603 | |||
604 | public Double TextSize |
||
605 | { |
||
606 | get { return (Double)GetValue(TextSizeProperty); } |
||
607 | set |
||
608 | { |
||
609 | if (this.TextSize != value) |
||
610 | { |
||
611 | SetValue(TextSizeProperty, value); |
||
612 | OnPropertyChanged("TextSize"); |
||
613 | } |
||
614 | } |
||
615 | } |
||
616 | |||
617 | public SolidColorBrush FontColor |
||
618 | { |
||
619 | get { return (SolidColorBrush)GetValue(FontColorProperty); } |
||
620 | set |
||
621 | { |
||
622 | if (this.FontColor != value) |
||
623 | { |
||
624 | SetValue(FontColorProperty, value); |
||
625 | OnPropertyChanged("FontColor"); |
||
626 | } |
||
627 | } |
||
628 | } |
||
629 | |||
630 | public SolidColorBrush BackColor |
||
631 | { |
||
632 | get { return (SolidColorBrush)GetValue(BackColorProperty); } |
||
633 | set |
||
634 | { |
||
635 | if (this.BackColor != value) |
||
636 | { |
||
637 | SetValue(BackColorProperty, value); |
||
638 | OnPropertyChanged("BackColor"); |
||
639 | } |
||
640 | } |
||
641 | } |
||
642 | |||
643 | public TextDecorationCollection UnderLine |
||
644 | { |
||
645 | get |
||
646 | { |
||
647 | return (TextDecorationCollection)GetValue(UnderLineProperty); |
||
648 | } |
||
649 | set |
||
650 | { |
||
651 | if (this.UnderLine != value) |
||
652 | { |
||
653 | SetValue(UnderLineProperty, value); |
||
654 | OnPropertyChanged("UnderLine"); |
||
655 | } |
||
656 | } |
||
657 | } |
||
658 | |||
659 | public double CanvasX |
||
660 | { |
||
661 | get { return (double)GetValue(CanvasXProperty); } |
||
662 | set |
||
663 | { |
||
664 | if (this.CanvasX != value) |
||
665 | { |
||
666 | SetValue(CanvasXProperty, value); |
||
667 | OnPropertyChanged("CanvasX"); |
||
668 | } |
||
669 | } |
||
670 | } |
||
671 | |||
672 | public double CanvasY |
||
673 | { |
||
674 | get { return (double)GetValue(CanvasYProperty); } |
||
675 | set |
||
676 | { |
||
677 | if (this.CanvasY != value) |
||
678 | { |
||
679 | SetValue(CanvasYProperty, value); |
||
680 | OnPropertyChanged("CanvasY"); |
||
681 | } |
||
682 | } |
||
683 | } |
||
684 | |||
685 | public Point EndPoint |
||
686 | { |
||
687 | get { return (Point)GetValue(EndPointProperty); } |
||
688 | set |
||
689 | { |
||
690 | if (this.EndPoint != value) |
||
691 | { |
||
692 | SetValue(EndPointProperty, value); |
||
693 | OnPropertyChanged("EndPoint"); |
||
694 | } |
||
695 | } |
||
696 | } |
||
697 | |||
698 | public Point StartPoint |
||
699 | { |
||
700 | get { return (Point)GetValue(StartPointProperty); } |
||
701 | set |
||
702 | { |
||
703 | if (this.StartPoint != value) |
||
704 | { |
||
705 | SetValue(StartPointProperty, value); |
||
706 | OnPropertyChanged("StartPoint"); |
||
707 | } |
||
708 | } |
||
709 | } |
||
710 | |||
711 | public FontStyle TextStyle |
||
712 | { |
||
713 | get { return (FontStyle)GetValue(TextStyleProperty); } |
||
714 | set |
||
715 | { |
||
716 | if (this.TextStyle != value) |
||
717 | { |
||
718 | SetValue(TextStyleProperty, value); |
||
719 | OnPropertyChanged("TextStyle"); |
||
720 | } |
||
721 | } |
||
722 | } |
||
723 | |||
724 | public FontFamily TextFamily |
||
725 | { |
||
726 | get { return (FontFamily)GetValue(TextFamilyProperty); } |
||
727 | set |
||
728 | { |
||
729 | if (this.TextFamily != value) |
||
730 | { |
||
731 | SetValue(TextFamilyProperty, value); |
||
732 | OnPropertyChanged("TextFamily"); |
||
733 | } |
||
734 | } |
||
735 | } |
||
736 | |||
737 | public FontWeight TextWeight |
||
738 | { |
||
739 | get { return (FontWeight)GetValue(TextWeightProperty); } |
||
740 | set |
||
741 | { |
||
742 | if (this.TextWeight != value) |
||
743 | { |
||
744 | SetValue(TextWeightProperty, value); |
||
745 | OnPropertyChanged("TextWeight"); |
||
746 | } |
||
747 | } |
||
748 | } |
||
749 | |||
750 | public PaintSet Paint |
||
751 | { |
||
752 | get { return (PaintSet)GetValue(PaintProperty); } |
||
753 | set |
||
754 | { |
||
755 | if (this.Paint != value) |
||
756 | { |
||
757 | SetValue(PaintProperty, value); |
||
758 | OnPropertyChanged("Paint"); |
||
759 | } |
||
760 | } |
||
761 | } |
||
762 | |||
763 | public PaintSet OverViewPaint |
||
764 | { |
||
765 | get { return (PaintSet)GetValue(OverViewPaintProperty); } |
||
766 | set |
||
767 | { |
||
768 | if (this.OverViewPaint != value) |
||
769 | { |
||
770 | SetValue(OverViewPaintProperty, value); |
||
771 | OnPropertyChanged("OverViewPaint"); |
||
772 | } |
||
773 | } |
||
774 | } |
||
775 | |||
776 | |||
777 | public Geometry PathData |
||
778 | { |
||
779 | get { return (Geometry)GetValue(PathDataProperty); } |
||
780 | set { SetValue(PathDataProperty, value); |
||
781 | OnPropertyChanged("PathData"); |
||
782 | } |
||
783 | } |
||
784 | |||
785 | public double Angle |
||
786 | { |
||
787 | get { return (double)GetValue(AngleProperty); } |
||
788 | set |
||
789 | { |
||
790 | if (this.Angle != value) |
||
791 | { |
||
792 | SetValue(AngleProperty, value); |
||
793 | |||
794 | OnPropertyChanged("Angle"); |
||
795 | UpdateLayout(); |
||
796 | } |
||
797 | } |
||
798 | } |
||
799 | |||
800 | public bool IsHighLight |
||
801 | { |
||
802 | get { return (bool)GetValue(IsHighlightProperty); } |
||
803 | set |
||
804 | { |
||
805 | if (this.IsHighLight != value) |
||
806 | { |
||
807 | SetValue(IsHighlightProperty, value); |
||
808 | OnPropertyChanged("IsHighLight"); |
||
809 | } |
||
810 | } |
||
811 | } |
||
812 | |||
813 | public List<Point> PointSet |
||
814 | { |
||
815 | get { return (List<Point>)GetValue(PointSetProperty); } |
||
816 | set { SetValue(PointSetProperty, value); |
||
817 | OnPropertyChanged("PointSet"); |
||
818 | } |
||
819 | } |
||
820 | |||
821 | #endregion Properties |
||
822 | |||
823 | #region Properties |
||
824 | |||
825 | |||
826 | |||
827 | public PathGeometry PathGeometry |
||
828 | { |
||
829 | get { return (PathGeometry)GetValue(PathGeometryProperty); } |
||
830 | set |
||
831 | { |
||
832 | SetValue(PathGeometryProperty, value); |
||
833 | OnPropertyChanged("PathGeometry"); |
||
834 | } |
||
835 | } |
||
836 | |||
837 | private double _BoxWidth; |
||
838 | public double BoxWidth |
||
839 | { |
||
840 | get |
||
841 | { |
||
842 | return _BoxWidth; |
||
843 | } |
||
844 | set |
||
845 | { |
||
846 | _BoxWidth = value; |
||
847 | OnPropertyChanged("BoxWidth"); |
||
848 | } |
||
849 | } |
||
850 | |||
851 | private double _BoxHeight; |
||
852 | public double BoxHeight |
||
853 | { |
||
854 | get |
||
855 | { |
||
856 | return _BoxHeight; |
||
857 | } |
||
858 | set |
||
859 | { |
||
860 | _BoxHeight = value; |
||
861 | OnPropertyChanged("BoxHeight"); |
||
862 | } |
||
863 | } |
||
864 | |||
865 | #endregion |
||
866 | |||
867 | #region CallBack Method |
||
868 | public static void SetPathGeometryChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
869 | { |
||
870 | var instance = (TextControl)sender; |
||
871 | |||
872 | if (e.OldValue != e.NewValue && instance.Base_TextPath != null) |
||
873 | { |
||
874 | instance.SetValue(e.Property, e.NewValue); |
||
875 | } |
||
876 | } |
||
877 | |||
878 | |||
879 | public static void OnTextBoxVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
880 | { |
||
881 | var instance = (TextControl)sender; |
||
882 | |||
883 | if (e.OldValue != e.NewValue && instance.Base_TextPath != null) |
||
884 | { |
||
885 | instance.SetValue(e.Property, e.NewValue); |
||
886 | } |
||
887 | } |
||
888 | |||
889 | public static void OnTextBlockVisibilityChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
890 | { |
||
891 | var instance = (TextControl)sender; |
||
892 | |||
893 | if (e.OldValue != e.NewValue && instance.Base_TextPath != null) |
||
894 | { |
||
895 | instance.SetValue(e.Property, e.NewValue); |
||
896 | } |
||
897 | } |
||
898 | |||
899 | public static void IsSelectedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
900 | { |
||
901 | var instance = (TextControl)sender; |
||
902 | |||
903 | if (e.OldValue != e.NewValue && instance.Base_Border != null) |
||
904 | { |
||
905 | instance.SetValue(e.Property, e.NewValue); |
||
906 | |||
907 | if (instance.IsSelected) |
||
908 | { |
||
909 | instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Blue); |
||
910 | } |
||
911 | else |
||
912 | { |
||
913 | instance.Base_Border.BorderBrush = new SolidColorBrush(Colors.Transparent); |
||
914 | } |
||
915 | } |
||
916 | } |
||
917 | |||
918 | public static void OnSetCansvasChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
919 | { |
||
920 | var instance = (TextControl)sender; |
||
921 | |||
922 | if (e.OldValue != e.NewValue && instance != null) |
||
923 | { |
||
924 | instance.SetValue(e.Property, e.NewValue); |
||
925 | |||
926 | Canvas.SetLeft(instance, instance.CanvasX); |
||
927 | |||
928 | Canvas.SetTop(instance, instance.CanvasY); |
||
929 | } |
||
930 | } |
||
931 | |||
932 | public static void OnIsEditingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
933 | { |
||
934 | var instance = (TextControl)sender; |
||
935 | |||
936 | if (e.OldValue != e.NewValue && instance.Base_TextBlock != null) |
||
937 | { |
||
938 | instance.SetValue(e.Property, e.NewValue); |
||
939 | |||
940 | if (instance.EnableEditing) |
||
941 | { |
||
942 | if (instance.IsEditing) |
||
943 | { |
||
944 | instance.EditingMode(); |
||
945 | } |
||
946 | else |
||
947 | { |
||
948 | instance.UnEditingMode(); |
||
949 | } |
||
950 | } |
||
951 | else |
||
952 | { |
||
953 | instance.UnEditingMode(); |
||
954 | } |
||
955 | } |
||
956 | } |
||
957 | |||
958 | public static void OnCenterXYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
959 | { |
||
960 | var instance = (TextControl)sender; |
||
961 | |||
962 | if (e.OldValue != e.NewValue && instance.Base_TextBlock != null) |
||
963 | { |
||
964 | instance.SetValue(e.Property, e.NewValue); |
||
965 | instance.SetText(); |
||
966 | } |
||
967 | } |
||
968 | |||
969 | public static void AngleValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
970 | { |
||
971 | var instance = (TextControl)sender; |
||
972 | if (e.OldValue != e.NewValue && instance.Base_TextBlock != null) |
||
973 | { |
||
974 | instance.SetValue(e.Property, e.NewValue); |
||
975 | instance.SetText(); |
||
976 | } |
||
977 | } |
||
978 | |||
979 | public static void PointValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) |
||
980 | { |
||
981 | var instance = (TextControl)sender; |
||
982 | if (e.OldValue != e.NewValue && instance!= null) |
||
983 | { |
||
984 | instance.SetValue(e.Property, e.NewValue); |
||
985 | instance.SetText(); |
||
986 | } |
||
987 | } |
||
988 | |||
989 | #endregion CallBack Method |
||
990 | |||
991 | protected void OnPropertyChanged(string propName) |
||
992 | { |
||
993 | if (PropertyChanged != null) |
||
994 | PropertyChanged(this, new PropertyChangedEventArgs(propName)); |
||
995 | } |
||
996 | } |
||
997 | } |