From f66bfd76bbda9934442dcefe37482bd2356cede5 Mon Sep 17 00:00:00 2001 From: krlvm <51774833+krlvm@users.noreply.github.com> Date: Sun, 19 Dec 2021 01:11:57 +0300 Subject: [PATCH] Improved entrace animation Fixed an issue when the region where flyout should be shown becomes blurry before the animation is finished --- MediaFlyout/FlyoutWindow.xaml.cs | 7 ++++--- MediaFlyout/Helpers/AnimationHelper.cs | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/MediaFlyout/FlyoutWindow.xaml.cs b/MediaFlyout/FlyoutWindow.xaml.cs index add3f33..c3a90fc 100644 --- a/MediaFlyout/FlyoutWindow.xaml.cs +++ b/MediaFlyout/FlyoutWindow.xaml.cs @@ -46,7 +46,7 @@ public FlyoutWindow() private void PrepareWindow() { - Left = 99999; + Left = 999999; Show(); Hide(); } @@ -87,10 +87,11 @@ private void Window_PreviewKeyDown(object sender, KeyEventArgs e) public async void DismissFlyout() { if (Visibility == Visibility.Hidden) return; - WindowStyle = WindowStyle.None; - Visibility = Visibility.Hidden; + Left = 999999; tray.isClosing = true; await System.Threading.Tasks.Task.Delay(System.Windows.Forms.SystemInformation.DoubleClickTime / 2); + WindowStyle = WindowStyle.None; + Visibility = Visibility.Hidden; tray.isClosing = false; } diff --git a/MediaFlyout/Helpers/AnimationHelper.cs b/MediaFlyout/Helpers/AnimationHelper.cs index 69c4259..058afb5 100644 --- a/MediaFlyout/Helpers/AnimationHelper.cs +++ b/MediaFlyout/Helpers/AnimationHelper.cs @@ -51,8 +51,10 @@ public static void ShowFlyout(T window, bool topmost = false) where T : Windo //window.IsRaising = true; BringTaskbarToFront(); - window.Visibility = Visibility.Visible; + if (property == Window.TopProperty) window.Top = 999999; else window.Left = 999999; window.WindowStyle = WindowStyle.SingleBorderWindow; + window.Visibility = Visibility.Visible; + System.Threading.Thread.Sleep(1); window.Activate(); InteropHelper.CloakWindow(window, false);