Skip to content

Commit

Permalink
SteamScreenshots: Add fade out animation before window is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
darklinkpower committed Dec 9, 2024
1 parent 83e20f3 commit f0bd825
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ private void FadeImages()
Storyboard.SetTarget(_fadeInAnimation, content.ImageB);
}

Storyboard.SetTargetProperty(_fadeOutAnimation, new PropertyPath("Opacity"));
Storyboard.SetTargetProperty(_fadeInAnimation, new PropertyPath("Opacity"));

var storyboard = new Storyboard();
storyboard.Children.Add(_fadeOutAnimation);
storyboard.Children.Add(_fadeInAnimation);
Expand All @@ -179,7 +176,26 @@ private void FadeImages()

private void CloseWindow()
{
_window.Close();
if (_window.Content is ScreenshotsView content)
{
if (_lastImageSet == ImageIdentifier.ImageA)
{
Storyboard.SetTarget(_fadeOutAnimation, content.ImageA);
}
else
{
Storyboard.SetTarget(_fadeOutAnimation, content.ImageB);
}

var storyboard = new Storyboard();
storyboard.Children.Add(_fadeOutAnimation);
storyboard.Completed += (s, e) => _window.Close();
storyboard.Begin();
}
else
{
_window.Close();
}
}

private bool CanNavigate()
Expand Down Expand Up @@ -228,6 +244,9 @@ private void InitializeAnimations()
Duration = TimeSpan.FromSeconds(0.25),
FillBehavior = FillBehavior.HoldEnd
};

Storyboard.SetTargetProperty(_fadeOutAnimation, new PropertyPath("Opacity"));
Storyboard.SetTargetProperty(_fadeInAnimation, new PropertyPath("Opacity"));
}

public event PropertyChangedEventHandler PropertyChanged;
Expand Down

0 comments on commit f0bd825

Please sign in to comment.