动画优化
This commit is contained in:
parent
7db24230e0
commit
7184b19d59
@ -46,9 +46,9 @@
|
||||
Margin="0,131,0,0"
|
||||
Visibility="{Binding ImageState, RelativeSource={RelativeSource AncestorType=UserControl}, Converter={StaticResource ImageStateToVisibilityConverter}, ConverterParameter=2}" />-->
|
||||
|
||||
<Image Source="/Resources/Img/test_img/one_rope/out_user.png" Width="250" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,131,0,0"
|
||||
<Image Source="/Resources/Img/test_img/one_rope/out_user.png" Width="230" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,151,0,0"
|
||||
x:Name="image3" Visibility="Hidden"/>
|
||||
<Image Source="/Resources/Img/test_img/one_rope/pre_user.png" Width="270" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,131,0,0"
|
||||
<Image Source="/Resources/Img/test_img/one_rope/pre_user.png" Width="230" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,151,0,0"
|
||||
x:Name="image1" Visibility="Collapsed" />
|
||||
<!--<Image Source="/Resources/Img/test_img/one_rope/nopeople.png" Width="270" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,131,0,0"
|
||||
x:Name="image0" Visibility="Collapsed"/>-->
|
||||
@ -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"
|
||||
/>
|
||||
|
||||
</Grid>
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user