diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 065c2203..d1f13ff0 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -17,8 +17,6 @@ using Bloxstrap.Models; using Bloxstrap.Models.Attributes; using Bloxstrap.UI; -using Bloxstrap.UI.BootstrapperDialogs; -using Bloxstrap.UI.MessageBox; using Bloxstrap.Utility; namespace Bloxstrap @@ -105,6 +103,7 @@ void GlobalExceptionHandler(object sender, DispatcherUnhandledExceptionEventArgs void FinalizeExceptionHandling(Exception exception) { +#pragma warning disable 162 #if DEBUG throw exception; #endif @@ -113,6 +112,7 @@ void FinalizeExceptionHandling(Exception exception) Controls.ShowExceptionDialog(exception); Terminate(Bootstrapper.ERROR_INSTALL_FAILURE); +#pragma warning restore 162 } protected override void OnStartup(StartupEventArgs e) @@ -248,7 +248,7 @@ protected override void OnStartup(StartupEventArgs e) else { if (Process.GetProcessesByName(ProjectName).Length > 1 && !IsQuiet) - FluentMessageBox.Show( + Controls.ShowMessageBox( $"{ProjectName} is currently running, likely as a background Roblox process. Please note that not all your changes will immediately apply until you close all currently open Roblox instances.", MessageBoxImage.Information ); diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index 33d2fabd..2b75af00 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -18,7 +18,6 @@ using Bloxstrap.Models; using Bloxstrap.Tools; using Bloxstrap.UI; -using Bloxstrap.UI.BootstrapperDialogs; namespace Bloxstrap { diff --git a/Bloxstrap/Extensions/BootstrapperStyleEx.cs b/Bloxstrap/Extensions/BootstrapperStyleEx.cs index fa555785..bb837d88 100644 --- a/Bloxstrap/Extensions/BootstrapperStyleEx.cs +++ b/Bloxstrap/Extensions/BootstrapperStyleEx.cs @@ -1,24 +1,10 @@ using Bloxstrap.Enums; -using Bloxstrap.UI.BootstrapperDialogs; -using Bloxstrap.UI.BootstrapperDialogs.WinForms; -using Bloxstrap.UI.BootstrapperDialogs.WPF.Views; +using Bloxstrap.UI; namespace Bloxstrap.Extensions { static class BootstrapperStyleEx { - public static IBootstrapperDialog GetNew(this BootstrapperStyle bootstrapperStyle) - { - return bootstrapperStyle switch - { - BootstrapperStyle.VistaDialog => new VistaDialog(), - BootstrapperStyle.LegacyDialog2009 => new LegacyDialog2009(), - BootstrapperStyle.LegacyDialog2011 => new LegacyDialog2011(), - BootstrapperStyle.ProgressDialog => new ProgressDialog(), - BootstrapperStyle.FluentDialog => new FluentDialog(), - BootstrapperStyle.ByfronDialog => new ByfronDialog(), - _ => new FluentDialog() - }; - } + public static IBootstrapperDialog GetNew(this BootstrapperStyle bootstrapperStyle) => Controls.GetBootstrapperDialog(bootstrapperStyle); } } diff --git a/Bloxstrap/UI/Controls.cs b/Bloxstrap/UI/Controls.cs index ad4ab765..22a6a61c 100644 --- a/Bloxstrap/UI/Controls.cs +++ b/Bloxstrap/UI/Controls.cs @@ -1,9 +1,10 @@ using System; -using System.Drawing; using System.Windows; using Bloxstrap.Enums; -using Bloxstrap.UI.Menu.Views; +using Bloxstrap.Extensions; +using Bloxstrap.UI.Elements.Bootstrapper; +using Bloxstrap.UI.Menu; using Bloxstrap.UI.MessageBox; namespace Bloxstrap.UI @@ -14,14 +15,22 @@ static class Controls public static MessageBoxResult ShowMessageBox(string message, MessageBoxImage icon = MessageBoxImage.None, MessageBoxButton buttons = MessageBoxButton.OK, MessageBoxResult defaultResult = MessageBoxResult.None) { + if (App.IsQuiet) + return defaultResult; + switch (App.Settings.Prop.BootstrapperStyle) { case BootstrapperStyle.FluentDialog: case BootstrapperStyle.ByfronDialog: - return FluentMessageBox.Show(message, icon, buttons, defaultResult); + return Application.Current.Dispatcher.Invoke(new Func(() => + { + var messagebox = new FluentMessageBox(message, icon, buttons); + messagebox.ShowDialog(); + return messagebox.Result; + })); default: - return NativeMessageBox.Show(message, icon, buttons, defaultResult); + return System.Windows.MessageBox.Show(message, App.ProjectName, buttons, icon); } } @@ -32,5 +41,19 @@ public static void ShowExceptionDialog(Exception exception) new ExceptionDialog(exception).ShowDialog(); }); } + + public static IBootstrapperDialog GetBootstrapperDialog(BootstrapperStyle style) + { + return style switch + { + BootstrapperStyle.VistaDialog => new VistaDialog(), + BootstrapperStyle.LegacyDialog2009 => new LegacyDialog2009(), + BootstrapperStyle.LegacyDialog2011 => new LegacyDialog2011(), + BootstrapperStyle.ProgressDialog => new ProgressDialog(), + BootstrapperStyle.FluentDialog => new FluentDialog(), + BootstrapperStyle.ByfronDialog => new ByfronDialog(), + _ => new FluentDialog() + }; + } } } diff --git a/Bloxstrap/UI/BootstrapperDialogs/BaseFunctions.cs b/Bloxstrap/UI/Elements/Bootstrapper/Base/BaseFunctions.cs similarity index 87% rename from Bloxstrap/UI/BootstrapperDialogs/BaseFunctions.cs rename to Bloxstrap/UI/Elements/Bootstrapper/Base/BaseFunctions.cs index 3a89637b..c3e3c087 100644 --- a/Bloxstrap/UI/BootstrapperDialogs/BaseFunctions.cs +++ b/Bloxstrap/UI/Elements/Bootstrapper/Base/BaseFunctions.cs @@ -1,7 +1,7 @@ using System; using System.Windows; -namespace Bloxstrap.UI.BootstrapperDialogs +namespace Bloxstrap.UI.Elements.Bootstrapper.Base { static class BaseFunctions { diff --git a/Bloxstrap/UI/BootstrapperDialogs/WinForms/DialogBase.cs b/Bloxstrap/UI/Elements/Bootstrapper/Base/WinFormsDialogBase.cs similarity index 93% rename from Bloxstrap/UI/BootstrapperDialogs/WinForms/DialogBase.cs rename to Bloxstrap/UI/Elements/Bootstrapper/Base/WinFormsDialogBase.cs index 253062c3..4627a0be 100644 --- a/Bloxstrap/UI/BootstrapperDialogs/WinForms/DialogBase.cs +++ b/Bloxstrap/UI/Elements/Bootstrapper/Base/WinFormsDialogBase.cs @@ -2,13 +2,13 @@ using System.Windows.Forms; using Bloxstrap.Extensions; -using Bloxstrap.Utility; +using Bloxstrap.UI.Utility; -namespace Bloxstrap.UI.BootstrapperDialogs.WinForms +namespace Bloxstrap.UI.Elements.Bootstrapper.Base { - public class DialogBase : Form, IBootstrapperDialog + public class WinFormsDialogBase : Form, IBootstrapperDialog { - public Bootstrapper? Bootstrapper { get; set; } + public Bloxstrap.Bootstrapper? Bootstrapper { get; set; } #region UI Elements protected virtual string _message { get; set; } = "Please wait..."; diff --git a/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/ByfronDialog.xaml b/Bloxstrap/UI/Elements/Bootstrapper/ByfronDialog.xaml similarity index 98% rename from Bloxstrap/UI/BootstrapperDialogs/WPF/Views/ByfronDialog.xaml rename to Bloxstrap/UI/Elements/Bootstrapper/ByfronDialog.xaml index ca5b62e0..b2b93870 100644 --- a/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/ByfronDialog.xaml +++ b/Bloxstrap/UI/Elements/Bootstrapper/ByfronDialog.xaml @@ -1,4 +1,4 @@ - /// Interaction logic for ByfronDialog.xaml @@ -17,7 +18,7 @@ public partial class ByfronDialog : IBootstrapperDialog { private readonly ByfronDialogViewModel _viewModel; - public Bootstrapper? Bootstrapper { get; set; } + public Bloxstrap.Bootstrapper? Bootstrapper { get; set; } #region UI Elements public string Message @@ -52,10 +53,12 @@ public int ProgressValue public bool CancelEnabled { - get => _viewModel.CancelButtonVisibility == Visibility.Visible; + get => _viewModel.CancelEnabled; set { - _viewModel.CancelButtonVisibility = (value ? Visibility.Visible : Visibility.Collapsed); + _viewModel.CancelEnabled = value; + + _viewModel.OnPropertyChanged(nameof(_viewModel.CancelEnabled)); _viewModel.OnPropertyChanged(nameof(_viewModel.CancelButtonVisibility)); _viewModel.OnPropertyChanged(nameof(_viewModel.VersionTextVisibility)); diff --git a/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/FluentDialog.xaml b/Bloxstrap/UI/Elements/Bootstrapper/FluentDialog.xaml similarity index 87% rename from Bloxstrap/UI/BootstrapperDialogs/WPF/Views/FluentDialog.xaml rename to Bloxstrap/UI/Elements/Bootstrapper/FluentDialog.xaml index 0de1cce5..5916c073 100644 --- a/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/FluentDialog.xaml +++ b/Bloxstrap/UI/Elements/Bootstrapper/FluentDialog.xaml @@ -1,4 +1,4 @@ - -