diff --git a/Wpf_AiSportsMicrospace/Resources/Img/提示图.png b/Wpf_AiSportsMicrospace/Resources/Img/提示图.png new file mode 100644 index 0000000..d923f6e Binary files /dev/null and b/Wpf_AiSportsMicrospace/Resources/Img/提示图.png differ diff --git a/Wpf_AiSportsMicrospace/Views/CenterHome.xaml.cs b/Wpf_AiSportsMicrospace/Views/CenterHome.xaml.cs index d24c21e..cb9a057 100644 --- a/Wpf_AiSportsMicrospace/Views/CenterHome.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/CenterHome.xaml.cs @@ -69,8 +69,7 @@ namespace Wpf_AiSportsMicrospace.Views { _mainWin.HumanFrameUpdated += OnHumanFrameUpdated; - Utils.PlayBackgroundMusic("homeprojectselected.mp3", true); - + //Utils.PlayBackgroundMusic("homeprojectselected.mp3", true); } private void CenterHome_Unloaded(object sender, RoutedEventArgs e) diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs index c0adc96..c097bf7 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs @@ -67,6 +67,56 @@ namespace Wpf_AiSportsMicrospace.Views { _mainWin.HumanFrameUpdated -= OnHumanFrameUpdated; } + private void ShowCenterTip(string imagePath, TimeSpan duration) + { + var tipImage = new Image + { + Source = new BitmapImage(new Uri(imagePath, UriKind.Absolute)), + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + Opacity = 0 + }; + + // 增加图片的大小,调整比例 + tipImage.Width = overlayCanvas.ActualWidth * 0.9; // 宽度为 Canvas 宽度的 90% + tipImage.Height = overlayCanvas.ActualHeight * 0.6; // 高度为 Canvas 高度的 60% + + // 将图片添加到 Overlay Canvas + overlayCanvas.Children.Add(tipImage); + Canvas.SetLeft(tipImage, (overlayCanvas.ActualWidth - tipImage.Width) / 2); // 居中 + Canvas.SetTop(tipImage, (overlayCanvas.ActualHeight - tipImage.Height) / 2); // 居中 + + // 渐变出现动画 + var fadeInAnimation = new DoubleAnimation + { + From = 0, + To = 1, + Duration = TimeSpan.FromSeconds(1.5) + }; + tipImage.BeginAnimation(UIElement.OpacityProperty, fadeInAnimation); + + // 定时移除,并且渐变消失 + Task.Delay(duration).ContinueWith(_ => + { + Dispatcher.Invoke(() => + { + // 渐变消失动画 + var fadeOutAnimation = new DoubleAnimation + { + From = 1, + To = 0, + Duration = TimeSpan.FromSeconds(1.5) + }; + tipImage.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation); + + // 完成后移除图片 + fadeOutAnimation.Completed += (s, e) => + { + overlayCanvas.Children.Remove(tipImage); + }; + }); + }); + } private void PlayMusic(string musicFileName) { @@ -150,7 +200,6 @@ namespace Wpf_AiSportsMicrospace.Views // 可在这里绑定抽帧事件 _mainWin.HumanFrameUpdated += OnHumanFrameUpdated; } - private void OnHumanFrameUpdated(object sender, List humans) { try diff --git a/Wpf_AiSportsMicrospace/Wpf_AiSportsMicrospace.csproj b/Wpf_AiSportsMicrospace/Wpf_AiSportsMicrospace.csproj index 6e0c6e9..3261e1b 100644 --- a/Wpf_AiSportsMicrospace/Wpf_AiSportsMicrospace.csproj +++ b/Wpf_AiSportsMicrospace/Wpf_AiSportsMicrospace.csproj @@ -57,6 +57,7 @@ + @@ -249,6 +250,9 @@ Always + + Always + Always