Ejemplo n.º 1
0
        protected override Size MeasureOverride(Size availableSize)
        {
            this.currentTabWidth = CalculateTabWidth(availableSize);
            ParentTabControl.SetCanAddTab(this.currentTabWidth > this.MinTabWidth);

            if (_hideAddButton)
            {
                this.addButton.Visibility = System.Windows.Visibility.Hidden;
            }
            else if (ParentTabControl.IsAddButtonVisible)
            {
                this.addButton.Visibility = this.currentTabWidth > this.MinTabWidth ? Visibility.Visible : Visibility.Collapsed;
            }
            else
            {
                this.addButton.Visibility = System.Windows.Visibility.Collapsed;
            }

            double height     = double.IsPositiveInfinity(availableSize.Height) ? this.defaultMeasureHeight : availableSize.Height;
            Size   resultSize = new Size(0, availableSize.Height);

            foreach (UIElement child in this.Children)
            {
                ChromeTabItem item    = ItemsControl.ContainerFromElement(this.ParentTabControl, child) as ChromeTabItem;
                Size          tabSize = new Size(GetWidthForTabItem(item), height - item.Margin.Bottom);
                child.Measure(tabSize);
                resultSize.Width += child.DesiredSize.Width - overlap;
            }
            if (ParentTabControl.IsAddButtonVisible)
            {
                this.addButton.Measure(this.addButtonSize);
                resultSize.Width += this.addButtonSize.Width;
            }
            return(resultSize);
        }
Ejemplo n.º 2
0
        protected override Size MeasureOverride(Size availableSize)
        {
            double activeWidth = double.IsPositiveInfinity(availableSize.Width) ? 500 : availableSize.Width - this.leftMargin - this.rightMargin;

            this.currentTabWidth = Math.Min(Math.Max((activeWidth + (this.Children.Count - 1) * overlap) / this.Children.Count, this.minTabWidth), this.maxTabWidth);
            ParentTabControl.SetCanAddTab(this.currentTabWidth > this.minTabWidth);
            this.addButton.Visibility = this.currentTabWidth > this.minTabWidth ? Visibility.Visible : Visibility.Collapsed;
            double height     = double.IsPositiveInfinity(availableSize.Height) ? this.defaultMeasureHeight : availableSize.Height;
            Size   resultSize = new Size(0, availableSize.Height);

            foreach (UIElement child in this.Children)
            {
                ChromeTabItem item    = ItemsControl.ContainerFromElement(this.ParentTabControl, child) as ChromeTabItem;
                Size          tabSize = new Size(this.currentTabWidth, height - item.Margin.Bottom);
                child.Measure(tabSize);
                resultSize.Width += child.DesiredSize.Width - overlap;
            }
            this.addButton.Measure(this.addButtonSize);
            resultSize.Width += this.addButtonSize.Width;
            return(resultSize);
        }
        protected override Size ArrangeOverride(Size finalSize)
        {
            this.rightMargin = ParentTabControl.IsAddButtonVisible ? 25 : 0;
            double activeWidth = finalSize.Width - this.leftMargin - this.rightMargin;

            this.currentTabWidth = Math.Min(Math.Max((activeWidth + (this.Children.Count - 1) * overlap) / this.Children.Count, this.minTabWidth), this.maxTabWidth);
            ParentTabControl.SetCanAddTab(this.currentTabWidth > this.minTabWidth);

            if (_hideAddButton)
            {
                this.addButton.Visibility = System.Windows.Visibility.Hidden;
            }
            else if (ParentTabControl.IsAddButtonVisible)
            {
                this.addButton.Visibility = this.currentTabWidth > this.minTabWidth ? Visibility.Visible : Visibility.Collapsed;
            }
            else
            {
                this.addButton.Visibility = System.Windows.Visibility.Collapsed;
            }

            this.finalSize = finalSize;
            double offset = leftMargin;

            foreach (UIElement element in this.Children)
            {
                double        thickness = 0.0;
                ChromeTabItem item      = ItemsControl.ContainerFromElement(this.ParentTabControl, element) as ChromeTabItem;
                thickness = item.Margin.Bottom;
                element.Arrange(new Rect(offset, 0, this.currentTabWidth, finalSize.Height - thickness));
                offset += this.currentTabWidth - overlap;
            }
            if (ParentTabControl.IsAddButtonVisible)
            {
                this.addButtonRect = new Rect(new Point(offset + overlap, (finalSize.Height - this.addButtonSize.Height) / 2), this.addButtonSize);
                this.addButton.Arrange(this.addButtonRect);
            }
            return(finalSize);
        }