mirror of
https://github.com/openhardwaremonitor/openhardwaremonitor
synced 2025-08-22 18:07:09 +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:
parent
39cfbc709d
commit
e82b9d7da2
@ -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;
|
||||
}
|
||||
|
@ -84,6 +84,12 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
Ring0.Open();
|
||||
Opcode.Open();
|
||||
|
||||
AddGroups();
|
||||
|
||||
open = true;
|
||||
}
|
||||
|
||||
private void AddGroups() {
|
||||
if (mainboardEnabled)
|
||||
Add(new Mainboard.MainboardGroup(smbios, settings));
|
||||
|
||||
@ -105,8 +111,14 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
|
||||
if (hddEnabled)
|
||||
Add(new HDD.HarddriveGroup(settings));
|
||||
}
|
||||
|
||||
open = true;
|
||||
public void Reset() {
|
||||
if (!open)
|
||||
return;
|
||||
|
||||
RemoveGroups();
|
||||
AddGroups();
|
||||
}
|
||||
|
||||
public bool MainboardEnabled {
|
||||
@ -351,10 +363,7 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
if (!open)
|
||||
return;
|
||||
|
||||
while (groups.Count > 0) {
|
||||
IGroup group = groups[groups.Count - 1];
|
||||
Remove(group);
|
||||
}
|
||||
RemoveGroups();
|
||||
|
||||
Opcode.Close();
|
||||
Ring0.Close();
|
||||
@ -364,6 +373,13 @@ namespace OpenHardwareMonitor.Hardware {
|
||||
open = false;
|
||||
}
|
||||
|
||||
private void RemoveGroups() {
|
||||
while (groups.Count > 0) {
|
||||
IGroup group = groups[groups.Count - 1];
|
||||
Remove(group);
|
||||
}
|
||||
}
|
||||
|
||||
public event HardwareEventHandler HardwareAdded;
|
||||
public event HardwareEventHandler HardwareRemoved;
|
||||
|
||||
|
@ -10,5 +10,5 @@
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("0.9.3.2")]
|
||||
[assembly: AssemblyInformationalVersion("0.9.3.2 Alpha")]
|
||||
[assembly: AssemblyVersion("0.9.3.3")]
|
||||
[assembly: AssemblyInformationalVersion("0.9.3.3 Alpha")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user