From 7184b19d594a0f0db6d9ecd261886ef87470c3d1 Mon Sep 17 00:00:00 2001
From: tanglong <842690096@qq.com>
Date: Mon, 13 Oct 2025 14:51:45 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E7=94=BB=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../MyUserControl/SportUserItem.xaml | 8 ++---
.../Views/JumpRope/GroupJumpRope.xaml.cs | 34 ++++++-------------
2 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/Wpf_AiSportsMicrospace/MyUserControl/SportUserItem.xaml b/Wpf_AiSportsMicrospace/MyUserControl/SportUserItem.xaml
index 5a12fde..fa3610b 100644
--- a/Wpf_AiSportsMicrospace/MyUserControl/SportUserItem.xaml
+++ b/Wpf_AiSportsMicrospace/MyUserControl/SportUserItem.xaml
@@ -46,9 +46,9 @@
Margin="0,131,0,0"
Visibility="{Binding ImageState, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource ImageStateToVisibilityConverter}, ConverterParameter=2}" />-->
-
-
@@ -58,8 +58,8 @@
gif:ImageBehavior.RepeatBehavior="Forever"
HorizontalAlignment="Center"
VerticalAlignment="Top"
- Width="370"
- Margin="0,131,0,0"
+ Width="345"
+ Margin="0,91,0,0"
/>
diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs
index 0647c8b..3400745 100644
--- a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs
+++ b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs
@@ -395,24 +395,28 @@ namespace Wpf_AiSportsMicrospace.Views
userList[circleIndex].ImageState = "1";
}
+ // 检查当前编号是否未变化超过 2 秒
if (userNumberList[circleIndex] == userList[circleIndex].NumberText)
{
- // 获取上次触发时间
+ // 获取上次变化时间
if (!_lastJumpUpdateTime.TryGetValue(circleIndex, out var lastTime))
- {
- lastTime = DateTime.MinValue;
- }
+ lastTime = DateTime.Now; // 默认当前时间
- // 判断是否超过 2 秒
- if ((DateTime.Now - lastTime).TotalSeconds >= 1)
+ var elapsed = (DateTime.Now - lastTime).TotalSeconds;
+
+ if (elapsed >1)
{
+ // 2 秒未变化,更新状态为禁止
userList[circleIndex].ImageState = "1";
- _lastJumpUpdateTime[circleIndex] = DateTime.Now;
+ _lastJumpUpdateTime[circleIndex] = DateTime.Now; // 重置时间
}
+ // 否则:2 秒内仍在变化,不更新状态
}
else
{
+ // 编号发生变化,更新记录,并保持状态不变
userNumberList[circleIndex] = userList[circleIndex].NumberText;
+ _lastJumpUpdateTime[circleIndex] = DateTime.Now;
}
}
//else if
@@ -464,24 +468,8 @@ namespace Wpf_AiSportsMicrospace.Views
// 订阅事件
sport.OnTicked += (count, times) =>
{
- //if (currentItem.NumberText == count.ToString())
- //{
- // currentItem.ImageState = "1";
- //}
- //else
- //{
-
- // currentItem.ImageState = "2";
- // currentItem.NumberText = count.ToString();
- //}
-
currentItem.ImageState = "2";
currentItem.NumberText = count.ToString();
-
- //Application.Current.Dispatcher.BeginInvoke(() =>
- //{
- // currentItem.NumberText = count.ToString();
- //});
};
sport.Start();