mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-08-23 10:04:40 -05:00
Fix GetUnderlyingControl call from ContextMenuStrip
https://projectpokemon.org/home/forums/topic/55096-unhandled-exception-error-pkmdb/?tab=comments#comment-249235 had recently moved the contextmenu to the designer, event handler has sender as the ContextMenuStrip use recursion -> while loop so that the input can be any of the 3 cases; it'll drill down until it gets a picturebox or none. make generic for giggles, update usages so Array.IndexOf uses picturebox[] instead of object[]
This commit is contained in:
@@ -131,8 +131,7 @@ private void MenuOpening(object sender, CancelEventArgs e)
|
||||
|
||||
private static SlotViewInfo<PictureBox> GetSenderInfo(ref object sender)
|
||||
{
|
||||
sender = WinFormsUtil.GetUnderlyingControl(sender);
|
||||
var pb = (PictureBox)sender;
|
||||
var pb = WinFormsUtil.GetUnderlyingControl<PictureBox>(sender);
|
||||
var view = WinFormsUtil.FindFirstControlOfType<ISlotViewer<PictureBox>>(pb);
|
||||
var loc = view.GetSlotData(pb);
|
||||
return new SlotViewInfo<PictureBox> {Slot = loc, View = view};
|
||||
|
||||
@@ -70,7 +70,7 @@ public ISlotInfo GetSlotData(PictureBox view)
|
||||
public ISlotInfo GetSlotData(int slot) => SlotOffsets[slot];
|
||||
|
||||
public IList<PictureBox> SlotPictureBoxes => slots;
|
||||
public int GetSlot(PictureBox sender) => slots.IndexOf(WinFormsUtil.GetUnderlyingControl(sender) as PictureBox);
|
||||
public int GetSlot(PictureBox sender) => slots.IndexOf(WinFormsUtil.GetUnderlyingControl<PictureBox>(sender));
|
||||
public int GetSlotOffset(int slot) => SlotOffsets[slot].Offset;
|
||||
public int ViewIndex { get; set; } = -1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user