From 17e2dc298411d08600b257be3141e02f7cd9544f Mon Sep 17 00:00:00 2001 From: Gustave Monce Date: Sun, 22 Dec 2019 13:34:03 +0100 Subject: [PATCH] Fixed the UI for phone shut down --- ViewModels/SwitchModeViewModel.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/ViewModels/SwitchModeViewModel.cs b/ViewModels/SwitchModeViewModel.cs index 3a068f8..b322e97 100644 --- a/ViewModels/SwitchModeViewModel.cs +++ b/ViewModels/SwitchModeViewModel.cs @@ -170,9 +170,23 @@ namespace WPinternals { IsSwitching = false; if ((UIContext == null) || (SynchronizationContext.Current == UIContext)) - ModeSwitchSuccess((IDisposable)PhoneNotifier.CurrentModel, (PhoneInterfaces)PhoneNotifier.CurrentInterface); + { + if (PhoneNotifier.CurrentInterface == null) + { + ModeSwitchErrorWrapper("Phone disconnected"); + } + else + ModeSwitchSuccess((IDisposable)PhoneNotifier.CurrentModel, (PhoneInterfaces)PhoneNotifier.CurrentInterface); + } else - UIContext.Post(s => { ModeSwitchSuccess((IDisposable)PhoneNotifier.CurrentModel, (PhoneInterfaces)PhoneNotifier.CurrentInterface); }, null); + { + if (PhoneNotifier.CurrentInterface == null) + { + UIContext.Post(s => { ModeSwitchErrorWrapper("Phone disconnected"); }, null); + } + else + UIContext.Post(s => { ModeSwitchSuccess((IDisposable)PhoneNotifier.CurrentModel, (PhoneInterfaces)PhoneNotifier.CurrentInterface); }, null); + } } ~SwitchModeViewModel() @@ -259,12 +273,12 @@ namespace WPinternals { case null: ((NokiaFlashModel)CurrentModel).Shutdown(); - ModeSwitchProgressWrapper("Shutting down phone...", null); - LogFile.Log("Shutting down phone", LogType.FileAndConsole); + ModeSwitchProgressWrapper("Please disconnect your device. Waiting...", null); + LogFile.Log("Please disconnect your device. Waiting...", LogType.FileAndConsole); new Thread(() => { PhoneNotifier.WaitForRemoval().Wait(); - //ModeSwitchSuccessWrapper(); TODO: Display UI + ModeSwitchSuccessWrapper(); }).Start(); break; case PhoneInterfaces.Lumia_Normal: