GUI/SensorNotifyIcon.cs
changeset 217 d93ddd6ca0af
parent 202 551243a66b32
child 252 e62afa69214f
     1.1 --- a/GUI/SensorNotifyIcon.cs	Wed Oct 06 19:50:10 2010 +0000
     1.2 +++ b/GUI/SensorNotifyIcon.cs	Thu Oct 07 19:34:36 2010 +0000
     1.3 @@ -66,7 +66,10 @@
     1.4        this.notifyIcon = new NotifyIcon();
     1.5  
     1.6        Color defaultColor = Color.Black;
     1.7 -      if (sensor.SensorType == SensorType.Load) {
     1.8 +      if (sensor.SensorType == SensorType.Load ||
     1.9 +          sensor.SensorType == SensorType.Control ||
    1.10 +          sensor.SensorType == SensorType.Level) 
    1.11 +      {
    1.12          defaultColor = Color.FromArgb(0xff, 0x70, 0x8c, 0xf1);
    1.13        }
    1.14        Color = settings.GetValue(new Identifier(sensor.Identifier, 
    1.15 @@ -173,6 +176,8 @@
    1.16            return string.Format("{0:F11}", 1e-3f * sensor.Value);
    1.17          case SensorType.Control:
    1.18            return string.Format("{0:F0}", sensor.Value);
    1.19 +        case SensorType.Level:
    1.20 +          return string.Format("{0:F0}", sensor.Value);
    1.21        }
    1.22        return "-";
    1.23      }
    1.24 @@ -209,7 +214,7 @@
    1.25        return IconFactory.Create(bytes, 16, 16, PixelFormat.Format32bppArgb);
    1.26      }
    1.27  
    1.28 -    private Icon CreateLoadIcon() {      
    1.29 +    private Icon CreatePercentageIcon() {      
    1.30        try {
    1.31          graphics.Clear(Color.Transparent);
    1.32        } catch (ArgumentException) {
    1.33 @@ -233,11 +238,17 @@
    1.34      public void Update() {
    1.35        Icon icon = notifyIcon.Icon;
    1.36  
    1.37 -      if (sensor.SensorType == SensorType.Load) {
    1.38 -        notifyIcon.Icon = CreateLoadIcon();
    1.39 -      } else {
    1.40 -        notifyIcon.Icon = CreateTransparentIcon();
    1.41 +      switch (sensor.SensorType) {
    1.42 +        case SensorType.Load:
    1.43 +        case SensorType.Control:
    1.44 +        case SensorType.Level:
    1.45 +          notifyIcon.Icon = CreatePercentageIcon();
    1.46 +          break;
    1.47 +        default:
    1.48 +          notifyIcon.Icon = CreateTransparentIcon();
    1.49 +          break;
    1.50        }
    1.51 +
    1.52        if (icon != null) 
    1.53          icon.Dispose();
    1.54  
    1.55 @@ -250,6 +261,7 @@
    1.56          case SensorType.Fan: format = "\n{0}: {1:F0} RPM"; break;
    1.57          case SensorType.Flow: format = "\n{0}: {1:F0} L/h"; break;
    1.58          case SensorType.Control: format = "\n{0}: {1:F1} %"; break;
    1.59 +        case SensorType.Level: format = "\n{0}: {1:F1} %"; break;
    1.60        }
    1.61        string formattedValue = string.Format(format, sensor.Name, sensor.Value);
    1.62        string hardwareName = sensor.Hardware.Name;