view Chronosv2/source/Presentation/Controls/Adorner/TextBlockAdorner.cs @ 19:09d18d6e5f40

airport work
author stevenh7776 stevenhollidge@hotmail.com
date Thu, 15 Mar 2012 06:59:15 +0000
parents 443821e55f06
children
line wrap: on
line source

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
    }
}