Example #1
0
        /// <summary>
        ///     Helper method which implements the stack like arrange.
        /// </summary>
        internal static Size StackArrangeHelper(IStackMeasure arrangeElement, IStackMeasureScrollData scrollData, Size arrangeSize)
        {
            UIElementCollection children = arrangeElement.InternalChildren;
            bool   fHorizontal           = (arrangeElement.Orientation == Orientation.Horizontal);
            Rect   rcChild           = new Rect(arrangeSize);
            double previousChildSize = 0.0;


            //
            // Compute scroll offset and seed it into rcChild.
            //
            if (arrangeElement.IsScrolling)
            {
                if (fHorizontal)
                {
                    rcChild.X = ComputePhysicalFromLogicalOffset(arrangeElement, scrollData.ComputedOffset.X, true);
                    rcChild.Y = -1.0 * scrollData.ComputedOffset.Y;
                }
                else
                {
                    rcChild.X = -1.0 * scrollData.ComputedOffset.X;
                    rcChild.Y = ComputePhysicalFromLogicalOffset(arrangeElement, scrollData.ComputedOffset.Y, false);
                }
            }

            //
            // Arrange and Position Children.
            //
            for (int i = 0, count = children.Count; i < count; ++i)
            {
                UIElement child = (UIElement)children[i];

                if (child == null)
                {
                    continue;
                }

                if (fHorizontal)
                {
                    rcChild.X        += previousChildSize;
                    previousChildSize = child.DesiredSize.Width;
                    rcChild.Width     = previousChildSize;
                    rcChild.Height    = Math.Max(arrangeSize.Height, child.DesiredSize.Height);
                }
                else
                {
                    rcChild.Y        += previousChildSize;
                    previousChildSize = child.DesiredSize.Height;
                    rcChild.Height    = previousChildSize;
                    rcChild.Width     = Math.Max(arrangeSize.Width, child.DesiredSize.Width);
                }

                child.Arrange(rcChild);
            }
            return(arrangeSize);
        }
Example #2
0
        /// <summary>
        /// Decorator computes the position of its single child inside child's Margin and calls Arrange
        /// on the child.
        /// </summary>
        /// <param name="arrangeSize">Size the Decorator will assume.</param>
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            UIElement child = Child;

            if (child != null)
            {
                child.Arrange(new Rect(arrangeSize));
            }
            return(arrangeSize);
        }
Example #3
0
        /// <summary>Positions the first visual child object and returns the size in layout required by this <see cref="T:System.Windows.Controls.AdornedElementPlaceholder" /> object.</summary>
        /// <param name="arrangeBounds">The size that this <see cref="T:System.Windows.Controls.AdornedElementPlaceholder" /> object should use to arrange its child element.</param>
        /// <returns>The actual size needed by the element.</returns>
        // Token: 0x06004229 RID: 16937 RVA: 0x0012EA40 File Offset: 0x0012CC40
        protected override Size ArrangeOverride(Size arrangeBounds)
        {
            UIElement child = this.Child;

            if (child != null)
            {
                child.Arrange(new Rect(arrangeBounds));
            }
            return(arrangeBounds);
        }
        /// <summary>
        /// Arrange a sequence of elements in a single line.
        /// </summary>
        /// <param name="lineStart">
        /// Index of the first element in the sequence to arrange.
        /// </param>
        /// <param name="lineEnd">
        /// Index of the last element in the sequence to arrange.
        /// </param>
        /// <param name="directDelta">
        /// Optional fixed growth in the primary direction.
        /// </param>
        /// <param name="indirectOffset">
        /// Offset of the line in the indirect direction.
        /// </param>
        /// <param name="indirectGrowth">
        /// Shared indirect growth of the elements on this line.
        /// </param>
        /// <param name="maxDirect">
        /// MaxSize of WrapPanel to be used in right to left orentation scenarios
        /// </param>
        private void ArrangeLine(int lineStart, int lineEnd, double?directDelta, double indirectOffset, double indirectGrowth
                                 // Added by lepipele
                                 , double maxDirect)
        {
            Orientation o            = Orientation;
            bool        isHorizontal = o == Orientation.Horizontal;

            FlowDirection f             = FlowDirection;
            bool          isLeftToRight = f == FlowDirection.LeftToRight;

            double directOffset = 0.0;

            if (!isLeftToRight)
            {
                directOffset = maxDirect;
            }

            UIElementCollection children = Children;

            for (int index = lineStart; index < lineEnd; index++)
            {
                // Get the size of the element
                UIElement    element     = children[index];
                OrientedSize elementSize = new OrientedSize(o, element.DesiredSize.Width, element.DesiredSize.Height);

                // Determine if we should use the element's desired size or the
                // fixed item width or height
                double directGrowth = directDelta != null ?
                                      directDelta.Value :
                                      elementSize.Direct;

                // Arrange the element
                Rect bounds = Rect.Empty;

                if (isLeftToRight)
                {
                    bounds = isHorizontal ?
                             new Rect(directOffset, indirectOffset, directGrowth, indirectGrowth) :
                             new Rect(indirectOffset, directOffset, indirectGrowth, directGrowth);

                    directOffset += directGrowth;
                }
                else
                {
                    bounds = isHorizontal ?
                             new Rect(directOffset - directGrowth, indirectOffset, directGrowth, indirectGrowth) :
                             new Rect(indirectOffset, directOffset - directGrowth, indirectGrowth, directGrowth);

                    directOffset -= directGrowth;
                }

                element.Arrange(bounds);
            }
        }
Example #5
0
            protected override void PerformTweening(double frame)
            {
                double left   = _initialRect.Left + (_finalRect.Left - _initialRect.Left) * frame;
                double top    = _initialRect.Top + (_finalRect.Top - _initialRect.Top) * frame;
                double width  = _initialRect.Width + (_finalRect.Width - _initialRect.Width) * frame;
                double height = _initialRect.Height + (_finalRect.Height - _initialRect.Height) * frame;

                Rect bounds = new Rect(left, top, width, height);

                _element.SetValue(BoundsProperty, bounds);
                _element.Arrange(bounds);
            }
Example #6
0
        /// <summary>
        /// Arranges the children of the panel.
        /// </summary>
        /// <param name="finalSize">The final size.</param>
        /// <returns>The size required by the children.</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            for (int cnt = this.Children.Count - 1; cnt >= 0; cnt--)
            {
                UIElement element = this.Children[cnt];
                Canvas.SetZIndex(element, this.Children.Count - cnt);
                Rect arrangeRect = new Rect(cnt * HorizontalMargin, cnt * VerticalMargin, element.DesiredSize.Width, element.DesiredSize.Height);
                element.Arrange(arrangeRect);
            }

            return(finalSize);
        }
Example #7
0
        /// <summary>
        /// </summary>
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            bool etwTracingEnabled = IsScrollClient && EventTrace.IsEnabled(EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Info);

            if (etwTracingEnabled)
            {
                EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientStringBegin, EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Info, "SCROLLCONTENTPRESENTER:ArrangeOverride");
            }
            try
            {
                int count = this.VisualChildrenCount;


                // Verifies IScrollInfo properties & invalidates ScrollViewer if necessary.
                if (IsScrollClient)
                {
                    VerifyScrollData(arrangeSize, _scrollData._extent);
                }

                if (count > 0)
                {
                    _adornerLayer.Arrange(new Rect(arrangeSize));

                    UIElement child = this.GetVisualChild(0) as UIElement;
                    if (child != null)
                    {
                        Rect childRect = new Rect(child.DesiredSize);

                        if (IsScrollClient)
                        {
                            childRect.X = -HorizontalOffset;
                            childRect.Y = -VerticalOffset;
                        }

                        //this is needed to stretch the child to arrange space,
                        childRect.Width  = Math.Max(childRect.Width, arrangeSize.Width);
                        childRect.Height = Math.Max(childRect.Height, arrangeSize.Height);

                        child.Arrange(childRect);
                    }
                }
            }
            finally
            {
                if (etwTracingEnabled)
                {
                    EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientStringEnd, EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Info, "SCROLLCONTENTPRESENTER:ArrangeOverride");
                }
            }
            return(arrangeSize);
        }
Example #8
0
        /// <summary>
        ///     Default control arrangement is to only arrange
        ///     the first visual child. No transforms will be applied.
        /// </summary>
        /// <param name="arrangeBounds">The computed size.</param>
        protected override Size ArrangeOverride(Size arrangeBounds)
        {
            int count = this.VisualChildrenCount;

            if (count > 0)
            {
                UIElement child = (UIElement)(this.GetVisualChild(0));
                if (child != null)
                {
                    child.Arrange(new Rect(arrangeBounds));
                }
            }
            return(arrangeBounds);
        }
Example #9
0
        /// <summary>Called to arrange and size the content of a <see cref="T:System.Windows.Controls.Control" /> object. </summary>
        /// <param name="arrangeBounds">The computed size that is used to arrange the content.</param>
        /// <returns>The size of the control.</returns>
        // Token: 0x060044BB RID: 17595 RVA: 0x00138210 File Offset: 0x00136410
        protected override Size ArrangeOverride(Size arrangeBounds)
        {
            int visualChildrenCount = this.VisualChildrenCount;

            if (visualChildrenCount > 0)
            {
                UIElement uielement = (UIElement)this.GetVisualChild(0);
                if (uielement != null)
                {
                    uielement.Arrange(new Rect(arrangeBounds));
                }
            }
            return(arrangeBounds);
        }
        /// <summary>Arranges the content (child elements) of a <see cref="T:System.Windows.Controls.DockPanel" /> element.</summary>
        /// <param name="arrangeSize">The <see cref="T:System.Windows.Size" /> this element uses to arrange its child elements.</param>
        /// <returns>The <see cref="T:System.Windows.Size" /> that represents the arranged size of this <see cref="T:System.Windows.Controls.DockPanel" /> element.</returns>
        // Token: 0x06004A89 RID: 19081 RVA: 0x0015024C File Offset: 0x0014E44C
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            UIElementCollection internalChildren = base.InternalChildren;
            int    count = internalChildren.Count;
            int    num   = count - (this.LastChildFill ? 1 : 0);
            double num2  = 0.0;
            double num3  = 0.0;
            double num4  = 0.0;
            double num5  = 0.0;

            for (int i = 0; i < count; i++)
            {
                UIElement uielement = internalChildren[i];
                if (uielement != null)
                {
                    Size desiredSize = uielement.DesiredSize;
                    Rect finalRect   = new Rect(num2, num3, Math.Max(0.0, arrangeSize.Width - (num2 + num4)), Math.Max(0.0, arrangeSize.Height - (num3 + num5)));
                    if (i < num)
                    {
                        switch (DockPanel.GetDock(uielement))
                        {
                        case Dock.Left:
                            num2           += desiredSize.Width;
                            finalRect.Width = desiredSize.Width;
                            break;

                        case Dock.Top:
                            num3            += desiredSize.Height;
                            finalRect.Height = desiredSize.Height;
                            break;

                        case Dock.Right:
                            num4           += desiredSize.Width;
                            finalRect.X     = Math.Max(0.0, arrangeSize.Width - num4);
                            finalRect.Width = desiredSize.Width;
                            break;

                        case Dock.Bottom:
                            num5            += desiredSize.Height;
                            finalRect.Y      = Math.Max(0.0, arrangeSize.Height - num5);
                            finalRect.Height = desiredSize.Height;
                            break;
                        }
                    }
                    uielement.Arrange(finalRect);
                }
            }
            return(arrangeSize);
        }
Example #11
0
        /// <summary>Arranges the content of a <see cref="T:System.Windows.Controls.Viewbox" /> element.</summary>
        /// <param name="arrangeSize">The <see cref="T:System.Windows.Size" /> this element uses to arrange its child elements.</param>
        /// <returns>
        ///   <see cref="T:System.Windows.Size" /> that represents the arranged size of this <see cref="T:System.Windows.Controls.Viewbox" /> element and its child elements.</returns>
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            UIElement internalChild = this.InternalChild;

            if (internalChild != null)
            {
                Size desiredSize = internalChild.DesiredSize;
                Size size        = Viewbox.ComputeScaleFactor(arrangeSize, desiredSize, this.Stretch, this.StretchDirection);
                this.InternalTransform = new ScaleTransform(size.Width, size.Height);
                internalChild.Arrange(new Rect(default(Point), internalChild.DesiredSize));
                arrangeSize.Width  = size.Width * desiredSize.Width;
                arrangeSize.Height = size.Height * desiredSize.Height;
            }
            return(arrangeSize);
        }
        /// <summary>Arranges the content (child elements) of the <see cref="T:System.Windows.Controls.Page" />. </summary>
        /// <param name="arrangeBounds">The size to use to arrange the child elements.</param>
        /// <returns>A <see cref="T:System.Windows.Size" /> that represents the arranged size of the page.</returns>
        // Token: 0x060052B9 RID: 21177 RVA: 0x00170F4C File Offset: 0x0016F14C
        protected override Size ArrangeOverride(Size arrangeBounds)
        {
            base.VerifyAccess();
            int visualChildrenCount = this.VisualChildrenCount;

            if (visualChildrenCount > 0)
            {
                UIElement uielement = this.GetVisualChild(0) as UIElement;
                if (uielement != null)
                {
                    uielement.Arrange(new Rect(default(Point), arrangeBounds));
                }
            }
            return(arrangeBounds);
        }
Example #13
0
        // Token: 0x0600569A RID: 22170 RVA: 0x0017F4C0 File Offset: 0x0017D6C0
        internal static Size StackArrangeHelper(IStackMeasure arrangeElement, IStackMeasureScrollData scrollData, Size arrangeSize)
        {
            UIElementCollection internalChildren = arrangeElement.InternalChildren;
            bool   flag      = arrangeElement.Orientation == Orientation.Horizontal;
            Rect   finalRect = new Rect(arrangeSize);
            double num       = 0.0;

            if (arrangeElement.IsScrolling)
            {
                if (flag)
                {
                    finalRect.X = StackPanel.ComputePhysicalFromLogicalOffset(arrangeElement, scrollData.ComputedOffset.X, true);
                    finalRect.Y = -1.0 * scrollData.ComputedOffset.Y;
                }
                else
                {
                    finalRect.X = -1.0 * scrollData.ComputedOffset.X;
                    finalRect.Y = StackPanel.ComputePhysicalFromLogicalOffset(arrangeElement, scrollData.ComputedOffset.Y, false);
                }
            }
            int i     = 0;
            int count = internalChildren.Count;

            while (i < count)
            {
                UIElement uielement = internalChildren[i];
                if (uielement != null)
                {
                    if (flag)
                    {
                        finalRect.X     += num;
                        num              = uielement.DesiredSize.Width;
                        finalRect.Width  = num;
                        finalRect.Height = Math.Max(arrangeSize.Height, uielement.DesiredSize.Height);
                    }
                    else
                    {
                        finalRect.Y     += num;
                        num              = uielement.DesiredSize.Height;
                        finalRect.Height = num;
                        finalRect.Width  = Math.Max(arrangeSize.Width, uielement.DesiredSize.Width);
                    }
                    uielement.Arrange(finalRect);
                }
                i++;
            }
            return(arrangeSize);
        }
Example #14
0
        /// <summary>
        ///     ArrangeOverride allows for the customization of the positioning of children.
        /// </summary>
        /// <param name="arrangeBounds">
        ///     Measured size.
        /// </param>
        protected override Size ArrangeOverride(Size arrangeBounds)
        {
            VerifyAccess();
            int count = this.VisualChildrenCount;

            if (count > 0)
            {
                UIElement child = this.GetVisualChild(0) as UIElement;

                if (child != null)
                {
                    child.Arrange(new Rect(new Point(), arrangeBounds));
                }
            }
            return(arrangeBounds);
        }
Example #15
0
        protected override Size ArrangeOverride(Size finalSize)
        {
            double remainingWidth  = finalSize.Width;
            double remainingHeight = finalSize.Height;

            double left = 0;
            double top  = 0;

            for (int i = 0; i < Children.Count; i++)
            {
                UIElement   child                = Children[i];
                Dock        childDock            = GetDock(child);
                Orientation childDockOrientation = GetDockOrientation(childDock);

                bool childFill = LastChildFill && i == Children.Count - 1;

                double cellWidth  = childDockOrientation == Orientation.Vertical || childFill ? remainingWidth : child.DesiredSize.Width;
                double cellHeight = childDockOrientation == Orientation.Horizontal || childFill ? remainingHeight : child.DesiredSize.Height;

                double cellLeft = childDock == Dock.Right ? remainingWidth - cellWidth : 0;
                double cellTop  = childDock == Dock.Bottom ? remainingHeight - cellHeight : 0;

                child.Arrange(new Rect(left + cellLeft, top + cellTop, cellWidth.Max(0), cellHeight.Max(0)));

                if (childDockOrientation == Orientation.Horizontal)
                {
                    remainingWidth -= cellWidth;

                    if (childDock == Dock.Left)
                    {
                        left += cellWidth;
                    }
                }
                else
                {
                    remainingHeight -= cellHeight;

                    if (childDock == Dock.Top)
                    {
                        top += cellHeight;
                    }
                }
            }

            return(finalSize);
        }
Example #16
0
        // Token: 0x06005B54 RID: 23380 RVA: 0x0019C068 File Offset: 0x0019A268
        private void arrangeLine(double v, double lineV, int start, int end, bool useItemU, double itemU)
        {
            double num  = 0.0;
            bool   flag = this.Orientation == Orientation.Horizontal;
            UIElementCollection internalChildren = base.InternalChildren;

            for (int i = start; i < end; i++)
            {
                UIElement uielement = internalChildren[i];
                if (uielement != null)
                {
                    WrapPanel.UVSize uvsize = new WrapPanel.UVSize(this.Orientation, uielement.DesiredSize.Width, uielement.DesiredSize.Height);
                    double           num2   = useItemU ? itemU : uvsize.U;
                    uielement.Arrange(new Rect(flag ? num : v, flag ? v : num, flag ? num2 : lineV, flag ? lineV : num2));
                    num += num2;
                }
            }
        }
Example #17
0
        /// <summary>Arranges the content of a <see cref="T:System.Windows.Controls.Decorator" /> element.</summary>
        /// <param name="arrangeSize">The <see cref="T:System.Windows.Size" /> this element uses to arrange its child content.</param>
        /// <returns>The <see cref="T:System.Windows.Size" /> that represents the arranged size of this <see cref="T:System.Windows.Controls.Decorator" /> element and its child.</returns>
        // Token: 0x06004F36 RID: 20278 RVA: 0x00163A24 File Offset: 0x00161C24
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            base.VerifyAccess();
            this.EnsureRootVisual();
            Size size = arrangeSize;

            if (!this._constraintSize.IsEmpty)
            {
                size = new Size(Math.Min(arrangeSize.Width, this._constraintSize.Width), Math.Min(arrangeSize.Height, this._constraintSize.Height));
            }
            UIElement child = this.Child;

            if (child != null)
            {
                child.Arrange(new Rect(size));
            }
            return(arrangeSize);
        }
Example #18
0
        // Token: 0x06005457 RID: 21591 RVA: 0x001757B4 File Offset: 0x001739B4
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            bool flag = this.IsScrollClient && EventTrace.IsEnabled(EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Info);

            if (flag)
            {
                EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientStringBegin, EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Info, "SCROLLCONTENTPRESENTER:ArrangeOverride");
            }
            try
            {
                int visualChildrenCount = this.VisualChildrenCount;
                if (this.IsScrollClient)
                {
                    this.VerifyScrollData(arrangeSize, this._scrollData._extent);
                }
                if (visualChildrenCount > 0)
                {
                    this._adornerLayer.Arrange(new Rect(arrangeSize));
                    UIElement uielement = this.GetVisualChild(0) as UIElement;
                    if (uielement != null)
                    {
                        Rect finalRect = new Rect(uielement.DesiredSize);
                        if (this.IsScrollClient)
                        {
                            finalRect.X = -this.HorizontalOffset;
                            finalRect.Y = -this.VerticalOffset;
                        }
                        finalRect.Width  = Math.Max(finalRect.Width, arrangeSize.Width);
                        finalRect.Height = Math.Max(finalRect.Height, arrangeSize.Height);
                        uielement.Arrange(finalRect);
                    }
                }
            }
            finally
            {
                if (flag)
                {
                    EventTrace.EventProvider.TraceEvent(EventTrace.Event.WClientStringEnd, EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Info, "SCROLLCONTENTPRESENTER:ArrangeOverride");
                }
            }
            return(arrangeSize);
        }
 /// <summary>Arranges the content of a <see cref="T:System.Windows.Controls.Canvas" /> element.</summary>
 /// <param name="arrangeSize">The size that this <see cref="T:System.Windows.Controls.Canvas" /> element should use to arrange its child elements.</param>
 /// <returns>A <see cref="T:System.Windows.Size" /> that represents the arranged size of this <see cref="T:System.Windows.Controls.Canvas" /> element and its descendants.</returns>
 // Token: 0x06004335 RID: 17205 RVA: 0x00133674 File Offset: 0x00131874
 protected override Size ArrangeOverride(Size arrangeSize)
 {
     foreach (object obj in base.InternalChildren)
     {
         UIElement uielement = (UIElement)obj;
         if (uielement != null)
         {
             double x    = 0.0;
             double y    = 0.0;
             double left = Canvas.GetLeft(uielement);
             if (!DoubleUtil.IsNaN(left))
             {
                 x = left;
             }
             else
             {
                 double right = Canvas.GetRight(uielement);
                 if (!DoubleUtil.IsNaN(right))
                 {
                     x = arrangeSize.Width - uielement.DesiredSize.Width - right;
                 }
             }
             double top = Canvas.GetTop(uielement);
             if (!DoubleUtil.IsNaN(top))
             {
                 y = top;
             }
             else
             {
                 double bottom = Canvas.GetBottom(uielement);
                 if (!DoubleUtil.IsNaN(bottom))
                 {
                     y = arrangeSize.Height - uielement.DesiredSize.Height - bottom;
                 }
             }
             uielement.Arrange(new Rect(new Point(x, y), uielement.DesiredSize));
         }
     }
     return(arrangeSize);
 }
Example #20
0
        /// <summary>
        /// Viewbox always sets the child to its desired size.  It then computes and applies a transformation
        /// from that size to the space available: Viewbox's own input size less child margin.
        ///
        /// Viewbox also calls arrange on its child.
        /// </summary>
        /// <param name="arrangeSize">Size in which Border will draw the borders/background and children.</param>
        protected override Size ArrangeOverride(Size arrangeSize)
        {
            UIElement child = InternalChild;

            if (child != null)
            {
                Size childSize = child.DesiredSize;

                // Compute scaling factors from arrange size and the measured child content size
                Size scalefac = ComputeScaleFactor(arrangeSize, childSize, this.Stretch, this.StretchDirection);

                InternalTransform = new ScaleTransform(scalefac.Width, scalefac.Height);

                // Arrange the child to the desired size
                child.Arrange(new Rect(new Point(), child.DesiredSize));

                //return the size oocupied by scaled child
                arrangeSize.Width  = scalefac.Width * childSize.Width;
                arrangeSize.Height = scalefac.Height * childSize.Height;
            }
            return(arrangeSize);
        }
Example #21
0
        private void arrangeLine(double v, double lineV, int start, int end, bool useItemU, double itemU)
        {
            double u            = 0;
            bool   isHorizontal = (Orientation == Orientation.Horizontal);

            UIElementCollection children = InternalChildren;

            for (int i = start; i < end; i++)
            {
                UIElement child = children[i] as UIElement;
                if (child != null)
                {
                    UVSize childSize   = new UVSize(Orientation, child.DesiredSize.Width, child.DesiredSize.Height);
                    double layoutSlotU = (useItemU ? itemU : childSize.U);
                    child.Arrange(new Rect(
                                      (isHorizontal ? u : v),
                                      (isHorizontal ? v : u),
                                      (isHorizontal ? layoutSlotU : lineV),
                                      (isHorizontal ? lineV : layoutSlotU)));
                    u += layoutSlotU;
                }
            }
        }
Example #22
0
        /// <summary>
        /// Border computes the position of its single child and applies its child's alignments to the child.
        ///
        /// </summary>
        /// <param name="finalSize">The size reserved for this element by the parent</param>
        /// <returns>The actual ink area of the element, typically the same as finalSize</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            Thickness borders = BorderThickness;

            if (this.UseLayoutRounding && !FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness)
            {
                DpiScale dpi = GetDpi();
                borders = new Thickness(UIElement.RoundLayoutValue(borders.Left, dpi.DpiScaleX), UIElement.RoundLayoutValue(borders.Top, dpi.DpiScaleY),
                                        UIElement.RoundLayoutValue(borders.Right, dpi.DpiScaleX), UIElement.RoundLayoutValue(borders.Bottom, dpi.DpiScaleY));
            }
            Rect boundRect = new Rect(finalSize);
            Rect innerRect = HelperDeflateRect(boundRect, borders);

            //  arrange child
            UIElement child = Child;

            if (child != null)
            {
                Rect childRect = HelperDeflateRect(innerRect, Padding);
                child.Arrange(childRect);
            }

            CornerRadius radii          = CornerRadius;
            Brush        borderBrush    = BorderBrush;
            bool         uniformCorners = AreUniformCorners(radii);

            //  decide which code path to execute. complex (geometry path based) rendering
            //  is used if one of the following is true:

            //  1. there are non-uniform rounded corners
            _useComplexRenderCodePath = !uniformCorners;

            if (!_useComplexRenderCodePath &&
                borderBrush != null)
            {
                SolidColorBrush originIndependentBrush = borderBrush as SolidColorBrush;

                bool uniformBorders = borders.IsUniform;

                _useComplexRenderCodePath =
                    //  2. the border brush is origin dependent (the only origin independent brush is a solid color brush)
                    (originIndependentBrush == null)
                    //  3. the border brush is semi-transtarent solid color brush AND border thickness is not uniform
                    //     (for uniform semi-transparent border Border.OnRender draws rectangle outline - so it works fine)
                    || ((originIndependentBrush.Color.A < 0xff) && !uniformBorders)
                    //  4. there are rounded corners AND the border thickness is not uniform
                    || (!DoubleUtil.IsZero(radii.TopLeft) && !uniformBorders);
            }

            if (_useComplexRenderCodePath)
            {
                Radii innerRadii = new Radii(radii, borders, false);

                StreamGeometry backgroundGeometry = null;

                //  calculate border / background rendering geometry
                if (!DoubleUtil.IsZero(innerRect.Width) && !DoubleUtil.IsZero(innerRect.Height))
                {
                    backgroundGeometry = new StreamGeometry();

                    using (StreamGeometryContext ctx = backgroundGeometry.Open())
                    {
                        GenerateGeometry(ctx, innerRect, innerRadii);
                    }

                    backgroundGeometry.Freeze();
                    BackgroundGeometryCache = backgroundGeometry;
                }
                else
                {
                    BackgroundGeometryCache = null;
                }

                if (!DoubleUtil.IsZero(boundRect.Width) && !DoubleUtil.IsZero(boundRect.Height))
                {
                    Radii          outerRadii     = new Radii(radii, borders, true);
                    StreamGeometry borderGeometry = new StreamGeometry();

                    using (StreamGeometryContext ctx = borderGeometry.Open())
                    {
                        GenerateGeometry(ctx, boundRect, outerRadii);

                        if (backgroundGeometry != null)
                        {
                            GenerateGeometry(ctx, innerRect, innerRadii);
                        }
                    }

                    borderGeometry.Freeze();
                    BorderGeometryCache = borderGeometry;
                }
                else
                {
                    BorderGeometryCache = null;
                }
            }
            else
            {
                BackgroundGeometryCache = null;
                BorderGeometryCache     = null;
            }

            return(finalSize);
        }
        /// <summary>
        /// Arrange the children
        /// </summary>
        /// <param name="finalSize">Size available</param>
        /// <returns>Size used</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            ItemsControl            itemsControl = ItemsControl.GetItemsOwner(this);
            TreeViewExItem          treeViewItem = itemsControl as TreeViewExItem;
            TreeViewEx              treeView     = itemsControl as TreeViewEx ?? treeViewItem.ParentTreeView;
            IItemContainerGenerator generator    = this.ItemContainerGenerator;

            //Extent = finalSize;
            bool   foundVisibleItem = false;;
            double currentY         = 0;

            if (treeView.IsVirtualizing)
            {
                //Debug("Arrange-" + itemsControl.DataContext);
                for (int i = 0; i < itemsControl.Items.Count; i++)
                {
                    TreeViewExItem child = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as TreeViewExItem;
                    int            childHierarchyLevel = 0;
                    if (child != null)
                    {
                        childHierarchyLevel = child.hierachyLevel;
                    }

                    if (foundVisibleItem)
                    {
                        if (child == null)
                        {
                            // other items are not visible / virtualized
                            break;
                        }
                    }
                    else
                    {
                        if (child != null)
                        {
                            // found first visible item
                            foundVisibleItem = true;
                        }
                    }

                    if (child != null)
                    {
                        child.Arrange(new Rect(-HorizontalOffset, currentY - VerticalOffset, finalSize.Width, child.DesiredSize.Height));
                        currentY += child.ActualHeight;
                    }
                    else
                    {
                        currentY += GetCachedOrEstimatedHeight(treeView, childHierarchyLevel);
                    }
                }
            }
            else
            {
                for (int i = 0; i < itemsControl.Items.Count; i++)
                {
                    UIElement child = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as UIElement;

                    if (child != null)
                    {
                        child.Arrange(new Rect(-HorizontalOffset, currentY - VerticalOffset, finalSize.Width, child.DesiredSize.Height));
                    }
                    currentY += child.DesiredSize.Height;
                }
            }

            return(finalSize);
        }
        /// <summary>Arranges the contents of a <see cref="T:System.Windows.Controls.Border" /> element.</summary>
        /// <param name="finalSize">The <see cref="T:System.Windows.Size" /> this element uses to arrange its child element.</param>
        /// <returns>The <see cref="T:System.Windows.Size" /> that represents the arranged size of this <see cref="T:System.Windows.Controls.Border" /> element and its child element.</returns>
        // Token: 0x06004265 RID: 16997 RVA: 0x0012F998 File Offset: 0x0012DB98
        protected override Size ArrangeOverride(Size finalSize)
        {
            Thickness borderThickness = this.BorderThickness;

            if (base.UseLayoutRounding && !FrameworkAppContextSwitches.DoNotApplyLayoutRoundingToMarginsAndBorderThickness)
            {
                DpiScale dpi = base.GetDpi();
                borderThickness = new Thickness(UIElement.RoundLayoutValue(borderThickness.Left, dpi.DpiScaleX), UIElement.RoundLayoutValue(borderThickness.Top, dpi.DpiScaleY), UIElement.RoundLayoutValue(borderThickness.Right, dpi.DpiScaleX), UIElement.RoundLayoutValue(borderThickness.Bottom, dpi.DpiScaleY));
            }
            Rect      rect  = new Rect(finalSize);
            Rect      rect2 = Border.HelperDeflateRect(rect, borderThickness);
            UIElement child = this.Child;

            if (child != null)
            {
                Rect finalRect = Border.HelperDeflateRect(rect2, this.Padding);
                child.Arrange(finalRect);
            }
            CornerRadius cornerRadius = this.CornerRadius;
            Brush        borderBrush  = this.BorderBrush;
            bool         flag         = Border.AreUniformCorners(cornerRadius);

            this._useComplexRenderCodePath = !flag;
            if (!this._useComplexRenderCodePath && borderBrush != null)
            {
                SolidColorBrush solidColorBrush = borderBrush as SolidColorBrush;
                bool            isUniform       = borderThickness.IsUniform;
                this._useComplexRenderCodePath = (solidColorBrush == null || (solidColorBrush.Color.A < byte.MaxValue && !isUniform) || (!DoubleUtil.IsZero(cornerRadius.TopLeft) && !isUniform));
            }
            if (this._useComplexRenderCodePath)
            {
                Border.Radii   radii          = new Border.Radii(cornerRadius, borderThickness, false);
                StreamGeometry streamGeometry = null;
                if (!DoubleUtil.IsZero(rect2.Width) && !DoubleUtil.IsZero(rect2.Height))
                {
                    streamGeometry = new StreamGeometry();
                    using (StreamGeometryContext streamGeometryContext = streamGeometry.Open())
                    {
                        Border.GenerateGeometry(streamGeometryContext, rect2, radii);
                    }
                    streamGeometry.Freeze();
                    this.BackgroundGeometryCache = streamGeometry;
                }
                else
                {
                    this.BackgroundGeometryCache = null;
                }
                if (!DoubleUtil.IsZero(rect.Width) && !DoubleUtil.IsZero(rect.Height))
                {
                    Border.Radii   radii2          = new Border.Radii(cornerRadius, borderThickness, true);
                    StreamGeometry streamGeometry2 = new StreamGeometry();
                    using (StreamGeometryContext streamGeometryContext2 = streamGeometry2.Open())
                    {
                        Border.GenerateGeometry(streamGeometryContext2, rect, radii2);
                        if (streamGeometry != null)
                        {
                            Border.GenerateGeometry(streamGeometryContext2, rect2, radii);
                        }
                    }
                    streamGeometry2.Freeze();
                    this.BorderGeometryCache = streamGeometry2;
                }
                else
                {
                    this.BorderGeometryCache = null;
                }
            }
            else
            {
                this.BackgroundGeometryCache = null;
                this.BorderGeometryCache     = null;
            }
            return(finalSize);
        }
Example #25
0
        private void ArrangeItemsBeyondTheExtendedViewport(
            bool isHorizontal,
            UIElement child,
            Size childDesiredSize,
            double arrangeLength,
            IList items,
            IItemContainerGenerator generator,
            IContainItemStorage itemStorageProvider,
            bool areContainersUniformlySized,
            double uniformOrAverageContainerSize,
            bool beforeExtendedViewport,
            ref Rect rcChild,
            ref Size previousChildSize,
            ref Point previousChildOffset,
            ref int previousChildItemIndex)
        {
            //
            // These are the items beyond the viewport. (Eg. Recyclable containers that
            // are waiting until next measure to be cleaned up, Elements that are kept
            // alive because they hold focus.) These element are arranged beyond the
            // visible viewport but at their right position. This is important because these
            // containers need to be brought into view when using keyboard navigation
            // and their arrange rect is what informs the scroillviewer of the right offset
            // to scroll to.
            //
            if (isHorizontal)
            {
                rcChild.Width = childDesiredSize.Width;
                rcChild.Height = Math.Max(arrangeLength, childDesiredSize.Height);

                if (IsPixelBased)
                {
                    int currChildItemIndex = ((ItemContainerGenerator)generator).IndexFromContainer(child, true /*returnLocalIndex*/);
                    double distance;

                    if (beforeExtendedViewport)
                    {
                        if (previousChildItemIndex == -1)
                        {
                            ComputeDistance(items, itemStorageProvider, isHorizontal, areContainersUniformlySized, uniformOrAverageContainerSize, 0, currChildItemIndex, out distance);
                        }
                        else
                        {
                            ComputeDistance(items, itemStorageProvider, isHorizontal, areContainersUniformlySized, uniformOrAverageContainerSize, currChildItemIndex, previousChildItemIndex-currChildItemIndex, out distance);
                        }

                        rcChild.X = previousChildOffset.X - distance;
                        rcChild.Y = previousChildOffset.Y;
                    }
                    else
                    {
                        if (previousChildItemIndex == -1)
                        {
                            ComputeDistance(items, itemStorageProvider, isHorizontal, areContainersUniformlySized, uniformOrAverageContainerSize, 0, currChildItemIndex, out distance);
                        }
                        else
                        {
                            ComputeDistance(items, itemStorageProvider, isHorizontal, areContainersUniformlySized, uniformOrAverageContainerSize, previousChildItemIndex, currChildItemIndex-previousChildItemIndex, out distance);
                        }

                        rcChild.X = previousChildOffset.X + distance;
                        rcChild.Y = previousChildOffset.Y;
                    }

                    previousChildItemIndex = currChildItemIndex;
                }
                else
                {
                    if (beforeExtendedViewport)
                    {
                        rcChild.X -= childDesiredSize.Width;
                    }
                    else
                    {
                        rcChild.X += previousChildSize.Width;
                    }
                }
            }
            else
            {
                rcChild.Height = childDesiredSize.Height;
                rcChild.Width = Math.Max(arrangeLength, childDesiredSize.Width);

                if (IsPixelBased)
                {
                    int currChildItemIndex = ((ItemContainerGenerator)generator).IndexFromContainer(child, true /*returnLocalIndex*/);
                    double distance;

                    if (beforeExtendedViewport)
                    {
                        if (previousChildItemIndex == -1)
                        {
                            ComputeDistance(items, itemStorageProvider, isHorizontal, areContainersUniformlySized, uniformOrAverageContainerSize, 0, currChildItemIndex, out distance);
                        }
                        else
                        {
                            ComputeDistance(items, itemStorageProvider, isHorizontal, areContainersUniformlySized, uniformOrAverageContainerSize, currChildItemIndex, previousChildItemIndex-currChildItemIndex, out distance);
                        }

                        rcChild.Y = previousChildOffset.Y - distance;
                        rcChild.X = previousChildOffset.X;
                    }
                    else
                    {
                        if (previousChildItemIndex == -1)
                        {
                            ComputeDistance(items, itemStorageProvider, isHorizontal, areContainersUniformlySized, uniformOrAverageContainerSize, 0, currChildItemIndex, out distance);
                        }
                        else
                        {
                            ComputeDistance(items, itemStorageProvider, isHorizontal, areContainersUniformlySized, uniformOrAverageContainerSize, previousChildItemIndex, currChildItemIndex-previousChildItemIndex, out distance);
                        }

                        rcChild.Y = previousChildOffset.Y + distance;
                        rcChild.X = previousChildOffset.X;
                    }

                    previousChildItemIndex = currChildItemIndex;
                }
                else
                {
                    if (beforeExtendedViewport)
                    {
                        rcChild.Y -= childDesiredSize.Height;
                    }
                    else
                    {
                        rcChild.Y += previousChildSize.Height;
                    }
                }
            }

            previousChildSize = childDesiredSize;
            previousChildOffset = rcChild.Location;

            child.Arrange(rcChild);
        }
Example #26
0
 private void ArrangeChild(UIElement child, double finalMainStart, double finalCrossStart, double finalMainLength, double finalCrossLength)
 {
     child.Arrange(Orientation == Orientation.Horizontal ?
         new Rect(finalMainStart, finalCrossStart, finalMainLength, finalCrossLength) :
         new Rect(finalCrossStart, finalMainStart, finalCrossLength, finalMainLength));
 }
        /// <summary>
        /// Arrange the children
        /// </summary>
        /// <param name="finalSize">Size available</param>
        /// <returns>Size used</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            ItemsControl            itemsControl = ItemsControl.GetItemsOwner(this);
            TreeViewExItem          treeViewItem = itemsControl as TreeViewExItem;
            TreeViewEx              treeView     = itemsControl as TreeViewEx ?? treeViewItem.ParentTreeView;
            IItemContainerGenerator generator    = this.ItemContainerGenerator;

            //Extent = finalSize;
            bool   foundVisibleItem = false;;
            double currentY         = 0;

            if (treeView.IsVirtualizing)
            {
                for (int i = 0; i < itemsControl.Items.Count; i++)
                {
                    FrameworkElement child = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as FrameworkElement;

                    if (foundVisibleItem)
                    {
                        if (child == null)
                        {
                            // other items are not visible / virtualized
                            break;
                        }
                    }
                    else
                    {
                        if (child != null)
                        {
                            // found first visible item
                            foundVisibleItem = true;
                        }
                    }

                    if (child != null)
                    {
                        child.Arrange(new Rect(-HorizontalOffset, currentY - VerticalOffset, finalSize.Width, child.DesiredSize.Height));
                        currentY += child.ActualHeight;
                    }
                    else
                    {
                        currentY += GetContainerHeightForItem(itemsControl, i);
                    }
                }

                // update average after arrange, because we have to use the same average as in measure for our calculation of currentY.
                cachedSizes.Update();
            }
            else
            {
                for (int i = 0; i < itemsControl.Items.Count; i++)
                {
                    UIElement child = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as UIElement;

                    if (child != null)
                    {
                        child.Arrange(new Rect(-HorizontalOffset, currentY - VerticalOffset, finalSize.Width, child.DesiredSize.Height));
                    }
                    currentY += child.DesiredSize.Height;
                }
            }

            return(finalSize);
        }
Example #28
0
        private void ArrangeFirstItemInExtendedViewport(
            bool isHorizontal,
            UIElement child,
            Size childDesiredSize,
            double arrangeLength,
            ref Rect rcChild,
            ref Size previousChildSize,
            ref Point previousChildOffset,
            ref int previousChildItemIndex)
        {
            //
            // This is the first child in the extendedViewport. Initialize the child rect.
            // This is required because there may have been other children
            // outside the viewport that were previously arranged and hence
            // mangled the child rect struct.
            //
            rcChild.X = 0.0;
            rcChild.Y = 0.0;

            if (IsScrolling)
            {
                //
                // This is the scrolling panel. Offset the arrange rect with
                // respect to the viewport.
                //
                if (!IsPixelBased)
                {
                    if (isHorizontal)
                    {
                        rcChild.X = -1.0 * _previousStackPixelSizeInCacheBeforeViewport.Width;
                        rcChild.Y = -1.0 * _scrollData._computedOffset.Y;
                    }
                    else
                    {
                        rcChild.Y = -1.0 * _previousStackPixelSizeInCacheBeforeViewport.Height;
                        rcChild.X = -1.0 * _scrollData._computedOffset.X;
                    }
                }
                else
                {
                    rcChild.X = -1.0 * _scrollData._computedOffset.X;
                    rcChild.Y = -1.0 * _scrollData._computedOffset.Y;
                }
            }

            if (IsVirtualizing && IsPixelBased)
            {
                if (isHorizontal)
                {
                    rcChild.X += _firstItemInExtendedViewportOffset;
                }
                else
                {
                    rcChild.Y += _firstItemInExtendedViewportOffset;
                }
            }

            bool isChildHorizontal = isHorizontal;
            IHierarchicalVirtualizationAndScrollInfo virtualizingChild = GetVirtualizingChild(child, ref isChildHorizontal);

            if (isHorizontal)
            {
                rcChild.Width = childDesiredSize.Width;
                rcChild.Height = Math.Max(arrangeLength, childDesiredSize.Height);
                previousChildSize = childDesiredSize;

                if (!IsPixelBased && virtualizingChild != null)
                {
                    //
                    // For a non leaf item we only want to account for the size in the extended viewport
                    //
                    HierarchicalVirtualizationItemDesiredSizes itemDesiredSizes = virtualizingChild.ItemDesiredSizes;
                    previousChildSize.Width = itemDesiredSizes.PixelSizeInViewport.Width;

                    if (isChildHorizontal == isHorizontal)
                    {
                        previousChildSize.Width += itemDesiredSizes.PixelSizeBeforeViewport.Width + itemDesiredSizes.PixelSizeAfterViewport.Width;
                    }

                    RelativeHeaderPosition headerPosition = RelativeHeaderPosition.Top; // virtualizingChild.RelativeHeaderPosition;
                    Size pixelHeaderSize = virtualizingChild.HeaderDesiredSizes.PixelSize;
                    if (headerPosition == RelativeHeaderPosition.Left || headerPosition == RelativeHeaderPosition.Right)
                    {
                        previousChildSize.Width += pixelHeaderSize.Width;
                    }
                    else
                    {
                        previousChildSize.Width = Math.Max(previousChildSize.Width, pixelHeaderSize.Width);
                    }
                }
            }
            else
            {
                rcChild.Height = childDesiredSize.Height;
                rcChild.Width = Math.Max(arrangeLength, childDesiredSize.Width);
                previousChildSize = childDesiredSize;

                if (!IsPixelBased && virtualizingChild != null)
                {
                    //
                    // For a non leaf item we only want to account for the size in the extended viewport
                    //
                    HierarchicalVirtualizationItemDesiredSizes itemDesiredSizes = virtualizingChild.ItemDesiredSizes;
                    previousChildSize.Height = itemDesiredSizes.PixelSizeInViewport.Height;

                    if (isChildHorizontal == isHorizontal)
                    {
                        previousChildSize.Height += itemDesiredSizes.PixelSizeBeforeViewport.Height + itemDesiredSizes.PixelSizeAfterViewport.Height;
                    }

                    RelativeHeaderPosition headerPosition = RelativeHeaderPosition.Top; // virtualizingChild.RelativeHeaderPosition;
                    Size pixelHeaderSize = virtualizingChild.HeaderDesiredSizes.PixelSize;
                    if (headerPosition == RelativeHeaderPosition.Top || headerPosition == RelativeHeaderPosition.Bottom)
                    {
                        previousChildSize.Height += pixelHeaderSize.Height;
                    }
                    else
                    {
                        previousChildSize.Height = Math.Max(previousChildSize.Height, pixelHeaderSize.Height);
                    }
                }
            }

            previousChildItemIndex = _firstItemInExtendedViewportIndex;
            previousChildOffset = rcChild.Location;

            child.Arrange(rcChild);
        }
Example #29
0
        /// <summary>
        /// Arrange a sequence of elements in a single line.
        /// </summary>
        /// <param name="lineStart">
        /// Index of the first element in the sequence to arrange.
        /// </param>
        /// <param name="lineEnd">
        /// Index of the last+1 element in the sequence to arrange.
        /// </param>
        /// <param name="directDelta">
        /// Optional fixed growth in the primary direction.
        /// </param>
        /// <param name="directMaximum">
        /// Maximum length in the direct direction.
        /// </param>
        /// <param name="indirectOffset">
        /// Offset of the line in the indirect direction.
        /// </param>
        /// <param name="indirectGrowth">
        /// Shared indirect growth of the elements on this line.
        /// </param>
        private void ArrangeLine(int lineStart, int lineEnd, double?directDelta, double directMaximum, double indirectOffset, double indirectGrowth)
        {
            Orientation         o            = Orientation;
            bool                isHorizontal = o == Orientation.Horizontal;
            UIElementCollection children     = Children;
            double              directLength = 0.0;
            double              itemCount    = 0.0;
            double              itemLength   = isHorizontal ? ItemWidth : ItemHeight;

            if (AlignLastItems && !itemLength.IsNaN())
            {
                // Length is easy to calculate in this case
                itemCount    = Math.Floor(directMaximum / itemLength);
                directLength = itemCount * itemLength;
            }
            else
            {
                // Make first pass to calculate the slack space
                itemCount = lineEnd - lineStart;
                for (int index = lineStart; index < lineEnd; index++)
                {
                    // Get the size of the element
                    UIElement    element     = children[index];
                    OrientedSize elementSize = new OrientedSize(o, element.DesiredSize.Width, element.DesiredSize.Height);

                    // Determine if we should use the element's desired size or the
                    // fixed item width or height
                    double directGrowth = directDelta != null ?
                                          directDelta.Value :
                                          elementSize.Direct;

                    // Update total length
                    directLength += directGrowth;
                }
            }

            // Determine slack
            double directSlack      = directMaximum - directLength;
            double directSlackSlice = directSlack / (itemCount + 1.0);
            double directOffset     = directSlackSlice;

            // Make second pass to arrange items
            for (int index = lineStart; index < lineEnd; index++)
            {
                // Get the size of the element
                UIElement    element     = children[index];
                OrientedSize elementSize = new OrientedSize(o, element.DesiredSize.Width, element.DesiredSize.Height);

                // Determine if we should use the element's desired size or the
                // fixed item width or height
                double directGrowth = directDelta != null ?
                                      directDelta.Value :
                                      elementSize.Direct;

                // Arrange the element
                Rect bounds = isHorizontal ?
                              new Rect(directOffset, indirectOffset, directGrowth, indirectGrowth) :
                              new Rect(indirectOffset, directOffset, indirectGrowth, directGrowth);
                element.Arrange(bounds);

                // Update offset for next time
                directOffset += directGrowth + directSlackSlice;
            }
        }
Example #30
0
 private void ArrangeChild(UIElement child, double finalMainStart, double finalCrossStart, double finalMainLength, double finalCrossLength)
 {
     child.Arrange(Orientation == Orientation.Horizontal ?
                   new Rect(finalMainStart, finalCrossStart, finalMainLength, finalCrossLength) :
                   new Rect(finalCrossStart, finalMainStart, finalCrossLength, finalMainLength));
 }
Example #31
0
        private void ArrangeOtherItemsInExtendedViewport(
            bool isHorizontal,
            UIElement child,
            Size childDesiredSize,
            double arrangeLength,
            int index,
            ref Rect rcChild,
            ref Size previousChildSize,
            ref Point previousChildOffset,
            ref int previousChildItemIndex)
        {
            //
            // These are the items within the viewport beyond the first.
            // So they only need to be offset from the previous child.
            //
            if (isHorizontal)
            {
                rcChild.X += previousChildSize.Width;
                rcChild.Width = childDesiredSize.Width;
                rcChild.Height = Math.Max(arrangeLength, childDesiredSize.Height);
            }
            else
            {
                rcChild.Y += previousChildSize.Height;
                rcChild.Height = childDesiredSize.Height;
                rcChild.Width = Math.Max(arrangeLength, childDesiredSize.Width);
            }

            previousChildSize = childDesiredSize;
            previousChildItemIndex = _firstItemInExtendedViewportIndex + (index - _firstItemInExtendedViewportChildIndex);
            previousChildOffset = rcChild.Location;

            child.Arrange(rcChild);
        }