Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the Accelerometer object.
        /// </summary>
        public Accelerometer()
        {
            if (instanceCount >= MaxSensorCount)
                throw new SensorFailedException("The limit of 10 simultaneous instances of the Accelerometer class per application has been exceeded.");
            ++instanceCount;

            state = sensor != null ? SensorState.Initializing : SensorState.NotSupported;
            listener = new SensorListener();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of the Compass object.
        /// </summary>
        public Compass()
        {
            if (instanceCount >= MaxSensorCount)
            {
                throw new SensorFailedException("The limit of 10 simultaneous instances of the Compass class per application has been exceeded.");
            }
            ++instanceCount;

            state    = sensorMagneticField != null ? SensorState.Initializing : SensorState.NotSupported;
            listener = new SensorListener();
        }
Exemplo n.º 3
0
        public Accelerometer()
        {
            if (!IsSupported)
            {
                throw new AccelerometerFailedException("Failed to start accelerometer data acquisition. No default sensor found.", -1);
            }

            else if (instanceCount >= MaxSensorCount)
            {
                throw new SensorFailedException(string.Format("The limit of {0} simultaneous instances of the Accelerometer class per application has been exceeded.", MaxSensorCount));
            }

            ++instanceCount;
#if ANDROID
            state    = sensor != null ? SensorState.Initializing : SensorState.NotSupported;
            listener = new SensorListener();
#elif iOS
            this.TimeBetweenUpdatesChanged += this.UpdateInterval;
            readingChanged += ReadingChangedHandler;
#endif
        }