示例#1
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            Rect finalRect = new Rect(0.0, 0.0, finalSize.Width, finalSize.Height);

            foreach (UIElement element in this.InternalChildren)
            {
                double actualSplitterLength = SplitterPanel.GetActualSplitterLength(element);
                if (this.Orientation == Orientation.Horizontal)
                {
                    finalRect.Width = actualSplitterLength;
                    element.Arrange(finalRect);
                    finalRect.X += actualSplitterLength;
                }
                else
                {
                    finalRect.Height = actualSplitterLength;
                    element.Arrange(finalRect);
                    finalRect.Y += actualSplitterLength;
                }
            }
            return(finalSize);
        }
示例#2
0
        internal void ResizeChildren(int index1, int index2, double pixelAmount)
        {
            if (!this.IsArrangeValid)
            {
                return;
            }
            UIElement      element1;
            SplitterLength splitterLength1;

            do
            {
                element1        = this.InternalChildren[index1];
                splitterLength1 = SplitterPanel.GetSplitterLength(element1);
                if (splitterLength1.IsFixed)
                {
                    --index1;
                }
            }while (splitterLength1.IsFixed && index1 >= 0);
            UIElement      element2;
            SplitterLength splitterLength2;

            do
            {
                element2        = this.InternalChildren[index2];
                splitterLength2 = SplitterPanel.GetSplitterLength(element2);
                if (splitterLength2.IsFixed)
                {
                    ++index2;
                }
            }while (splitterLength2.IsFixed && index2 < this.InternalChildren.Count);
            if (index1 < 0 || index2 >= this.InternalChildren.Count)
            {
                return;
            }
            double actualSplitterLength1 = SplitterPanel.GetActualSplitterLength(element1);
            double actualSplitterLength2 = SplitterPanel.GetActualSplitterLength(element2);
            double num1           = Math.Max(0.0, Math.Min(actualSplitterLength1 + actualSplitterLength2, actualSplitterLength1 + pixelAmount));
            double num2           = Math.Max(0.0, Math.Min(actualSplitterLength1 + actualSplitterLength2, actualSplitterLength2 - pixelAmount));
            double minimumLength1 = SplitterPanel.GetMinimumLength(element1);
            double minimumLength2 = SplitterPanel.GetMinimumLength(element2);

            if (minimumLength1 + minimumLength2 > num1 + num2)
            {
                return;
            }
            if (num1 < minimumLength1)
            {
                num2 -= minimumLength1 - num1;
                num1  = minimumLength1;
            }
            if (num2 < minimumLength2)
            {
                num1 -= minimumLength2 - num2;
                num2  = minimumLength2;
            }
            if (splitterLength1.IsFill && splitterLength2.IsFill || splitterLength1.IsStretch && splitterLength2.IsStretch)
            {
                SplitterPanel.SetSplitterLength(element1, new SplitterLength(num1 / (num1 + num2) * (splitterLength1.Value + splitterLength2.Value), splitterLength1.SplitterUnitType));
                SplitterPanel.SetSplitterLength(element2, new SplitterLength(num2 / (num1 + num2) * (splitterLength1.Value + splitterLength2.Value), splitterLength1.SplitterUnitType));
            }
            else if (splitterLength1.IsFill)
            {
                SplitterPanel.SetSplitterLength(element2, new SplitterLength(num2, SplitterUnitType.Stretch));
            }
            else
            {
                SplitterPanel.SetSplitterLength(element1, new SplitterLength(num1, SplitterUnitType.Stretch));
            }
            this.InvalidateMeasure();
        }