Check destination validity

locked slot would throw exception
This commit is contained in:
Kurt
2016-12-26 18:22:45 -08:00
parent 4041f56519
commit 53f8abc26c
2 changed files with 4 additions and 5 deletions

View File

@@ -4204,7 +4204,7 @@ private void pbBoxSlot_MouseMove(object sender, MouseEventArgs e)
getQuickFiller(pb, SAV.getStoredSlot(DragInfo.slotSourceOffset));
pb.BackgroundImage = null;
if (DragInfo.SameBox)
if (DragInfo.SameBox && DragInfo.DestinationValid)
SlotPictureBoxes[DragInfo.slotDestinationSlotNumber].Image = img;
if (result == DragDropEffects.Copy) // viewed in tabs, apply 'view' highlight
@@ -4242,7 +4242,6 @@ private void pbBoxSlot_DragDrop(object sender, DragEventArgs e)
if (Directory.Exists(files[0])) { loadBoxesFromDB(files[0]); return; }
if (DragInfo.SameSlot)
return;
if (DragInfo.SameBox)
if (SAV.getIsSlotLocked(DragInfo.slotDestinationBoxNumber, DragInfo.slotDestinationSlotNumber))
{
DragInfo.slotDestinationSlotNumber = -1; // Invalidate
@@ -4368,8 +4367,8 @@ public static class DragInfo
public static bool SameBox => slotSourceBoxNumber > -1 && slotSourceBoxNumber == slotDestinationBoxNumber;
public static bool SameSlot => slotSourceSlotNumber == slotDestinationSlotNumber && slotSourceBoxNumber == slotDestinationBoxNumber;
public static bool SourceValid => slotSourceBoxNumber > -1 || SourceParty;
public static bool DestinationValid => slotDestinationBoxNumber > -1 || DestinationParty;
public static bool SourceValid => slotSourceSlotNumber > -1 && (slotSourceBoxNumber > -1 || SourceParty);
public static bool DestinationValid => slotDestinationSlotNumber > -1 && (slotDestinationBoxNumber > -1 || DestinationParty);
public static bool SourceParty => 30 <= slotSourceSlotNumber && slotSourceSlotNumber < 36;
public static bool DestinationParty => 30 <= slotDestinationSlotNumber && slotDestinationSlotNumber < 36;

View File

@@ -213,7 +213,7 @@ private void pbBoxSlot_MouseMove(object sender, MouseEventArgs e)
getQuickFiller(pb, SAV.getStoredSlot(DragInfo.slotSourceOffset));
pb.BackgroundImage = null;
if (DragInfo.SameBox)
if (DragInfo.SameBox && DragInfo.DestinationValid)
SlotPictureBoxes[DragInfo.slotDestinationSlotNumber].Image = img;
}
catch (Exception x)