From 4742c334666c6b838403223538f37031271fb257 Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Sun, 30 Jul 2023 13:48:53 +0200 Subject: [PATCH] Auto refresh mice when hovering over their buttons and the mouse is marked as "Not ready". --- app/Settings.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/Settings.cs b/app/Settings.cs index 6cb45584..6289c6c5 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -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;