update:GroupPoints点位切换
This commit is contained in:
parent
635c9bb800
commit
6d93c2332b
14
Wpf_AiSportsMicrospace/Views/Setting/GroupSetting.xaml
Normal file
14
Wpf_AiSportsMicrospace/Views/Setting/GroupSetting.xaml
Normal file
@ -0,0 +1,14 @@
|
||||
<Page x:Class="Views.Setting.GroupSetting"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Views.Setting"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
Title="GroupSetting">
|
||||
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
</Page>
|
||||
26
Wpf_AiSportsMicrospace/Views/Setting/GroupSetting.xaml.cs
Normal file
26
Wpf_AiSportsMicrospace/Views/Setting/GroupSetting.xaml.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Views.Setting
|
||||
{
|
||||
/// <summary>
|
||||
/// GroupSetting.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class GroupSetting : Page
|
||||
{
|
||||
public GroupSetting()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -134,7 +134,7 @@ namespace Wpf_AiSportsMicrospace.Views
|
||||
ClearPoints();
|
||||
|
||||
// 获取已保存的点位数据
|
||||
var pointsData = await db.SixGroupPoints.FirstOrDefaultAsync(x => x.Code == AppSettings.Code);
|
||||
var pointsData = await db.GroupPoints.FirstOrDefaultAsync(x => x.Code == AppSettings.Code);
|
||||
|
||||
if (pointsData != null)
|
||||
{
|
||||
@ -251,9 +251,9 @@ namespace Wpf_AiSportsMicrospace.Views
|
||||
|
||||
/// <summary>
|
||||
/// 从数据库数据加载点位
|
||||
/// db.SixGroupPoints 包含 Point1_X, Point1_Y, Point2_X, Point2_Y 等字段
|
||||
/// db.GroupPoints 包含 Point1_X, Point1_Y, Point2_X, Point2_Y 等字段
|
||||
/// </summary>
|
||||
private void LoadPointsFromDatabaseData(SixGroupPoints data, int pointCount)
|
||||
private void LoadPointsFromDatabaseData(GroupPoints data, int pointCount)
|
||||
{
|
||||
for (int i = 1; i <= pointCount; i++)
|
||||
{
|
||||
@ -264,7 +264,7 @@ namespace Wpf_AiSportsMicrospace.Views
|
||||
};
|
||||
|
||||
// 从数据库读取 Point 类型的属性
|
||||
var pointProperty = typeof(SixGroupPoints).GetProperty($"Point{i}");
|
||||
var pointProperty = typeof(GroupPoints).GetProperty($"Point{i}");
|
||||
|
||||
if (pointProperty != null)
|
||||
{
|
||||
@ -883,12 +883,12 @@ namespace Wpf_AiSportsMicrospace.Views
|
||||
using var scope = App.AppHost.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
|
||||
var pointsData = db.SixGroupPoints.FirstOrDefault(x => x.Code == AppSettings.Code);
|
||||
var pointsData = db.GroupPoints.FirstOrDefault(x => x.Code == AppSettings.Code);
|
||||
|
||||
if (pointsData == null)
|
||||
{
|
||||
pointsData = new SixGroupPoints { Code = AppSettings.Code };
|
||||
db.SixGroupPoints.Add(pointsData);
|
||||
pointsData = new GroupPoints { Code = AppSettings.Code };
|
||||
db.GroupPoints.Add(pointsData);
|
||||
}
|
||||
|
||||
// 获取 Point 类型(支持 System.Drawing.Point 或 System.Windows.Point)
|
||||
@ -898,7 +898,7 @@ namespace Wpf_AiSportsMicrospace.Views
|
||||
{
|
||||
foreach (var point in _points)
|
||||
{
|
||||
var pointProperty = typeof(SixGroupPoints).GetProperty($"Point{point.Id}");
|
||||
var pointProperty = typeof(GroupPoints).GetProperty($"Point{point.Id}");
|
||||
|
||||
if (pointProperty != null)
|
||||
{
|
||||
@ -932,10 +932,10 @@ namespace Wpf_AiSportsMicrospace.Views
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
|
||||
// 删除现有的点位数据
|
||||
var existingData = db.SixGroupPoints.FirstOrDefault(x => x.Code == AppSettings.Code);
|
||||
var existingData = db.GroupPoints.FirstOrDefault(x => x.Code == AppSettings.Code);
|
||||
if (existingData != null)
|
||||
{
|
||||
db.SixGroupPoints.Remove(existingData);
|
||||
db.GroupPoints.Remove(existingData);
|
||||
db.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user