Exemplo n.º 1
0
        /// <summary>
        /// When overridden in a derived class, measures the size in layout required for child elements and determines a size for the <see cref="T:System.Windows.FrameworkElement" />-derived class.
        /// </summary>
        /// <param name="availableSize">The available size that this element can give to child elements. Infinity can be specified as a value to indicate that the element will size to whatever content is available.</param>
        /// <returns>The size that this element determines it needs during layout, based on its calculations of child element sizes.</returns>
        protected override Size MeasureOverride(Size availableSize)
        {
            if (HeaderRenderer == null)
            {
                HeaderRenderer = new TabItemsHeaderRenderer();
            }

            var widest            = 0d;
            var tallest           = 0d;
            var availableItemSize = HeaderRenderer.GetClientRect(this, availableSize).Size;

            foreach (var element in Children.OfType <UIElement>().Where(e => e.Visibility == Visibility.Visible))
            {
                element.Measure(availableItemSize);
                widest  = Math.Max(widest, element.DesiredSize.Width);
                tallest = Math.Max(tallest, element.DesiredSize.Height);
            }

            base.MeasureOverride(availableSize);

            if (!double.IsInfinity(availableSize.Width) && !double.IsInfinity(availableSize.Height))
            {
                return(availableSize);
            }
            return(new Size(widest, tallest));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Draws the content of a <see cref="T:System.Windows.Media.DrawingContext" /> object during the render pass of a <see cref="T:System.Windows.Controls.Panel" /> element.
        /// </summary>
        /// <param name="dc">The <see cref="T:System.Windows.Media.DrawingContext" /> object to draw.</param>
        protected override void OnRender(DrawingContext dc)
        {
            base.OnRender(dc);

            if (HeaderRenderer == null)
            {
                HeaderRenderer = new TabItemsHeaderRenderer();
            }
            HeaderRenderer.Render(dc, this);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Invoked when an unhandled <see cref="E:System.Windows.UIElement.MouseLeftButtonDown" /> routed event is raised on this element. Implement this method to add class handling for this event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs" /> that contains the event data. The event data reports that the left mouse button was pressed.</param>
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            if (HeaderRenderer == null)
            {
                HeaderRenderer = new TabItemsHeaderRenderer();
            }
            var position = e.GetPosition(this);

            HeaderRenderer.MouseClick(position, e, this);
            base.OnMouseLeftButtonDown(e);
        }
Exemplo n.º 4
0
        /// <summary>
        /// When overridden in a derived class, positions child elements and determines a size for a <see cref="T:System.Windows.FrameworkElement" /> derived class.
        /// </summary>
        /// <param name="finalSize">The final area within the parent that this element should use to arrange itself and its children.</param>
        /// <returns>The actual size used.</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            if (HeaderRenderer == null)
            {
                HeaderRenderer = new TabItemsHeaderRenderer();
            }
            var clientRect = HeaderRenderer.GetClientRect(this, finalSize);

            foreach (var element in Children.OfType <UIElement>().Where(e => e.Visibility == Visibility.Visible))
            {
                element.Arrange(clientRect);
            }
            base.ArrangeOverride(finalSize);
            return(clientRect.Size);
        }