public void UpdateFromGaugeSensor(GaugeDeviceSensor sensor) { if (viewSensor == null) { return; } var device = ((GaugeDeviceSensor)viewSensor)?.device; var state = device.connection.connectionState; labelHeader.Text = device.serialNumber.deviceModel.GetTypeString() + ": " + viewSensor.name; imageSensorIcon.Image = DeviceUtil.GetUIImageFromDeviceModel(device.serialNumber.deviceModel); labelMeasurement.Text = sensor.ToFormattedString(); labelUnit.Text = sensor.unit.ToString(); activityConnectStatus.Hidden = EConnectionState.Resolving != sensor.device.connection.connectionState; buttonConnection.Hidden = false; UpdateAlarm(sensor); if (device.isConnected) { UpdateBatteryIcon(device.battery); buttonConnection.SetImage(UIImage.FromBundle("ic_bluetooth_connected"), UIControlState.Normal); buttonConnection.BackgroundColor = UIColor.Green; labelMeasurement.TextColor = new UIColor(Colors.BLACK); labelUnit.TextColor = new UIColor(Colors.BLACK); labelConnectionStatus.Text = "Connected"; labelConnectionStatus.TextColor = UIColor.Green; } else { if (EConnectionState.Broadcasting == device.connection.connectionState) { UpdateBatteryIcon(device.battery); labelConnectionStatus.Text = "Long Range Mode"; labelConnectionStatus.TextColor = UIColor.Blue; } else { labelConnectionStatus.Text = "Disconnected"; labelConnectionStatus.TextColor = UIColor.Red; UpdateBatteryIcon(-1); } buttonConnection.SetImage(UIImage.FromBundle("ic_bluetooth_disconnected"), UIControlState.Normal); buttonConnection.BackgroundColor = UIColor.Red; labelMeasurement.TextColor = new UIColor(Colors.LIGHT_GRAY); labelUnit.TextColor = new UIColor(Colors.LIGHT_GRAY); } }
private void InvalidateSensor(GaugeDeviceSensor sensor, View container) { var title = container.FindViewById <TextView>(Resource.Id.title); var measurement = container.FindViewById <TextView>(Resource.Id.measurement); var state = container.FindViewById <TextView>(Resource.Id.state); var unit = container.FindViewById <TextView>(Resource.Id.unit); title.Text = sensor.type.GetSensorTypeName(); if (sensor.removed) { measurement.Text = "- - - -"; } else { measurement.Text = sensor.ToFormattedString(false); } state.Visibility = ViewStates.Gone; unit.Text = sensor.measurement.unit.ToString(); }