Bugfix: limit range during drag interactions

don't allow the user to drag before the first position or after the last position.
This commit is contained in:
Benjamin Popp 2020-05-07 11:01:56 -05:00
parent 8f1dd3f78f
commit 89bd28232a
2 changed files with 3 additions and 1 deletions

View File

@ -120,7 +120,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels {
}
public void HandleMove(int originalIndex, int newIndex) {
if (originalIndex == newIndex || originalIndex >= Elements.Count || newIndex >= Elements.Count) return;
if (originalIndex == newIndex) return;
var element = Elements[originalIndex];
Elements.RemoveAt(originalIndex);
Elements.Insert(newIndex, element);

View File

@ -35,6 +35,8 @@ namespace HavenSoft.HexManiac.WPF.Controls {
var newTileIndex = newTileY * tileWidth + newTileX;
var viewModel = (DexReorderTab)DataContext;
oldTileIndex = Math.Min(Math.Max(0, oldTileIndex), Container.Items.Count - 1);
newTileIndex = Math.Min(Math.Max(0, newTileIndex), Container.Items.Count - 1);
viewModel.HandleMove(oldTileIndex, newTileIndex);
for (int i = oldTileIndex; i < newTileIndex; i++) {