This commit is contained in:
tanglong 2025-10-21 17:41:08 +08:00
parent 3057f34cda
commit 452ed85339

View File

@ -26,10 +26,12 @@ namespace Views.JumpRope
{ {
private Main _mainWin => Application.Current.MainWindow as Main; private Main _mainWin => Application.Current.MainWindow as Main;
private GroupJumpRopeContext _groupJumpRopeContext; private GroupJumpRopeContext _groupJumpRopeContext;
UserControl newPage = null;
public TrainingRecords() public TrainingRecords()
{ {
InitializeComponent(); InitializeComponent();
Loaded += UserControl_Loaded; Loaded += UserControl_Loaded;
_groupJumpRopeContext = new GroupJumpRopeContext();
LoadData(); LoadData();
} }
@ -37,6 +39,7 @@ namespace Views.JumpRope
{ {
Utils.PlayBackgroundMusic("homeprojectselected.mp3", true); Utils.PlayBackgroundMusic("homeprojectselected.mp3", true);
_mainWin.HumanFrameUpdated += OnHumanFrameUpdated; _mainWin.HumanFrameUpdated += OnHumanFrameUpdated;
_mainWin.WebcamClient.StartExtract();
} }
private void OnHumanFrameUpdated(object sender, List<Human> humans) private void OnHumanFrameUpdated(object sender, List<Human> humans)
@ -48,13 +51,17 @@ namespace Views.JumpRope
int leftWaving = DetectLeftHandRaise(humans); int leftWaving = DetectLeftHandRaise(humans);
if (leftWaving == 5) if (leftWaving == 5)
{ {
_mainWin.HumanFrameUpdated -= OnHumanFrameUpdated; //_mainWin.HumanFrameUpdated -= OnHumanFrameUpdated;
_mainWin.WebcamClient.StopExtract(); if(newPage == null)
{
// 举左手逻辑,例如结束动画或退出 newPage = new Home();
var newPage = new Home();
_mainWin?.SwitchPageWithMaskAnimation(newPage, true); _mainWin?.SwitchPageWithMaskAnimation(newPage, true);
} }
// 举左手逻辑,例如结束动画或退出
//return;
//_mainWin.WebcamClient.StopExtract();
}
} }
catch (Exception ex) catch (Exception ex)
@ -66,7 +73,6 @@ namespace Views.JumpRope
public void LoadData() public void LoadData()
{ {
_groupJumpRopeContext = new GroupJumpRopeContext();
ShowRankingBoard(_groupJumpRopeContext.UpdateRankList()); ShowRankingBoard(_groupJumpRopeContext.UpdateRankList());
} }
public void ShowRankingBoard(List<RankItem> list) public void ShowRankingBoard(List<RankItem> list)