From 48d09f6730f4d29c0dc578804eacce9eb5ba9dd0 Mon Sep 17 00:00:00 2001 From: pizzaboxer <41478239+pizzaboxer@users.noreply.github.com> Date: Sun, 12 Feb 2023 23:19:00 +0000 Subject: [PATCH] Draft design and functionality for Fluent Dialog --- Bloxstrap/App.xaml | 3 +- Bloxstrap/App.xaml.cs | 7 +- Bloxstrap/Bloxstrap.csproj | 14 ++ Bloxstrap/Dialogs/BootstrapperDialogForm.cs | 20 +-- Bloxstrap/Dialogs/FluentDialog.xaml | 40 ++++++ Bloxstrap/Dialogs/FluentDialog.xaml.cs | 122 ++++++++++++++++++ Bloxstrap/Dialogs/IBootstrapperDialog.cs | 2 +- Bloxstrap/Enums/BootstrapperIcon.cs | 8 +- Bloxstrap/Enums/BootstrapperStyle.cs | 4 +- Bloxstrap/Models/Settings.cs | 2 +- Bloxstrap/ViewModels/BootstrapperViewModel.cs | 19 +-- Bloxstrap/ViewModels/FluentDialogViewModel.cs | 42 ++++++ Bloxstrap/Views/MainWindow.xaml.cs | 7 +- 13 files changed, 258 insertions(+), 32 deletions(-) create mode 100644 Bloxstrap/Dialogs/FluentDialog.xaml create mode 100644 Bloxstrap/Dialogs/FluentDialog.xaml.cs create mode 100644 Bloxstrap/ViewModels/FluentDialogViewModel.cs diff --git a/Bloxstrap/App.xaml b/Bloxstrap/App.xaml index afdfb30..28b450e 100644 --- a/Bloxstrap/App.xaml +++ b/Bloxstrap/App.xaml @@ -2,7 +2,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Bloxstrap" - xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"> + xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" + ShutdownMode="OnExplicitShutdown"> diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index d938d46..9620c2b 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -55,9 +55,9 @@ namespace Bloxstrap public static void Terminate(int code = Bootstrapper.ERROR_SUCCESS) { + Debug.WriteLine($"[App] Terminating with exit code {code}"); Settings.Save(); State.Save(); - Debug.WriteLine($"[App] Terminating with exit code {code}"); Environment.Exit(code); } @@ -109,14 +109,12 @@ namespace Bloxstrap registryKey.Close(); } - // preferences dialog was closed, and so base directory was never set + // exit if we don't click the install button on installation if (!IsSetupComplete) Environment.Exit(Bootstrapper.ERROR_INSTALL_USEREXIT); Directories.Initialize(BaseDirectory); - //Settings.FileLocation = Path.Combine(Directories.Base, "Settings.json"); - // we shouldn't save settings on the first run until the first installation is finished, // just in case the user decides to cancel the install if (!IsFirstRun) @@ -185,6 +183,7 @@ namespace Bloxstrap Task bootstrapperTask = Task.Run(() => bootstrapper.Run()).ContinueWith(t => { // TODO: add error logging + Debug.WriteLine("[App] Bootstrapper task has finished"); if (t.Exception is null) return; diff --git a/Bloxstrap/Bloxstrap.csproj b/Bloxstrap/Bloxstrap.csproj index 7a5330e..7077d10 100644 --- a/Bloxstrap/Bloxstrap.csproj +++ b/Bloxstrap/Bloxstrap.csproj @@ -13,7 +13,14 @@ + + + + + + + @@ -35,7 +42,14 @@ + + + + + + + diff --git a/Bloxstrap/Dialogs/BootstrapperDialogForm.cs b/Bloxstrap/Dialogs/BootstrapperDialogForm.cs index 62e2a50..f0bf3ae 100644 --- a/Bloxstrap/Dialogs/BootstrapperDialogForm.cs +++ b/Bloxstrap/Dialogs/BootstrapperDialogForm.cs @@ -10,8 +10,9 @@ namespace Bloxstrap.Dialogs { public class BootstrapperDialogForm : Form, IBootstrapperDialog { - public Bootstrapper Bootstrapper { get; set; } = null!; + public Bootstrapper? Bootstrapper { get; set; } + #region UI Elements protected virtual string _message { get; set; } = "Please wait..."; protected virtual ProgressBarStyle _progressStyle { get; set; } protected virtual int _progressValue { get; set; } @@ -64,6 +65,7 @@ namespace Bloxstrap.Dialogs _cancelEnabled = value; } } + #endregion public void ScaleWindow() { @@ -83,6 +85,13 @@ namespace Bloxstrap.Dialogs this.Icon = App.Settings.Prop.BootstrapperIcon.GetIcon(); } + public void ButtonCancel_Click(object? sender, EventArgs e) + { + Bootstrapper?.CancelInstall(); + this.Close(); + } + + #region IBootstrapperDialog Methods public void ShowBootstrapper() => this.ShowDialog(); public virtual void CloseBootstrapper() @@ -116,11 +125,6 @@ namespace Bloxstrap.Dialogs if (result != MessageBoxResult.OK) Environment.Exit(Bootstrapper.ERROR_INSTALL_USEREXIT); } - - public void ButtonCancel_Click(object? sender, EventArgs e) - { - Bootstrapper.CancelInstall(); - this.Close(); - } - } + #endregion + } } diff --git a/Bloxstrap/Dialogs/FluentDialog.xaml b/Bloxstrap/Dialogs/FluentDialog.xaml new file mode 100644 index 0000000..604b2e4 --- /dev/null +++ b/Bloxstrap/Dialogs/FluentDialog.xaml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + +