From 7daea89ec48c6809c11169acc222e7b22a5c6361 Mon Sep 17 00:00:00 2001 From: ltx <1006158920@qq.com> Date: Tue, 11 Nov 2025 14:30:29 +0800 Subject: [PATCH] =?UTF-8?q?update:=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DBContext/AppDbContext.cs | 19 +++++++++++++++++++ AiSportsMicrospaceDB/Entities/BasicConfig.cs | 7 +++++++ .../Dto/GroupJumpRopeContext.cs | 2 +- .../Views/JumpRope/GroupJumpRope.xaml.cs | 18 ++++++++++++++++-- 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/AiSportsMicrospaceDB/DBContext/AppDbContext.cs b/AiSportsMicrospaceDB/DBContext/AppDbContext.cs index ddec24f..28e070f 100644 --- a/AiSportsMicrospaceDB/DBContext/AppDbContext.cs +++ b/AiSportsMicrospaceDB/DBContext/AppDbContext.cs @@ -15,6 +15,25 @@ namespace AiSportsMicrospaceDB.DBContext { } + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasData( + new SixGroupPoints + { + Id = 1, + points = [ + (0.21, 0.88 ), + (0.36, 0.58 ), + (0.50, 0.88), + (0.64, 0.58 ), + (0.78, 0.88), + (0.92, 0.58 ) + ] + }); + } + public DbSet BasicConfig { get; set; } + + public DbSet SixGroupPoints { get; set; } } } diff --git a/AiSportsMicrospaceDB/Entities/BasicConfig.cs b/AiSportsMicrospaceDB/Entities/BasicConfig.cs index 5b02428..5cef090 100644 --- a/AiSportsMicrospaceDB/Entities/BasicConfig.cs +++ b/AiSportsMicrospaceDB/Entities/BasicConfig.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; @@ -14,4 +15,10 @@ namespace AiSportsMicrospaceDB.Entities public string UserName { get; set; } public string Password { get; set; } } + + public class SixGroupPoints { + // ✅ 主键 + public int Id { get; set; } + public List<(double,double)> points { get; set; } + } } diff --git a/Wpf_AiSportsMicrospace/Dto/GroupJumpRopeContext.cs b/Wpf_AiSportsMicrospace/Dto/GroupJumpRopeContext.cs index e21485a..3c1a305 100644 --- a/Wpf_AiSportsMicrospace/Dto/GroupJumpRopeContext.cs +++ b/Wpf_AiSportsMicrospace/Dto/GroupJumpRopeContext.cs @@ -14,7 +14,7 @@ namespace Dto { // 静态字段,保存排名列表 public static List RankList { get; set; } = new List(); - public List<(double XNorm, double YNorm)> CirclePositions { get; private set; } + public List<(double XNorm, double YNorm)> CirclePositions { get; set; } = new List<(double XNorm, double YNorm)>(); public List UserList { get; private set; } public List UserNumberList { get; private set; } public List Sports { get; private set; } diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs index bc47647..4d7d463 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs @@ -1,4 +1,5 @@ -using Dto; +using AiSportsMicrospaceDB.DBContext; +using Dto; using Emgu.CV.Flann; using Enum; using HandyControl.Controls; @@ -67,9 +68,23 @@ namespace Wpf_AiSportsMicrospace.Views Unloaded += UserControl_Unloaded; _groupJumpRopeContext = new GroupJumpRopeContext(); + // 将原来的赋值方式: + //_groupJumpRopeContext.CirclePositions = config != null ? config.sixJumpPoints : _groupJumpRopeContext.CirclePositions; + + // 修改为:先清空再添加元素(因为 CirclePositions 只有 get,没有 set) + //_groupJumpRopeContext.CirclePositions.Clear(); + //if (config != null && config.sixJumpPoints != null) + //{ + // foreach (var pt in config.sixJumpPoints) + // { + // _groupJumpRopeContext.CirclePositions.Add(pt); + // } + //} + } private async void UserControl_Loaded(object sender, RoutedEventArgs e) { + // 绑定人脸识别事件 _mainWin.FacialRecognitionEvent += async (sender, buffer) => { @@ -679,6 +694,5 @@ namespace Wpf_AiSportsMicrospace.Views var fadeIn = new DoubleAnimation(0, 1, TimeSpan.FromMilliseconds(time)); Element.BeginAnimation(UIElement.OpacityProperty, fadeIn); } - } }