public ItemStop(StartViewItem item, int position) { Item = item; Position = position; }
internal void GetSnapOffset(int offset, int viewportWidth, int direction, out int snapTo, out int newDirection, out StartViewItem newSelection) { int snapThreshold = viewportWidth / SnapThresholdDivisor; snapTo = offset; newDirection = direction; newSelection = _selectedItem; if (VisibleChildren.Count == 0) { return; } foreach (ItemStop itemStop in _itemStops) { if (itemStop.Position == -offset) { newSelection = itemStop.Item; return; } } int leftIndex; int leftInView; int centerIndex; int rightIndex; int rightInView; GetItemsInView(offset, viewportWidth, out leftIndex, out leftInView, out centerIndex, out rightIndex, out rightInView); if (leftIndex == rightIndex && leftIndex != -1) { newSelection = _selectedItem = _visibleChildren[leftIndex]; } else { if (leftIndex == -1) { leftIndex = _visibleChildren.Count - 1; } if (rightIndex == -1) { rightIndex = 0; } int index; if (direction < 0) { if (rightInView > snapThreshold) { index = GetBestIndex(centerIndex, rightIndex, leftIndex); newDirection = -1; } else { index = GetBestIndex(leftIndex, centerIndex, rightIndex); newDirection = 1; } } else if (direction > 0) { if (leftInView > snapThreshold) { index = StartViewPanel.GetBestIndex(leftIndex, centerIndex, rightIndex); newDirection = 1; } else { index = StartViewPanel.GetBestIndex(centerIndex, rightIndex, leftIndex); newDirection = -1; } } else if (centerIndex != -1) { index = centerIndex; newDirection = -1; } else if (leftInView > rightInView) { index = leftIndex; newDirection = -1; } else { index = rightIndex; newDirection = 1; } _selectedItem = _visibleChildren[index]; snapTo = -_selectedItem.StartPosition; newSelection = _selectedItem; } }