GUI/SensorSystemTray.cs
changeset 42 47385d4fc990
parent 40 2392f7402fb6
child 64 15181001ee61
     1.1 --- a/GUI/SensorSystemTray.cs	Fri Feb 12 08:17:51 2010 +0000
     1.2 +++ b/GUI/SensorSystemTray.cs	Fri Feb 12 22:46:31 2010 +0000
     1.3 @@ -37,6 +37,7 @@
     1.4  
     1.5  using System;
     1.6  using System.Collections.Generic;
     1.7 +using System.Drawing;
     1.8  using System.Text;
     1.9  using System.Windows.Forms;
    1.10  using OpenHardwareMonitor.Hardware;
    1.11 @@ -69,14 +70,12 @@
    1.12  
    1.13      private void SensorAdded(ISensor sensor) {
    1.14        if (Config.Get(sensor.Identifier + "/tray", false)) 
    1.15 -        Add(sensor);   
    1.16 +        Add(sensor, false);   
    1.17      }
    1.18  
    1.19      private void SensorRemoved(ISensor sensor) {
    1.20 -      if (Contains(sensor)) {        
    1.21 -        Remove(sensor);
    1.22 -        Config.Set(sensor.Identifier + "/tray", true);
    1.23 -      }
    1.24 +      if (Contains(sensor)) 
    1.25 +        Remove(sensor, false);
    1.26      }
    1.27  
    1.28      public void Dispose() {
    1.29 @@ -96,17 +95,24 @@
    1.30        return false;
    1.31      }
    1.32  
    1.33 -    public void Add(ISensor sensor) {
    1.34 +    public void Add(ISensor sensor, bool balloonTip) {
    1.35        if (Contains(sensor)) {
    1.36          return;
    1.37 -      } else {
    1.38 -        list.Add(new SensorNotifyIcon(this, sensor));
    1.39 +      } else {        
    1.40 +        list.Add(new SensorNotifyIcon(this, sensor, balloonTip));
    1.41          Config.Set(sensor.Identifier + "/tray", true);
    1.42        }
    1.43      }
    1.44  
    1.45      public void Remove(ISensor sensor) {
    1.46 -      Config.Remove(sensor.Identifier + "/tray");
    1.47 +      Remove(sensor, true);
    1.48 +    }
    1.49 +
    1.50 +    private void Remove(ISensor sensor, bool deleteConfig) {
    1.51 +      if (deleteConfig) {
    1.52 +        Config.Remove(sensor.Identifier + "/tray");
    1.53 +        Config.Remove(sensor.Identifier + "/traycolor");
    1.54 +      }
    1.55        SensorNotifyIcon instance = null;
    1.56        foreach (SensorNotifyIcon icon in list)
    1.57          if (icon.Sensor == sensor)