GUI/SensorNode.cs
changeset 165 813d8bc3192f
parent 134 8b3b9b2e28e5
child 166 fa9dfbfc4145
     1.1 --- a/GUI/SensorNode.cs	Thu Aug 05 19:28:50 2010 +0000
     1.2 +++ b/GUI/SensorNode.cs	Sun Aug 08 13:57:26 2010 +0000
     1.3 @@ -44,13 +44,15 @@
     1.4    public class SensorNode : Node {
     1.5      
     1.6      private ISensor sensor;
     1.7 +    private PersistentSettings settings;
     1.8 +    private UnitManager unitManager;
     1.9      private string format;
    1.10 -    private bool plot = false;
    1.11 +    private bool plot = false;       
    1.12  
    1.13      public string ValueToString(float? value) {
    1.14        if (value.HasValue) {
    1.15          if (sensor.SensorType == SensorType.Temperature && 
    1.16 -          UnitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
    1.17 +          unitManager.TemperatureUnit == TemperatureUnit.Fahrenheit) {
    1.18            return string.Format("{0:F1} °F", value * 1.8 + 32);
    1.19          } else {
    1.20            return string.Format(format, value);
    1.21 @@ -59,8 +61,11 @@
    1.22          return "-";
    1.23      }
    1.24  
    1.25 -    public SensorNode(ISensor sensor) : base() {
    1.26 +    public SensorNode(ISensor sensor, PersistentSettings settings, 
    1.27 +      UnitManager unitManager) : base() {      
    1.28        this.sensor = sensor;
    1.29 +      this.settings = settings;
    1.30 +      this.unitManager = unitManager;
    1.31        switch (sensor.SensorType) {
    1.32          case SensorType.Voltage: format = "{0:F2} V"; break;
    1.33          case SensorType.Clock: format = "{0:F0} MHz"; break;
    1.34 @@ -71,7 +76,7 @@
    1.35          case SensorType.Control: format = "{0:F1} %"; break;
    1.36        }
    1.37  
    1.38 -      bool hidden = Config.Get(new Identifier(sensor.Identifier, 
    1.39 +      bool hidden = settings.Get(new Identifier(sensor.Identifier, 
    1.40          "hidden").ToString(), sensor.IsDefaultHidden);
    1.41        base.IsVisible = !hidden;
    1.42      }
    1.43 @@ -85,7 +90,7 @@
    1.44        get { return base.IsVisible; }
    1.45        set { 
    1.46          base.IsVisible = value;
    1.47 -        Config.Set(new Identifier(sensor.Identifier,
    1.48 +        settings.Set(new Identifier(sensor.Identifier,
    1.49            "hidden").ToString(), !value);
    1.50        }
    1.51      }