mirror of
https://github.com/ZuneDev/ZuneModdingHelper.git
synced 2026-07-27 13:12:21 -07:00
Crude method for dialog close animation
This commit is contained in:
@@ -29,6 +29,11 @@
|
||||
<Setter Property="AllowUncheck" Value="False"/>
|
||||
<Setter Property="HorizontalAlignment" Value="Center"/>
|
||||
</Style>
|
||||
|
||||
<Storyboard x:Key="DialogExitAnimation" x:Name="DialogExitAnimation">
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity"
|
||||
From="1.0" To="0.0" Duration="0:0:0.25" />
|
||||
</Storyboard>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid x:Name="LayoutRoot">
|
||||
@@ -120,7 +125,7 @@
|
||||
</ContentControl>
|
||||
</Border>
|
||||
|
||||
<ContentControl x:Name="DialogPresenter" Grid.RowSpan="3" Visibility="Collapsed" />
|
||||
<ContentControl x:Name="DialogPresenter" Grid.RowSpan="3" IsHitTestVisible="False"/>
|
||||
</Grid>
|
||||
|
||||
</Window>
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Interop;
|
||||
using System.Windows.Media.Animation;
|
||||
using ZuneModdingHelper.Controls;
|
||||
using ZuneModdingHelper.Messages;
|
||||
using ZuneModdingHelper.Pages;
|
||||
@@ -18,14 +19,18 @@ namespace ZuneModdingHelper
|
||||
{
|
||||
private IntPtr _windowHandle;
|
||||
private int _selectedPivotIdx = -1;
|
||||
private int _lastClosedDialog = 0;
|
||||
|
||||
private readonly Type[] _pages = [typeof(ModsPage), typeof(SettingsPage), typeof(AboutPage)];
|
||||
private readonly Storyboard _dialogExitAnimation;
|
||||
|
||||
public AppWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Pivot.Loaded += Pivot_Loaded;
|
||||
|
||||
_dialogExitAnimation = (Storyboard)Resources["DialogExitAnimation"];
|
||||
|
||||
WeakReferenceMessenger.Default.Register<ShowDialogMessage>(this);
|
||||
WeakReferenceMessenger.Default.Register<CloseDialogMessage>(this);
|
||||
}
|
||||
@@ -92,12 +97,27 @@ namespace ZuneModdingHelper
|
||||
{
|
||||
ViewModel = message.ViewModel
|
||||
};
|
||||
DialogPresenter.Visibility = Visibility.Visible;
|
||||
|
||||
DialogPresenter.IsHitTestVisible = true;
|
||||
}
|
||||
|
||||
void IRecipient<CloseDialogMessage>.Receive(CloseDialogMessage message)
|
||||
{
|
||||
DialogPresenter.Visibility = Visibility.Collapsed;
|
||||
DialogPresenter.IsHitTestVisible = false;
|
||||
|
||||
_dialogExitAnimation.Completed += DialogExitAnimation_Completed;
|
||||
|
||||
_lastClosedDialog = DialogPresenter.Content.GetHashCode();
|
||||
(DialogPresenter.Content as FrameworkElement)?.BeginStoryboard(_dialogExitAnimation);
|
||||
}
|
||||
|
||||
private void DialogExitAnimation_Completed(object sender, EventArgs e)
|
||||
{
|
||||
_dialogExitAnimation.Completed -= DialogExitAnimation_Completed;
|
||||
|
||||
if (_lastClosedDialog != DialogPresenter.Content?.GetHashCode())
|
||||
return;
|
||||
|
||||
DialogPresenter.Content = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user