/// <summary>Opens a system dialog box to request user permission to access sensor data.</summary> /// <param name="parentWindowHandle">The handle to a window that can act as a parent to the permissions dialog box.</param> /// <param name="modal">Specifies whether the window should be modal.</param> /// <param name="sensors">The sensors for which to request permission.</param> public static void RequestPermission(IntPtr parentWindowHandle, bool modal, SensorList <Sensor> sensors) { if (sensors == null || sensors.Count == 0) { throw new ArgumentException(LocalizedMessages.SensorManagerEmptySensorsCollection, "sensors"); } ISensorCollection sensorCollection = new SensorCollection(); foreach (var sensor in sensors) { sensorCollection.Add(sensor.internalObject); } sensorManager.RequestPermissions(parentWindowHandle, sensorCollection, modal); }
/// <summary> /// Opens a system dialog box to request user permission to access sensor data. /// </summary> /// <param name="parentWindowHandle">The handle to a window that can act as a parent to the permissions dialog box.</param> /// <param name="modal">Specifies whether the window should be modal.</param> /// <param name="sensors">The sensors for which to request permission.</param> public static void RequestPermission(IntPtr parentWindowHandle, bool modal, SensorList <Sensor> sensors) { if (sensors == null && sensors.Count == 0) { throw new ArgumentNullException("sensors", "Sensors collection must not be null or empty."); } ISensorCollection sensorCollection = new SensorCollection( ); foreach (Sensor sensor in sensors) { sensorCollection.Add(sensor.internalObject); } sensorManager.RequestPermissions(parentWindowHandle, sensorCollection, modal); }
internal static SensorList <S> nativeSensorCollectionToSensorCollection <S>(ISensorCollection nativeCollection) where S : Sensor { var sensors = new SensorList <S>(); if (nativeCollection != null) { nativeCollection.GetCount(out var sensorCount); for (uint i = 0; i < sensorCount; i++) { nativeCollection.GetAt(i, out var iSensor); var sensor = GetSensorWrapperInstance <S>(iSensor); if (sensor != null) { sensor.internalObject = iSensor; sensors.Add(sensor); } } } return(sensors); }