示例#1
0
        /// <summary>
        /// Stops reading data from the motion sensor.
        /// </summary>
        public void Stop()
        {
            if (motion != null)
            {
                motion.CurrentValueChanged -= motion_CurrentValueChanged;
                motion.Stop();

                motion    = null;
                IsRunning = false;
            }
        }
示例#2
0
 /// <summary>
 /// Starts reading data from the motion sensor.
 /// This method throws an exception if <see cref="Microsoft.Devices.Sensors.Motion.IsSupported"/>
 /// is false.
 /// </summary>
 /// <exception cref="InvalidOperationException">Thrown if motion sensor is not supported</exception>
 public void Start()
 {
     if (!IsRunning)
     {
         if (Microsoft.Devices.Sensors.Motion.IsSupported)
         {
             motion = new Microsoft.Devices.Sensors.Motion();
             motion.CurrentValueChanged += motion_CurrentValueChanged;
             motion.Start();
             IsRunning = true;
         }
         else
         {
             throw new InvalidOperationException("Motion sensor not supported on this device");
         }
     }
 }
示例#3
0
        /// <summary>
        /// Stops reading data from the motion sensor.
        /// </summary>
        public void Stop()
        {
            if (motion != null)
            {
                motion.CurrentValueChanged -= motion_CurrentValueChanged;
                motion.Stop();

                motion = null;
                IsRunning = false;
            }
        }
示例#4
0
 /// <summary>
 /// Starts reading data from the motion sensor.
 /// This method throws an exception if <see cref="Microsoft.Devices.Sensors.Motion.IsSupported"/>
 /// is false.
 /// </summary>
 /// <exception cref="InvalidOperationException">Thrown if motion sensor is not supported</exception>
 public void Start()
 {
     if (!IsRunning)
     {
         if (Microsoft.Devices.Sensors.Motion.IsSupported)
         {
             motion = new Microsoft.Devices.Sensors.Motion();
             motion.CurrentValueChanged += motion_CurrentValueChanged;
             motion.Start();
             IsRunning = true;
         }
         else
         {
             throw new InvalidOperationException("Motion sensor not supported on this device");
         }
     }
 }