Skip to content

Commit 01d30dd

Browse files
committed
优化背景图像设置和动画持续时间
1 parent 7d845c0 commit 01d30dd

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

Mikoto/Windows/MainWindow.xaml.cs

+10-14
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,16 @@ public void Refresh()
7272

7373
private async void SetRandomBlurredBackground()
7474
{
75-
if (GameInfoList.Count > 5)
75+
if (GameInfoList.Count <= 5) return;
76+
77+
BitmapSource? image = await Task.Run(GetRandomBlurredImage);
78+
if (image != null)
7679
{
77-
await Task.Run(() =>
78-
{
79-
BitmapSource? image = GetRandomBlurredImage();
80-
if (image != null)
81-
{
82-
Dispatcher.BeginInvoke(() =>
83-
{
84-
Background = new ImageBrush(image);
85-
PlayFadeInAnimation(this);
86-
});
87-
}
88-
});
80+
await Dispatcher.BeginInvoke(() =>
81+
{
82+
Background = new ImageBrush(image);
83+
PlayFadeInAnimation(this);
84+
});
8985
}
9086
}
9187

@@ -126,7 +122,7 @@ private static void PlayFadeInAnimation(UIElement element)
126122
{
127123
From = 0,
128124
To = 1,
129-
Duration = TimeSpan.FromMilliseconds(1000),
125+
Duration = TimeSpan.FromSeconds(1),
130126
EasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseOut }
131127
};
132128

0 commit comments

Comments
 (0)