diff --git a/src/PicView.Avalonia/Update/UpdateManager.cs b/src/PicView.Avalonia/Update/UpdateManager.cs index 54b051a5d..5af95d25b 100644 --- a/src/PicView.Avalonia/Update/UpdateManager.cs +++ b/src/PicView.Avalonia/Update/UpdateManager.cs @@ -5,6 +5,7 @@ using Microsoft.Win32; using PicView.Avalonia.UI; using PicView.Avalonia.ViewModels; +using PicView.Avalonia.WindowBehavior; using PicView.Core.Config; using PicView.Core.FileHandling; @@ -141,6 +142,7 @@ public static async Task UpdateCurrentVersion(MainViewModel vm) switch (architecture) { case InstalledArchitecture.Arm64Install: + // Launch the installer and close the window var fileName = Path.GetFileName(updateInfo.X64Install); var tempFileDownloadPath = Path.Combine(tempPath, fileName); await StartFileDownloader(vm, updateInfo.Arm64Install, tempFileDownloadPath); @@ -153,8 +155,10 @@ public static async Task UpdateCurrentVersion(MainViewModel vm) } }; process.Start(); + await WindowFunctions.WindowClosingBehavior(); return; case InstalledArchitecture.Arm64Portable: + // Download the zip package in browser process = new Process { StartInfo = new ProcessStartInfo(updateInfo.Arm64Portable) @@ -167,6 +171,7 @@ public static async Task UpdateCurrentVersion(MainViewModel vm) await process.WaitForExitAsync(); return; case InstalledArchitecture.X64Install: + // Launch the installer and close the window fileName = Path.GetFileName(updateInfo.X64Install); tempFileDownloadPath = Path.Combine(tempPath, fileName); await StartFileDownloader(vm, updateInfo.X64Install, tempFileDownloadPath); @@ -179,8 +184,11 @@ public static async Task UpdateCurrentVersion(MainViewModel vm) } }; process.Start(); + await WindowFunctions.WindowClosingBehavior(); return; case InstalledArchitecture.X64Portable: + + // Download the zip package in browser process = new Process { StartInfo = new ProcessStartInfo(updateInfo.X64Portable) diff --git a/src/PicView.Avalonia/WindowBehavior/WindowFunctions.cs b/src/PicView.Avalonia/WindowBehavior/WindowFunctions.cs index 96eb3ff3c..993ed2c82 100644 --- a/src/PicView.Avalonia/WindowBehavior/WindowFunctions.cs +++ b/src/PicView.Avalonia/WindowBehavior/WindowFunctions.cs @@ -17,6 +17,14 @@ namespace PicView.Avalonia.WindowBehavior; public static class WindowFunctions { + public static async Task WindowClosingBehavior() + { + if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop) + { + return; + } + await WindowClosingBehavior(desktop.MainWindow); + } public static async Task WindowClosingBehavior(Window window) { if (!SettingsHelper.Settings.WindowProperties.Maximized ||