Fixed the following Exception:
authormoel.mich
Sat, 15 May 2010 11:34:36 +0000
changeset 116c92e98bc2073
parent 115 03d3325e85d4
child 117 14329d236f05
Fixed the following Exception:

System.ArgumentOutOfRangeException: ??? ??? 64? ????? ???.
?? ?? ??: Text
?? ?? ATI Radeon HD 4800 Series (Microsoft Corporation WDDM 1.1)
GPU Core: 56.5 ?C???.
??: System.Windows.Forms.NotifyIcon.set_Text(String value)
??: OpenHardwareMonitor.GUI.SensorNotifyIcon.Update()
??: OpenHardwareMonitor.GUI.SensorSystemTray.Redraw()
??: System.Windows.Forms.Timer.OnTick(EventArgs e)
??: System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
??: System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
GUI/SensorNotifyIcon.cs
     1.1 --- a/GUI/SensorNotifyIcon.cs	Sat May 15 11:20:50 2010 +0000
     1.2 +++ b/GUI/SensorNotifyIcon.cs	Sat May 15 11:34:36 2010 +0000
     1.3 @@ -227,16 +227,22 @@
     1.4  
     1.5        string format = "";
     1.6        switch (sensor.SensorType) {
     1.7 -        case SensorType.Voltage: format = "{0}\n{1}: {2:F2} V"; break;
     1.8 -        case SensorType.Clock: format = "{0}\n{1}: {2:F0} MHz"; break;
     1.9 -        case SensorType.Load: format = "{0}\n{1}: {2:F1} %"; break;
    1.10 -        case SensorType.Temperature: format = "{0}\n{1}: {2:F1} °C"; break;
    1.11 -        case SensorType.Fan: format = "{0}\n{1}: {2:F0} RPM"; break;
    1.12 -        case SensorType.Flow: format = "{0}\n{1}: {2:F0} L/h"; break;
    1.13 +        case SensorType.Voltage: format = "\n{0}: {1:F2} V"; break;
    1.14 +        case SensorType.Clock: format = "\n{0}: {1:F0} MHz"; break;
    1.15 +        case SensorType.Load: format = "\n{0}: {1:F1} %"; break;
    1.16 +        case SensorType.Temperature: format = "\n{0}: {1:F1} °C"; break;
    1.17 +        case SensorType.Fan: format = "\n{0}: {1:F0} RPM"; break;
    1.18 +        case SensorType.Flow: format = "\n{0}: {1:F0} L/h"; break;
    1.19        }
    1.20 +      string formattedValue = string.Format(format, sensor.Name, sensor.Value);
    1.21 +      string hardwareName = sensor.Hardware.Name;
    1.22 +      hardwareName = hardwareName.Substring(0, 
    1.23 +        Math.Min(63 - formattedValue.Length, hardwareName.Length));
    1.24 +      string text = hardwareName + formattedValue;
    1.25 +      if (text.Length > 63)
    1.26 +        text = null;
    1.27  
    1.28 -      notifyIcon.Text = string.Format(format, sensor.Hardware.Name, sensor.Name,
    1.29 -        sensor.Value);    
    1.30 +      notifyIcon.Text = text;
    1.31        notifyIcon.Visible = true;         
    1.32      }
    1.33    }