Task 5– integrate ViewModel and sensor assistants
1. Open SensorViewModel.cs and create a property in the private area to expose the light sensor.
C#
private SensorHelper<AmbientLightSensor, AmbientLightSensor.LuminousIntensity> _sensor;
public SensorHelper<AmbientLightSensor, AmbientLightSensor.LuminousIntensity>
LightSensor
{
get { return _sensor; }
}
2. Now let's do the same thing with the accelerometer.
C#
private SensorHelper<Accelerometer3D, Accelerometer3D.Acceleration3D>
_acceleromaterSensor;
public SensorHelper<Accelerometer3D, Accelerometer3D.Acceleration3D>
AcceleromaterSensor
{
get { return _acceleromaterSensor; }
}
3. We add a structure for Sensorviewmodel to set up the sensor.
C#
public SensorViewModel()
{
_sensor = new SensorHelper<AmbientLightSensor,
AmbientLightSensor.LuminousIntensity>();
_sensor.Initialize();
_acceleromaterSensor = new SensorHelper<Accelerometer3D,
Accelerometer3D.Acceleration3D>();
_acceleromaterSensor.Initialize();
}
4. Compile and test your code. You should be able to run and integrate with the sensor.