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();