diff --git a/Bloxstrap/Bootstrapper.cs b/Bloxstrap/Bootstrapper.cs index ab22d14..55c6046 100644 --- a/Bloxstrap/Bootstrapper.cs +++ b/Bloxstrap/Bootstrapper.cs @@ -688,7 +688,27 @@ namespace Bloxstrap App.Logger.WriteLine($"Could not fully uninstall! ({ex})"); } - Dialog?.ShowSuccess($"{App.ProjectName} has succesfully uninstalled"); + Action? callback = null; + + if (Directory.Exists(Directories.Base)) + { + callback = () => + { + // this is definitely one of the workaround hacks of all time + // could antiviruses falsely detect this as malicious behaviour though? + // "hmm whats this program doing running a cmd command chain quietly in the background that auto deletes an entire folder" + + Process.Start(new ProcessStartInfo() + { + FileName = "cmd.exe", + Arguments = $"/c timeout 5 && del /Q \"{Directories.Base}\\*\" && rmdir \"{Directories.Base}\"", + UseShellExecute = true, + WindowStyle = ProcessWindowStyle.Hidden + }); + }; + } + + Dialog?.ShowSuccess($"{App.ProjectName} has succesfully uninstalled", callback); } #endregion diff --git a/Bloxstrap/UI/BootstrapperDialogs/IBootstrapperDialog.cs b/Bloxstrap/UI/BootstrapperDialogs/IBootstrapperDialog.cs index 0531c1e..5b36844 100644 --- a/Bloxstrap/UI/BootstrapperDialogs/IBootstrapperDialog.cs +++ b/Bloxstrap/UI/BootstrapperDialogs/IBootstrapperDialog.cs @@ -1,4 +1,5 @@ -using System.Windows.Forms; +using System; +using System.Windows.Forms; namespace Bloxstrap.UI.BootstrapperDialogs { @@ -13,7 +14,7 @@ namespace Bloxstrap.UI.BootstrapperDialogs void ShowBootstrapper(); void CloseBootstrapper(); - void ShowSuccess(string message); + void ShowSuccess(string message, Action? callback = null); void ShowError(string message); void PromptShutdown(); } diff --git a/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/ByfronDialog.xaml.cs b/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/ByfronDialog.xaml.cs index 200327d..76c8c0c 100644 --- a/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/ByfronDialog.xaml.cs +++ b/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/ByfronDialog.xaml.cs @@ -91,9 +91,13 @@ namespace Bloxstrap.UI.BootstrapperDialogs.WPF.Views public void CloseBootstrapper() => Dispatcher.BeginInvoke(this.Close); - public void ShowSuccess(string message) + public void ShowSuccess(string message, Action? callback) { App.ShowMessageBox(message, MessageBoxImage.Information); + + if (callback is not null) + callback(); + App.Terminate(); } diff --git a/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/FluentDialog.xaml.cs b/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/FluentDialog.xaml.cs index 052d7ba..559a2ab 100644 --- a/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/FluentDialog.xaml.cs +++ b/Bloxstrap/UI/BootstrapperDialogs/WPF/Views/FluentDialog.xaml.cs @@ -85,9 +85,13 @@ namespace Bloxstrap.UI.BootstrapperDialogs.WPF.Views // TODO: make prompts use dialog view natively rather than using message dialog boxes - public void ShowSuccess(string message) + public void ShowSuccess(string message, Action? callback) { App.ShowMessageBox(message, MessageBoxImage.Information); + + if (callback is not null) + callback(); + App.Terminate(); } diff --git a/Bloxstrap/UI/BootstrapperDialogs/WinForms/DialogBase.cs b/Bloxstrap/UI/BootstrapperDialogs/WinForms/DialogBase.cs index 3bec0eb..dfcc15e 100644 --- a/Bloxstrap/UI/BootstrapperDialogs/WinForms/DialogBase.cs +++ b/Bloxstrap/UI/BootstrapperDialogs/WinForms/DialogBase.cs @@ -99,9 +99,13 @@ namespace Bloxstrap.UI.BootstrapperDialogs.WinForms Close(); } - public virtual void ShowSuccess(string message) + public virtual void ShowSuccess(string message, Action? callback) { App.ShowMessageBox(message, MessageBoxImage.Information); + + if (callback is not null) + callback(); + App.Terminate(); } diff --git a/Bloxstrap/UI/BootstrapperDialogs/WinForms/VistaDialog.cs b/Bloxstrap/UI/BootstrapperDialogs/WinForms/VistaDialog.cs index d211101..211036f 100644 --- a/Bloxstrap/UI/BootstrapperDialogs/WinForms/VistaDialog.cs +++ b/Bloxstrap/UI/BootstrapperDialogs/WinForms/VistaDialog.cs @@ -80,11 +80,11 @@ namespace Bloxstrap.UI.BootstrapperDialogs.WinForms SetupDialog(); } - public override void ShowSuccess(string message) + public override void ShowSuccess(string message, Action? callback) { if (this.InvokeRequired) { - this.Invoke(ShowSuccess, message); + this.Invoke(ShowSuccess, message, callback); } else { @@ -96,7 +96,13 @@ namespace Bloxstrap.UI.BootstrapperDialogs.WinForms Buttons = { TaskDialogButton.OK } }; - successDialog.Buttons[0].Click += (_, _) => App.Terminate(); + successDialog.Buttons[0].Click += (_, _) => + { + if (callback is not null) + callback(); + + App.Terminate(); + }; _dialogPage.Navigate(successDialog); _dialogPage = successDialog;