From fe816fd2b66c997551c2a3374731659eb96d4ebd Mon Sep 17 00:00:00 2001 From: rjindael Date: Wed, 2 Aug 2023 03:09:03 -0700 Subject: [PATCH] fix: bootstrapper dry run fix --- Kiseki.Launcher.Windows/MainWindow.cs | 14 +++++++++++--- Kiseki.Launcher.Windows/Win32.cs | 23 ++++++++++------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Kiseki.Launcher.Windows/MainWindow.cs b/Kiseki.Launcher.Windows/MainWindow.cs index 1012c88..1ab601d 100644 --- a/Kiseki.Launcher.Windows/MainWindow.cs +++ b/Kiseki.Launcher.Windows/MainWindow.cs @@ -31,9 +31,17 @@ public class MainWindow : Form Buttons = { CloseButton } }; - Page.Created += (s, e) => + Page.Created += (_, _) => { - Bootstrapper.Run(); + if (Bootstrapper.Initialize()) + Bootstrapper.Run(); + }; + + // This is a small hack to ensure that the underlying Form that MainWindow has + // doesn't open when the TaskDialogPage is destroyed. + Page.Destroyed += (_, _) => + { + Environment.Exit(0); }; ShowTaskDialog(); @@ -75,8 +83,8 @@ public class MainWindow : Form private void Bootstrapper_Errored(object? sender, string[] texts) { - Page.Icon = TaskDialogIcon.Error; Page.Heading = texts[0]; Page.Text = texts[1]; + Page.ProgressBar!.State = TaskDialogProgressBarState.Error; } } \ No newline at end of file diff --git a/Kiseki.Launcher.Windows/Win32.cs b/Kiseki.Launcher.Windows/Win32.cs index 4235297..2764883 100644 --- a/Kiseki.Launcher.Windows/Win32.cs +++ b/Kiseki.Launcher.Windows/Win32.cs @@ -1,18 +1,15 @@ -using System.Runtime.InteropServices; +namespace Kiseki.Launcher.Windows; -namespace Kiseki.Launcher.Windows +public static class Win32 { - public static class Win32 + // Ref: https://learn.microsoft.com/en-us/windows/win32/msi/error-codes + // Ref: https://i-logic.com/serial/errorcodes.htm + public enum ErrorCode { - // Ref: https://learn.microsoft.com/en-us/windows/win32/msi/error-codes - // Ref: https://i-logic.com/serial/errorcodes.htm - public enum ErrorCode - { - ERROR_SUCCESS = 0, - ERROR_INSTALL_USEREXIT = 1602, - ERROR_INSTALL_FAILURE = 1603, - ERROR_CANCELLED = 1223, - ERROR_INTERNAL_ERROR = 1359 - } + ERROR_SUCCESS = 0, + ERROR_INSTALL_USEREXIT = 1602, + ERROR_INSTALL_FAILURE = 1603, + ERROR_CANCELLED = 1223, + ERROR_INTERNAL_ERROR = 1359 } } \ No newline at end of file