Example #1
0
        public Rect MeasureTabStrip()
        {
            if (this.TabStrip == null)
            {
                throw new InvalidOperationException("TabStrip must be initialized.");
            }
            this.draggedTabPosition = -1;
            Point topLeft     = new Point(double.MaxValue, double.MaxValue);
            Point bottomRight = new Point(double.MinValue, double.MinValue);

            this.tabRects.Clear();
            foreach (UIElement uiElement in this.TabStrip.Children)
            {
                TabItem tabChild = uiElement as TabItem;
                if (tabChild != null)
                {
                    this.MeasureTabItem(tabChild, ref topLeft, ref bottomRight);
                    ViewElement viewElement = tabChild.DataContext as ViewElement;
                    if (viewElement != null && viewElement == this.DraggedViewElement)
                    {
                        this.draggedTabPosition = this.tabRects.Count - 1;
                    }
                }
            }
            if (topLeft.X == double.MaxValue || topLeft.Y == double.MaxValue || (bottomRight.X == double.MinValue || bottomRight.Y == double.MinValue))
            {
                topLeft.X     = 0.0;
                topLeft.Y     = 0.0;
                bottomRight.X = 0.0;
                bottomRight.Y = 0.0;
                this.tabRects.Clear();
            }
            this.tabStripRect = new Rect(topLeft, bottomRight);
            DockTarget ancestor = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <DockTarget>((Visual)this.TabStrip);

            if (ancestor != null && ancestor.DockTargetType == DockTargetType.Auto && ExtensionMethods.IsConnectedToPresentationSource((DependencyObject)ancestor))
            {
                this.tabStripRect = new Rect(ancestor.PointToScreen(new Point(0.0, 0.0)), DpiHelper.LogicalToDeviceUnits(new Size(ancestor.ActualWidth, ancestor.ActualHeight)));
            }
            this.NormalizeTabHeight();
            return(this.tabStripRect);
        }