Exemplo n.º 1
0
 private void EnableDisplayOnOffController()
 {
     if (_sensor != null && _displayController == null)
     {
         // Acquires the display on/off controller for this proximity sensor.
         // This tells the system to use the sensor's IsDetected state to
         // turn the screen on or off.  If the display does not support this
         // feature, this code will do nothing.
         _displayController = _sensor.CreateDisplayOnOffController();
     }
 }
Exemplo n.º 2
0
        private async Task AttachAsync()
        {
            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
            {
                var devices = await DeviceInformation.FindAllAsync(ProximitySensor.GetDeviceSelector());

                if (devices.Count > 0)
                {
                    _sensor = ProximitySensor.FromId(devices[0].Id);
                    //_sensor.ReadingChanged += OnReadingChanged;

                    _controller = _sensor.CreateDisplayOnOffController();
                }
            }
        }
Exemplo n.º 3
0
 public void EnableDisplayAutoOff(bool _enabled)
 {
     if (_enabled)
     {
         if ((_sensor != null) && (_displayController == null))
         {
             _displayController = _sensor.CreateDisplayOnOffController();
         }
     }
     else
     {
         if (_displayController != null)
         {
             _displayController.Dispose();
             _displayController = null;
         }
     }
 }
        /// <summary>
        /// This is the click handler for the 'Enable' button.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ScenarioEnable(object sender, RoutedEventArgs e)
        {
            if (null != sensor)
            {
                // Acquires the display on/off controller for this proximity sensor.
                // This tells the system to use the sensor's IsDetected state to
                // turn the screen on or off.  If the display does not support this
                // feature, this code will do nothing.
                displayController = sensor.CreateDisplayOnOffController();

                ScenarioEnableButton.IsEnabled  = false;
                ScenarioDisableButton.IsEnabled = true;
            }
            else
            {
                rootPage.NotifyUser("No proximity sensors found", NotifyType.ErrorMessage);
            }
        }