GUI/HardwareNode.cs
changeset 327 e837e1e4b282
parent 324 c6ee430d6995
child 340 600962f8a298
     1.1 --- a/GUI/HardwareNode.cs	Sun Jan 01 15:46:42 2012 +0000
     1.2 +++ b/GUI/HardwareNode.cs	Sun Jan 01 17:12:34 2012 +0000
     1.3 @@ -108,9 +108,14 @@
     1.4              if (n != null && n.Sensor == sensor)
     1.5                sensorNode = n;
     1.6            }
     1.7 -          typeNode.Nodes.Remove(sensorNode);
     1.8 -          UpdateNode(typeNode);
     1.9 +          if (sensorNode != null) {
    1.10 +            sensorNode.PlotSelectionChanged -= SensorPlotSelectionChanged;
    1.11 +            typeNode.Nodes.Remove(sensorNode);
    1.12 +            UpdateNode(typeNode);
    1.13 +          }
    1.14          }
    1.15 +      if (PlotSelectionChanged != null)
    1.16 +        PlotSelectionChanged(this, null);
    1.17      }
    1.18  
    1.19      private void InsertSorted(Node node, ISensor sensor) {
    1.20 @@ -119,15 +124,25 @@
    1.21          ((SensorNode)node.Nodes[i]).Sensor.Index < sensor.Index)
    1.22          i++;
    1.23        SensorNode sensorNode = new SensorNode(sensor, settings, unitManager);
    1.24 +      sensorNode.PlotSelectionChanged += SensorPlotSelectionChanged;
    1.25        node.Nodes.Insert(i, sensorNode);
    1.26      }
    1.27  
    1.28 +    private void SensorPlotSelectionChanged(object sender, EventArgs e) {
    1.29 +      if (PlotSelectionChanged != null)
    1.30 +        PlotSelectionChanged(this, null);
    1.31 +    }
    1.32 +
    1.33      private void SensorAdded(ISensor sensor) {
    1.34        foreach (TypeNode typeNode in typeNodes)
    1.35          if (typeNode.SensorType == sensor.SensorType) {
    1.36            InsertSorted(typeNode, sensor);
    1.37            UpdateNode(typeNode);          
    1.38          }
    1.39 -    }    
    1.40 +      if (PlotSelectionChanged != null)
    1.41 +        PlotSelectionChanged(this, null);
    1.42 +    }
    1.43 +
    1.44 +    public event EventHandler PlotSelectionChanged;
    1.45    }
    1.46  }