diff --git a/Wpf_AiSportsMicrospace/Views/Home.xaml.cs b/Wpf_AiSportsMicrospace/Views/Home.xaml.cs index 39c8f01..880f0de 100644 --- a/Wpf_AiSportsMicrospace/Views/Home.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/Home.xaml.cs @@ -175,7 +175,8 @@ namespace Wpf_AiSportsMicrospace else { //var newPage = new TrainingRecords(); - var newPage = new WhackAMole(); + //var newPage = new WhackAMole(); + var newPage = new StandingLeap(); mainWin?.SwitchPageWithMaskAnimation(newPage, true); } } diff --git a/Wpf_AiSportsMicrospace/Views/JumpLong/StandingLeap.xaml b/Wpf_AiSportsMicrospace/Views/JumpLong/StandingLeap.xaml index 93f7d06..b98e9c0 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpLong/StandingLeap.xaml +++ b/Wpf_AiSportsMicrospace/Views/JumpLong/StandingLeap.xaml @@ -25,7 +25,9 @@ x:Name="centerImg4" Visibility="Hidden" gif:ImageBehavior.AnimatedSource="/Resources/Img/test_img/jump_long/jumping.gif" - gif:ImageBehavior.RepeatBehavior="0" + gif:ImageBehavior.RepeatBehavior="1x" + gif:ImageBehavior.AutoStart="False" + gif:ImageBehavior.AnimationSpeedRatio="1.5" gif:ImageBehavior.AnimateInDesignMode="True" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="824,72,0,0" Width="824" Height="610"/> diff --git a/Wpf_AiSportsMicrospace/Views/JumpLong/StandingLeap.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpLong/StandingLeap.xaml.cs index aad17ea..1d160b5 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpLong/StandingLeap.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpLong/StandingLeap.xaml.cs @@ -230,7 +230,7 @@ namespace Views.JumpLong ImageBehavior.SetRepeatBehavior(centerImg4, new RepeatBehavior(2)); ImageBehavior.SetRepeatBehavior(centerImg4, new RepeatBehavior(1)); ImageBehavior.GetAnimationController(centerImg4).Play(); - await Task.Delay(800); + await Task.Delay(2100); _sport.Stop();//关闭运动 _mainWin.FacialRecognitionEvent -= this.HumanPredicting; count.Text = counts; diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs index 0509e06..cfd104d 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs @@ -226,13 +226,13 @@ namespace Wpf_AiSportsMicrospace.Views StartCountdown(3); _isCountdownStarted = true; // 倒计时开始,停止左手检测 break; - case (int)WavingAction.Raising: - UpdateCountdown(); - break; - case (int)WavingAction.RaiseHand: - FinishCountdown(); - _currentGameState = GameState.Running; // 倒计时完成 → 游戏开始 - break; + //case (int)WavingAction.Raising: + // UpdateCountdown(); + // break; + //case (int)WavingAction.RaiseHand: + // FinishCountdown(); + // _currentGameState = GameState.Running; // 倒计时完成 → 游戏开始 + // break; } } break; @@ -246,7 +246,7 @@ namespace Wpf_AiSportsMicrospace.Views private double _currentCountdown = 3600; private DateTime _lastUpdateTime = DateTime.Now; - private void StartCountdown(int start = 3) + private async void StartCountdown(int start = 3) { _mainWin.ShowCountDownAnimation(); //_currentCountdown = start; @@ -289,6 +289,10 @@ namespace Wpf_AiSportsMicrospace.Views // 绑定事件 _mainWin.FacialRecognitionEvent += handler; + + await Task.Delay(3000); + FinishCountdown(); + _currentGameState = GameState.Running; } private void UpdateCountdown() diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs index 1e251ee..0ea1f99 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs @@ -201,15 +201,18 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope switch (rightWaving) { case (int)WavingAction.FirstHand: - StartCountdown(3); - _isCountdownStarted = true; + if (!_isCountdownStarted) + { + StartCountdown(3); + } + break; case (int)WavingAction.Raising: - UpdateCountdown(); + //UpdateCountdown(); break; case (int)WavingAction.RaiseHand: - FinishCountdown(); - _currentGameState = GameState.Running; + //FinishCountdown(); + //_currentGameState = GameState.Running; break; } } @@ -230,15 +233,18 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope private int _currentCountdown = 3; private DateTime _lastUpdateTime = DateTime.Now; - private void StartCountdown(int start = 4) + private async void StartCountdown(int start = 4) { + _mainWin.ShowCountDownAnimation(); + _isCountdownStarted = true; _currentCountdown = start; //countdownText.Text = _currentCountdown.ToString(); //countdownGrid.Visibility = Visibility.Visible; _lastUpdateTime = DateTime.Now; - _mainWin.ShowCountDownAnimation(); Utils.PlayBackgroundMusic("countdown_3.mp3", false); + //UpdateCountdown(); + //开始人脸识别============================================= Action handler = null; @@ -269,8 +275,31 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope // 这里可以继续处理 studentList }; - // 绑定事件 + //// 绑定事件 _mainWin.FacialRecognitionEvent += handler; + + await Task.Delay(3000); + FinishCountdown(); + _currentGameState = GameState.Running; + } + + private void UpdateCountdown() + { + if ((DateTime.Now - _lastUpdateTime).TotalSeconds >= 1) + { + _lastUpdateTime = DateTime.Now; + _currentCountdown--; + + if (_currentCountdown > 0) + { + countdownText.Text = _currentCountdown.ToString(); + } + else + { + FinishCountdown(); + _currentGameState = GameState.Running; + } + } } private async Task LoadImageFromUrlAsync(string imageUrl, Image image) @@ -301,24 +330,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope } } - private void UpdateCountdown() - { - if ((DateTime.Now - _lastUpdateTime).TotalSeconds >= 1) - { - _lastUpdateTime = DateTime.Now; - _currentCountdown--; - - if (_currentCountdown > 0) - { - countdownText.Text = _currentCountdown.ToString(); - } - else - { - FinishCountdown(); - } - } - } - private async void FinishCountdown() { countdownText.Text = "GO!"; @@ -593,8 +604,10 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope private void Image_MouseDown(object sender, MouseButtonEventArgs e) { - popSilder1.StartMarginAnimation(); - popSilder2.StartMarginAnimation(); + //popSilder1.StartMarginAnimation(); + //popSilder2.StartMarginAnimation(); + //StartCountdown(); + StartCountdown(3); } } }