Auto refresh mice when hovering over their buttons and the mouse is marked as "Not ready".

This commit is contained in:
IceStormNG
2023-07-30 13:48:53 +02:00
parent 7c80a32fc2
commit 4742c33466

View File

@@ -188,6 +188,10 @@ namespace GHelper
buttonPeripheral2.Click += ButtonPeripheral_Click;
buttonPeripheral3.Click += ButtonPeripheral_Click;
buttonPeripheral1.MouseEnter += ButtonPeripheral_MouseEnter;
buttonPeripheral2.MouseEnter += ButtonPeripheral_MouseEnter;
buttonPeripheral3.MouseEnter += ButtonPeripheral_MouseEnter;
Text = "G-Helper " + (ProcessHelper.IsUserAdministrator() ? "—" : "-") + " " + AppConfig.GetModelShort();
TopMost = AppConfig.Is("topmost");
@@ -1129,6 +1133,26 @@ namespace GHelper
panelPeripherals.Visible = true;
}
private void ButtonPeripheral_MouseEnter(object? sender, EventArgs e)
{
int index = 0;
if (sender == buttonPeripheral2) index = 1;
if (sender == buttonPeripheral3) index = 2;
IPeripheral iph = PeripheralsProvider.AllPeripherals().ElementAt(index);
if (iph is null)
{
return;
}
if (!iph.IsDeviceReady)
{
//Refresh battery on hover if the device is marked as "Not Ready"
iph.ReadBattery();
}
}
private void ButtonPeripheral_Click(object? sender, EventArgs e)
{
int index = 0;