private void UpdateSensorPanel(Sensor sensor, StackPanel sensorPanel) { sensorPanel.Children.Clear(); string sType = MySensors.GetSimpleSensorType(sensor.GetSensorType()); if (sensor.description != null) sType = String.Format("{0} {1}", sType, sensor.description); sensorPanel.Children.Add(new TextBlock { Text = sType, Margin = new Thickness(5), Foreground = new SolidColorBrush(Colors.Gray) }); foreach (SensorData data in sensor.sensorData) { StackPanel dataPanel = CreateSensorData(data, sensor); sensorPanel.Children.Add(dataPanel); } }
private StackPanel CreateSensor(Sensor sensor) { StackPanel sensorPanel = new StackPanel(); sensorPanel.Orientation = Orientation.Vertical; sensorPanel.Margin = new Thickness(5); sensorPanel.BorderThickness = new Thickness(1); sensorPanel.BorderBrush = new SolidColorBrush(Colors.Gainsboro); sensorPanel.Background = new SolidColorBrush(Colors.Gray); sensorPanel.Children.Add(new TextBlock { Text = "Sensor id: " + sensor.sensorId, Margin = new Thickness(5), Foreground = new SolidColorBrush(Colors.Gainsboro) }); string sType = (sensor.GetSensorType() == null) ? "unknown" : sensor.GetSensorType().ToString(); sensorPanel.Children.Add(new TextBlock { Text = "Sensor type: " + sType, Margin = new Thickness(5), Foreground = new SolidColorBrush(Colors.Gainsboro) }); if (sensor.description != null) sensorPanel.Children.Add(new TextBlock { Text = "Description: " + sensor.description, Margin = new Thickness(5), Foreground = new SolidColorBrush(Colors.Gainsboro) }); foreach (SensorData data in sensor.sensorData) { StackPanel dataPanel = CreateSensorData(data); sensorPanel.Children.Add(dataPanel); } return sensorPanel; }