Use selectable picturebox

Closes #3757
Allows tabbing between windows, or pressing the keyboard's contextmenu key to pop up the context menu without ever needing to use the mouse.

changes pkmeditor dragout, box slot displays, sav-mystery gift r/w, and all the encounter/pkm db's
This commit is contained in:
Kurt 2023-02-04 14:52:38 -08:00
parent 31733671ec
commit d8b8646de6
4 changed files with 38 additions and 4 deletions

View file

@ -0,0 +1,34 @@
using System;
using System.Windows.Forms;
namespace PKHeX.WinForms.Controls;
public class SelectablePictureBox : PictureBox
{
public SelectablePictureBox() => SetStyle(ControlStyles.Selectable, TabStop = true);
protected override void OnMouseDown(MouseEventArgs e)
{
Focus();
base.OnMouseDown(e);
}
protected override void OnEnter(EventArgs e)
{
Invalidate();
base.OnEnter(e);
}
protected override void OnLeave(EventArgs e)
{
Invalidate();
base.OnLeave(e);
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
if (!Focused)
return;
var rc = ClientRectangle;
rc.Inflate(-2, -2);
ControlPaint.DrawFocusRectangle(pe.Graphics, rc);
}
}

View file

@ -74,7 +74,7 @@ public partial class PokeGrid : UserControl
public void SetBackground(Image img) => BackgroundImage = img;
public static PictureBox GetControl(int width, int height) => new()
public static SelectablePictureBox GetControl(int width, int height) => new()
{
AutoSize = false,
SizeMode = PictureBoxSizeMode.CenterImage,

View file

@ -62,7 +62,7 @@ namespace PKHeX.WinForms
this.L_UpdateAvailable = new System.Windows.Forms.LinkLabel();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.dragout = new System.Windows.Forms.PictureBox();
this.dragout = new PKHeX.WinForms.Controls.SelectablePictureBox();
this.PB_Legal = new System.Windows.Forms.PictureBox();
this.PKME_Tabs = new PKHeX.WinForms.Controls.PKMEditor();
this.C_SAV = new PKHeX.WinForms.Controls.SAVEditor();
@ -566,7 +566,7 @@ namespace PKHeX.WinForms
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.SplitContainer splitContainer2;
private System.Windows.Forms.PictureBox dragout;
private PKHeX.WinForms.Controls.SelectablePictureBox dragout;
private System.Windows.Forms.PictureBox PB_Legal;
}
}

View file

@ -678,7 +678,7 @@ public partial class SAV_Wondercard : Form
Margin = new Padding(0),
};
private static PictureBox GetPictureBox(int width, int height) => new()
private static SelectablePictureBox GetPictureBox(int width, int height) => new()
{
Size = new Size(width + 2, height + 2), // +1 to each side for the FixedSingle border
SizeMode = PictureBoxSizeMode.CenterImage,