private async void ConnectDeviceToggleButton_Unchecked(object sender, RoutedEventArgs e) { try { ConnectDeviceToggleButton.IsEnabled = false; ConnectingActivity.Begin(); await DeviceConnectionHandler.Instance.Disconnect(); } finally { ConnectingActivity.Stop(); ConnectDeviceToggleButton.IsEnabled = true; } }
private async Task Connect(object sender) { try { ConnectDeviceToggleButton.IsEnabled = false; symbolIcon.Symbol = Symbol.Sync; ConnectingActivity.Begin(); ConnectionFlyoutText.Text = DeviceConnectionHandler.ConnectionFlyoutText; if (!DeviceConnectionHandler.Instance.CheckParametersSet()) { if (await DeviceConnectionHandler.Instance.ShowMissingHostParametersDialog() == ContentDialogResult.Primary) { if (this.AppFrame.CurrentSourcePageType != typeof(AppSettingsPage)) { this.AppFrame.Navigate(typeof(AppSettingsPage), sender, new Windows.UI.Xaml.Media.Animation.DrillInNavigationTransitionInfo()); } } ConnectDeviceToggleButton.IsChecked = false; return; } ContentDialogResult result = ContentDialogResult.Primary; ConnectionFlyout.ShowAt(sender as FrameworkElement); while (result == ContentDialogResult.Primary && !await DeviceConnectionHandler.Instance.Connect()) { ConnectionFlyout.ShowAt(sender as FrameworkElement); result = await DeviceConnectionHandler.Instance.ShowConnectionFailedDialog(); } if (result == ContentDialogResult.Secondary) { if (this.AppFrame.CurrentSourcePageType != typeof(AppSettingsPage)) { this.AppFrame.Navigate(typeof(AppSettingsPage), sender, new Windows.UI.Xaml.Media.Animation.DrillInNavigationTransitionInfo()); } ConnectDeviceToggleButton.IsChecked = false; } } finally { ConnectionFlyout.Hide(); ConnectingActivity.Stop(); symbolIcon.Symbol = Symbol.Remote; ConnectDeviceToggleButton.IsEnabled = true; } }