Skip to content

Commit 8830f3d

Browse files
committed
tray hint decimal digits fix for Power & Data
1 parent 58163e2 commit 8830f3d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

OpenHardwareMonitor/UI/SensorNotifyIcon.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ private Icon CreatePercentageIcon()
312312
public void Update(bool showPercentageIcons)
313313
{
314314
Icon icon = _notifyIcon.Icon;
315-
316315
switch (Sensor.SensorType)
317316
{
318317
case SensorType.Load:
@@ -324,10 +323,9 @@ public void Update(bool showPercentageIcons)
324323
_notifyIcon.Icon = CreateTransparentIcon();
325324
break;
326325
}
327-
328326
icon?.Destroy();
329327

330-
string format = "";
328+
string format;
331329
switch (Sensor.SensorType)
332330
{
333331
case SensorType.Voltage: format = "\n{0}: {1:F2} V"; break;
@@ -339,33 +337,36 @@ public void Update(bool showPercentageIcons)
339337
case SensorType.Flow: format = "\n{0}: {1:F0} L/h"; break;
340338
case SensorType.Control: format = "\n{0}: {1:F1} %"; break;
341339
case SensorType.Level: format = "\n{0}: {1:F1} %"; break;
342-
case SensorType.Power: format = "\n{0}: {1:F1} W"; break;
343-
case SensorType.Data: format = "\n{0}: {1:F0} GB"; break;
340+
case SensorType.Power: format = "\n{0}: {1:F2} W"; break;
341+
case SensorType.Data: format = "\n{0}: {1:F2} GB"; break;
344342
case SensorType.Factor: format = "\n{0}: {1:F3}"; break;
345343
case SensorType.IntFactor: format = "\n{0}: {1:F0}"; break;
346344
case SensorType.Energy: format = "\n{0}: {0:F0} mWh"; break;
347345
case SensorType.Noise: format = "\n{0}: {0:F0} dBA"; break;
348346
case SensorType.Conductivity: format = "\n{0}: {0:F1} µS/cm"; break;
349347
case SensorType.Humidity: format = "\n{0}: {0:F0} %"; break;
348+
default: format = "\n{0}: {1}"; break;
350349
}
351350

352-
string formattedValue = string.Format(format, Sensor.Name, Sensor.Value);
353-
351+
string formattedValue;
354352
if (Sensor.SensorType == SensorType.Temperature && UnitManager.IsFahrenheitUsed)
355353
{
356-
format = "\n{0}: {1:F1} °F";
357-
formattedValue = string.Format(format, Sensor.Name, UnitManager.CelsiusToFahrenheit(Sensor.Value));
354+
formattedValue = string.Format("\n{0}: {1:F1} °F", Sensor.Name, UnitManager.CelsiusToFahrenheit(Sensor.Value));
358355
}
359356
else if (Sensor.SensorType == SensorType.Throughput && !"Connection Speed".Equals(Sensor.Name))
360357
{
361358
formattedValue = $"\n{Sensor.Name}: {GetThroughputValue(Sensor.Value ?? 0, 0, true)}/s";
362359
}
360+
else
361+
{
362+
formattedValue = string.Format(format, Sensor.Name, Sensor.Value);
363+
}
363364

364365
string hardwareName = Sensor.Hardware.Name;
365366
hardwareName = hardwareName.Substring(0, Math.Min(63 - formattedValue.Length, hardwareName.Length));
366367
string text = hardwareName + formattedValue;
367368
if (text.Length > 63)
368-
text = null;
369+
text = text.Substring(0, 63);
369370

370371
_notifyIcon.Text = text;
371372
_notifyIcon.Visible = true;

0 commit comments

Comments
 (0)