From f8e306cff75bc59678e2447e7e535d8d86e68578 Mon Sep 17 00:00:00 2001 From: ScrubN <72096833+ScrubN@users.noreply.github.com> Date: Fri, 5 Jan 2024 17:07:15 -0500 Subject: [PATCH] Move taskbar flash before FFmpeg check, and flash on successful FFmpeg download --- TwitchDownloaderWPF/MainWindow.xaml.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/TwitchDownloaderWPF/MainWindow.xaml.cs b/TwitchDownloaderWPF/MainWindow.xaml.cs index 0da35cb3..b7d876d9 100644 --- a/TwitchDownloaderWPF/MainWindow.xaml.cs +++ b/TwitchDownloaderWPF/MainWindow.xaml.cs @@ -74,6 +74,10 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) Settings.Default.Save(); } + // Flash the window taskbar icon if it is not in the foreground. This is to mitigate a problem where + // it will sometimes start behind other windows, usually (but not always) due to the user's actions. + FlashTaskbarIconIfNotForeground(TimeSpan.FromSeconds(3)); + var currentVersion = Version.Parse("1.53.6"); Title = $"Twitch Downloader v{currentVersion}"; @@ -84,6 +88,9 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) try { await FFmpegDownloader.GetLatestVersion(FFmpegVersion.Full, new FfmpegDownloadProgress()); + + // Flash the window to signify that FFmpeg has been downloaded + FlashTaskbarIconIfNotForeground(TimeSpan.FromSeconds(3)); } catch (Exception ex) { @@ -102,10 +109,6 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) Title = oldTitle; } - // Flash the window taskbar icon if it is not in the foreground. This is to mitigate a problem where - // it will sometimes start behind other windows, usually (but not always) due to the user's actions. - await FlashWindowIfNotForeground(TimeSpan.FromSeconds(3)); - AutoUpdater.InstalledVersion = currentVersion; #if !DEBUG if (AppContext.BaseDirectory.StartsWith(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile))) @@ -117,7 +120,7 @@ private async void Window_Loaded(object sender, RoutedEventArgs e) #endif } - private async Task FlashWindowIfNotForeground(TimeSpan flashDuration) + private async void FlashTaskbarIconIfNotForeground(TimeSpan flashDuration) { var currentWindow = new WindowInteropHelper(this).Handle; var foregroundWindow = NativeFunctions.GetForegroundWindow();