Restructure how XAML controls and UI stuff work

This commit is contained in:
pizzaboxer 2023-10-24 14:58:26 +01:00
parent f6dc303e14
commit fb1865c3f7
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
15 changed files with 36 additions and 36 deletions

View File

@ -212,12 +212,12 @@ namespace Bloxstrap
else else
{ {
if (Process.GetProcessesByName(ProjectName).Length > 1 && !IsQuiet) if (Process.GetProcessesByName(ProjectName).Length > 1 && !IsQuiet)
Controls.ShowMessageBox( Methods.ShowMessageBox(
Bloxstrap.Resources.Strings.Menu_AlreadyRunning, Bloxstrap.Resources.Strings.Menu_AlreadyRunning,
MessageBoxImage.Information MessageBoxImage.Information
); );
Controls.ShowMenu(); Methods.ShowMenu();
} }
} }
else if (LaunchArgs.Length > 0) else if (LaunchArgs.Length > 0)
@ -231,7 +231,7 @@ namespace Bloxstrap
else if (LaunchArgs[0].StartsWith("roblox:")) else if (LaunchArgs[0].StartsWith("roblox:"))
{ {
if (Settings.Prop.UseDisableAppPatch) if (Settings.Prop.UseDisableAppPatch)
Controls.ShowMessageBox( Methods.ShowMessageBox(
Bloxstrap.Resources.Strings.Bootstrapper_DeeplinkTempEnabled, Bloxstrap.Resources.Strings.Bootstrapper_DeeplinkTempEnabled,
MessageBoxImage.Information MessageBoxImage.Information
); );

View File

@ -157,7 +157,7 @@ namespace Bloxstrap
else if (ex.GetType() == typeof(AggregateException)) else if (ex.GetType() == typeof(AggregateException))
ex = ex.InnerException!; ex = ex.InnerException!;
Controls.ShowConnectivityDialog("Roblox", message, ex); Methods.ShowConnectivityDialog("Roblox", message, ex);
App.Terminate(ErrorCode.ERROR_CANCELLED); App.Terminate(ErrorCode.ERROR_CANCELLED);
} }
@ -262,7 +262,7 @@ namespace Bloxstrap
{ {
MessageBoxResult action = App.Settings.Prop.ChannelChangeMode switch MessageBoxResult action = App.Settings.Prop.ChannelChangeMode switch
{ {
ChannelChangeMode.Prompt => Controls.ShowMessageBox( ChannelChangeMode.Prompt => Methods.ShowMessageBox(
string.Format(Resources.Strings.Bootstrapper_ChannelOutOfDate, App.Settings.Prop.Channel, RobloxDeployment.DefaultChannel), string.Format(Resources.Strings.Bootstrapper_ChannelOutOfDate, App.Settings.Prop.Channel, RobloxDeployment.DefaultChannel),
MessageBoxImage.Warning, MessageBoxImage.Warning,
MessageBoxButton.YesNo MessageBoxButton.YesNo
@ -301,7 +301,7 @@ namespace Bloxstrap
if (!File.Exists(Path.Combine(Paths.System, "mfplat.dll"))) if (!File.Exists(Path.Combine(Paths.System, "mfplat.dll")))
{ {
Controls.ShowMessageBox( Methods.ShowMessageBox(
Resources.Strings.Bootstrapper_WMFNotFound, Resources.Strings.Bootstrapper_WMFNotFound,
MessageBoxImage.Error MessageBoxImage.Error
); );
@ -674,7 +674,7 @@ namespace Bloxstrap
App.Logger.WriteLine(LOG_IDENT, "An exception occurred when running the auto-updater"); App.Logger.WriteLine(LOG_IDENT, "An exception occurred when running the auto-updater");
App.Logger.WriteException(LOG_IDENT, ex); App.Logger.WriteException(LOG_IDENT, ex);
Controls.ShowMessageBox( Methods.ShowMessageBox(
string.Format(Resources.Strings.Bootstrapper_AutoUpdateFailed, releaseInfo.TagName), string.Format(Resources.Strings.Bootstrapper_AutoUpdateFailed, releaseInfo.TagName),
MessageBoxImage.Information MessageBoxImage.Information
); );
@ -690,7 +690,7 @@ namespace Bloxstrap
{ {
App.Logger.WriteLine(LOG_IDENT, $"Prompting to shut down all open Roblox instances"); App.Logger.WriteLine(LOG_IDENT, $"Prompting to shut down all open Roblox instances");
MessageBoxResult result = Controls.ShowMessageBox( MessageBoxResult result = Methods.ShowMessageBox(
Resources.Strings.Bootstrapper_Uninstall_RobloxRunning, Resources.Strings.Bootstrapper_Uninstall_RobloxRunning,
MessageBoxImage.Information, MessageBoxImage.Information,
MessageBoxButton.OKCancel MessageBoxButton.OKCancel
@ -864,7 +864,7 @@ namespace Bloxstrap
if (Filesystem.GetFreeDiskSpace(Paths.Base) < totalSizeRequired) if (Filesystem.GetFreeDiskSpace(Paths.Base) < totalSizeRequired)
{ {
Controls.ShowMessageBox( Methods.ShowMessageBox(
Resources.Strings.Bootstrapper_NotEnoughSpace, Resources.Strings.Bootstrapper_NotEnoughSpace,
MessageBoxImage.Error MessageBoxImage.Error
); );
@ -1059,7 +1059,7 @@ namespace Bloxstrap
if (File.Exists(injectorLocation)) if (File.Exists(injectorLocation))
{ {
Controls.ShowMessageBox( Methods.ShowMessageBox(
Resources.Strings.Bootstrapper_HyperionUpdateInfo, Resources.Strings.Bootstrapper_HyperionUpdateInfo,
MessageBoxImage.Warning MessageBoxImage.Warning
); );

View File

@ -2,6 +2,6 @@
{ {
static class BootstrapperStyleEx static class BootstrapperStyleEx
{ {
public static IBootstrapperDialog GetNew(this BootstrapperStyle bootstrapperStyle) => Controls.GetBootstrapperDialog(bootstrapperStyle); public static IBootstrapperDialog GetNew(this BootstrapperStyle bootstrapperStyle) => Methods.GetBootstrapperDialog(bootstrapperStyle);
} }
} }

View File

@ -32,7 +32,7 @@ namespace Bloxstrap
_installLocation = Path.GetDirectoryName(Paths.Process)!; _installLocation = Path.GetDirectoryName(Paths.Process)!;
var result = Controls.ShowMessageBox( var result = Methods.ShowMessageBox(
string.Format(Resources.Strings.InstallChecker_NotInstalledProperly, _installLocation), string.Format(Resources.Strings.InstallChecker_NotInstalledProperly, _installLocation),
MessageBoxImage.Warning, MessageBoxImage.Warning,
MessageBoxButton.YesNo MessageBoxButton.YesNo
@ -74,7 +74,7 @@ namespace Bloxstrap
{ {
App.Logger.WriteLine(LOG_IDENT, $"Drive has changed from {driveName} to {newDriveName}"); App.Logger.WriteLine(LOG_IDENT, $"Drive has changed from {driveName} to {newDriveName}");
Controls.ShowMessageBox( Methods.ShowMessageBox(
string.Format(Resources.Strings.InstallChecker_DriveLetterChangeDetected, driveName, newDriveName), string.Format(Resources.Strings.InstallChecker_DriveLetterChangeDetected, driveName, newDriveName),
MessageBoxImage.Warning, MessageBoxImage.Warning,
MessageBoxButton.OK MessageBoxButton.OK
@ -87,7 +87,7 @@ namespace Bloxstrap
{ {
App.Logger.WriteLine(LOG_IDENT, $"Drive {driveName} does not exist anymore, and has likely been removed"); App.Logger.WriteLine(LOG_IDENT, $"Drive {driveName} does not exist anymore, and has likely been removed");
var result = Controls.ShowMessageBox( var result = Methods.ShowMessageBox(
string.Format(Resources.Strings.InstallChecker_InstallDriveMissing, driveName), string.Format(Resources.Strings.InstallChecker_InstallDriveMissing, driveName),
MessageBoxImage.Warning, MessageBoxImage.Warning,
MessageBoxButton.OKCancel MessageBoxButton.OKCancel
@ -130,7 +130,7 @@ namespace Bloxstrap
App.IsSetupComplete = false; App.IsSetupComplete = false;
App.FastFlags.Load(); App.FastFlags.Load();
Controls.ShowMenu(); Methods.ShowMenu();
// exit if we don't click the install button on installation // exit if we don't click the install button on installation
if (App.IsSetupComplete) if (App.IsSetupComplete)
@ -165,7 +165,7 @@ namespace Bloxstrap
} }
else else
{ {
result = Controls.ShowMessageBox( result = Methods.ShowMessageBox(
Resources.Strings.InstallChecker_VersionDifferentThanInstalled, Resources.Strings.InstallChecker_VersionDifferentThanInstalled,
MessageBoxImage.Question, MessageBoxImage.Question,
MessageBoxButton.YesNo MessageBoxButton.YesNo
@ -240,13 +240,13 @@ namespace Bloxstrap
} }
else if (!App.IsQuiet) else if (!App.IsQuiet)
{ {
Controls.ShowMessageBox( Methods.ShowMessageBox(
string.Format(Resources.Strings.InstallChecker_Updated, currentVersionInfo.ProductVersion), string.Format(Resources.Strings.InstallChecker_Updated, currentVersionInfo.ProductVersion),
MessageBoxImage.Information, MessageBoxImage.Information,
MessageBoxButton.OK MessageBoxButton.OK
); );
Controls.ShowMenu(); Methods.ShowMenu();
App.Terminate(); App.Terminate();
} }

View File

@ -90,7 +90,7 @@ namespace Bloxstrap
if (channel == App.State.Prop.LastEnrolledChannel) if (channel == App.State.Prop.LastEnrolledChannel)
return; return;
MessageBoxResult result = Controls.ShowMessageBox( MessageBoxResult result = Methods.ShowMessageBox(
string.Format(Resources.Strings.ProtocolHandler_RobloxSwitchedChannel, channel, App.Settings.Prop.Channel), string.Format(Resources.Strings.ProtocolHandler_RobloxSwitchedChannel, channel, App.Settings.Prop.Channel),
MessageBoxImage.Question, MessageBoxImage.Question,
MessageBoxButton.YesNo MessageBoxButton.YesNo

View File

@ -6,7 +6,7 @@ namespace Bloxstrap.UI.Elements.Bootstrapper.Base
{ {
public static void ShowSuccess(string message, Action? callback) public static void ShowSuccess(string message, Action? callback)
{ {
Controls.ShowMessageBox(message, MessageBoxImage.Information); Methods.ShowMessageBox(message, MessageBoxImage.Information);
if (callback is not null) if (callback is not null)
callback(); callback();

View File

@ -126,7 +126,7 @@ namespace Bloxstrap.UI.Elements.ContextMenu
private void CloseRobloxMenuItem_Click(object sender, RoutedEventArgs e) private void CloseRobloxMenuItem_Click(object sender, RoutedEventArgs e)
{ {
MessageBoxResult result = Controls.ShowMessageBox( MessageBoxResult result = Methods.ShowMessageBox(
Bloxstrap.Resources.Strings.ContextMenu_CloseRobloxMessage, Bloxstrap.Resources.Strings.ContextMenu_CloseRobloxMessage,
MessageBoxImage.Warning, MessageBoxImage.Warning,
MessageBoxButton.YesNo MessageBoxButton.YesNo

View File

@ -7,7 +7,7 @@ using Markdig.Syntax;
using Markdig.Syntax.Inlines; using Markdig.Syntax.Inlines;
using Markdig; using Markdig;
namespace Bloxstrap.ControlsWpf namespace Bloxstrap.UI.Elements.Controls
{ {
/// <summary> /// <summary>
/// TextBlock with markdown support. <br/> /// TextBlock with markdown support. <br/>

View File

@ -122,7 +122,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
if (App.FastFlags.GetValue(newName) is not null) if (App.FastFlags.GetValue(newName) is not null)
{ {
Controls.ShowMessageBox("A FastFlag with this name already exists.", MessageBoxImage.Information); Methods.ShowMessageBox("A FastFlag with this name already exists.", MessageBoxImage.Information);
e.Cancel = true; e.Cancel = true;
textbox.Text = oldName; textbox.Text = oldName;
return; return;
@ -181,7 +181,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
} }
else else
{ {
Controls.ShowMessageBox("An entry for this FastFlag already exists.", MessageBoxImage.Information); Methods.ShowMessageBox("An entry for this FastFlag already exists.", MessageBoxImage.Information);
bool refresh = false; bool refresh = false;
@ -256,7 +256,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
} }
catch (Exception ex) catch (Exception ex)
{ {
Controls.ShowMessageBox( Methods.ShowMessageBox(
"The JSON you've entered does not appear to be valid. Please double check it and try again.\n" + "The JSON you've entered does not appear to be valid. Please double check it and try again.\n" +
"\n" + "\n" +
"More information:\n" + "More information:\n" +
@ -271,7 +271,7 @@ namespace Bloxstrap.UI.Elements.Menu.Pages
if (conflictingFlags.Any()) if (conflictingFlags.Any())
{ {
var result = Controls.ShowMessageBox( var result = Methods.ShowMessageBox(
"Some of the flags you are attempting to import already have set values. Would you like to overwrite their current values with the ones defined in the import?\n" + "Some of the flags you are attempting to import already have set values. Would you like to overwrite their current values with the ones defined in the import?\n" +
"\n" + "\n" +
"Conflicting flags:\n" + "Conflicting flags:\n" +

View File

@ -6,7 +6,7 @@
xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels" xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:resources="clr-namespace:Bloxstrap.Resources" xmlns:resources="clr-namespace:Bloxstrap.Resources"
xmlns:controls="clr-namespace:Bloxstrap.ControlsWpf" xmlns:controls="clr-namespace:Bloxstrap.UI.Elements.Controls"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="1000" d:DesignWidth="800" d:DesignHeight="1000" d:DesignWidth="800"
Title="FastFlagsPage" Title="FastFlagsPage"

View File

@ -6,7 +6,7 @@
xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels" xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:resources="clr-namespace:Bloxstrap.Resources" xmlns:resources="clr-namespace:Bloxstrap.Resources"
xmlns:controls="clr-namespace:Bloxstrap.ControlsWpf" xmlns:controls="clr-namespace:Bloxstrap.UI.Elements.Controls"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800" d:DesignHeight="800" d:DesignWidth="800"
Title="ModsPage" Title="ModsPage"

View File

@ -7,7 +7,7 @@
xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Menu.Pages" xmlns:local="clr-namespace:Bloxstrap.UI.Elements.Menu.Pages"
xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels" xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels"
xmlns:resources="clr-namespace:Bloxstrap.Resources" xmlns:resources="clr-namespace:Bloxstrap.Resources"
xmlns:controls="clr-namespace:Bloxstrap.ControlsWpf" xmlns:controls="clr-namespace:Bloxstrap.UI.Elements.Controls"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DesignHeight="450" d:DesignWidth="800"
Title="PreInstallPage" Title="PreInstallPage"

View File

@ -6,7 +6,7 @@ using Bloxstrap.UI.Elements.Menu;
namespace Bloxstrap.UI namespace Bloxstrap.UI
{ {
static class Controls static class Methods
{ {
public static void ShowMenu() => new MainWindow().ShowDialog(); public static void ShowMenu() => new MainWindow().ShowDialog();

View File

@ -42,7 +42,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
if (string.IsNullOrEmpty(App.BaseDirectory)) if (string.IsNullOrEmpty(App.BaseDirectory))
{ {
Controls.ShowMessageBox(Resources.Strings.Menu_InstallLocation_NotSet, MessageBoxImage.Error); Methods.ShowMessageBox(Resources.Strings.Menu_InstallLocation_NotSet, MessageBoxImage.Error);
return; return;
} }
@ -59,7 +59,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
} }
catch (UnauthorizedAccessException) catch (UnauthorizedAccessException)
{ {
Controls.ShowMessageBox( Methods.ShowMessageBox(
Resources.Strings.Menu_InstallLocation_NoWritePerms, Resources.Strings.Menu_InstallLocation_NoWritePerms,
MessageBoxImage.Error MessageBoxImage.Error
); );
@ -67,7 +67,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
} }
catch (Exception ex) catch (Exception ex)
{ {
Controls.ShowMessageBox(ex.Message, MessageBoxImage.Error); Methods.ShowMessageBox(ex.Message, MessageBoxImage.Error);
return; return;
} }
@ -75,7 +75,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
{ {
string suggestedChange = Path.Combine(App.BaseDirectory, App.ProjectName); string suggestedChange = Path.Combine(App.BaseDirectory, App.ProjectName);
MessageBoxResult result = Controls.ShowMessageBox( MessageBoxResult result = Methods.ShowMessageBox(
string.Format(Resources.Strings.Menu_InstallLocation_NotEmpty, suggestedChange), string.Format(Resources.Strings.Menu_InstallLocation_NotEmpty, suggestedChange),
MessageBoxImage.Warning, MessageBoxImage.Warning,
MessageBoxButton.YesNoCancel, MessageBoxButton.YesNoCancel,
@ -95,7 +95,7 @@ namespace Bloxstrap.UI.ViewModels.Menu
Directory.GetParent(App.BaseDirectory)!.ToString().ToLowerInvariant() == Paths.UserProfile.ToLowerInvariant() // prevent from installing to an essential user profile folder Directory.GetParent(App.BaseDirectory)!.ToString().ToLowerInvariant() == Paths.UserProfile.ToLowerInvariant() // prevent from installing to an essential user profile folder
) )
{ {
Controls.ShowMessageBox( Methods.ShowMessageBox(
Resources.Strings.Menu_InstallLocation_CantInstall, Resources.Strings.Menu_InstallLocation_CantInstall,
MessageBoxImage.Error, MessageBoxImage.Error,
MessageBoxButton.OK MessageBoxButton.OK

View File

@ -30,7 +30,7 @@ namespace Bloxstrap.Utility
_loadStatus = AssemblyLoadStatus.Failed; _loadStatus = AssemblyLoadStatus.Failed;
Controls.ShowMessageBox( Methods.ShowMessageBox(
$"{App.ProjectName} was unable to create shortcuts for the Desktop and Start menu. They will be created the next time Roblox is launched.", $"{App.ProjectName} was unable to create shortcuts for the Desktop and Start menu. They will be created the next time Roblox is launched.",
MessageBoxImage.Information MessageBoxImage.Information
); );