2023-02-04 22:52:38 +00:00
|
|
|
using System;
|
|
|
|
using System.Windows.Forms;
|
2023-02-05 08:42:37 +00:00
|
|
|
using System.Windows.Forms.Automation;
|
2023-02-04 22:52:38 +00:00
|
|
|
|
|
|
|
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);
|
2023-02-05 08:42:37 +00:00
|
|
|
AccessibilityObject.RaiseAutomationNotification(AutomationNotificationKind.Other,
|
|
|
|
AutomationNotificationProcessing.All, AccessibleDescription ?? AccessibleName ?? "");
|
2023-02-04 22:52:38 +00:00
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|