Added Battery Charge

This commit is contained in:
Serge
2023-08-03 17:15:46 +02:00
parent 2a6d02b1cb
commit b808efb502
8 changed files with 111 additions and 52 deletions

View File

@@ -178,9 +178,13 @@ namespace GHelper
sensorTimer.Elapsed += OnTimedEvent;
sensorTimer.Enabled = true;
panelBattery.MouseEnter += PanelBattery_MouseEnter;
labelCharge.MouseEnter += PanelBattery_MouseEnter;
labelBattery.MouseEnter += PanelBattery_MouseEnter;
labelBatteryTitle.MouseEnter += PanelBattery_MouseEnter;
panelBattery.MouseLeave += PanelBattery_MouseLeave;
labelCharge.MouseLeave += PanelBattery_MouseLeave;
labelBattery.MouseLeave += PanelBattery_MouseLeave;
labelBatteryTitle.MouseLeave += PanelBattery_MouseLeave;
@@ -229,7 +233,7 @@ namespace GHelper
if (HardwareControl.batteryHealth != -1)
{
labelBattery.Text = Properties.Strings.BatteryHealth + ": " + Math.Round(HardwareControl.batteryHealth, 1) + "%";
labelCharge.Text = Properties.Strings.BatteryHealth + ": " + Math.Round(HardwareControl.batteryHealth, 1) + "%";
}
}
@@ -822,6 +826,7 @@ namespace GHelper
string cpuTemp = "";
string gpuTemp = "";
string battery = "";
string charge = "";
HardwareControl.ReadSensors();
Task.Run((Action)PeripheralsProvider.RefreshBatteryForAllDevices);
@@ -829,6 +834,9 @@ namespace GHelper
if (HardwareControl.cpuTemp > 0)
cpuTemp = ": " + Math.Round((decimal)HardwareControl.cpuTemp).ToString() + "°C";
if (HardwareControl.batteryCapacity > 0)
charge = Properties.Strings.BatteryCharge + ": " + Math.Round(HardwareControl.batteryCapacity, 1) + "% ";
if (HardwareControl.batteryRate < 0)
battery = Properties.Strings.Discharging + ": " + Math.Round(-(decimal)HardwareControl.batteryRate, 1).ToString() + "W";
else if (HardwareControl.batteryRate > 0)
@@ -847,7 +855,8 @@ namespace GHelper
if (HardwareControl.midFan is not null)
labelMidFan.Text = "Mid " + HardwareControl.midFan;
if (!batteryMouseOver) labelBattery.Text = battery;
labelBattery.Text = battery;
if (!batteryMouseOver) labelCharge.Text = charge;
});
string trayTip = "CPU" + cpuTemp + " " + HardwareControl.cpuFan;