mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-06-01 04:53:29 -05:00
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:
parent
8f1dd3f78f
commit
89bd28232a
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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++) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user