From ec7b800c26d082edae8cd11396502f8143192b09 Mon Sep 17 00:00:00 2001 From: ltx <1006158920@qq.com> Date: Fri, 21 Nov 2025 13:23:46 +0800 Subject: [PATCH] =?UTF-8?q?update=EF=BC=9A=E6=96=B0=E5=BB=BA=E5=A4=9A?= =?UTF-8?q?=E4=BA=BA=E8=B7=B3=E7=BB=B3=E8=A1=A8&=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E8=B7=B3=E8=BF=9C=E4=BD=8D=E7=BD=AE=E7=82=B9=E8=A1=A8&?= =?UTF-8?q?=E8=B7=B3=E8=BF=9C=E9=85=8D=E7=BD=AE=E9=A1=B5=E9=9D=A2&?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E5=AF=86=E7=A0=81=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DBContext/AppDbContext.cs | 1 + .../Entities/JumpLongPoints.cs | 25 ++ Wpf_AiSportsMicrospace/App.xaml | 36 +- Wpf_AiSportsMicrospace/App.xaml.cs | 86 +++- Wpf_AiSportsMicrospace/MainWindow.xaml.cs | 10 +- Wpf_AiSportsMicrospace/Views/Home.xaml | 39 +- Wpf_AiSportsMicrospace/Views/Home.xaml.cs | 87 +++- .../Views/Setting/LongSetting.xaml | 85 ++++ .../Views/Setting/LongSetting.xaml.cs | 415 ++++++++++++++++++ 9 files changed, 755 insertions(+), 29 deletions(-) create mode 100644 AiSportsMicrospaceDB/Entities/JumpLongPoints.cs create mode 100644 Wpf_AiSportsMicrospace/Views/Setting/LongSetting.xaml create mode 100644 Wpf_AiSportsMicrospace/Views/Setting/LongSetting.xaml.cs diff --git a/AiSportsMicrospaceDB/DBContext/AppDbContext.cs b/AiSportsMicrospaceDB/DBContext/AppDbContext.cs index 29152b5..fb91f03 100644 --- a/AiSportsMicrospaceDB/DBContext/AppDbContext.cs +++ b/AiSportsMicrospaceDB/DBContext/AppDbContext.cs @@ -19,6 +19,7 @@ namespace AiSportsMicrospaceDB.DBContext public DbSet BasicConfig { get; set; } public DbSet SixGroupPoints { get; set; } + public DbSet JumpLongPoints { get; set; } } } diff --git a/AiSportsMicrospaceDB/Entities/JumpLongPoints.cs b/AiSportsMicrospaceDB/Entities/JumpLongPoints.cs new file mode 100644 index 0000000..c3e5bad --- /dev/null +++ b/AiSportsMicrospaceDB/Entities/JumpLongPoints.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AiSportsMicrospaceDB.Entities +{ + + public class JumpLongPoints { + // ✅ 主键 + public int Id { get; set; } + public Point TopPoint1 { get; set; } + public Point TopPoint2 { get; set; } + public Point TopPoint3 { get; set; } + public Point BottomPoint1 { get; set; } + public Point BottomPoint2 { get; set; } + public Point BottomPoint3 { get; set; } + } + + + +} diff --git a/Wpf_AiSportsMicrospace/App.xaml b/Wpf_AiSportsMicrospace/App.xaml index 7e24728..517d202 100644 --- a/Wpf_AiSportsMicrospace/App.xaml +++ b/Wpf_AiSportsMicrospace/App.xaml @@ -1,6 +1,7 @@  @@ -8,12 +9,33 @@ - ./Resoures/Fonts/myFontFamily - - - - + + + + + + + + + pack://application:,,,/YourApp;component/Resources/Fonts/#MyFontFamily + + + + + + + + + + + + + diff --git a/Wpf_AiSportsMicrospace/App.xaml.cs b/Wpf_AiSportsMicrospace/App.xaml.cs index 64f36c6..285b1b7 100644 --- a/Wpf_AiSportsMicrospace/App.xaml.cs +++ b/Wpf_AiSportsMicrospace/App.xaml.cs @@ -55,24 +55,65 @@ public partial class App : Application var db = scope.ServiceProvider.GetRequiredService(); //db.Database.EnsureDeleted(); // 删除数据库和表 db.Database.EnsureCreated(); - - //db.SixGroupPoints.Add(new AiSportsMicrospaceDB.Entities.SixGroupPoints - //{ - // Id = 1, - // point1 = new AiSportsMicrospaceDB.Entities.Point { X = 0.21, Y = 0.88 }, - // point2 = new AiSportsMicrospaceDB.Entities.Point { X = 0.36, Y = 0.58 }, - // point3 = new AiSportsMicrospaceDB.Entities.Point { X = 0.50, Y = 0.88 }, - // point4 = new AiSportsMicrospaceDB.Entities.Point { X = 0.64, Y = 0.58 }, - // point5 = new AiSportsMicrospaceDB.Entities.Point { X = 0.78, Y = 0.88 }, - // point6 = new AiSportsMicrospaceDB.Entities.Point { X = 0.92, Y = 0.58 } - //}); - //db.SaveChanges(); + //db.Database.ExecuteSqlRaw("DROP TABLE [JumpLongPoints]"); + if (!db.SixGroupPoints.Any()) + { + db.SixGroupPoints.Add(new AiSportsMicrospaceDB.Entities.SixGroupPoints + { + Id = 1, + point1 = new AiSportsMicrospaceDB.Entities.Point { X = 0.21, Y = 0.88 }, + point2 = new AiSportsMicrospaceDB.Entities.Point { X = 0.36, Y = 0.58 }, + point3 = new AiSportsMicrospaceDB.Entities.Point { X = 0.50, Y = 0.88 }, + point4 = new AiSportsMicrospaceDB.Entities.Point { X = 0.64, Y = 0.58 }, + point5 = new AiSportsMicrospaceDB.Entities.Point { X = 0.78, Y = 0.88 }, + point6 = new AiSportsMicrospaceDB.Entities.Point { X = 0.92, Y = 0.58 } + }); + db.SaveChanges(); + } + + if (!CheckTableExists(db , "JumpLongPoints")) + { + var createTableSql = @" + CREATE TABLE IF NOT EXISTS JumpLongPoints ( + Id INTEGER PRIMARY KEY, + TopPoint1_X TEXT NOT NULL, + TopPoint2_X TEXT NOT NULL, + TopPoint3_X TEXT NOT NULL, + BottomPoint1_X TEXT NOT NULL, + BottomPoint2_X TEXT NOT NULL, + BottomPoint3_X TEXT NOT NULL, + TopPoint1_Y TEXT NOT NULL, + TopPoint2_Y TEXT NOT NULL, + TopPoint3_Y TEXT NOT NULL, + BottomPoint1_Y TEXT NOT NULL, + BottomPoint2_Y TEXT NOT NULL, + BottomPoint3_Y TEXT NOT NULL + )"; + + db.Database.ExecuteSqlRaw(createTableSql); + } + + if (!db.JumpLongPoints.Any()) + { + db.JumpLongPoints.Add(new AiSportsMicrospaceDB.Entities.JumpLongPoints + { + Id = 1, + TopPoint1 = new AiSportsMicrospaceDB.Entities.Point { X = 245, Y = 741 }, + TopPoint2 = new AiSportsMicrospaceDB.Entities.Point { X = 1498, Y = 730 }, + TopPoint3 = new AiSportsMicrospaceDB.Entities.Point { X = 1689, Y = 724 }, + BottomPoint1 = new AiSportsMicrospaceDB.Entities.Point { X = 191, Y = 918 }, + BottomPoint2 = new AiSportsMicrospaceDB.Entities.Point { X = 1516, Y = 918 }, + BottomPoint3 = new AiSportsMicrospaceDB.Entities.Point { X = 1722, Y = 909 }, + }); + db.SaveChanges(); + } + //var mainWindow = new MainWindow(db); + //mainWindow.Show(); } // 用 DI 创建窗口 - //var mainWindow = AppHost.Services.GetRequiredService(); - //mainWindow.Show(); + var mainWin = AppHost.Services.GetRequiredService
(); Current.MainWindow = mainWin; @@ -81,5 +122,22 @@ public partial class App : Application var newPage = new Home(); mainWin.SwitchPage(newPage, true); } + + + private bool CheckTableExists(AppDbContext dbContext , String name) + { + try + { + // 使用原始SQL检查表是否存在 + var result = dbContext.Database.ExecuteSqlRaw(@" + SELECT count(*) FROM sqlite_master + WHERE type='table' AND name='JumpLongPoints'"); + return result > 0; + } + catch + { + return false; + } + } } diff --git a/Wpf_AiSportsMicrospace/MainWindow.xaml.cs b/Wpf_AiSportsMicrospace/MainWindow.xaml.cs index aca9758..6aa4e9d 100644 --- a/Wpf_AiSportsMicrospace/MainWindow.xaml.cs +++ b/Wpf_AiSportsMicrospace/MainWindow.xaml.cs @@ -106,12 +106,12 @@ public partial class MainWindow : Window private void ping_Click(object sender, RoutedEventArgs e) { - var config = _context.BasicConfig.FirstOrDefault(); + //var config = _context.BasicConfig.FirstOrDefault(); - if (config != null) - { - //var ip = config.Ip; - } + //if (config != null) + //{ + // //var ip = config.Ip; + //} var host = this.host.Text.Trim(); if (string.IsNullOrWhiteSpace(host)) diff --git a/Wpf_AiSportsMicrospace/Views/Home.xaml b/Wpf_AiSportsMicrospace/Views/Home.xaml index b770e0d..99cc5fa 100644 --- a/Wpf_AiSportsMicrospace/Views/Home.xaml +++ b/Wpf_AiSportsMicrospace/Views/Home.xaml @@ -3,12 +3,12 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Wpf_AiSportsMicrospace.MyUserControl" xmlns:gif="http://wpfanimatedgif.codeplex.com" + xmlns:hc="https://handyorg.github.io/handycontrol" Height="1080" Width="1920" Loaded="Window_Loaded" Unloaded="Home_Unloaded"> - + + +