private void SynchItemOffsetInRow(WrapRow row) { RadVirtualizingDataControlItem firstItem = row.firstItem; switch (this.orientationCache) { case Orientation.Horizontal: while (true) { firstItem.SetVerticalOffset(row.rowOffset); firstItem = firstItem.next; if (firstItem.wrapRow != row) { break; } } break; case Orientation.Vertical: while (true) { firstItem.SetHorizontalOffset(row.rowOffset); firstItem = firstItem.next; if (firstItem.wrapRow != row) { break; } } break; } }
internal override void OnOrientationChanged(Orientation newValue) { base.OnOrientationChanged(newValue); if (this.owner == null || !this.owner.IsTemplateApplied) { return; } if (this.owner.GetItemCount() > 0) { this.owner.StopAllAddedAnimations(); this.owner.StopAllRemovedAnimations(); while (this.owner.realizedItems.Count > 0) { RadVirtualizingDataControlItem lastItem = this.owner.realizedItems[this.owner.realizedItems.Count - 1]; lastItem.SetVerticalOffset(0); lastItem.SetHorizontalOffset(0); this.owner.RecycleLastItem(); } this.wrapRows.Clear(); this.owner.BeginAsyncBalance(); this.owner.BalanceVisualSpace(); } }
private void PositionRealizedItemTop(RadVirtualizingDataControlItem firstRealizedItem, ref double visibleItemsTop) { Rect slot = this.FindFreeSpotForItemTop(firstRealizedItem); switch (this.orientationCache) { case Orientation.Horizontal: firstRealizedItem.SetHorizontalOffset(slot.Left); firstRealizedItem.SetVerticalOffset(slot.Top); visibleItemsTop = slot.Top - this.ScrollOffset + this.GetElementCanvasOffset(this.owner.itemsPanel); break; case Orientation.Vertical: firstRealizedItem.SetVerticalOffset(slot.Top); firstRealizedItem.SetHorizontalOffset(slot.Left); visibleItemsTop = slot.Left - this.ScrollOffset + this.GetElementCanvasOffset(this.owner.itemsPanel); break; } }
internal virtual void SetItemOffset(RadVirtualizingDataControlItem item, double offset) { if (this.LayoutOrientation == Orientation.Vertical) { item.SetVerticalOffset(offset); } else { item.SetHorizontalOffset(offset); } }
private void PositionRealizedItemBottom(RadVirtualizingDataControlItem lastRealizedItem, ref double visibleItemsBottom) { Rect slot = this.FindFreeSpotForItemBottom(lastRealizedItem); switch (this.orientationCache) { case Orientation.Horizontal: visibleItemsBottom = slot.Bottom - this.ScrollOffset + this.GetElementCanvasOffset(this.owner.itemsPanel); lastRealizedItem.SetHorizontalOffset(slot.Left); lastRealizedItem.SetVerticalOffset(slot.Top); this.slotsRepository[lastRealizedItem.associatedDataItem.GetHashCode()] = (int)(slot.Left / this.itemExtent); break; case Orientation.Vertical: visibleItemsBottom = slot.Right - this.ScrollOffset + this.GetElementCanvasOffset(this.owner.itemsPanel); lastRealizedItem.SetVerticalOffset(slot.Top); lastRealizedItem.SetHorizontalOffset(slot.Left); this.slotsRepository[lastRealizedItem.associatedDataItem.GetHashCode()] = (int)(slot.Top / this.itemExtent); break; } }
private void SynchRowItemsHorizontalStartPosition(WrapRow row) { RadVirtualizingDataControlItem firstItem = row.firstItem; double currentPosition = this.wrapLineAlignment == WrapLineAlignment.Center ? (this.owner.availableWidth - this.GetRowExtent(row)) / 2 : this.wrapLineAlignment == WrapLineAlignment.Near ? 0 : this.owner.availableWidth - this.GetRowExtent(row); while (true) { firstItem.SetHorizontalOffset(currentPosition); currentPosition += firstItem.width; firstItem = firstItem.next; if (firstItem == null || firstItem.wrapRow != row) { break; } } }
internal override void ReorderViewportItemsOnItemAdded(int physicalChangeLocation, RadVirtualizingDataControlItem addedItem) { this.owner.OnContainerStateChanged(addedItem, addedItem.associatedDataItem, ItemState.Realized); int slot = -1; if (this.slotsRepository.TryGetValue(addedItem.next.associatedDataItem.GetHashCode(), out slot)) { this.slotsRepository.Remove(addedItem.next.associatedDataItem.GetHashCode()); this.slotsRepository.Add(addedItem.associatedDataItem.GetHashCode(), slot); RadVirtualizingDataControlItem nextContainer = addedItem.next; addedItem.SetHorizontalOffset(nextContainer.horizontalOffsetCache); addedItem.SetVerticalOffset(nextContainer.verticalOffsetCache); } RadVirtualizingDataControlItem pivotContainer = addedItem.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.Index); pivotContainer = pivotContainer.next; } this.ReorderViewportOnItemsChanged(); }
internal override bool PositionTopRealizedItem(ref double visibleItemsTop) { RadVirtualizingDataControlItem firstRealizedItem = this.owner.firstItemCache; WrapRow firstWrapRow = null; int wrapRowsCount = this.wrapRows.Count; if (wrapRowsCount > 0) { firstWrapRow = this.wrapRows[0]; } bool isEnoughSpaceForItemInRow = this.CheckEnoughSpaceForItemInRow(firstWrapRow, firstRealizedItem, false); if (firstWrapRow == null || !isEnoughSpaceForItemInRow) { if (!isEnoughSpaceForItemInRow) { visibleItemsTop -= firstWrapRow.rowLength; this.OnRowFilled(firstWrapRow, false); if (!this.CanRealizeTop(visibleItemsTop)) { return(false); } } firstWrapRow = this.InsertWrapRowAt(0); firstWrapRow.lastItem = firstRealizedItem; firstWrapRow.rowLength = this.GetItemLength(firstRealizedItem); firstWrapRow.rowOffset = firstWrapRow.next != null ? firstWrapRow.next.rowOffset - firstWrapRow.rowLength : 0; } double currentRowLength = firstWrapRow.rowLength; double difference = 0; switch (this.orientationCache) { case Orientation.Horizontal: difference = firstRealizedItem.height - currentRowLength; if (currentRowLength < firstRealizedItem.height) { firstWrapRow.rowLength = firstRealizedItem.height; visibleItemsTop -= difference; firstWrapRow.rowOffset -= difference; } firstRealizedItem.SetVerticalOffset(firstWrapRow.rowOffset); if (firstWrapRow.firstItem == null) { firstRealizedItem.SetHorizontalOffset(this.owner.availableWidth - firstRealizedItem.width); } else { firstRealizedItem.SetHorizontalOffset(firstWrapRow.firstItem.horizontalOffsetCache - firstRealizedItem.width); if (difference != 0) { this.SynchItemOffsetInRow(firstWrapRow); } } break; case Orientation.Vertical: difference = firstRealizedItem.width - currentRowLength; if (currentRowLength < firstRealizedItem.width) { firstWrapRow.rowLength = firstRealizedItem.width; visibleItemsTop -= difference; firstWrapRow.rowOffset -= difference; } firstRealizedItem.SetHorizontalOffset(firstWrapRow.rowOffset); if (firstWrapRow.firstItem == null) { firstRealizedItem.SetVerticalOffset(this.owner.availableHeight - firstRealizedItem.height); } else { firstRealizedItem.SetVerticalOffset(firstWrapRow.firstItem.verticalOffsetCache - firstRealizedItem.height); if (difference != 0) { this.SynchItemOffsetInRow(firstWrapRow); } } break; } firstWrapRow.firstItem = firstRealizedItem; firstRealizedItem.wrapRow = firstWrapRow; if (this.owner.IsFirstItemFirstInListSource()) { this.OnRowFilled(firstWrapRow, false); } return(true); }
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; } } }