From 8a78d2bbf7ff2d26032e0c87a7e11e116872f085 Mon Sep 17 00:00:00 2001 From: Yoshi Askharoun Date: Mon, 13 May 2024 23:02:07 -0500 Subject: [PATCH] Animate About sections --- .../Behaviors/FadeAnimateItemsBehavior.cs | 38 +++++++++++++++++++ ZuneModdingHelper/Pages/AboutPage.xaml | 20 ++++++++-- 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/ZuneModdingHelper/Behaviors/FadeAnimateItemsBehavior.cs b/ZuneModdingHelper/Behaviors/FadeAnimateItemsBehavior.cs index 7ee5b6a..14d3c70 100644 --- a/ZuneModdingHelper/Behaviors/FadeAnimateItemsBehavior.cs +++ b/ZuneModdingHelper/Behaviors/FadeAnimateItemsBehavior.cs @@ -76,3 +76,41 @@ public class FadeAnimateItemsBehavior : Behavior } } } + +public class FadeAnimateItemsPanelBehavior : Behavior +{ + public DoubleAnimation Animation { get; set; } + public TimeSpan Tick { get; set; } + + protected override void OnAttached() + { + base.OnAttached(); + AssociatedObject.Loaded += AssociatedObject_Loaded; + } + + void AssociatedObject_Loaded(object sender, RoutedEventArgs e) + { + var items = AssociatedObject.Children.OfType().PruneNull(); + + foreach (var item in items) + item.Opacity = 0; + + var enumerator = items.GetEnumerator(); + if (enumerator.MoveNext()) + { + DispatcherTimer timer = new() { Interval = Tick }; + timer.Tick += (s, timerE) => + { + var item = enumerator.Current; + if (item is null) return; + + item.BeginAnimation(UIElement.OpacityProperty, Animation); + if (!enumerator.MoveNext()) + { + timer.Stop(); + } + }; + timer.Start(); + } + } +} diff --git a/ZuneModdingHelper/Pages/AboutPage.xaml b/ZuneModdingHelper/Pages/AboutPage.xaml index fcc5f54..14cfffb 100644 --- a/ZuneModdingHelper/Pages/AboutPage.xaml +++ b/ZuneModdingHelper/Pages/AboutPage.xaml @@ -5,6 +5,8 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:ZuneModdingHelper.Pages" xmlns:zmh="clr-namespace:ZuneModdingHelper" + xmlns:b="clr-namespace:ZuneModdingHelper.Behaviors" + xmlns:i="http://schemas.microsoft.com/xaml/behaviors" mc:Ignorable="d" d:DesignHeight="350" d:DesignWidth="750" d:Background="White"> @@ -43,8 +45,9 @@ - + + @@ -54,8 +57,9 @@ - - + + + @@ -75,8 +79,16 @@ - + + + + + + + + +