mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-09-02 07:15:31 +00:00
Added a PowerModeChanged event handler to reset the hardware tree when resuming from sleep. This should correctly restore fan controls and other states.
This commit is contained in:
@@ -172,6 +172,8 @@ namespace OpenHardwareMonitor.GUI {
|
||||
|
||||
computer.Open();
|
||||
|
||||
Microsoft.Win32.SystemEvents.PowerModeChanged += PowerModeChanged;
|
||||
|
||||
timer.Enabled = true;
|
||||
|
||||
showHiddenSensors = new UserOption("hiddenMenuItem", false,
|
||||
@@ -334,6 +336,14 @@ namespace OpenHardwareMonitor.GUI {
|
||||
};
|
||||
}
|
||||
|
||||
private void PowerModeChanged(object sender,
|
||||
Microsoft.Win32.PowerModeChangedEventArgs e) {
|
||||
|
||||
if (e.Mode == Microsoft.Win32.PowerModes.Resume) {
|
||||
computer.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializePlotForm() {
|
||||
plotForm = new Form();
|
||||
plotForm.FormBorderStyle = FormBorderStyle.SizableToolWindow;
|
||||
@@ -880,8 +890,7 @@ namespace OpenHardwareMonitor.GUI {
|
||||
// disable the fallback MainIcon during reset, otherwise icon visibility
|
||||
// might be lost
|
||||
systemTray.IsMainIconEnabled = false;
|
||||
computer.Close();
|
||||
computer.Open();
|
||||
computer.Reset();
|
||||
// restore the MainIcon setting
|
||||
systemTray.IsMainIconEnabled = minimizeToTray.Value;
|
||||
}
|
||||
|
Reference in New Issue
Block a user