Example #1
0
        internal override bool PositionBottomRealizedItem(ref double visibleItemsBottom)
        {
            RadVirtualizingDataControlItem lastRealizedItem = this.owner.lastItemCache;
            double  itemLength    = this.GetItemLength(lastRealizedItem);
            WrapRow lastWrapRow   = null;
            int     wrapRowsCount = this.wrapRows.Count;

            if (wrapRowsCount > 0)
            {
                lastWrapRow = this.wrapRows[wrapRowsCount - 1];
            }

            bool isEnoughSpaceForItemInRow = true;

            if (lastWrapRow != null)
            {
                isEnoughSpaceForItemInRow = this.CheckEnoughSpaceForItemInRow(lastWrapRow, lastRealizedItem, true);
            }

            if (lastWrapRow == null || !isEnoughSpaceForItemInRow)
            {
                if (!isEnoughSpaceForItemInRow)
                {
                    visibleItemsBottom += lastWrapRow.rowLength;
                    this.OnRowFilled(lastWrapRow, true);
                    if (!this.CanRealizeBottom(visibleItemsBottom))
                    {
                        return(false);
                    }
                }

                lastWrapRow           = this.InsertWrapRowAt(wrapRowsCount);
                lastWrapRow.firstItem = lastRealizedItem;
                lastWrapRow.rowOffset = lastWrapRow.previous != null ? lastWrapRow.previous.rowOffset + lastWrapRow.previous.rowLength : 0;
                lastWrapRow.rowLength = itemLength;
            }

            double currentRowLength = lastWrapRow.rowLength;

            switch (this.orientationCache)
            {
            case Orientation.Horizontal:
                if (currentRowLength < lastRealizedItem.height)
                {
                    lastWrapRow.rowLength = lastRealizedItem.height;
                    visibleItemsBottom   += lastRealizedItem.height - currentRowLength;
                }
                lastRealizedItem.SetVerticalOffset(lastWrapRow.rowOffset);
                if (lastWrapRow.lastItem == null)
                {
                    lastRealizedItem.SetHorizontalOffset(0);
                }
                else
                {
                    lastRealizedItem.SetHorizontalOffset(lastWrapRow.lastItem.horizontalOffsetCache + lastWrapRow.lastItem.width);
                }
                break;

            case Orientation.Vertical:
                if (currentRowLength < lastRealizedItem.width)
                {
                    lastWrapRow.rowLength = lastRealizedItem.width;
                    visibleItemsBottom   += lastRealizedItem.width - currentRowLength;
                }
                lastRealizedItem.SetHorizontalOffset(lastWrapRow.rowOffset);
                if (lastWrapRow.lastItem == null)
                {
                    lastRealizedItem.SetVerticalOffset(0);
                }
                else
                {
                    lastRealizedItem.SetVerticalOffset(lastWrapRow.lastItem.verticalOffsetCache + lastWrapRow.lastItem.height);
                }
                break;
            }

            lastWrapRow.lastItem     = lastRealizedItem;
            lastRealizedItem.wrapRow = lastWrapRow;

            if (this.owner.IsLastItemLastInListSource())
            {
                this.OnRowFilled(lastWrapRow, true);
            }

            return(true);
        }
        internal override void OnContainerSizeChanged(RadVirtualizingDataControlItem container, Size newSize, Size oldSize)
        {
            if (!this.topRealized.Contains(container))
            {
                RadVirtualizingDataControlItem pivotContainer = container.next;

                int containersToSkip = 0;

                if (pivotContainer != null)
                {
                    containersToSkip = Math.Max(this.stackCount - this.owner.realizedItems.IndexOf(pivotContainer), 0);
                }

                while (pivotContainer != null)
                {
                    if (containersToSkip > 0)
                    {
                        containersToSkip--;
                        continue;
                    }

                    this.slotsRepository.Remove(pivotContainer.associatedDataItem.GetHashCode());
                    pivotContainer = pivotContainer.next;
                }

                this.ReorderViewportOnItemsChanged();
            }
            else
            {
                double newOffset   = 0;
                double offsetDelta = 0;
                switch (this.orientationCache)
                {
                case Orientation.Horizontal:
                    offsetDelta = newSize.Height - oldSize.Height;
                    newOffset   = container.verticalOffsetCache - offsetDelta;
                    container.SetVerticalOffset(newOffset);
                    double horizontalOffset = container.horizontalOffsetCache;
                    while (container.previous != null)
                    {
                        container = container.previous;
                        if (container.horizontalOffsetCache == horizontalOffset)
                        {
                            container.SetVerticalOffset(container.verticalOffsetCache - offsetDelta);
                        }
                    }
                    break;

                case Orientation.Vertical:
                    offsetDelta = newSize.Width - oldSize.Width;
                    newOffset   = container.horizontalOffsetCache - offsetDelta;
                    container.SetHorizontalOffset(newOffset);
                    double verticalOffset = container.verticalOffsetCache;

                    while (container.previous != null)
                    {
                        container = container.previous;
                        if (container.verticalOffsetCache == verticalOffset)
                        {
                            container.SetHorizontalOffset(container.horizontalOffsetCache - offsetDelta);
                        }
                    }
                    break;
                }
            }
        }