Exemplo n.º 1
0
        internal void ResizeChildren(int index1, int index2, double pixelAmount)
        {
            SplitterMeasureData child1 = new SplitterMeasureData(this.InternalChildren[index1]);
            SplitterMeasureData child2 = new SplitterMeasureData(this.InternalChildren[index2]);

            if (!this.ResizeChildrenCore(child1, child2, pixelAmount))
            {
                return;
            }
            SplitterPanel.SetSplitterLength(child1.Element, child1.AttachedLength);
            SplitterPanel.SetSplitterLength(child2.Element, child2.AttachedLength);
            this.InvalidateMeasure();
        }
Exemplo n.º 2
0
        private void UpdateIndices()
        {
            int count = this.InternalChildren.Count;
            int num   = this.InternalChildren.Count - 1;

            for (int index = 0; index < count; ++index)
            {
                UIElement internalChild = this.InternalChildren[index];
                if (internalChild != null)
                {
                    SplitterPanel.SetIndex(internalChild, index);
                    SplitterPanel.SetIsFirst(internalChild, index == 0);
                    SplitterPanel.SetIsLast(internalChild, index == num);
                }
            }
        }
Exemplo n.º 3
0
        private bool ResizeChildrenCore(SplitterMeasureData child1, SplitterMeasureData child2, double pixelAmount)
        {
            UIElement      element1              = child1.Element;
            UIElement      element2              = child2.Element;
            SplitterLength attachedLength1       = child1.AttachedLength;
            SplitterLength attachedLength2       = child2.AttachedLength;
            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(false);
            }
            if (num1 < minimumLength1)
            {
                num2 -= minimumLength1 - num1;
                num1  = minimumLength1;
            }
            if (num2 < minimumLength2)
            {
                num1 -= minimumLength2 - num2;
                num2  = minimumLength2;
            }
            if (attachedLength1.IsFill && attachedLength2.IsFill || attachedLength1.IsStretch && attachedLength2.IsStretch)
            {
                SplitterMeasureData splitterMeasureData = child1;
                double         num3           = num1;
                SplitterLength splitterLength = new SplitterLength(num3 / (num3 + num2) * (attachedLength1.Value + attachedLength2.Value), attachedLength1.SplitterUnitType);
                splitterMeasureData.AttachedLength = splitterLength;
                child2.AttachedLength = new SplitterLength(num2 / (num1 + num2) * (attachedLength1.Value + attachedLength2.Value), attachedLength1.SplitterUnitType);
            }
            else if (attachedLength1.IsFill)
            {
                child2.AttachedLength = new SplitterLength(num2, SplitterUnitType.Stretch);
            }
            else
            {
                child1.AttachedLength = new SplitterLength(num1, SplitterUnitType.Stretch);
            }
            return(true);
        }
Exemplo n.º 4
0
 public SplitterMeasureData(UIElement element)
 {
     this.Element        = element;
     this.AttachedLength = SplitterPanel.GetSplitterLength(element);
 }
Exemplo n.º 5
0
        public static Size Measure(Size availableSize, Orientation orientation, IEnumerable <SplitterMeasureData> measureData, bool remeasureElements)
        {
            double num1 = 0.0;
            double num2 = 0.0;
            double num3 = 0.0;
            double num4 = 0.0;

            if (orientation == Orientation.Horizontal && availableSize.Width.IsNonreal() || orientation == Orientation.Vertical && availableSize.Height.IsNonreal())
            {
                return(SplitterPanel.MeasureNonreal(availableSize, orientation, measureData, remeasureElements));
            }
            foreach (SplitterMeasureData splitterMeasureData in measureData)
            {
                SplitterLength attachedLength = splitterMeasureData.AttachedLength;
                double         minimumLength  = SplitterPanel.GetMinimumLength(splitterMeasureData.Element);
                if (attachedLength.IsStretch)
                {
                    num1 += attachedLength.Value;
                    num4 += minimumLength;
                }
                else
                {
                    num2 += attachedLength.Value;
                    num3 += minimumLength;
                }
                splitterMeasureData.IsMinimumReached = false;
                splitterMeasureData.IsMaximumReached = false;
            }
            double num5   = num4 + num3;
            double width  = availableSize.Width;
            double height = availableSize.Height;
            double num6   = orientation == Orientation.Horizontal ? width : height;
            double num7   = num2 == 0.0 ? 0.0 : Math.Max(0.0, num6 - num1);
            double num8   = num7 == 0.0 ? num6 : num1;
            double num9   = num6;

            if (num5 <= num9)
            {
                foreach (SplitterMeasureData splitterMeasureData in measureData)
                {
                    SplitterLength attachedLength = splitterMeasureData.AttachedLength;
                    double         maximumLength  = SplitterPanel.GetMaximumLength(splitterMeasureData.Element);
                    if (attachedLength.IsStretch && (num1 == 0.0 ? 0.0 : attachedLength.Value / num1 * num8) > maximumLength)
                    {
                        splitterMeasureData.IsMaximumReached = true;
                        if (num1 == attachedLength.Value)
                        {
                            num1 = maximumLength;
                            splitterMeasureData.AttachedLength = new SplitterLength(maximumLength);
                        }
                        else
                        {
                            num1 -= attachedLength.Value;
                            splitterMeasureData.AttachedLength = new SplitterLength(num1);
                            double num10 = num1;
                            num1 = num10 + num10;
                        }
                        num7 = num2 == 0.0 ? 0.0 : Math.Max(0.0, num6 - num1);
                        num8 = num7 == 0.0 ? num6 : num1;
                    }
                }
                if (num7 < num3)
                {
                    num7 = num3;
                    num8 = num6 - num7;
                }
                foreach (SplitterMeasureData splitterMeasureData in measureData)
                {
                    SplitterLength attachedLength = splitterMeasureData.AttachedLength;
                    double         minimumLength  = SplitterPanel.GetMinimumLength(splitterMeasureData.Element);
                    if (attachedLength.IsFill)
                    {
                        if ((num2 == 0.0 ? 0.0 : attachedLength.Value / num2 * num7) < minimumLength)
                        {
                            splitterMeasureData.IsMinimumReached = true;
                            num7 -= minimumLength;
                            num2 -= attachedLength.Value;
                        }
                    }
                    else if ((num1 == 0.0 ? 0.0 : attachedLength.Value / num1 * num8) < minimumLength)
                    {
                        splitterMeasureData.IsMinimumReached = true;
                        num8 -= minimumLength;
                        num1 -= attachedLength.Value;
                    }
                }
            }
            Size availableSize1 = new Size(width, height);
            Rect rect           = new Rect(0.0, 0.0, width, height);

            foreach (SplitterMeasureData splitterMeasureData in measureData)
            {
                SplitterLength attachedLength = splitterMeasureData.AttachedLength;
                double         num10          = splitterMeasureData.IsMinimumReached ? SplitterPanel.GetMinimumLength(splitterMeasureData.Element) : (!attachedLength.IsFill ? (num1 == 0.0 ? 0.0 : attachedLength.Value / num1 * num8) : (num2 == 0.0 ? 0.0 : attachedLength.Value / num2 * num7));
                if (remeasureElements)
                {
                    SplitterPanel.SetActualSplitterLength(splitterMeasureData.Element, num10);
                }
                if (orientation == Orientation.Horizontal)
                {
                    availableSize1.Width = num10;
                    splitterMeasureData.MeasuredBounds = new Rect(rect.Left, rect.Top, num10, rect.Height);
                    rect.X += num10;
                    if (remeasureElements)
                    {
                        splitterMeasureData.Element.Measure(availableSize1);
                    }
                }
                else
                {
                    availableSize1.Height = num10;
                    splitterMeasureData.MeasuredBounds = new Rect(rect.Left, rect.Top, rect.Width, num10);
                    rect.Y += num10;
                    if (remeasureElements)
                    {
                        splitterMeasureData.Element.Measure(availableSize1);
                    }
                }
            }
            return(new Size(width, height));
        }
Exemplo n.º 6
0
 protected override Size MeasureOverride(Size availableSize)
 {
     this.UpdateIndices();
     return(SplitterPanel.Measure(availableSize, this.Orientation, (IEnumerable <SplitterMeasureData>)SplitterMeasureData.FromElements((IList)this.InternalChildren), true));
 }