From ea023679dfa9ae781902f8d633de298a238f50df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?gabriel=2Ehuot-v=C3=A9zina?= Date: Tue, 27 Feb 2024 14:55:12 -0500 Subject: [PATCH] #315 quick fix for airplane mode crashing the app. --- GSCFieldApp/ViewModels/MapPageViewModel.cs | 31 +++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/GSCFieldApp/ViewModels/MapPageViewModel.cs b/GSCFieldApp/ViewModels/MapPageViewModel.cs index 47fc4a9b..4936165e 100644 --- a/GSCFieldApp/ViewModels/MapPageViewModel.cs +++ b/GSCFieldApp/ViewModels/MapPageViewModel.cs @@ -1538,18 +1538,37 @@ public async Task NoLocationRoutine() /// When no location is available probably due to flight mode. Display this message. /// - private async void CheckAirplaneMode() + private async Task CheckAirplaneMode() { var connectionProfile = NetworkInformation.GetInternetConnectionProfile(); if (connectionProfile == null) { - // Possible airplane mode - var messageDialog = new Windows.UI.Popups.MessageDialog("Airplane Mode or No Network Connection Found"); - messageDialog.Commands.Add(new Windows.UI.Popups.UICommand("OK")); - await messageDialog.ShowAsync(); + + + ContentDialog noLocationFlightModeDialog = new ContentDialog() + { + Title = "No Data", + Content = "Airplane Mode or No Network Connection Found", + PrimaryButtonText = "OK", + }; + + noLocationFlightModeDialog.Style = (Style)Application.Current.Resources["WarningDialog"]; + + + try + { + ContentDialogResult flightModeResult = await Services.ContentDialogMaker.CreateContentDialogAsync(noLocationFlightModeDialog, false).Result; + } + catch (Exception) + { + Debug.WriteLine("Warning dialog for location allocation failed."); + } + + + } - //Windows.UI.Popups.MessageDialog.Style = (Style)Application.Current.Resources["WarningDialog"]; + } public async Task NoLocationFlightMode() {