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"> - + + +