Fully cleanup Bloxstrap folder after install

this also goes to show just how much of a mess bootstrapper dialog management is lol
This commit is contained in:
pizzaboxer 2023-05-24 18:27:11 +01:00
parent 57e6454fd7
commit 244c3dee40
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
6 changed files with 48 additions and 9 deletions

View File

@ -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

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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;