Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/openhardwaremonitor/openhardwaremonitor.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Möller <mmoeller@openhardwaremonitor.org>2020-05-17 19:13:32 +0300
committerMichael Möller <mmoeller@openhardwaremonitor.org>2020-05-17 19:13:32 +0300
commite82b9d7da284b40ababa4daa7537fc930f1af53d (patch)
tree1fd9a46ad5b4c1b5c6af876c77ab373806f96204
parent39cfbc709d37706e78455aeb2a837d43d789129a (diff)
Added a PowerModeChanged event handler to reset the hardware tree when resuming from sleep. This should correctly restore fan controls and other states.
-rw-r--r--GUI/MainForm.cs13
-rw-r--r--Hardware/Computer.cs30
-rw-r--r--Properties/AssemblyVersion.cs4
3 files changed, 36 insertions, 11 deletions
diff --git a/GUI/MainForm.cs b/GUI/MainForm.cs
index 217ff9b..905a809 100644
--- a/GUI/MainForm.cs
+++ b/GUI/MainForm.cs
@@ -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;
}
diff --git a/Hardware/Computer.cs b/Hardware/Computer.cs
index 8a77c90..d5245bc 100644
--- a/Hardware/Computer.cs
+++ b/Hardware/Computer.cs
@@ -84,9 +84,15 @@ namespace OpenHardwareMonitor.Hardware {
Ring0.Open();
Opcode.Open();
+ AddGroups();
+
+ open = true;
+ }
+
+ private void AddGroups() {
if (mainboardEnabled)
Add(new Mainboard.MainboardGroup(smbios, settings));
-
+
if (cpuEnabled)
Add(new CPU.CPUGroup(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 {
@@ -347,14 +359,11 @@ namespace OpenHardwareMonitor.Hardware {
}
}
- public void Close() {
+ public void Close() {
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;
diff --git a/Properties/AssemblyVersion.cs b/Properties/AssemblyVersion.cs
index 8489e24..f05e622 100644
--- a/Properties/AssemblyVersion.cs
+++ b/Properties/AssemblyVersion.cs
@@ -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")]