Beispiel #1
0
        /// <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 (Sensor sensor in sensors)
            {
                sensorCollection.Add(sensor.internalObject);
            }

            sensorManager.RequestPermissions(parentWindowHandle, sensorCollection, modal);
        }
Beispiel #2
0
        internal static SensorList <S> nativeSensorCollectionToSensorCollection <S>(ISensorCollection nativeCollection) where S : Sensor
        {
            SensorList <S> sensors = new SensorList <S>();

            if (nativeCollection != null)
            {
                uint sensorCount = 0;
                nativeCollection.GetCount(out sensorCount);

                for (uint i = 0; i < sensorCount; i++)
                {
                    ISensor iSensor = null;
                    nativeCollection.GetAt(i, out iSensor);
                    S sensor = GetSensorWrapperInstance <S>(iSensor);
                    if (sensor != null)
                    {
                        sensor.internalObject = iSensor;
                        sensors.Add(sensor);
                    }
                }
            }

            return(sensors);
        }