From 8c5a0047329b8f12d7ed8759c2528bdd4cc850c8 Mon Sep 17 00:00:00 2001 From: Matt <97983689+bluepilledgreat@users.noreply.github.com> Date: Thu, 17 Oct 2024 15:34:03 +0100 Subject: [PATCH] Enhance the error experience (#3259) * set taskbar state to error upon failing * add version text to the exception dialog * vertically align version text --- Bloxstrap/App.xaml.cs | 11 +++++++++++ Bloxstrap/LaunchHandler.cs | 8 ++++---- Bloxstrap/Resources/Strings.Designer.cs | 9 +++++++++ Bloxstrap/Resources/Strings.resx | 3 +++ Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml | 14 +++++++++----- .../UI/Elements/Dialogs/ExceptionDialog.xaml.cs | 2 ++ 6 files changed, 38 insertions(+), 9 deletions(-) diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index ce40e07..f5bcefb 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -1,6 +1,7 @@ using System.Reflection; using System.Security.Cryptography; using System.Windows; +using System.Windows.Shell; using System.Windows.Threading; using Microsoft.Win32; @@ -35,6 +36,8 @@ namespace Bloxstrap public static string Version = Assembly.GetExecutingAssembly().GetName().Version!.ToString()[..^2]; + public static Bootstrapper? Bootstrapper { get; set; } = null!; + public static bool IsActionBuild => !String.IsNullOrEmpty(BuildMetadata.CommitRef); public static bool IsProductionBuild => IsActionBuild && BuildMetadata.CommitRef.StartsWith("tag", StringComparison.Ordinal); @@ -104,6 +107,14 @@ namespace Bloxstrap _showingExceptionDialog = true; + if (Bootstrapper?.Dialog != null) + { + if (Bootstrapper.Dialog.TaskbarProgressValue == 0) + Bootstrapper.Dialog.TaskbarProgressValue = 1; // make sure it's visible + + Bootstrapper.Dialog.TaskbarProgressState = TaskbarItemProgressState.Error; + } + Frontend.ShowExceptionDialog(ex); Terminate(ErrorCode.ERROR_INSTALL_FAILURE); diff --git a/Bloxstrap/LaunchHandler.cs b/Bloxstrap/LaunchHandler.cs index cf7f165..35739fd 100644 --- a/Bloxstrap/LaunchHandler.cs +++ b/Bloxstrap/LaunchHandler.cs @@ -202,18 +202,18 @@ namespace Bloxstrap // start bootstrapper and show the bootstrapper modal if we're not running silently App.Logger.WriteLine(LOG_IDENT, "Initializing bootstrapper"); - var bootstrapper = new Bootstrapper(launchMode); + App.Bootstrapper = new Bootstrapper(launchMode); IBootstrapperDialog? dialog = null; if (!App.LaunchSettings.QuietFlag.Active) { App.Logger.WriteLine(LOG_IDENT, "Initializing bootstrapper dialog"); dialog = App.Settings.Prop.BootstrapperStyle.GetNew(); - bootstrapper.Dialog = dialog; - dialog.Bootstrapper = bootstrapper; + App.Bootstrapper.Dialog = dialog; + dialog.Bootstrapper = App.Bootstrapper; } - Task.Run(bootstrapper.Run).ContinueWith(t => + Task.Run(App.Bootstrapper.Run).ContinueWith(t => { App.Logger.WriteLine(LOG_IDENT, "Bootstrapper task has finished"); diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index cf5e6a6..ad28195 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -974,6 +974,15 @@ namespace Bloxstrap.Resources { } } + /// + /// Looks up a localized string similar to Version {0}. + /// + public static string Dialog_Exception_Version { + get { + return ResourceManager.GetString("Dialog.Exception.Version", resourceCulture); + } + } + /// /// Looks up a localized string similar to The chosen bootstrapper icon could not be loaded. /// diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index 4d9d54b..6b7fe31 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -1236,4 +1236,7 @@ Would you like to enable test mode? Icons Name of the folder that gets created according to the "create shortcut icons" option. Ensure that it is a valid folder name. + + Version {0} + \ No newline at end of file diff --git a/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml index 1debcfd..b98372d 100644 --- a/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml +++ b/Bloxstrap/UI/Elements/Dialogs/ExceptionDialog.xaml @@ -40,11 +40,15 @@ - -