mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01: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;
|
return;
|
||||||
|
|
||||||
// keep bloxstrap open in the background
|
// keep bloxstrap open in the background
|
||||||
Dialog.CloseDialog();
|
Dialog.HideBootstrapper();
|
||||||
await gameClient.WaitForExitAsync();
|
await gameClient.WaitForExitAsync();
|
||||||
|
|
||||||
richPresence?.Dispose();
|
richPresence?.Dispose();
|
||||||
|
@ -67,6 +67,11 @@ namespace Bloxstrap.Dialogs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BootstrapperDialogForm(Bootstrapper? bootstrapper = null)
|
||||||
|
{
|
||||||
|
Bootstrapper = bootstrapper;
|
||||||
|
}
|
||||||
|
|
||||||
public void ScaleWindow()
|
public void ScaleWindow()
|
||||||
{
|
{
|
||||||
this.Size = this.MinimumSize = this.MaximumSize = WindowScaling.GetScaledSize(this.Size);
|
this.Size = this.MinimumSize = this.MaximumSize = WindowScaling.GetScaledSize(this.Size);
|
||||||
@ -120,6 +125,29 @@ namespace Bloxstrap.Dialogs
|
|||||||
App.Terminate();
|
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)
|
public virtual void ShowSuccess(string message)
|
||||||
{
|
{
|
||||||
App.ShowMessageBox(message, MessageBoxImage.Information);
|
App.ShowMessageBox(message, MessageBoxImage.Information);
|
||||||
@ -132,14 +160,6 @@ namespace Bloxstrap.Dialogs
|
|||||||
App.Terminate(Bootstrapper.ERROR_INSTALL_FAILURE);
|
App.Terminate(Bootstrapper.ERROR_INSTALL_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void CloseDialog()
|
|
||||||
{
|
|
||||||
if (this.InvokeRequired)
|
|
||||||
this.Invoke(CloseDialog);
|
|
||||||
else
|
|
||||||
this.Hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PromptShutdown()
|
public void PromptShutdown()
|
||||||
{
|
{
|
||||||
MessageBoxResult result = App.ShowMessageBox(
|
MessageBoxResult result = App.ShowMessageBox(
|
||||||
|
@ -12,9 +12,11 @@ namespace Bloxstrap.Dialogs
|
|||||||
bool CancelEnabled { get; set; }
|
bool CancelEnabled { get; set; }
|
||||||
|
|
||||||
void RunBootstrapper();
|
void RunBootstrapper();
|
||||||
|
void ShowAsPreview();
|
||||||
|
void ShowAsBootstrapper();
|
||||||
|
void HideBootstrapper();
|
||||||
void ShowSuccess(string message);
|
void ShowSuccess(string message);
|
||||||
void ShowError(string message);
|
void ShowError(string message);
|
||||||
void CloseDialog();
|
|
||||||
void PromptShutdown();
|
void PromptShutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,10 @@ namespace Bloxstrap.Dialogs
|
|||||||
set => this.buttonCancel.Enabled = value;
|
set => this.buttonCancel.Enabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LegacyDialog2009(Bootstrapper? bootstrapper = null)
|
public LegacyDialog2009(Bootstrapper? bootstrapper = null) : base(bootstrapper)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Bootstrapper = bootstrapper;
|
|
||||||
|
|
||||||
ScaleWindow();
|
ScaleWindow();
|
||||||
SetupDialog();
|
SetupDialog();
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,10 @@ namespace Bloxstrap.Dialogs
|
|||||||
set => this.buttonCancel.Enabled = this.buttonCancel.Visible = value;
|
set => this.buttonCancel.Enabled = this.buttonCancel.Visible = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LegacyDialog2011(Bootstrapper? bootstrapper = null)
|
public LegacyDialog2011(Bootstrapper? bootstrapper = null) : base(bootstrapper)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Bootstrapper = bootstrapper;
|
|
||||||
|
|
||||||
// have to convert icon -> bitmap since winforms scaling is poop
|
// have to convert icon -> bitmap since winforms scaling is poop
|
||||||
this.IconBox.BackgroundImage = App.Settings.Prop.BootstrapperIcon.GetIcon().ToBitmap();
|
this.IconBox.BackgroundImage = App.Settings.Prop.BootstrapperIcon.GetIcon().ToBitmap();
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ namespace Bloxstrap.Dialogs
|
|||||||
set => this.buttonCancel.Enabled = this.buttonCancel.Visible = value;
|
set => this.buttonCancel.Enabled = this.buttonCancel.Visible = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProgressDialog(Bootstrapper? bootstrapper = null)
|
public ProgressDialog(Bootstrapper? bootstrapper = null) : base(bootstrapper)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
@ -46,8 +46,6 @@ namespace Bloxstrap.Dialogs
|
|||||||
this.BackColor = Color.FromArgb(25, 27, 29);
|
this.BackColor = Color.FromArgb(25, 27, 29);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bootstrapper = bootstrapper;
|
|
||||||
|
|
||||||
this.IconBox.BackgroundImage = App.Settings.Prop.BootstrapperIcon.GetBitmap();
|
this.IconBox.BackgroundImage = App.Settings.Prop.BootstrapperIcon.GetBitmap();
|
||||||
|
|
||||||
SetupDialog();
|
SetupDialog();
|
||||||
|
@ -60,12 +60,10 @@ namespace Bloxstrap.Dialogs
|
|||||||
set => Dialog.Buttons[0].Enabled = value;
|
set => Dialog.Buttons[0].Enabled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VistaDialog(Bootstrapper? bootstrapper = null)
|
public VistaDialog(Bootstrapper? bootstrapper = null) : base(bootstrapper)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Bootstrapper = bootstrapper;
|
|
||||||
|
|
||||||
Dialog = new TaskDialogPage()
|
Dialog = new TaskDialogPage()
|
||||||
{
|
{
|
||||||
Icon = new TaskDialogIcon(App.Settings.Prop.BootstrapperIcon.GetIcon()),
|
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)
|
if (this.InvokeRequired)
|
||||||
{
|
{
|
||||||
this.Invoke(CloseDialog);
|
this.Invoke(HideBootstrapper);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ namespace Bloxstrap.Enums
|
|||||||
{
|
{
|
||||||
public static void Show(this BootstrapperStyle bootstrapperStyle, Bootstrapper? bootstrapper = null)
|
public static void Show(this BootstrapperStyle bootstrapperStyle, Bootstrapper? bootstrapper = null)
|
||||||
{
|
{
|
||||||
Form dialog = bootstrapperStyle switch
|
IBootstrapperDialog dialog = bootstrapperStyle switch
|
||||||
{
|
{
|
||||||
BootstrapperStyle.VistaDialog => new VistaDialog(bootstrapper),
|
BootstrapperStyle.VistaDialog => new VistaDialog(bootstrapper),
|
||||||
BootstrapperStyle.LegacyDialog2009 => new LegacyDialog2009(bootstrapper),
|
BootstrapperStyle.LegacyDialog2009 => new LegacyDialog2009(bootstrapper),
|
||||||
@ -27,17 +27,14 @@ namespace Bloxstrap.Enums
|
|||||||
|
|
||||||
if (bootstrapper is null)
|
if (bootstrapper is null)
|
||||||
{
|
{
|
||||||
dialog.ShowDialog();
|
dialog.ShowAsPreview();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (App.IsQuiet)
|
if (App.IsQuiet)
|
||||||
{
|
dialog.HideBootstrapper();
|
||||||
dialog.Opacity = 0;
|
|
||||||
dialog.ShowInTaskbar = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Application.Run(dialog);
|
dialog.ShowAsBootstrapper();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@
|
|||||||
</ui:CardAction>
|
</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">
|
<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>
|
<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}" />
|
<TextBlock FontSize="12" Text="MIT License" Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ui:CardAction>
|
</ui:CardAction>
|
||||||
|
Loading…
Reference in New Issue
Block a user