GUI/HardwareNode.cs
changeset 111 2b8a8cf92c3a
parent 57 142907c75be4
child 118 407f98562c3b
     1.1 --- a/GUI/HardwareNode.cs	Sun May 09 16:22:13 2010 +0000
     1.2 +++ b/GUI/HardwareNode.cs	Fri May 14 22:30:06 2010 +0000
     1.3 @@ -38,7 +38,6 @@
     1.4  using System;
     1.5  using System.Collections.Generic;
     1.6  using System.Drawing;
     1.7 -using Aga.Controls.Tree;
     1.8  using OpenHardwareMonitor.Hardware;
     1.9  
    1.10  namespace OpenHardwareMonitor.GUI {
    1.11 @@ -71,16 +70,8 @@
    1.12        get { return hardware; }
    1.13      }
    1.14  
    1.15 -    public void SetVisible(SensorType sensorType, bool visible) {
    1.16 -      foreach (TypeNode node in typeNodes)
    1.17 -        if (node.SensorType == sensorType) {
    1.18 -          node.IsVisible = visible;
    1.19 -          UpdateNode(node);
    1.20 -        }
    1.21 -    }
    1.22 -
    1.23 -    private void UpdateNode(TypeNode node) {      
    1.24 -      if (node.IsVisible && node.Nodes.Count > 0) {
    1.25 +    private void UpdateNode(TypeNode node) {  
    1.26 +      if (node.Nodes.Count > 0) {
    1.27          if (!Nodes.Contains(node)) {
    1.28            int i = 0;
    1.29            while (i < Nodes.Count &&
    1.30 @@ -95,10 +86,16 @@
    1.31      }
    1.32  
    1.33      private void SensorRemoved(ISensor sensor) {
    1.34 -      foreach (TypeNode node in typeNodes)
    1.35 -        if (node.SensorType == sensor.SensorType) {
    1.36 -          node.Nodes.Remove(new SensorNode(sensor));
    1.37 -          UpdateNode(node);
    1.38 +      foreach (TypeNode typeNode in typeNodes)
    1.39 +        if (typeNode.SensorType == sensor.SensorType) { 
    1.40 +          SensorNode sensorNode = null;
    1.41 +          foreach (Node node in typeNode.Nodes) {
    1.42 +            SensorNode n = node as SensorNode;
    1.43 +            if (n != null && n.Sensor == sensor)
    1.44 +              sensorNode = n;
    1.45 +          }
    1.46 +          typeNode.Nodes.Remove(sensorNode);
    1.47 +          UpdateNode(typeNode);
    1.48          }
    1.49      }
    1.50  
    1.51 @@ -107,15 +104,16 @@
    1.52        while (i < node.Nodes.Count &&
    1.53          ((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index)
    1.54          i++;
    1.55 -      node.Nodes.Insert(i, new SensorNode(sensor));        
    1.56 +      SensorNode sensorNode = new SensorNode(sensor);
    1.57 +      node.Nodes.Insert(i, sensorNode);
    1.58      }
    1.59  
    1.60      private void SensorAdded(ISensor sensor) {
    1.61 -      foreach (TypeNode node in typeNodes)
    1.62 -        if (node.SensorType == sensor.SensorType) {
    1.63 -          InsertSorted(node, sensor);
    1.64 -          UpdateNode(node);
    1.65 +      foreach (TypeNode typeNode in typeNodes)
    1.66 +        if (typeNode.SensorType == sensor.SensorType) {
    1.67 +          InsertSorted(typeNode, sensor);
    1.68 +          UpdateNode(typeNode);          
    1.69          }
    1.70 -    }
    1.71 +    }    
    1.72    }
    1.73  }