/// <summary>
 /// Error handling for device level error conditions
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 public async void OnAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         if (DeviceAccessStatus.DeniedByUser == args.Status)
         {
             Debug.WriteLine("Location has been disabled by the user. Enable access through the settings charm.");
         }
         else if (DeviceAccessStatus.DeniedBySystem == args.Status)
         {
             Debug.WriteLine("Location has been disabled by the system. The administrator of the device must enable location access through the location control panel.");
         }
         else if (DeviceAccessStatus.Unspecified == args.Status)
         {
             Debug.WriteLine("Location has been disabled by unspecified source. The administrator of the device may need to enable location access through the location control panel, then enable access through the settings charm.");
         }
         else if (DeviceAccessStatus.Allowed == args.Status)
         {
         }
         else
         {
             Debug.WriteLine("Unknown device access information status");
         }
     });
 }
Exemple #2
0
        public async void OnAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs args)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var status = args.Status;

                string eventDescription = GetTimeStampedMessage("Device Access Status");

                eventDescription += " (" + status.ToString() + ")";

                AddEventDescription(eventDescription);

                if (DeviceAccessStatus.DeniedByUser == args.Status)
                {
                    rootPage.NotifyUser("Location has been disabled by the user. Enable access through the settings charm.", NotifyType.StatusMessage);
                }
                else if (DeviceAccessStatus.DeniedBySystem == args.Status)
                {
                    rootPage.NotifyUser("Location has been disabled by the system. The administrator of the device must enable location access through the location control panel.", NotifyType.StatusMessage);
                }
                else if (DeviceAccessStatus.Unspecified == args.Status)
                {
                    rootPage.NotifyUser("Location has been disabled by unspecified source. The administrator of the device may need to enable location access through the location control panel, then enable access through the settings charm.", NotifyType.StatusMessage);
                }
                else if (DeviceAccessStatus.Allowed == args.Status)
                {
                    // clear status
                    rootPage.NotifyUser("", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Unknown device access information status", NotifyType.StatusMessage);
                }
            });
        }
 /// <summary>
 /// Close the device if the device access was denied by anyone (system or the user) and reopen it if permissions are allowed again
 /// </summary>
 private async void OnDeviceAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs eventArgs)
 {
     if ((eventArgs.Status == DeviceAccessStatus.DeniedBySystem) || (eventArgs.Status == DeviceAccessStatus.DeniedByUser))
     {
         CloseCurrentlyConnectedDevice();
     }
     else if ((eventArgs.Status == DeviceAccessStatus.Allowed) && (DeviceInformation != null) && IsEnabledAutoReconnect)
     {
         await OpenDeviceAsync(DeviceInformation);
     }
 }
 /// <summary>
 /// Close the device if the device access was denied by anyone (system or the user) and reopen it if permissions are allowed again
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="eventArgs"></param>
 private void OnDeviceAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs eventArgs)
 {
     if ((eventArgs.Status == DeviceAccessStatus.DeniedBySystem) ||
         (eventArgs.Status == DeviceAccessStatus.DeniedByUser))
     {
         CloseCurrentlyConnectedDevice();
     }
     else if ((eventArgs.Status == DeviceAccessStatus.Allowed) && (_deviceInformation != null))
     {
     }
 }
        /// <summary>
        /// Invoked when ActivitySensor device access gets changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void DeviceAccessInfo_AccessChangedAsync(DeviceAccessInformation sender, DeviceAccessChangedEventArgs args)
        {
            var status = args.Status;

            if (status == DeviceAccessStatus.Allowed)
            {
                await InitializeAsync();
            }
            else
            {
                Release();
            }
        }
        /// <summary>
        /// This is the event handler for AccessChanged events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void OnAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs e)
        {
            var status = e.Status;

            if (status != DeviceAccessStatus.Allowed)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    rootPage.NotifyUser("Custom sensor access denied", NotifyType.ErrorMessage);
                    customSensor = null;
                });
            }
        }
Exemple #7
0
 private static void OnAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs args)
 {
     if (Dispatcher != null)
     {
         Dispatcher.BeginInvoke(() =>
         {
             OnAccessChanged(args);
         });
     }
     else
     {
         OnAccessChanged(args);
     }
 }
        /// <summary>
        /// This is the event handler for AccessChanged events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async private void AccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs e)
        {
            var status = e.Status;

            if (status != DeviceAccessStatus.Allowed)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    rootPage.NotifyUser("Access denied to pedometers", NotifyType.ErrorMessage);
                    pedometer = null;

                    registeredForEvents    = false;
                    RegisterButton.Content = "Register ReadingChanged";
                });
            }
        }
        /// <summary>
        /// This is the event handler for AccessChanged events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs e)
        {
            var status = e.Status;

            if (status != DeviceAccessStatus.Allowed)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    rootPage.NotifyUser("Access denied to activity sensors", NotifyType.ErrorMessage);
                    _activitySensor = null;

                    ScenarioEnableReadingChangedButton.IsEnabled  = true;
                    ScenarioDisableReadingChangedButton.IsEnabled = false;
                });
            }
        }
Exemple #10
0
        /// <summary>
        /// Close the device if the device access was denied by anyone (system or the user) and reopen it if permissions are allowed again
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private async void OnDeviceAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs eventArgs)
        {
            if ((eventArgs.Status == DeviceAccessStatus.DeniedBySystem) ||
                (eventArgs.Status == DeviceAccessStatus.DeniedByUser))
            {
                CloseCurrentlyConnectedDevice();
            }
            else if ((eventArgs.Status == DeviceAccessStatus.Allowed) && (deviceInformation != null) && isEnabledAutoReconnect)
            {
                //await rootPage.Dispatcher.RunAsync(
                //    CoreDispatcherPriority.Normal,
                //    new DispatchedHandler(async () => {
                //        await OpenDeviceAsync(deviceInformation, deviceSelector);

                //        // Any app specific device intialization should be done here because we don't know the state of the device when it is re-enumerated.
                //    }));
            }
        }
Exemple #11
0
 private static void OnAccessChanged(DeviceAccessChangedEventArgs args)
 {
     if (DeviceAccessStatus.DeniedByUser == args.Status)
     {
         MessageBox.Show("Location has been disabled by the user. Enable access through the settings charm.");
     }
     else if (DeviceAccessStatus.DeniedBySystem == args.Status)
     {
         MessageBox.Show("Location has been disabled by the system. The administrator of the device must enable location access through the location control panel.");
     }
     else if (DeviceAccessStatus.Unspecified == args.Status)
     {
         MessageBox.Show("Location has been disabled by unspecified source. The administrator of the device may need to enable location access through the location control panel, then enable access through the settings charm.");
     }
     else
     {
         MessageBox.Show("Unknown device access information status");
     }
 }
Exemple #12
0
        /// <summary>
        /// Close the device if the device access was denied by anyone (system or the user) and reopen it if permissions are allowed again
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private async void OnDeviceAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs eventArgs)
        {
            if ((eventArgs.Status == DeviceAccessStatus.DeniedBySystem) ||
                (eventArgs.Status == DeviceAccessStatus.DeniedByUser))
            {
                CloseCurrentlyConnectedDevice();
            }
            else if ((eventArgs.Status == DeviceAccessStatus.Allowed) && (deviceInformation != null) && isEnabledAutoReconnect)
            {
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                    CoreDispatcherPriority.Normal, async
                        () =>
                {
                    await OpenDeviceAsync(deviceInformation, deviceSelector);

                    // Any app specific device intialization should be done here because we don't know the state of the device when it is re-enumerated.
                });
            }
        }
        private async void OnDeviceAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs eventArgs)
        {
            if ((eventArgs.Status == DeviceAccessStatus.DeniedBySystem) ||
                (eventArgs.Status == DeviceAccessStatus.DeniedByUser))
            {
                CloseCurrentlyConnectedDevice();
            }
            else if ((eventArgs.Status == DeviceAccessStatus.Allowed) &&
                     (deviceInformation != null))
            {
                await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, new DispatchedHandler(async() =>
                {
                    if (deviceId != null)
                    {
                        await ConnectAsyncFromId(deviceId);
                    }

                    // await OpenDeviceAsync(deviceInformation, deviceSelector);
                }));
            }
        }
 private async void OnAccessInformation_AccessChanged(
     DeviceAccessInformation sender,
     DeviceAccessChangedEventArgs args)
 {
     try
     {
         if (args.Status == DeviceAccessStatus.DeniedBySystem ||
             args.Status == DeviceAccessStatus.DeniedByUser)
         {
             CloseCurrentlyConnectedDevice();
         }
         else if (args.Status == DeviceAccessStatus.Allowed && DeviceInformation != null)
         {
             var result = await InternalOpenDeviceAsync(DeviceInformation);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.Message);
     }
 }
        /// <summary>
        /// Close the device if the device access was denied by anyone (system or the user) and reopen it if permissions are allowed again
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private async void OnDeviceAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs eventArgs)
        {
            if ((eventArgs.Status == DeviceAccessStatus.DeniedBySystem)
                || (eventArgs.Status == DeviceAccessStatus.DeniedByUser))
            {
                CloseCurrentlyConnectedDevice();
            }
            else if ((eventArgs.Status == DeviceAccessStatus.Allowed) && (deviceInformation != null) && isEnabledAutoReconnect)
            {
                await rootPage.Dispatcher.RunAsync(
                    CoreDispatcherPriority.Normal,
                    new DispatchedHandler(async () =>
                    {
                        // If we failed to reconnect to the device, don't try to connect anymore
                        isEnabledAutoReconnect = await OpenDeviceAsync(deviceInformation, deviceSelector);

                        // Any app specific device intialization should be done here because we don't know the state of the device when it is re-enumerated.
                    }));
            }
        }
        /// <summary>
        /// This is the event handler for AccessChanged events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void AccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs e)
        {
            var status = e.Status;
            if (status != DeviceAccessStatus.Allowed)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    rootPage.NotifyUser("Access denied to activity sensors", NotifyType.ErrorMessage);
                    _activitySensor = null;

                    ScenarioEnableReadingChangedButton.IsEnabled = true;
                    ScenarioDisableReadingChangedButton.IsEnabled = false;
                });
            }
        }
Exemple #17
0
 private async void AccessInformationOnAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs args)
 {
     if (args.Status == DeviceAccessStatus.DeniedByUser)
     {
         await TryGetPermissionsAsync().ConfigureAwait(false);
     }
 }
Exemple #18
0
        private async void OnAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs e)
        {
            var status = e.Status;

            await SetStatus(status == DeviceAccessStatus.Allowed);
        }
 private static void OnAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs args)
 {
     if (Dispatcher != null)
     {
         Dispatcher.BeginInvoke(() =>
         {
             OnAccessChanged(args);
         });
     }
     else
     {
         OnAccessChanged(args);
     }
 }
 private static void OnAccessChanged(DeviceAccessChangedEventArgs args)
 {
     if (DeviceAccessStatus.DeniedByUser == args.Status)
     {
         MessageBox.Show("Location has been disabled by the user. Enable access through the settings charm.");
     }
     else if (DeviceAccessStatus.DeniedBySystem == args.Status)
     {
         MessageBox.Show("Location has been disabled by the system. The administrator of the device must enable location access through the location control panel.");
     }
     else if (DeviceAccessStatus.Unspecified == args.Status)
     {
         MessageBox.Show("Location has been disabled by unspecified source. The administrator of the device may need to enable location access through the location control panel, then enable access through the settings charm.");
     }
     else
     {
         MessageBox.Show("Unknown device access information status");
     }
 }
        public async void OnAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs args)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                var status = args.Status;

                string eventDescription = GetTimeStampedMessage("Device Access Status");
                
                eventDescription += " (" + status.ToString() + ")";

                AddEventDescription(eventDescription);

                if (DeviceAccessStatus.DeniedByUser == args.Status)
                {
                    rootPage.NotifyUser("Location has been disabled by the user. Enable access through the settings charm.", NotifyType.StatusMessage);
                }
                else if (DeviceAccessStatus.DeniedBySystem == args.Status)
                {
                    rootPage.NotifyUser("Location has been disabled by the system. The administrator of the device must enable location access through the location control panel.", NotifyType.StatusMessage);
                }
                else if (DeviceAccessStatus.Unspecified == args.Status)
                {
                    rootPage.NotifyUser("Location has been disabled by unspecified source. The administrator of the device may need to enable location access through the location control panel, then enable access through the settings charm.", NotifyType.StatusMessage);
                }
                else if (DeviceAccessStatus.Allowed == args.Status)
                {
                    // clear status
                    rootPage.NotifyUser("", NotifyType.StatusMessage);
                }
                else
                {
                    rootPage.NotifyUser("Unknown device access information status", NotifyType.StatusMessage);
                }
            });
        }
        /// <summary>
        /// Invoked when ActivitySensor device access gets changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void DeviceAccessInfo_AccessChangedAsync(DeviceAccessInformation sender, DeviceAccessChangedEventArgs args)
        {
            var status = args.Status;

            if (status == DeviceAccessStatus.Allowed)
            {
                await InitializeAsync();
            }
            else
            {
                Release();
            }
        }
 /// <summary>
 /// This is the event handler for AccessChanged events.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void OnAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs e)
 {
     var status = e.Status;
     if (status != DeviceAccessStatus.Allowed)
     {
         await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             rootPage.NotifyUser("Custom sensor access denied", NotifyType.ErrorMessage);
             customSensor = null;
         });
     }
 }
 private void OnAccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs args)
 {
 }
        /// <summary>
        /// This is the event handler for AccessChanged events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        async private void AccessChanged(DeviceAccessInformation sender, DeviceAccessChangedEventArgs e)
        {
            var status = e.Status;
            if (status != DeviceAccessStatus.Allowed)
            {
                await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    rootPage.NotifyUser("Access denied to pedometers", NotifyType.ErrorMessage);
                    pedometer = null;

                    registeredForEvents = false;
                    RegisterButton.Content = "Register ReadingChanged";
                });
            }
        }