internal void ScrollColumnIntoViewCore(ScrollIntoViewOperation <int> scrollOperation) { var update = new DelegateUpdate <UpdateFlags>(() => { if (scrollOperation.ScrollAttempts < ScrollIntoViewOperation <int> .MaxScrollAttempts) { this.ScrollColumnIndexIntoView(scrollOperation); scrollOperation.ScrollAttempts++; if (this.IsColumnIndexInView(scrollOperation)) { if (scrollOperation.CompletedAction != null) { scrollOperation.CompletedAction(); } } else { this.ScrollColumnIntoViewCore(scrollOperation); } } }); this.GridView.UpdateService.RegisterUpdate(update); }
internal void ScrollIndexIntoView(ScrollIntoViewOperation <ItemInfo?> operation) { var index = operation.RequestedItem.Value.Slot; var frozenContainersLength = 0; var itemLength = this.layoutController.strategy.Layout.PhysicalLengthForSlot(index); var offsetToScroll = this.layoutController.strategy.Layout.PhysicalOffsetFromSlot(index) - itemLength; if (DoubleArithmetics.IsLessThan(operation.InitialScrollOffset + frozenContainersLength, offsetToScroll)) { if (index > 0) { offsetToScroll -= this.View.Orientation == Orientation.Vertical ? this.View.ViewportHeight : this.View.ViewportWidth; offsetToScroll += itemLength; } } else if (DoubleArithmetics.IsLessThanOrEqual(offsetToScroll, operation.InitialScrollOffset + frozenContainersLength)) { offsetToScroll -= frozenContainersLength; } var scrollPosition = this.View.Orientation == Orientation.Vertical ? new RadPoint(this.View.ScrollOffset, Math.Max(0, offsetToScroll)) : new RadPoint(Math.Max(0, offsetToScroll), this.View.ScrollOffset); this.View.SetScrollPosition(scrollPosition, true, true); }
internal void ScrollIndexIntoViewCore(ScrollIntoViewOperation <int> scrollOperation) { var update = new DelegateUpdate <UpdateFlags>(() => { if (scrollOperation.ScrollAttempts < ScrollIntoViewOperation <int> .MaxScrollAttempts) { if (this.IsIndexInView(scrollOperation)) { if (scrollOperation.CompletedAction != null) { this.GridView.UpdateService.RegisterUpdate(new DelegateUpdate <UpdateFlags>(scrollOperation.CompletedAction)); } } else { this.ScrollIndexIntoView(scrollOperation); scrollOperation.ScrollAttempts++; this.ScrollIndexIntoViewCore(scrollOperation); } } }) { RequiresValidMeasure = true }; this.GridView.UpdateService.RegisterUpdate(update); }
internal void ScrollIndexIntoView(ScrollIntoViewOperation <int> operation) { var index = operation.RequestedItem; var frozenContainersLength = Math.Max(0, this.RowPool.FrozenContainersLength); var itemLength = this.rowLayout.RenderInfo.ValueForIndex(index); var offsetToScroll = this.rowLayout.RenderInfo.OffsetFromIndex(index) - itemLength; if (DoubleArithmetics.IsLessThan(operation.InitialScrollOffset + frozenContainersLength, offsetToScroll)) { if (index > 0) { offsetToScroll -= this.View.ViewportHeight; offsetToScroll += itemLength; } } else if (DoubleArithmetics.IsLessThanOrEqual(offsetToScroll, operation.InitialScrollOffset + frozenContainersLength)) { offsetToScroll -= frozenContainersLength; } var scrollPosition = new RadPoint(this.PhysicalHorizontalOffset, Math.Max(0, offsetToScroll)); this.GridView.SetScrollPosition(scrollPosition, true, true); }
internal bool IsIndexInView(ScrollIntoViewOperation <ItemInfo?> operation) { var element = this.layoutController.strategy.GetDisplayedElement(operation.RequestedItem.Value.Slot, operation.RequestedItem.Value.Id); if (element == null) { return(false); } var frozenContainersLength = 0; bool isIndexIntoView; if (this.View.Orientation == Orientation.Vertical) { isIndexIntoView = DoubleArithmetics.IsGreaterThanOrEqual(element.LayoutSlot.Y, this.View.ScrollOffset + frozenContainersLength) && DoubleArithmetics.IsLessThanOrEqual(element.LayoutSlot.Y + element.LayoutSlot.Height, this.View.ScrollOffset + this.View.ViewportHeight); } else { isIndexIntoView = DoubleArithmetics.IsGreaterThanOrEqual(element.LayoutSlot.X, this.View.ScrollOffset + frozenContainersLength) && DoubleArithmetics.IsLessThanOrEqual(element.LayoutSlot.X + element.LayoutSlot.Width, this.View.ScrollOffset + this.View.ViewportWidth); } return(isIndexIntoView); }
internal bool IsColumnIndexInView(ScrollIntoViewOperation <int> operation) { var column = this.ColumnPool.GetDisplayedElement(operation.RequestedItem); if (column == null) { return(false); } // Since the headers are not part of the scrollviewer we need to compare their position to the viewport window and omit the scroll offset. return(DoubleArithmetics.Ceiling(column.LayoutSlot.X) >= 0 && DoubleArithmetics.IsLessThanOrEqual(column.LayoutSlot.X + column.layoutSlot.Width, this.View.ViewportWidth)); }
internal bool IsIndexInView(ScrollIntoViewOperation <int> operation) { var layoutSlot = this.RowPool.GetPreviousDisplayedLayoutSlot(operation.RequestedItem); if (layoutSlot == RadRect.Invalid) { return(false); } var frozenContainersLength = Math.Max(0, this.RowPool.FrozenContainersLength); return(DoubleArithmetics.IsGreaterThanOrEqual(layoutSlot.Y, this.PhysicalVerticalOffset + frozenContainersLength) && DoubleArithmetics.IsLessThanOrEqual(layoutSlot.Y + layoutSlot.Height, this.PhysicalVerticalOffset + this.View.ViewportHeight)); }
/// <summary> /// Attempts to bring the data item at the specified zero-based index into view asynchronously. /// </summary> /// <param name="index">The zero-based index of the item to scroll.</param> /// <param name="scrollCompletedAction">Arbitrary action that may be executed after the asynchronous update is executed.</param> public void ScrollIndexIntoView(int index, Action scrollCompletedAction) { if (!this.IsTemplateApplied) { this.updateService.RegisterUpdate(new DelegateUpdate <UpdateFlags>(() => this.ScrollIndexIntoView(index, scrollCompletedAction))); return; } var scrollOperation = new ScrollIntoViewOperation <int>(index, this.ScrollViewer.VerticalOffset) { CompletedAction = scrollCompletedAction }; this.Model.ScrollIndexIntoViewCore(scrollOperation); }
/// <summary> /// Attempts to bring the specified data item into view asynchronously. /// </summary> /// <param name="item">The data item to scroll to.</param> /// <param name="scrollCompletedAction">Arbitrary action that may be executed after the asynchronous update is executed.</param> public void ScrollItemIntoView(object item, Action scrollCompletedAction) { if (!this.IsTemplateApplied) { this.updateService.RegisterUpdate(new DelegateUpdate <UpdateFlags>(() => this.ScrollItemIntoView(item, scrollCompletedAction))); return; } var info = this.model.FindItemInfo(item); if (info != null) { var scrollOperation = new ScrollIntoViewOperation <int>(info.Value.LayoutInfo.Line, this.ScrollViewer.VerticalOffset) { CompletedAction = scrollCompletedAction }; this.Model.ScrollIndexIntoViewCore(scrollOperation); } }
internal void ScrollColumnIndexIntoView(ScrollIntoViewOperation <int> operation) { var columnIndex = operation.RequestedItem; if (columnIndex < 0) { return; } var itemLength = this.columnLayout.RenderInfo.ValueForIndex(columnIndex); var offsetToScroll = this.columnLayout.RenderInfo.OffsetFromIndex(columnIndex) - itemLength; if (this.PhysicalHorizontalOffset < offsetToScroll) { offsetToScroll -= this.View.ViewportWidth - itemLength; } var scrollPosition = new RadPoint(offsetToScroll, this.PhysicalVerticalOffset); this.GridView.SetScrollPosition(scrollPosition, true, true); }
/// <summary> /// Attempts to bring the specified <see cref="DataGridColumn" /> into view asynchronously. /// </summary> /// <param name="column">The column.</param> /// <param name="scrollCompletedAction">Arbitrary action that may be executed after the asynchronous update is executed.</param> public void ScrollColumnIntoView(DataGridColumn column, Action scrollCompletedAction) { if (!this.IsTemplateApplied) { this.updateService.RegisterUpdate(new DelegateUpdate <UpdateFlags>(() => this.ScrollColumnIntoView(column, scrollCompletedAction))); return; } // TODO: consider adding displayindex to the columns to improve this when this operation become a performance issue. var columnIndex = this.Columns.IndexOf(column); if (columnIndex < 0) { return; } var scrollOperation = new ScrollIntoViewOperation <int>(columnIndex, this.ScrollViewer.VerticalOffset) { CompletedAction = scrollCompletedAction }; this.Model.ScrollColumnIntoViewCore(scrollOperation); }