in sensors/Tools/SensorExplorer/Scenario0_Testing.xaml.cs [108:262]
private async void EnumerateSensors()
{
try
{
rootPage.DisableScenarioSelect();
await Sensor.GetDefault(false);
rootPage.EnableScenarioSelect();
int totalIndex = -1;
SensorType = new List<int>();
totalIndexToIndex = new List<int>();
for (int index = 0; index < Sensor.AccelerometerStandardList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.ACCELEROMETER, index, totalIndex);
SensorType.Add(Sensor.ACCELEROMETER);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.AccelerometerGravityList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.ACCELEROMETERGRAVITY, index, totalIndex);
SensorType.Add(Sensor.ACCELEROMETERGRAVITY);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.AccelerometerLinearList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.ACCELEROMETERLINEAR, index, totalIndex);
SensorType.Add(Sensor.ACCELEROMETERLINEAR);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.ActivitySensorList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.ACTIVITYSENSOR, index, totalIndex);
SensorType.Add(Sensor.ACTIVITYSENSOR);
totalIndexToIndex.Add(index);
}
if (Sensor.Altimeter != null)
{
totalIndex++;
AddPivotItem(Sensor.ALTIMETER, 0, totalIndex);
SensorType.Add(Sensor.ALTIMETER);
totalIndexToIndex.Add(0);
}
for (int index = 0; index < Sensor.BarometerList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.BAROMETER, index, totalIndex);
SensorType.Add(Sensor.BAROMETER);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.CompassList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.COMPASS, index, totalIndex);
SensorType.Add(Sensor.COMPASS);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.CustomSensorList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.CUSTOMSENSOR, index, totalIndex);
SensorType.Add(Sensor.CUSTOMSENSOR);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.GyrometerList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.GYROMETER, index, totalIndex);
SensorType.Add(Sensor.GYROMETER);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.InclinometerList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.INCLINOMETER, index, totalIndex);
SensorType.Add(Sensor.INCLINOMETER);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.LightSensorList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.LIGHTSENSOR, index, totalIndex);
SensorType.Add(Sensor.LIGHTSENSOR);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.MagnetometerList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.MAGNETOMETER, index, totalIndex);
SensorType.Add(Sensor.MAGNETOMETER);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.OrientationAbsoluteList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.ORIENTATIONSENSOR, index, totalIndex);
SensorType.Add(Sensor.ORIENTATIONSENSOR);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.OrientationGeomagneticList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.ORIENTATIONGEOMAGNETIC, index, totalIndex);
SensorType.Add(Sensor.ORIENTATIONGEOMAGNETIC);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.OrientationRelativeList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.ORIENTATIONRELATIVE, index, totalIndex);
SensorType.Add(Sensor.ORIENTATIONRELATIVE);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.PedometerList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.PEDOMETER, index, totalIndex);
SensorType.Add(Sensor.PEDOMETER);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.ProximitySensorList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.PROXIMITYSENSOR, index, totalIndex);
SensorType.Add(Sensor.PROXIMITYSENSOR);
totalIndexToIndex.Add(index);
}
for (int index = 0; index < Sensor.SimpleOrientationSensorList.Count; index++)
{
totalIndex++;
AddPivotItem(Sensor.SIMPLEORIENTATIONSENSOR, index, totalIndex);
SensorType.Add(Sensor.SIMPLEORIENTATIONSENSOR);
totalIndexToIndex.Add(0);
}
rootPage.NotifyUser("Number of sensors: " + pivotSensor.Items.Count + "\nNumber of sensors failed to enumerate: " + Sensor.NumFailedEnumerations, NotifyType.StatusMessage);
if (pivotSensor.Items.Count > 0)
{
pivotSensor.SelectionChanged += PivotSensorSelectionChanged;
pivotSensor.SelectedIndex = 0;
PivotSensorSelectionChanged(null, null);
}
else
{
textBlockNoSensor.Text = ResourceLoader.GetForCurrentView().GetString("CannotFindSensor");
}
}
catch (Exception ex)
{
rootPage.NotifyUser(ex.Message, NotifyType.ErrorMessage);
}
}