Mercurial > silverbladetech
diff Chronosv2/source/Presentation/Controls/Adorner/TextBlockAdorner.cs @ 10:443821e55f06
Initial cleaned up add from Codeplex files
author | stevenh7776 stevenhollidge@hotmail.com |
---|---|
date | Tue, 21 Feb 2012 17:25:44 +0700 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Chronosv2/source/Presentation/Controls/Adorner/TextBlockAdorner.cs Tue Feb 21 17:25:44 2012 +0700 @@ -0,0 +1,58 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; + +namespace Chronos.Presentation.Controls.Adorner +{ + public sealed class TextBlockAdorner + : System.Windows.Documents.Adorner + { + #region · Fields · + + private readonly TextBlock adornerTextBlock; + + #endregion + + #region · Properties · + + protected override int VisualChildrenCount + { + get { return 1; } + } + + #endregion + + #region · Constructors · + + public TextBlockAdorner(UIElement adornedElement, string label, Style labelStyle) + : base(adornedElement) + { + this.adornerTextBlock = new TextBlock { Style = labelStyle, Text = label }; + } + + #endregion + + #region · Overriden Methods · + + protected override Size MeasureOverride(Size constraint) + { + this.adornerTextBlock.Measure(constraint); + + return constraint; + } + + protected override Size ArrangeOverride(Size finalSize) + { + this.adornerTextBlock.Arrange(new Rect(finalSize)); + + return finalSize; + } + + protected override Visual GetVisualChild(int index) + { + return this.adornerTextBlock; + } + + #endregion + } +}