# HG changeset patch
# User moel.mich
# Date 1286480076 0
# Node ID d93ddd6ca0af53b0816cf0188ab39610879d0886
# Parent b5b076457b686f00e824ed3b9a858b8a37468493
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).
diff -r b5b076457b68 -r d93ddd6ca0af GUI/HardwareNode.cs
--- a/GUI/HardwareNode.cs Wed Oct 06 19:50:10 2010 +0000
+++ b/GUI/HardwareNode.cs Thu Oct 07 19:34:36 2010 +0000
@@ -64,6 +64,7 @@
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 -r b5b076457b68 -r d93ddd6ca0af GUI/SensorGadget.cs
--- a/GUI/SensorGadget.cs Wed Oct 06 19:50:10 2010 +0000
+++ b/GUI/SensorGadget.cs Thu Oct 07 19:34:36 2010 +0000
@@ -429,7 +429,8 @@
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 -r b5b076457b68 -r d93ddd6ca0af GUI/SensorNode.cs
--- a/GUI/SensorNode.cs Wed Oct 06 19:50:10 2010 +0000
+++ b/GUI/SensorNode.cs Thu Oct 07 19:34:36 2010 +0000
@@ -74,6 +74,7 @@
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 -r b5b076457b68 -r d93ddd6ca0af GUI/SensorNotifyIcon.cs
--- a/GUI/SensorNotifyIcon.cs Wed Oct 06 19:50:10 2010 +0000
+++ b/GUI/SensorNotifyIcon.cs Thu Oct 07 19:34:36 2010 +0000
@@ -66,7 +66,10 @@
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 @@
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 @@
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 @@
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 @@
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 -r b5b076457b68 -r d93ddd6ca0af GUI/TypeNode.cs
--- a/GUI/TypeNode.cs Wed Oct 06 19:50:10 2010 +0000
+++ b/GUI/TypeNode.cs Thu Oct 07 19:34:36 2010 +0000
@@ -76,6 +76,10 @@
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 -r b5b076457b68 -r d93ddd6ca0af Hardware/ISensor.cs
--- a/Hardware/ISensor.cs Wed Oct 06 19:50:10 2010 +0000
+++ b/Hardware/ISensor.cs Thu Oct 07 19:34:36 2010 +0000
@@ -48,7 +48,8 @@
Load,
Fan,
Flow,
- Control
+ Control,
+ Level
}
public struct SensorValue {
diff -r b5b076457b68 -r d93ddd6ca0af OpenHardwareMonitor.csproj
--- a/OpenHardwareMonitor.csproj Wed Oct 06 19:50:10 2010 +0000
+++ b/OpenHardwareMonitor.csproj Thu Oct 07 19:34:36 2010 +0000
@@ -205,6 +205,9 @@
+
+
+
diff -r b5b076457b68 -r d93ddd6ca0af Resources/level.png
Binary file Resources/level.png has changed