From d9ae399ad2f4b000c7d34cdddbb88950306e689b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Thu, 7 Oct 2010 19:34:36 +0000 Subject: [PATCH] Added a new sensor type "Level" for wear or charge level (or any other percentage based sensors that don't fit into Load or Control). --- GUI/HardwareNode.cs | 1 + GUI/SensorGadget.cs | 3 ++- GUI/SensorNode.cs | 1 + GUI/SensorNotifyIcon.cs | 24 ++++++++++++++++++------ GUI/TypeNode.cs | 4 ++++ Hardware/ISensor.cs | 3 ++- OpenHardwareMonitor.csproj | 3 +++ Resources/level.png | Bin 0 -> 290 bytes 8 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 Resources/level.png diff --git a/GUI/HardwareNode.cs b/GUI/HardwareNode.cs index 3c90d34..def8753 100644 --- a/GUI/HardwareNode.cs +++ b/GUI/HardwareNode.cs @@ -64,6 +64,7 @@ namespace OpenHardwareMonitor.GUI { typeNodes.Add(new TypeNode(SensorType.Fan)); typeNodes.Add(new TypeNode(SensorType.Flow)); typeNodes.Add(new TypeNode(SensorType.Control)); + typeNodes.Add(new TypeNode(SensorType.Level)); foreach (ISensor sensor in hardware.Sensors) SensorAdded(sensor); diff --git a/GUI/SensorGadget.cs b/GUI/SensorGadget.cs index ee079c9..684a73f 100644 --- a/GUI/SensorGadget.cs +++ b/GUI/SensorGadget.cs @@ -429,7 +429,8 @@ namespace OpenHardwareMonitor.GUI { if ((sensor.SensorType != SensorType.Load && - sensor.SensorType != SensorType.Control) || !sensor.Value.HasValue) + sensor.SensorType != SensorType.Control && + sensor.SensorType != SensorType.Level) || !sensor.Value.HasValue) { string formatted; diff --git a/GUI/SensorNode.cs b/GUI/SensorNode.cs index 8cb39b9..9d721bf 100644 --- a/GUI/SensorNode.cs +++ b/GUI/SensorNode.cs @@ -74,6 +74,7 @@ namespace OpenHardwareMonitor.GUI { case SensorType.Fan: format = "{0:F0} RPM"; break; case SensorType.Flow: format = "{0:F0} L/h"; break; case SensorType.Control: format = "{0:F1} %"; break; + case SensorType.Level: format = "{0:F1} %"; break; } bool hidden = settings.GetValue(new Identifier(sensor.Identifier, diff --git a/GUI/SensorNotifyIcon.cs b/GUI/SensorNotifyIcon.cs index 46ea599..8a5f704 100644 --- a/GUI/SensorNotifyIcon.cs +++ b/GUI/SensorNotifyIcon.cs @@ -66,7 +66,10 @@ namespace OpenHardwareMonitor.GUI { this.notifyIcon = new NotifyIcon(); Color defaultColor = Color.Black; - if (sensor.SensorType == SensorType.Load) { + if (sensor.SensorType == SensorType.Load || + sensor.SensorType == SensorType.Control || + sensor.SensorType == SensorType.Level) + { defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1); } Color = settings.GetValue(new Identifier(sensor.Identifier, @@ -173,6 +176,8 @@ namespace OpenHardwareMonitor.GUI { return string.Format("{0:F11}", 1e-3f * sensor.Value); case SensorType.Control: return string.Format("{0:F0}", sensor.Value); + case SensorType.Level: + return string.Format("{0:F0}", sensor.Value); } return "-"; } @@ -209,7 +214,7 @@ namespace OpenHardwareMonitor.GUI { return IconFactory.Create(bytes, 16, 16, PixelFormat.Format32bppArgb); } - private Icon CreateLoadIcon() { + private Icon CreatePercentageIcon() { try { graphics.Clear(Color.Transparent); } catch (ArgumentException) { @@ -233,11 +238,17 @@ namespace OpenHardwareMonitor.GUI { public void Update() { Icon icon = notifyIcon.Icon; - if (sensor.SensorType == SensorType.Load) { - notifyIcon.Icon = CreateLoadIcon(); - } else { - notifyIcon.Icon = CreateTransparentIcon(); + switch (sensor.SensorType) { + case SensorType.Load: + case SensorType.Control: + case SensorType.Level: + notifyIcon.Icon = CreatePercentageIcon(); + break; + default: + notifyIcon.Icon = CreateTransparentIcon(); + break; } + if (icon != null) icon.Dispose(); @@ -250,6 +261,7 @@ namespace OpenHardwareMonitor.GUI { case SensorType.Fan: format = "\n{0}: {1:F0} RPM"; break; case SensorType.Flow: format = "\n{0}: {1:F0} L/h"; break; case SensorType.Control: format = "\n{0}: {1:F1} %"; break; + case SensorType.Level: format = "\n{0}: {1:F1} %"; break; } string formattedValue = string.Format(format, sensor.Name, sensor.Value); string hardwareName = sensor.Hardware.Name; diff --git a/GUI/TypeNode.cs b/GUI/TypeNode.cs index eabd722..f53b393 100644 --- a/GUI/TypeNode.cs +++ b/GUI/TypeNode.cs @@ -76,6 +76,10 @@ namespace OpenHardwareMonitor.GUI { this.Image = Utilities.EmbeddedResources.GetImage("control.png"); this.Text = "Controls"; break; + case SensorType.Level: + this.Image = Utilities.EmbeddedResources.GetImage("level.png"); + this.Text = "Levels"; + break; } NodeAdded += new NodeEventHandler(TypeNode_NodeAdded); diff --git a/Hardware/ISensor.cs b/Hardware/ISensor.cs index 3e12069..849d1a4 100644 --- a/Hardware/ISensor.cs +++ b/Hardware/ISensor.cs @@ -48,7 +48,8 @@ namespace OpenHardwareMonitor.Hardware { Load, Fan, Flow, - Control + Control, + Level } public struct SensorValue { diff --git a/OpenHardwareMonitor.csproj b/OpenHardwareMonitor.csproj index 5e27749..41463eb 100644 --- a/OpenHardwareMonitor.csproj +++ b/OpenHardwareMonitor.csproj @@ -205,6 +205,9 @@ + + + diff --git a/Resources/level.png b/Resources/level.png new file mode 100644 index 0000000000000000000000000000000000000000..0c78b538f79f08855b1066b40cf61ac1b57b137e GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgg4E_PvQ;{_9#LV!Y&C9V-A&iT2y zsd*&~&PAz-C8;S2<(VZJ3hti10pX2&;y^{Uo-U3d7N?UF76=#^85kIFM4tYu?*4iA z;(m$91R1|n$4Msj`+v`C1cA;V{eT<>Zf0iY!}r(km;6`r$8*xL{qgn6JOZBr6E=J- zP&(P5Z2ir!X3vK?MfzalK1h4~dp_a0y65Bmc6mv=xQcTYuUemnczGBIv$HTT*dH^R UBt8ErJJ2Bvp00i_>zopr0FtI&eE