diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs index 96c5094..5868a77 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs @@ -2,7 +2,6 @@ using Common; using Dto; using Emgu.CV.Flann; -using Emgu.CV.Structure; using Enum; using HandyControl.Controls; using Microsoft.EntityFrameworkCore; @@ -67,7 +66,7 @@ namespace Wpf_AiSportsMicrospace.Views private readonly object _updateLock = new object(); private readonly Dictionary _jumpStatus = new Dictionary(); private GroupJumpRopeContext _groupJumpRopeContext; - Image tipImage; + public GroupJumpRope() { InitializeComponent(); @@ -85,9 +84,11 @@ namespace Wpf_AiSportsMicrospace.Views using var scope = App.AppHost.Services.CreateScope(); var db = scope.ServiceProvider.GetRequiredService(); - var points = new[] { cfg.Point1, cfg.Point2, cfg.Point3, - cfg.Point4, cfg.Point5, cfg.Point6, - cfg.Point7, cfg.Point8, cfg.Point9, cfg.Point10 }; + // 获取配置 + var pointCount = await db.BasicConfig + .Where(x => x.Code == AppSettings.Code) + .Select(x => x.HomeWidth) + .FirstOrDefaultAsync(); var cfg = await db.GroupPoints.FirstOrDefaultAsync(x => x.Code == AppSettings.Code); @@ -137,14 +138,13 @@ namespace Wpf_AiSportsMicrospace.Views } private void ShowCenterTip(string imagePath, TimeSpan duration) { - tipImage = new Image + var tipImage = new Image { Source = new BitmapImage(new Uri(imagePath, UriKind.Absolute)), HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Opacity = 0, Margin = new Thickness(0, -100, 0, 0), - Name= "TipImage" }; // 增加图片的大小,调整比例 @@ -164,26 +164,26 @@ namespace Wpf_AiSportsMicrospace.Views tipImage.BeginAnimation(UIElement.OpacityProperty, fadeInAnimation); // 定时移除,并且渐变消失 - //Task.Delay(duration).ContinueWith(_ => - //{ - // Dispatcher.Invoke(() => - // { - // // 渐变消失动画 - // var fadeOutAnimation = new DoubleAnimation - // { - // From = 1, - // To = 0, - // Duration = TimeSpan.FromSeconds(1.5) - // }; - // tipImage.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation); + Task.Delay(duration).ContinueWith(_ => + { + Dispatcher.Invoke(() => + { + // 渐变消失动画 + var fadeOutAnimation = new DoubleAnimation + { + From = 1, + To = 0, + Duration = TimeSpan.FromSeconds(1.5) + }; + tipImage.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation); - // // 完成后移除图片 - // fadeOutAnimation.Completed += (s, e) => - // { - // userBox.Children.Remove(tipImage); - // }; - // }); - //}); + // 完成后移除图片 + fadeOutAnimation.Completed += (s, e) => + { + userBox.Children.Remove(tipImage); + }; + }); + }); } private void MediaPlayer_MediaEnded(object sender, EventArgs e) @@ -239,7 +239,6 @@ namespace Wpf_AiSportsMicrospace.Views private async void StartCountdown(int start = 3) { _mainWin.ShowCountDownAnimation(); - //_currentCountdown = start; Utils.PlayBackgroundMusic("countdown_3.mp3", false);