mirror of
https://github.com/kwsch/PKHeX
synced 2025-01-25 10:45:05 +00:00
3871b2f316
Can set to -1 to remove it
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms.Automation;
|
|
|
|
namespace PKHeX.WinForms.Controls;
|
|
|
|
public class SelectablePictureBox : PictureBox
|
|
{
|
|
public SelectablePictureBox() => SetStyle(ControlStyles.Selectable, TabStop = true);
|
|
|
|
public static int FocusBorderDeflate { get; set; }
|
|
|
|
protected override void OnMouseDown(MouseEventArgs e)
|
|
{
|
|
Focus();
|
|
base.OnMouseDown(e);
|
|
}
|
|
protected override void OnEnter(EventArgs e)
|
|
{
|
|
Invalidate();
|
|
base.OnEnter(e);
|
|
AccessibilityObject.RaiseAutomationNotification(AutomationNotificationKind.Other,
|
|
AutomationNotificationProcessing.All, AccessibleDescription ?? AccessibleName ?? "");
|
|
}
|
|
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(-FocusBorderDeflate, -FocusBorderDeflate);
|
|
ControlPaint.DrawFocusRectangle(pe.Graphics, rc);
|
|
}
|
|
}
|