Skip to content

Commit 4878766

Browse files
committed
round tray value for data sensors
1 parent 8830f3d commit 4878766

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

OpenHardwareMonitor/UI/SensorNotifyIcon.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ private string GetString()
179179
case SensorType.Energy:
180180
case SensorType.Power:
181181
case SensorType.Data:
182-
return Sensor.Value.Value < 10
183-
? $"{Sensor.Value:0.00}".Substring(0, 3)
184-
: $"{Sensor.Value:F0}";
182+
return Sensor.Value.Value.ToTrayValue();
185183
default:
186184
return "-";
187185
}

OpenHardwareMonitor/Utilities/IconFactory.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,10 @@ public static void Destroy(this Icon icon)
188188
DestroyIcon(icon.Handle);
189189
icon.Dispose();
190190
}
191+
192+
public static string ToTrayValue(this float value)
193+
{
194+
double rounded1 = Math.Round(value, 1);
195+
return rounded1 < 10 ? rounded1.ToString("0.0") : Math.Round(value).ToString("0");
196+
}
191197
}

0 commit comments

Comments
 (0)