From 67b17d9e99b53e937bf8a5cf2aac016e42327ad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=91=84?= Date: Mon, 2 Jan 2023 02:41:14 +0000 Subject: [PATCH] Update animations for Busy Indicator --- VTube-IFacial-Link/MainPage.xaml | 4 ++-- VTube-IFacial-Link/MainPage.xaml.cs | 28 +++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/VTube-IFacial-Link/MainPage.xaml b/VTube-IFacial-Link/MainPage.xaml index 5ebd083..75b4d14 100644 --- a/VTube-IFacial-Link/MainPage.xaml +++ b/VTube-IFacial-Link/MainPage.xaml @@ -139,8 +139,8 @@ - - + + diff --git a/VTube-IFacial-Link/MainPage.xaml.cs b/VTube-IFacial-Link/MainPage.xaml.cs index d224363..38b2991 100644 --- a/VTube-IFacial-Link/MainPage.xaml.cs +++ b/VTube-IFacial-Link/MainPage.xaml.cs @@ -258,15 +258,26 @@ public bool StartOnLaunch // show Busy Indicator if the process is longer than one second uint startDelay = 1000; Animation animation = new Animation(); - Animation ch_animation = new Animation(v => mainPage.BusyMessageOpacity = v, mainPage.BusyMessageOpacity, 1); - animation.Add((double)startDelay / (startDelay + duration), 1, ch_animation); - animation.Commit(mainPage, "BusyMessageFadeAnimation", 16, (startDelay + duration), Easing.CubicOut, (v, c) => { if (!c) mainPage.BusyMessageOpacity = 1; }, () => false); + animation.Add((double)startDelay / (startDelay + duration), 1, new Animation(v => mainPage.BusyMessageOpacity = v, 0, 1, Easing.CubicOut)); + animation.Add((double)startDelay / (startDelay + duration), 1, new Animation(v => mainPage.BusyMessageScale = v, 1.15, 1, Easing.CubicOut)); + animation.Commit(mainPage, "BusyMessageFadeAnimation", 16, (startDelay + duration), null, (v, c) => { + if (c) return; + mainPage.BusyMessageOpacity = 1; + mainPage.BusyMessageScale = 1; + }, () => false); } else { // hide Busy Indicator immediately - Animation animation = new Animation(v => mainPage.BusyMessageOpacity = v, mainPage.BusyMessageOpacity, 0); - animation.Commit(mainPage, "BusyMessageFadeAnimation", 16, duration, Easing.CubicIn, (v, c) => { if (!c) mainPage.BusyMessageOpacity = 0; }, () => false); + Animation animation = new Animation(); + animation.Add(0, 1, new Animation(v => mainPage.BusyMessageOpacity = v, mainPage.BusyMessageOpacity, 0, Easing.CubicIn)); + animation.Add(0, 1, new Animation(v => mainPage.BusyMessageScale = v, mainPage.BusyMessageScale, 1.15, Easing.CubicIn)); + animation.Commit(mainPage, "BusyMessageFadeAnimation", 16, duration, null, (v, c) => + { + if (c) return; + mainPage.BusyMessageOpacity = 0; + mainPage.BusyMessageScale = 1.15; + }, () => false); } }); public new bool IsBusy @@ -286,6 +297,13 @@ public double BusyMessageOpacity set => SetValue(BusyMessageOpacityProperty, value); } + public static readonly BindableProperty BusyMessageScaleProperty = BindableProperty.Create(nameof(BusyMessageScale), typeof(double), typeof(MainPage), 1d); + public double BusyMessageScale + { + get => (double)GetValue(BusyMessageScaleProperty); + set => SetValue(BusyMessageScaleProperty, value); + } + public static readonly BindableProperty BusyMessageProperty = BindableProperty.Create(nameof(BusyMessage), typeof(string), typeof(MainPage), string.Empty); public string BusyMessage {