mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 18:11:27 -07:00
Rework dialog handling for better generic support
preparation for FluentDIalog
This commit is contained in:
parent
d468157488
commit
93ad0fb609
@ -286,7 +286,7 @@ namespace Bloxstrap
|
||||
return;
|
||||
|
||||
// keep bloxstrap open in the background
|
||||
Dialog.CloseDialog();
|
||||
Dialog.HideBootstrapper();
|
||||
await gameClient.WaitForExitAsync();
|
||||
|
||||
richPresence?.Dispose();
|
||||
|
@ -67,6 +67,11 @@ namespace Bloxstrap.Dialogs
|
||||
}
|
||||
}
|
||||
|
||||
public BootstrapperDialogForm(Bootstrapper? bootstrapper = null)
|
||||
{
|
||||
Bootstrapper = bootstrapper;
|
||||
}
|
||||
|
||||
public void ScaleWindow()
|
||||
{
|
||||
this.Size = this.MinimumSize = this.MaximumSize = WindowScaling.GetScaledSize(this.Size);
|
||||
@ -120,6 +125,29 @@ namespace Bloxstrap.Dialogs
|
||||
App.Terminate();
|
||||
}
|
||||
|
||||
public void ShowAsPreview()
|
||||
{
|
||||
this.ShowDialog();
|
||||
}
|
||||
|
||||
public void ShowAsBootstrapper()
|
||||
{
|
||||
System.Windows.Forms.Application.Run(this);
|
||||
}
|
||||
|
||||
public virtual void HideBootstrapper()
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(HideBootstrapper);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Opacity = 0;
|
||||
this.ShowInTaskbar = false;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ShowSuccess(string message)
|
||||
{
|
||||
App.ShowMessageBox(message, MessageBoxImage.Information);
|
||||
@ -132,14 +160,6 @@ namespace Bloxstrap.Dialogs
|
||||
App.Terminate(Bootstrapper.ERROR_INSTALL_FAILURE);
|
||||
}
|
||||
|
||||
public virtual void CloseDialog()
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
this.Invoke(CloseDialog);
|
||||
else
|
||||
this.Hide();
|
||||
}
|
||||
|
||||
public void PromptShutdown()
|
||||
{
|
||||
MessageBoxResult result = App.ShowMessageBox(
|
||||
|
@ -12,9 +12,11 @@ namespace Bloxstrap.Dialogs
|
||||
bool CancelEnabled { get; set; }
|
||||
|
||||
void RunBootstrapper();
|
||||
void ShowAsPreview();
|
||||
void ShowAsBootstrapper();
|
||||
void HideBootstrapper();
|
||||
void ShowSuccess(string message);
|
||||
void ShowError(string message);
|
||||
void CloseDialog();
|
||||
void PromptShutdown();
|
||||
}
|
||||
}
|
||||
|
@ -32,12 +32,10 @@ namespace Bloxstrap.Dialogs
|
||||
set => this.buttonCancel.Enabled = value;
|
||||
}
|
||||
|
||||
public LegacyDialog2009(Bootstrapper? bootstrapper = null)
|
||||
public LegacyDialog2009(Bootstrapper? bootstrapper = null) : base(bootstrapper)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Bootstrapper = bootstrapper;
|
||||
|
||||
ScaleWindow();
|
||||
SetupDialog();
|
||||
}
|
||||
|
@ -33,12 +33,10 @@ namespace Bloxstrap.Dialogs
|
||||
set => this.buttonCancel.Enabled = this.buttonCancel.Visible = value;
|
||||
}
|
||||
|
||||
public LegacyDialog2011(Bootstrapper? bootstrapper = null)
|
||||
public LegacyDialog2011(Bootstrapper? bootstrapper = null) : base(bootstrapper)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Bootstrapper = bootstrapper;
|
||||
|
||||
// have to convert icon -> bitmap since winforms scaling is poop
|
||||
this.IconBox.BackgroundImage = App.Settings.Prop.BootstrapperIcon.GetIcon().ToBitmap();
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace Bloxstrap.Dialogs
|
||||
set => this.buttonCancel.Enabled = this.buttonCancel.Visible = value;
|
||||
}
|
||||
|
||||
public ProgressDialog(Bootstrapper? bootstrapper = null)
|
||||
public ProgressDialog(Bootstrapper? bootstrapper = null) : base(bootstrapper)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@ -46,8 +46,6 @@ namespace Bloxstrap.Dialogs
|
||||
this.BackColor = Color.FromArgb(25, 27, 29);
|
||||
}
|
||||
|
||||
Bootstrapper = bootstrapper;
|
||||
|
||||
this.IconBox.BackgroundImage = App.Settings.Prop.BootstrapperIcon.GetBitmap();
|
||||
|
||||
SetupDialog();
|
||||
|
@ -60,12 +60,10 @@ namespace Bloxstrap.Dialogs
|
||||
set => Dialog.Buttons[0].Enabled = value;
|
||||
}
|
||||
|
||||
public VistaDialog(Bootstrapper? bootstrapper = null)
|
||||
public VistaDialog(Bootstrapper? bootstrapper = null) : base(bootstrapper)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Bootstrapper = bootstrapper;
|
||||
|
||||
Dialog = new TaskDialogPage()
|
||||
{
|
||||
Icon = new TaskDialogIcon(App.Settings.Prop.BootstrapperIcon.GetIcon()),
|
||||
@ -143,11 +141,11 @@ namespace Bloxstrap.Dialogs
|
||||
}
|
||||
}
|
||||
|
||||
public override void CloseDialog()
|
||||
public override void HideBootstrapper()
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(CloseDialog);
|
||||
this.Invoke(HideBootstrapper);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -16,7 +16,7 @@ namespace Bloxstrap.Enums
|
||||
{
|
||||
public static void Show(this BootstrapperStyle bootstrapperStyle, Bootstrapper? bootstrapper = null)
|
||||
{
|
||||
Form dialog = bootstrapperStyle switch
|
||||
IBootstrapperDialog dialog = bootstrapperStyle switch
|
||||
{
|
||||
BootstrapperStyle.VistaDialog => new VistaDialog(bootstrapper),
|
||||
BootstrapperStyle.LegacyDialog2009 => new LegacyDialog2009(bootstrapper),
|
||||
@ -27,17 +27,14 @@ namespace Bloxstrap.Enums
|
||||
|
||||
if (bootstrapper is null)
|
||||
{
|
||||
dialog.ShowDialog();
|
||||
dialog.ShowAsPreview();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (App.IsQuiet)
|
||||
{
|
||||
dialog.Opacity = 0;
|
||||
dialog.ShowInTaskbar = false;
|
||||
}
|
||||
dialog.HideBootstrapper();
|
||||
|
||||
Application.Run(dialog);
|
||||
dialog.ShowAsBootstrapper();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@
|
||||
</ui:CardAction>
|
||||
<ui:CardAction Grid.Row="2" Grid.Column="0" Margin="0,8,8,0" Command="{Binding OpenWebpageCommand}" CommandParameter="https://github.com/rickyah/ini-parser/blob/development/LICENSE">
|
||||
<StackPanel>
|
||||
<TextBlock FontSize="13" FontWeight="Medium" Text="ini-parser by rickyah" />
|
||||
<TextBlock FontSize="13" FontWeight="Medium" Text="IniParser by rickyah" />
|
||||
<TextBlock FontSize="12" Text="MIT License" Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
||||
</StackPanel>
|
||||
</ui:CardAction>
|
||||
|
Loading…
Reference in New Issue
Block a user