From d1932b62a96eda5883e5281e879938493e0514bc Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Wed, 11 Mar 2026 13:16:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Wpf_AiSportsMicrospace/Common/SportOperate.cs | 6 ++-- .../MyUserControl/CoverFlowControl.xaml.cs | 29 ++++++++++++++++--- Wpf_AiSportsMicrospace/Views/Home.xaml.cs | 17 +++++++---- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/Wpf_AiSportsMicrospace/Common/SportOperate.cs b/Wpf_AiSportsMicrospace/Common/SportOperate.cs index b538c19..24a6af1 100644 --- a/Wpf_AiSportsMicrospace/Common/SportOperate.cs +++ b/Wpf_AiSportsMicrospace/Common/SportOperate.cs @@ -31,7 +31,7 @@ namespace Wpf_AiSportsMicrospace.Common IPointTracker _rightTracker; private int _leftWaveCount = 0; private int _rightWaveCount = 0; - private const int WaveThreshold =1; + private const int WaveThreshold = 3; WebcamClient _webcamClient; private DateTime? _wristStartTime = null; @@ -43,8 +43,8 @@ namespace Wpf_AiSportsMicrospace.Common _leftTracker = PostureCalculate.CreatePointTracker("left_wrist", 0); _rightTracker = PostureCalculate.CreatePointTracker("right_wrist", 0); - _leftTracker.Amplitude = 0.3f; - _rightTracker.Amplitude = 0.3f; + //_leftTracker.Amplitude = 0.3f; + //_rightTracker.Amplitude = 0.3f; } public WebcamClient CreateRTSP() diff --git a/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs b/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs index 4d2df00..c57c8ba 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs +++ b/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using System.Windows.Controls.Primitives; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; @@ -271,15 +272,35 @@ namespace Wpf_AiSportsMicrospace.MyUserControl } - public void SlideLeft() + public async void SlideLeft() { StopProgress(); - SelectedIndex++; + + await Dispatcher.InvokeAsync(async () => + { + while (ItemsHost.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) + await Task.Delay(10); + + // 强制刷新布局 + ItemsHost.UpdateLayout(); + + SelectedIndex++; + }, DispatcherPriority.ContextIdle); } - public void SlideRight() + + public async void SlideRight() { StopProgress(); - SelectedIndex--; + + await Dispatcher.InvokeAsync(async () => + { + while (ItemsHost.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) + await Task.Delay(10); + + ItemsHost.UpdateLayout(); + + SelectedIndex--; + }, DispatcherPriority.ContextIdle); } } } \ No newline at end of file diff --git a/Wpf_AiSportsMicrospace/Views/Home.xaml.cs b/Wpf_AiSportsMicrospace/Views/Home.xaml.cs index 91885d8..cfc7a74 100644 --- a/Wpf_AiSportsMicrospace/Views/Home.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/Home.xaml.cs @@ -106,16 +106,23 @@ namespace Wpf_AiSportsMicrospace switch (wavingaction) { case (int)WavingAction.LeftWave: // 左手挥动 - Application.Current.Dispatcher.Invoke(() => coverFlow.SlideRight()); + //Application.Current.Dispatcher.Invoke(() => coverFlow.SlideRight()); + + + coverFlow.SlideRight(); break; case (int)WavingAction.RightWave: // 右手挥动 - Application.Current.Dispatcher.Invoke(() => coverFlow.SlideLeft()); + //Application.Current.Dispatcher.Invoke(() => coverFlow.SlideLeft()); + coverFlow.SlideLeft(); break; case (int)WavingAction.FirstHand: // 举手开始 - //Application.Current.Dispatcher.BeginInvoke(() => coverFlow.StartSelectedProgress()); - RouterGoNew(); + Dispatcher.InvokeAsync(() => + { + coverFlow.StartSelectedProgress(); + }, DispatcherPriority.Render); + //RouterGoNew(); break; case (int)WavingAction.Raising: // 举手中,实时更新进度 @@ -124,7 +131,7 @@ namespace Wpf_AiSportsMicrospace case (int)WavingAction.RaiseHand: // 举手完成 // 设置标记,停止后续手势识别 //IsGestureActive = false; - //RouterGoNew(); + RouterGoNew(); //coverFlow.ProgressCompleted += CoverFlow_ProgressCompleted; break;