in sensors/Tools/SensorExplorer/Scenario1_View.xaml.cs [126:282]
private async void EnumerateSensors()
{
try
{
rootPage.DisableScenarioSelect();
await Sensor.GetDefault(true);
rootPage.EnableScenarioSelect();
int totalIndex = -1;
for (int index = 0; index < Sensor.AccelerometerStandardList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.ACCELEROMETER, index, totalIndex, -2, 2, 2, Constants.AccelerometerColors));
Sensor.SensorData.Add(new SensorData(Sensor.ACCELEROMETER, totalIndex, Constants.AccelerometerPropertyTitles));
AddPivotItem(Sensor.ACCELEROMETER, index, totalIndex);
}
for (int index = 0; index < Sensor.AccelerometerGravityList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.ACCELEROMETERGRAVITY, index, totalIndex, -2, 2, 2, Constants.AccelerometerColors));
Sensor.SensorData.Add(new SensorData(Sensor.ACCELEROMETERGRAVITY, totalIndex, Constants.AccelerometerPropertyTitles));
AddPivotItem(Sensor.ACCELEROMETERGRAVITY, index, totalIndex);
}
for (int index = 0; index < Sensor.AccelerometerLinearList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.ACCELEROMETERLINEAR, index, totalIndex, -2, 2, 2, Constants.AccelerometerColors));
Sensor.SensorData.Add(new SensorData(Sensor.ACCELEROMETERLINEAR, totalIndex, Constants.AccelerometerPropertyTitles));
AddPivotItem(Sensor.ACCELEROMETERLINEAR, index, totalIndex);
}
for (int index = 0; index < Sensor.ActivitySensorList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.ACTIVITYSENSOR, index, totalIndex, 2, 0, 2, Constants.ActivitySensorColors));
Sensor.SensorData.Add(new SensorData(Sensor.ACTIVITYSENSOR, totalIndex, Constants.ActivitySensorPropertyTitles));
AddPivotItem(Sensor.ACTIVITYSENSOR, index, totalIndex);
}
if (Sensor.Altimeter != null)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.ALTIMETER, 0, totalIndex, -10, 10, 2, Constants.AltimeterColors));
Sensor.SensorData.Add(new SensorData(Sensor.ALTIMETER, totalIndex, Constants.AltimeterPropertyTitles));
AddPivotItem(Sensor.ALTIMETER, 0, totalIndex);
}
for (int index = 0; index < Sensor.BarometerList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.BAROMETER, index, totalIndex, 950, 1050, 2, Constants.BarometerColors));
Sensor.SensorData.Add(new SensorData(Sensor.BAROMETER, totalIndex, Constants.BarometerPropertyTitles));
AddPivotItem(Sensor.BAROMETER, index, totalIndex);
}
for (int index = 0; index < Sensor.CompassList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.COMPASS, index, totalIndex, 0, 360, 2, Constants.CompassColors));
Sensor.SensorData.Add(new SensorData(Sensor.COMPASS, totalIndex, Constants.CompassPropertyTitles));
AddPivotItem(Sensor.COMPASS, index, totalIndex);
}
for (int index = 0; index < Sensor.CustomSensorList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.CUSTOMSENSOR, index, totalIndex, 0, 360, 2, Constants.CustomSensorColors));
Sensor.SensorData.Add(new SensorData(Sensor.CUSTOMSENSOR, totalIndex, Constants.CustomSensorPropertyTitles));
AddPivotItem(Sensor.CUSTOMSENSOR, index, totalIndex);
}
for (int index = 0; index < Sensor.GyrometerList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.GYROMETER, index, totalIndex, -200, 200, 2, Constants.GyrometerColors));
Sensor.SensorData.Add(new SensorData(Sensor.GYROMETER, totalIndex, Constants.GyrometerPropertyTitles));
AddPivotItem(Sensor.GYROMETER, index, totalIndex);
}
for (int index = 0; index < Sensor.InclinometerList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.INCLINOMETER, index, totalIndex, -180, 360, 3, Constants.InclinometerColors));
Sensor.SensorData.Add(new SensorData(Sensor.INCLINOMETER, totalIndex, Constants.InclinometerPropertyTitles));
AddPivotItem(Sensor.INCLINOMETER, index, totalIndex);
}
for (int index = 0; index < Sensor.LightSensorList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.LIGHTSENSOR, index, totalIndex, 0, 1000, 2, Constants.LightSensorColors));
Sensor.SensorData.Add(new SensorData(Sensor.LIGHTSENSOR, totalIndex, Constants.LightSensorPropertyTitles));
AddPivotItem(Sensor.LIGHTSENSOR, index, totalIndex);
}
for (int index = 0; index < Sensor.MagnetometerList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.MAGNETOMETER, index, totalIndex, -500, 500, 2, Constants.MagnetometerColors));
Sensor.SensorData.Add(new SensorData(Sensor.MAGNETOMETER, totalIndex, Constants.MagnetometerPropertyTitles));
AddPivotItem(Sensor.MAGNETOMETER, index, totalIndex);
}
for (int index = 0; index < Sensor.OrientationAbsoluteList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.ORIENTATIONSENSOR, index, totalIndex, -1, 1, 2, Constants.OrientationSensorColors));
Sensor.SensorData.Add(new SensorData(Sensor.ORIENTATIONSENSOR, totalIndex, Constants.OrientationSensorPropertyTitles));
AddPivotItem(Sensor.ORIENTATIONSENSOR, index, totalIndex);
}
for (int index = 0; index < Sensor.OrientationGeomagneticList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.ORIENTATIONGEOMAGNETIC, index, totalIndex, -1, 1, 2, Constants.OrientationSensorColors));
Sensor.SensorData.Add(new SensorData(Sensor.ORIENTATIONGEOMAGNETIC, totalIndex, Constants.OrientationSensorPropertyTitles));
AddPivotItem(Sensor.ORIENTATIONGEOMAGNETIC, index, totalIndex);
}
for (int index = 0; index < Sensor.OrientationRelativeList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.ORIENTATIONRELATIVE, index, totalIndex, -1, 1, 2, Constants.OrientationSensorColors));
Sensor.SensorData.Add(new SensorData(Sensor.ORIENTATIONRELATIVE, totalIndex, Constants.OrientationSensorPropertyTitles));
AddPivotItem(Sensor.ORIENTATIONRELATIVE, index, totalIndex);
}
for (int index = 0; index < Sensor.PedometerList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.PEDOMETER, index, totalIndex, 0, 50, 2, Constants.PedometerColors));
Sensor.SensorData.Add(new SensorData(Sensor.PEDOMETER, totalIndex, Constants.PedometerPropertyTitles));
AddPivotItem(Sensor.PEDOMETER, index, totalIndex);
}
for (int index = 0; index < Sensor.ProximitySensorList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.PROXIMITYSENSOR, index, totalIndex, 0, 3000, 3, Constants.ProximitySensorColors));
Sensor.SensorData.Add(new SensorData(Sensor.PROXIMITYSENSOR, totalIndex, Constants.ProximitySensorPropertyTitles));
AddPivotItem(Sensor.PROXIMITYSENSOR, index, totalIndex);
}
for (int index = 0; index < Sensor.SimpleOrientationSensorList.Count; index++)
{
totalIndex++;
Sensor.SensorDisplay.Add(new SensorDisplay(Sensor.SIMPLEORIENTATIONSENSOR, index, totalIndex, 0, 5, 5, Constants.SimpleOrientationSensorColors));
Sensor.SensorData.Add(new SensorData(Sensor.SIMPLEORIENTATIONSENSOR, totalIndex, Constants.SimpleOrientationSensorPropertyTitles));
AddPivotItem(Sensor.SIMPLEORIENTATIONSENSOR, index, totalIndex);
}
AddSummaryPage();
rootPage.NotifyUser("Number of sensors: " + (PivotSensor.Items.Count - 1) + "\nNumber of sensors failed to enumerate: " + Sensor.NumFailedEnumerations, NotifyType.StatusMessage);
ProgressRingSensor.IsActive = false;
if (PivotSensor.Items.Count > 1) // 1 for Summary Page which always exists
{
PivotSensor.SelectionChanged += PivotSensorSelectionChanged;
PivotSensor.SelectedIndex = 0;
PivotSensorSelectionChanged(null, null);
}
}
catch (Exception ex)
{
rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
}
ProgressRingSensor.IsActive = false;
}