Skip to content

Commit

Permalink
Move taskbar flash before FFmpeg check, and flash on successful FFmpe…
Browse files Browse the repository at this point in the history
…g download
  • Loading branch information
ScrubN committed Jan 5, 2024
1 parent 092db64 commit f8e306c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions TwitchDownloaderWPF/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}";

Expand All @@ -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)
{
Expand All @@ -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)))
Expand All @@ -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();
Expand Down

0 comments on commit f8e306c

Please sign in to comment.