private void OnLeftMoved(int oldIndex, int newIndex, KeyValuePair <TKey, TLeft> value) { var startIndex = _leftJoiners[oldIndex].Offset; int endIndex; if (oldIndex < newIndex) { endIndex = (_leftJoiners[newIndex].Offset + _leftJoiners[newIndex].Count) - _leftJoiners[oldIndex].Count; } else { endIndex = _leftJoiners[newIndex].Offset; } var count = _leftJoiners[oldIndex].Count; _leftJoiners.Move(oldIndex, newIndex); var min = oldIndex < newIndex ? oldIndex : newIndex; var max = oldIndex > newIndex ? oldIndex : newIndex; for (int i = min; i <= max; ++i) { _leftJoiners[i].SourceIndex = i; } UpdateIndices(min); _resultList.MoveRange(startIndex, endIndex, count); }
private void HandleRightMoved(int oldIndex, int newIndex) { var startIndex = _rightJoiners[oldIndex].Offset; int endIndex; if (oldIndex < newIndex) { endIndex = (_rightJoiners[newIndex].Offset + _rightJoiners[newIndex].Count) - _rightJoiners[oldIndex].Count; } else { endIndex = _rightJoiners[newIndex].Offset; } var count = _rightJoiners[oldIndex].Count; _rightJoiners.Move(oldIndex, newIndex); var min = oldIndex < newIndex ? oldIndex : newIndex; var max = oldIndex > newIndex ? oldIndex : newIndex; for (int i = min; i <= max; ++i) { _rightJoiners[i].SourceIndex = i; } UpdateIndices(min); _resultList.MoveRange(startIndex, endIndex, count); }
protected override void OnMoved(int collectionIndex, int oldIndex, int newIndex, int value) { var oldItem = _indexes[oldIndex]; _indexes.Move(oldIndex, newIndex); if (oldItem.InList) { if (oldIndex < newIndex) { RecalculateIndexes(oldIndex, newIndex); } else { RecalculateIndexes(newIndex, oldIndex); } var newItem = _indexes[newIndex]; ResultList.Move(oldItem.Index, newItem.Index); } else { _indexes[newIndex] = GetItem(newIndex, false); } }
protected override void OnMoved(int oldIndex, int newIndex, TSource value) { var oldTargetIndex = _indexList[oldIndex]; if (oldTargetIndex >= 0) { RemoveIndex(oldIndex, false); var newTargetIndex = AddIndex(newIndex, false); ResultList.Move(oldTargetIndex, newTargetIndex); } else { _indexList.Move(oldIndex, newIndex); _indexList[newIndex] = -1; } }
protected override void OnMoved(int oldIndex, int newIndex, TSource value) { var item = _sourceData[oldIndex]; _sourceData.Move(oldIndex, newIndex); var min = oldIndex < newIndex ? oldIndex : newIndex; var max = oldIndex < newIndex ? newIndex : oldIndex; for (int i = min; i <= max; ++i) { _sourceData[i].SourceIndex = i; } item.SourceIndex = oldIndex; if (_resultSet.TryGetValue(item.Key, out GroupData group)) { var oldTargetIndex = item.TargetIndex; item.TargetIndex = FindTargetIndex(group.Items, newIndex); if (item.TargetIndex > oldTargetIndex) { --item.TargetIndex; } item.SourceIndex = newIndex; group.Items.Move(oldTargetIndex, item.TargetIndex); min = oldTargetIndex < item.TargetIndex ? oldTargetIndex : item.TargetIndex; max = oldTargetIndex < item.TargetIndex ? item.TargetIndex : oldTargetIndex; for (int i = min; i <= max; ++i) { group.Items[i].TargetIndex = i; } if (oldTargetIndex == 0 || item.TargetIndex == 0) { UpdateGroupIndex(group); } } }
protected void MoveSourceCollection(int oldCollectionIndex, int newCollectionIndex) { if (oldCollectionIndex < 0 || oldCollectionIndex >= _sourceLists.Count) { throw new ArgumentOutOfRangeException(nameof(oldCollectionIndex)); } if (newCollectionIndex < 0 || newCollectionIndex >= _sourceLists.Count) { throw new ArgumentOutOfRangeException(nameof(newCollectionIndex)); } _sourceLists.Move(oldCollectionIndex, newCollectionIndex); var min = oldCollectionIndex < newCollectionIndex ? oldCollectionIndex : newCollectionIndex; var max = oldCollectionIndex > newCollectionIndex ? oldCollectionIndex : newCollectionIndex; for (int i = min; i <= max; ++i) { _sourceLists[i].CollectionIndex = i; } }
protected override void OnMoved(int oldIndex, int newIndex, TSource value) { var itemSet = _sourceList[oldIndex]; var newTargetIndex = FindByKey(itemSet.Key, newIndex); if (newTargetIndex > itemSet.TargetIndex) { --newTargetIndex; } _sourceList.Move(oldIndex, newIndex); if (oldIndex < newIndex) { UpdateSourceIndexes(oldIndex, newIndex); } else { UpdateSourceIndexes(newIndex, oldIndex); } if (itemSet.TargetIndex != newTargetIndex) { ResultList.Move(itemSet.TargetIndex, newTargetIndex); if (itemSet.TargetIndex < newTargetIndex) { UpdateTargetIndexes(itemSet.TargetIndex, newTargetIndex); } else { UpdateTargetIndexes(newTargetIndex, itemSet.TargetIndex); } } }
protected override void OnMoved(int collectionIndex, int oldIndex, int newIndex, TSource value) => _rightKeys.Move(oldIndex, newIndex);
protected override void OnMoved(int oldIndex, int newIndex, TSource value) => _leftKeys.Move(oldIndex, newIndex);