1 Commits
xyy3 ... new

Author SHA1 Message Date
529c0a008b test 2026-05-04 14:28:31 +08:00
25 changed files with 1575 additions and 2155 deletions

4
.gitignore vendored
View File

@@ -76,6 +76,4 @@ Thumbs.db
# 忽略编译生成的 obj 目录(核心!) # 忽略编译生成的 obj 目录(核心!)
obj/ obj/
*.g.cs *.g.cs
*.g.i.cs *.g.i.cs
/头罩视野slove/头罩视野/obj/Debug/net10.0-windows/头罩视野_MarkupCompile.lref
/头罩视野slove/头罩视野/obj/头罩视野.csproj.nuget.g.props

View File

@@ -1,10 +0,0 @@
{
"runtimeOptions": {
"tfm": "net10.0",
"framework": {
"name": "Microsoft.WindowsDesktop.App",
"version": "10.0.7"
},
"rollForward": "latestMinor"
}
}

View File

@@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:头罩视野" xmlns:local="clr-namespace:头罩视野"
StartupUri="MainWindow.xaml" Exit="MainForm_FormClosing"> StartupUri="MainWindow.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>

View File

@@ -1,27 +1,14 @@
using Modbus.Device; using System.Configuration;
using System.Configuration;
using System.Data; using System.Data;
using System.Windows; using System.Windows;
using .Services.Data;
namespace namespace
{ {
/// <summary> /// <summary>
/// Interaction logic for App.xaml /// Interaction logic for App.xaml
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
private IModbusMaster _modbusMaster => ModbusResourceManager.Instance.ModbusMaster;
private void MainForm_FormClosing(object sender, ExitEventArgs e)
{
_modbusMaster.WriteSingleCoil(1, 1, false);
_modbusMaster.WriteSingleCoil(1, 0, false);
// 最后退出程序
System.Windows.Application.Current.Shutdown();
}
} }
} }

View File

@@ -7,7 +7,7 @@
xmlns:local="clr-namespace:头罩视野" xmlns:local="clr-namespace:头罩视野"
mc:Ignorable="d" mc:Ignorable="d"
Background="#FFE6F2FF" Background="#FFE6F2FF"
Title="MainWindow" Height="768" Width="1024" WindowStartupLocation="CenterScreen" WindowState="Maximized" > Title="MainWindow" Height="768" Width="1024">
<Window.Resources> <Window.Resources>
<Style x:Key="TabButtonStyle" TargetType="Button"> <Style x:Key="TabButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#3498DB"/> <Setter Property="Background" Value="#3498DB"/>

View File

@@ -6,7 +6,6 @@ using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Documents; using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
@@ -22,12 +21,11 @@ namespace 头罩视野
public partial class MainWindow : Window public partial class MainWindow : Window
{ {
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
ModbusHelper.Connect("192.168.1.10", 502); // 连接一次,全局生效 ModbusHelper.Connect("192.168.1.10", 502); // 连接一次,全局生效
} }
// 程序退出 // 程序退出
@@ -48,7 +46,5 @@ namespace 头罩视野
//NavigationService.Navigate(new Views.RecordDate()); 页面相互跳转 //NavigationService.Navigate(new Views.RecordDate()); 页面相互跳转
//private void ShowError(string msg) => MessageBox.Show(msg, "错误", MessageBoxButton.OK, MessageBoxImage.Error); //private void ShowError(string msg) => MessageBox.Show(msg, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
} }
} }

View File

@@ -1,111 +1,130 @@
using System;
using System.Collections.Generic; using MathNet.Numerics.LinearAlgebra;
using System.Linq; using MathNetMatrix = MathNet.Numerics.LinearAlgebra.Matrix<double>;
using MathNetVector = MathNet.Numerics.LinearAlgebra.Vector<double>;
using System.Drawing;
namespace .Services namespace .Services
{ {
public static class GetArea class GetArea
{ {
// 灯条参数
public const int totalLights = 81; // 每条灯条81个灯
public static double verticalAngleStep = 90.0 / (totalLights - 1); // 1.125°
public static double CalculateBottomViewAngle(int[] lightData, List<(int m, int n)> lightPositions) // 设备固定参数
{ private static double R = 330; // 半球半径
int bottomLampCount = 0; private static double angleStep = 10; // 每格角度
for (int i = 0; i < lightData.Length && i < lightPositions.Count; i++)
{
if (lightPositions[i].n == 1 && lightData[i] == 1)
bottomLampCount++;
}
return (double)bottomLampCount / 81 * 90.0;
}
/// <summary> // 定义参数(和你代码里一致)
/// 根据径向灯条0/1数据计算边界角度极角 private const int totalLights = 81;
/// </summary>
/// <param name="lightStates">从上到下的灯条状态索引0=顶部0°索引80=底部90°</param> // 传入72个灯的亮灭数据0=灭1=亮)
public static double ComputeBoundaryAngle(int[] lightStates) // 返回:椭圆面积
public static double CalculateEllipseArea(int[] lightData, List<(int m, int n)> lightPositions)
{ {
if (lightStates == null || lightStates.Length != totalLights) return 0; //if (lightData.Length != totalLights || lightPositions.Count != totalLights)
int firstZero = -1; // throw new Exception("必须是81个灯的数据");
// 第一步:收集所有亮灯坐标
List<System.Drawing.Point> brightPoints = new List<System.Drawing.Point>();
for (int i = 0; i < totalLights; i++) for (int i = 0; i < totalLights; i++)
{ {
if (lightStates[i] == 0) if (lightData[i] == 1)
{ {
firstZero = i; var (m, n) = lightPositions[i];
break; System.Drawing.Point p = GetLightPoint(m, n);
brightPoints.Add(p);
} }
} }
if (firstZero == -1) return 90.0; // 全亮
if (firstZero == 0) return 0.0; // 顶部即被遮
// 边界角度 = 上一个灯条的结束角 = (firstZero) * verticalAngleStep
return firstZero * verticalAngleStep;
}
/// <summary> // 第二步:用亮点拟合椭圆
/// 极坐标梯形法积分面积(半径数组单位:度,步长单位:度) var (cx, cy, a, b, area) = FitEllipse(brightPoints);
/// </summary>
public static double IntegrateArea(double[] radiiDeg, double deltaThetaDeg) // 返回面积
return area;
}
/// 生成设备全部243盏灯的(m,n)位置 上爪1条、下爪1条、左右共用1条各81灯
private static System.Drawing.Point GetLightPoint(int m, int n)
{ {
if (radiiDeg == null || radiiDeg.Length < 2) return 0; double radH, radV;
double deltaRad = deltaThetaDeg * Math.PI / 180.0;
double sum = 0.0; // 上爪灯条n=0水平角固定m控制垂直角
for (int i = 0; i < radiiDeg.Length - 1; i++) if (n == 0)
{ {
double r1 = radiiDeg[i]; radH = 0;
double r2 = radiiDeg[i + 1]; radV = m * angleStep * Math.PI / 180;
double avgRSq = (r1 * r1 + r2 * r2) / 2.0;
sum += avgRSq * deltaRad;
} }
return 0.5 * sum; // 下爪灯条n=1水平角固定为180°m控制垂直角
} else if (n == 1)
/// <summary>
/// 根据左右眼边界半径数组,计算总视野(并集)和双目视野(交集)面积
/// </summary>
public static (double totalArea, double biArea) ComputeTotalAndBinocularArea(double[] leftRadii, double[] rightRadii, double deltaThetaDeg)
{
int len = Math.Min(leftRadii.Length, rightRadii.Length);
double[] totalRadii = new double[len];
double[] biRadii = new double[len];
for (int i = 0; i < len; i++)
{ {
totalRadii[i] = Math.Max(leftRadii[i], rightRadii[i]); radH = Math.PI;
biRadii[i] = Math.Min(leftRadii[i], rightRadii[i]); radV = m * angleStep * Math.PI / 180;
} }
double totalArea = IntegrateArea(totalRadii, deltaThetaDeg); // 左右共用灯条n=2垂直角固定m控制水平角
double biArea = IntegrateArea(biRadii, deltaThetaDeg); else
return (totalArea, biArea);
}
/// <summary>
/// 保存率计算公式(带γ校正)
/// </summary>
public static double ComputePreservation(double measuredArea, double standardArea, double gamma)
{
if (standardArea <= 0) return 0;
return gamma * (measuredArea / standardArea) * 100.0;
}
/// <summary>
/// 根据面积比获取γ校正系数GB 2890-2022 图D.4
/// </summary>
public static double GetGammaByRatio(double ratio)
{
double[] x = { 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 };
double[] y = { 1.22, 1.18, 1.14, 1.10, 1.06, 1.03, 1.02, 1.01, 1.00 };
if (ratio <= x[0]) return y[0];
if (ratio >= x.Last()) return y.Last();
for (int i = 0; i < x.Length - 1; i++)
{ {
if (ratio >= x[i] && ratio <= x[i + 1]) radH = m * angleStep * Math.PI / 180;
radV = 0;
}
// 保留你原来的投影公式
double x = R * Math.Tan(radH);
double y = R * Math.Tan(radV);
return new System.Drawing.Point((int)Math.Round(x), (int)Math.Round(y));
}
// 最小二乘法拟合椭圆核心算法cx椭圆中心点的 X 坐标 cy椭圆中心点的 Y 坐标 a椭圆的长半轴长度较大的那个半径b椭圆的短半轴长度较小的那个半径
private static (double cx, double cy, double a, double b, double area) FitEllipse(List<Point> points)
{
int n = points.Count;
if (n < 5)
throw new Exception("至少需要5个点来拟合椭圆");
// 这里是正确写法
var M = MathNetMatrix.Build.Dense(n, 5);
var Y = MathNetVector.Build.Dense(n, i => -1.0);
for (int i = 0; i < n; i++)
{ {
double t = (ratio - x[i]) / (x[i + 1] - x[i]); double x = points[i].X;
return y[i] + t * (y[i + 1] - y[i]); double y = points[i].Y;
M[i, 0] = x * x;
M[i, 1] = x * y;
M[i, 2] = y * y;
M[i, 3] = x;
M[i, 4] = y;
} }
}
return 1.0; // 求解
Vector<double> sol = M.QR().Solve(Y);
double A = sol[0], B = sol[1], C = sol[2], D = sol[3], E = sol[4], F = 1;
// 椭圆中心
double cx = (2 * C * D - B * E) / (B * B - 4 * A * C);
double cy = (2 * A * E - B * D) / (B * B - 4 * A * C);
// 半轴
double term1 = 2 * (A * E * E + C * D * D - B * D * E + (B * B - 4 * A * C) * F);
double term2 = (A + C) + Math.Sqrt((A - C) * (A - C) + B * B);
double term3 = (A + C) - Math.Sqrt((A - C) * (A - C) + B * B);
double a = Math.Sqrt(Math.Abs(term1 / ((B * B - 4 * A * C) * term3)));
double b = Math.Sqrt(Math.Abs(term1 / ((B * B - 4 * A * C) * term2)));
if (a < b) (a, b) = (b, a);
double area = Math.PI * a * b;
return (cx, cy, a, b, area);
} }
} }
}
}

View File

@@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using static OfficeOpenXml.ExcelErrorValue;
namespace namespace
{ {
@@ -19,11 +18,6 @@ namespace 头罩视野
//public double BlankArea { get; set; } //public double BlankArea { get; set; }
public double LowerVision { get; set; } public double LowerVision { get; set; }
public double VisionRetentionRate { get; set; } public double VisionRetentionRate { get; set; }
public double totalVisionArea { get; set; }
public double GetVisionRetentionRate { get; set; }
} }
@@ -55,8 +49,6 @@ namespace 头罩视野
public static class GlobalData public static class GlobalData
{ {
// 要传的所有数据放这里 // 要传的所有数据放这里
public static string CurrentMode{ get; set; } = "5";
public static string JudgmentalPerspective { get; set; } = "空白测试";
public static double LeftEyeArea { get; set; } public static double LeftEyeArea { get; set; }
public static double RightEyeArea { get; set; } public static double RightEyeArea { get; set; }
public static double TotalEyeArea { get; set; } public static double TotalEyeArea { get; set; }
@@ -64,12 +56,6 @@ namespace 头罩视野
public static double BlankArea { get; set; } public static double BlankArea { get; set; }
public static double LowerVision { get; set; }//下方视野角度 public static double LowerVision { get; set; }//下方视野角度
public static double VisionRetentionRate { get; set; } public static double VisionRetentionRate { get; set; }
public static double zsymjValue { get; set; }
public static double kbsmsyArea { get; set; }
//public static string LampValueLeft { get; set; } = "左眼开";
//public static string LampValueRight { get; set; } = "右眼开";
} }
} }
} }

View File

@@ -3,247 +3,247 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:local="clr-namespace:头罩视野.Views"
mc:Ignorable="d" mc:Ignorable="d"
Background="#F0F2F5" Background="#F5F7FA"
d:DesignHeight="768" d:DesignWidth="1024" d:DesignHeight="768" d:DesignWidth="1024"
Title="PageTest" Loaded="Page_Loaded" Unloaded="Page_Unloaded"> Title="PageTest" Loaded="Page_Loaded" Unloaded="Page_Unloaded" >
<Page.Resources> <Page.Resources>
<!-- 全局字体 -->
<FontFamily x:Key="DefaultFont">Segoe UI, Microsoft YaHei</FontFamily>
<!-- 标题样式 --> <!-- 标题样式 -->
<Style x:Key="MainTitleStyle" TargetType="TextBlock"> <Style x:Key="MainTitleStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/> <Setter Property="FontSize" Value="28"/>
<Setter Property="FontSize" Value="26"/> <Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Foreground" Value="#2C3E50"/> <Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,15,0,15"/> <Setter Property="Margin" Value="0,15,0,15"/>
</Style> </Style>
<!-- 标签样式(宽度减少) -->
<Style x:Key="LabelStyle" TargetType="TextBlock"> <Style x:Key="LabelStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/> <Setter Property="FontSize" Value="16"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="Foreground" Value="#5D6D7E"/> <Setter Property="Foreground" Value="#5D6D7E"/>
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,0,8,0"/> <Setter Property="Margin" Value="0,0,10,0"/>
<Setter Property="Width" Value="90"/> <Setter Property="Margin" Value="0,0,10,0"/>
<Setter Property="Width" Value="100"/>
</Style> </Style>
<!-- 单位样式 -->
<Style x:Key="UnitStyle" TargetType="TextBlock"> <Style x:Key="UnitStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/> <Setter Property="FontSize" Value="14"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Foreground" Value="#7F8C8D"/> <Setter Property="Foreground" Value="#7F8C8D"/>
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="5,0,0,0"/> <Setter Property="Margin" Value="10,0,0,0"/>
<Setter Property="FontStyle" Value="Italic"/> <Setter Property="FontStyle" Value="Italic"/>
</Style> </Style>
<!-- 文本框样式(宽度减少) -->
<Style x:Key="TextBoxStyle" TargetType="TextBox"> <Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="Height" Value="32"/> <Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="140"/> <Setter Property="Width" Value="200"/>
<Setter Property="FontSize" Value="15"/> <Setter Property="FontSize" Value="18"/>
<Setter Property="TextAlignment" Value="Center"/> <Setter Property="TextAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderBrush" Value="#BDC3C7"/> <Setter Property="BorderBrush" Value="#D5D8DC"/>
<Setter Property="BorderThickness" Value="1"/> <Setter Property="BorderThickness" Value="2"/>
<Setter Property="Background" Value="#FFFFFF"/> <Setter Property="Background" Value="#FFFFFF"/>
<Setter Property="Foreground" Value="#2C3E50"/> <Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="Padding" Value="5,2"/> <Setter Property="Padding" Value="10,5"/>
<Style.Triggers> <Style.Triggers>
<Trigger Property="IsFocused" Value="True"> <Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" Value="#3498DB"/> <Setter Property="BorderBrush" Value="#3498DB"/>
</Trigger> </Trigger>
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<!-- 卡片样式 -->
<Style x:Key="CardStyle" TargetType="Border">
<Setter Property="Background" Value="#FFFFFF"/>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="12" ShadowDepth="2" Opacity="0.1" Color="#000000"/>
</Setter.Value>
</Setter>
</Style>
<!-- 底部导航按钮样式 -->
<Style x:Key="TabButtonStyle" TargetType="Button"> <Style x:Key="TabButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#2C3E50"/> <Setter Property="Background" Value="#3498DB"/>
<Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/> <Setter Property="FontSize" Value="20"/>
<Setter Property="FontSize" Value="16"/> <Setter Property="Foreground" Value="#fff"/>
<Setter Property="Foreground" Value="#ECF0F1"/> <Setter Property="Height" Value="70"/>
<Setter Property="Height" Value="48"/> <Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontWeight" Value="SemiBold"/> <Setter Property="BorderBrush" Value="#fff"/>
<Setter Property="BorderBrush" Value="#34495E"/>
<Setter Property="BorderThickness" Value="0,1,0,0"/>
<Setter Property="Cursor" Value="Hand"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#34495E"/>
<Setter Property="Foreground" Value="#FFFFFF"/>
</Trigger>
</Style.Triggers>
</Style> </Style>
<!--<Style x:Key="ActButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#8AB1EB"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Foreground" Value="#fff"/>
<Setter Property="Height" Value="60"/>
<Setter Property="Width" Value="120"/>
</Style>-->
<!-- 控制按钮样式 -->
<Style x:Key="CtrlButtonStyle" TargetType="Button">
<Setter Property="Height" Value="36"/>
<Setter Property="Width" Value="100"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="BorderThickness" Value="0"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.85"/>
</Trigger>
</Style.Triggers>
</Style>
</Page.Resources> </Page.Resources>
<Grid Margin="10,0,0,0 ">
<Grid Margin="20,0,20,10">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto" MinHeight="227"/>
<RowDefinition/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 顶部标题 --> <!-- 顶部标题 -->
<Grid Grid.Row="0" Margin="0,0,0,10"> <Grid Grid.Row="0" Margin="0,0,0,10">
<TextBlock Style="{StaticResource MainTitleStyle}" Text="头罩视野测试系统" HorizontalAlignment="Center"/> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- 测试界面标题 -->
<TextBlock Grid.Column="2" Style="{StaticResource MainTitleStyle}" Text="测试界面"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid> </Grid>
<!-- 参数区:使用两行布局,避免过宽 --> <!-- 第二行:参数显示区 -->
<Border Grid.Row="1" Style="{StaticResource CardStyle}" Padding="15,12" Margin="0,0,0,20"> <Grid Grid.Row="1" Margin="0,0,0,10">
<Grid> <Grid.ColumnDefinitions>
<Grid.RowDefinitions> <ColumnDefinition Width="Auto"/>
<RowDefinition Height="Auto"/> <ColumnDefinition Width="Auto"/>
<RowDefinition Height="Auto"/> <ColumnDefinition Width="*"/>
</Grid.RowDefinitions> <ColumnDefinition Width="Auto"/>
<Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/> </Grid.ColumnDefinitions>
</Grid.ColumnDefinitions> <Border Grid.Row="0" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
<!-- 第一行参数:分辨角度、当前角度 --> Padding="25,20" Margin="0,0,0,25" >
<StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal" Margin="0,5,0,5"> <StackPanel Cursor="" Grid.Column="0">
<StackPanel Orientation="Horizontal" Margin="0,0,20,0"> <StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="分辨角度:" Style="{StaticResource LabelStyle}"/> <TextBlock Text="分辨角度:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="fbspeed" Style="{StaticResource TextBoxStyle}" GotFocus="fbspeed_GotFocus"/> <TextBox Name="fbspeed" Text="" Style="{StaticResource TextBoxStyle}" GotFocus="fbspeed_GotFocus"/>
<TextBlock Text="°" Style="{StaticResource UnitStyle}"/> <TextBlock Text="°" Style="{StaticResource UnitStyle}"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="当前角度:" Style="{StaticResource LabelStyle}"/> <TextBlock Text="当前角度:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="dqangle" Style="{StaticResource TextBoxStyle}" GotFocus="dqangle_GotFocus"/> <TextBox Name="dqangle" Text="" Style="{StaticResource TextBoxStyle}" GotFocus="dqangle_GotFocus"/>
<TextBlock Text="°" Style="{StaticResource UnitStyle}"/> <TextBlock Text="°" Style="{StaticResource UnitStyle}"/>
</StackPanel> </StackPanel>
</StackPanel>
<!-- 第二行参数:转动速度(单独一行) --> <StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" Margin="0,5,0,5"> <TextBlock Text="转动速度:" Style="{StaticResource LabelStyle}"/>
<TextBlock Text="转动速度:" Style="{StaticResource LabelStyle}"/> <TextBox Name="zdangle" Text="" Style="{StaticResource TextBoxStyle}" GotFocus="zdangle_GotFocus"/>
<TextBox Name="zdangle" Style="{StaticResource TextBoxStyle}" GotFocus="zdangle_GotFocus"/> <TextBlock Text="°/S" Style="{StaticResource UnitStyle}"/>
<TextBlock Text="°/s" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<!-- 右侧:模式切换和指示灯,垂直居中 -->
<StackPanel Grid.Row="0" Grid.RowSpan="2" Grid.Column="1"
Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10,0,0,0">
<ToggleButton x:Name="tbTest" FontSize="13" Width="90" Height="28"
Background="#E0E0E0" Margin="0,0,12,0"
Checked="TbTest_Checked" Unchecked="TbTest_Unchecked">
<ToggleButton.Template>
<ControlTemplate TargetType="ToggleButton">
<Border x:Name="border" CornerRadius="4" Background="{TemplateBinding Background}" BorderThickness="0">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="border" Property="Background" Value="#3A6B4B"/>
<Setter Property="Foreground" Value="White"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ToggleButton.Template>
空白测试
</ToggleButton>
<TextBlock Text="当前模式:" VerticalAlignment="Center" Margin="0,0,6,0" FontSize="13" Foreground="#5D6D7E"/>
<TextBlock x:Name="当前模式" Text="空白测试" VerticalAlignment="Center" FontSize="13" FontWeight="Bold" Foreground="#3A6B4B" Margin="0,0,15,0"/>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Ellipse x:Name="led0" Width="18" Height="18" Fill="LightGray" Stroke="#BDC3C7" Margin="3,0"/>
<Ellipse x:Name="led1" Width="18" Height="18" Fill="LightGray" Stroke="#BDC3C7" Margin="3,0"/>
</StackPanel>
</StackPanel>
</Grid>
</Border>
<!-- 数据区:两列卡片 -->
<Grid Grid.Row="2" Margin="0,0,0,20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- 左侧卡片 -->
<Border Grid.Column="0" Style="{StaticResource CardStyle}" Padding="20,15" Margin="0,0,10,0">
<StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="左目视野面积:" Style="{StaticResource LabelStyle}" Width="110"/>
<TextBox Name="zmsyarea" Style="{StaticResource TextBoxStyle}" Width="150"/>
<TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="双目视野面积:" Style="{StaticResource LabelStyle}" Width="110"/>
<TextBox Name="smsyarea" Style="{StaticResource TextBoxStyle}" Width="150"/>
<TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="总视野面积:" Style="{StaticResource LabelStyle}" Width="110"/>
<TextBox Name="zsyareaNum" Style="{StaticResource TextBoxStyle}" Width="150"/>
<TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Border> </Border>
<Button Grid.Column="2" Content="打印" Margin="356,11,0,0" VerticalAlignment="Top" Height="42" Width="75" Click="Button_Click_Print" FontSize="18" RenderTransformOrigin="0.330,-0.63" HorizontalAlignment="Left"/>
<ToggleButton x:Name="tbTest"
FontSize="18"
Width="111" Height="40"
Background="LightGray"
Checked="TbTest_Checked"
Unchecked="TbTest_Unchecked" Grid.Column="1" HorizontalAlignment="Left" Margin="131,8,0,0" VerticalAlignment="Top" Grid.ColumnSpan="2">
<!-- 关键用Style去掉边框 -->
<ToggleButton.Template>
<ControlTemplate TargetType="ToggleButton">
<!-- 自定义外观去掉所有默认hover效果 -->
<Border x:Name="border"
CornerRadius="3"
Background="{TemplateBinding Background}"
BorderThickness="0">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<!-- 右侧卡片 --> <!-- 去掉默认的hover/点击效果触发器 -->
<Border Grid.Column="1" Style="{StaticResource CardStyle}" Padding="20,15" Margin="10,0,0,0"> <ControlTemplate.Triggers>
<StackPanel> <Trigger Property="IsChecked" Value="True">
<Setter TargetName="border" Property="Background" Value="LightGray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ToggleButton.Template>
试样测试
</ToggleButton>
<TextBlock x:Name="当前模式" Grid.Column="1" HorizontalAlignment="Left" Margin="39,16,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="18" RenderTransformOrigin="-6.776,-2.381" Width="116"><Run Text="当前模式"/><Run Language="zh-cn" Text=""/></TextBlock>
<StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Left" Margin="121,48,0,53" Width="181">
<!-- 左灯BL_0 (M-104) -->
<Ellipse x:Name="led0"
Width="50" Height="50"
Margin="10"
Fill="LightGray"
Stroke="LightGray" StrokeThickness="1" >
<Ellipse.Effect>
<DropShadowEffect Color="LightGray" ShadowDepth="2" BlurRadius="5"/>
</Ellipse.Effect>
</Ellipse>
<!-- 右灯BL_1 (M-105) -->
<Ellipse x:Name="led1"
Width="50" Height="50"
Margin="30"
Fill="LightGray"
Stroke="LightGray" StrokeThickness="1">
<Ellipse.Effect>
<DropShadowEffect Color="LightGray" ShadowDepth="2" BlurRadius="5"/>
</Ellipse.Effect>
</Ellipse>
</StackPanel>
</Grid>
<!-- 第三行:视野数据区 -->
<Grid Grid.Row="2" Margin="0,0,0,15">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border Grid.Row="0" Grid.Column="0" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="25,20" Margin="0,0,0,-15" >
<StackPanel Cursor="">
<StackPanel Orientation="Horizontal" Margin="0,0,0,15"> <StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="目视野面积:" Style="{StaticResource LabelStyle}" Width="110"/> <TextBlock Text="目视野面积:" Style="{StaticResource LabelStyle}" />
<TextBox Name="ymsyarea" Style="{StaticResource TextBoxStyle}" Width="150"/> <TextBox Name="zmsyarea" Text="" Style="{StaticResource TextBoxStyle}" />
<TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/> <TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="双目视野面积:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="smsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBlock Text="空白视野面积:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="kbsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
</StackPanel>
</StackPanel>
</Border>
<Border Grid.Column="1" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="25,20" Margin="31,0,19,-15" >
<StackPanel Cursor="">
<StackPanel Orientation="Horizontal" Margin="0,0,0,15"> <StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="下方视野" Style="{StaticResource LabelStyle}" Width="110"/> <TextBlock Text="右目视野面积" Style="{StaticResource LabelStyle}"/>
<TextBox Name="xfsyarea" Style="{StaticResource TextBoxStyle}" Width="150"/> <TextBox Name="ymsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="cm²" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="下方视野:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="xfsyarea" Text="" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="°" Style="{StaticResource UnitStyle}"/> <TextBlock Text="°" Style="{StaticResource UnitStyle}"/>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="双目视野保存率:" Style="{StaticResource LabelStyle}" Width="110"/> <StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<TextBox Name="sybhl" Style="{StaticResource TextBoxStyle}" Width="150"/> <TextBlock Text="视野保存率:" Style="{StaticResource LabelStyle}"/>
<TextBlock Text="%" Style="{StaticResource UnitStyle}"/> <TextBox Name="sybhl" Text="" Style="{StaticResource TextBoxStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="总视野保存率:" Style="{StaticResource LabelStyle}" Width="110"/>
<TextBox Name="zsysaveSum" Style="{StaticResource TextBoxStyle}" Width="150"/>
<TextBlock Text="%" Style="{StaticResource UnitStyle}"/> <TextBlock Text="%" Style="{StaticResource UnitStyle}"/>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Border> </Border>
</Grid> </Grid>
<!-- 控制按钮区 --> <!-- 第四行:控制按钮区 -->
<Grid Grid.Row="3" Margin="0,0,0,20"> <Grid Grid.Row="3" Margin="0,10,0,25">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
@@ -257,37 +257,52 @@
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Button Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Content="复位" <!-- 复位 -->
Style="{StaticResource CtrlButtonStyle}" Background="#4A6D8C" Margin="5" Click="Button_Click_Reset"/> <Button Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Content="复位" FontSize="18"
<Button Grid.Row="0" Name="btnLeft" Grid.Column="1" Content="左眼开" Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_Reset" />
Style="{StaticResource CtrlButtonStyle}" Background="#4A6D8C" Margin="5" Click="Button_Click_left"/>
<Button Grid.Row="0" Grid.Column="2" Content="反转" <!-- 左眼开 -->
Style="{StaticResource CtrlButtonStyle}" Background="#4A6D8C" Margin="5" <Button Grid.Row="0" Name="btnLeft" Grid.Column="1" Content="左眼开" FontSize="18"
PreviewMouseLeftButtonDown="Button_Click_ResDown" PreviewMouseLeftButtonUp="Button_Click_ResUp"/> Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_left" />
<Button Grid.Row="1" Name="btnRight" Grid.Column="1" Content="右眼开"
Style="{StaticResource CtrlButtonStyle}" Background="#4A6D8C" Margin="5" Click="Button_Click_Right"/> <!-- 反转 -->
<Button Grid.Row="1" Grid.Column="2" Content="转" <Button Grid.Row="0" Grid.Column="2" Content="转" FontSize="18"
Style="{StaticResource CtrlButtonStyle}" Background="#4A6D8C" Margin="5" Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" PreviewMouseLeftButtonDown="Button_Click_ResDown"
PreviewMouseLeftButtonDown="Button_Click_ForDown" PreviewMouseLeftButtonUp="Button_Click_ForUp"/> PreviewMouseLeftButtonUp="Button_Click_ResUp" />
<Button Grid.Row="0" Grid.Column="4" Name="ButtonTest" Grid.RowSpan="2" Content="测试"
Style="{StaticResource CtrlButtonStyle}" Background="#27AE60" Margin="5" Click="Button_Click_Test"/> <!-- 右眼开 -->
<Button Grid.Row="0" Grid.Column="5" Grid.RowSpan="2" Content="停止" <Button Grid.Row="1" Name="btnRight" Grid.Column="1" Content="右眼开" FontSize="18"
Style="{StaticResource CtrlButtonStyle}" Background="#E74C3C" Margin="5" Click="Button_Click_Stop"/> Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" Click="Button_Click_Right" />
<!-- 正转 -->
<Button Grid.Row="1" Grid.Column="2" Content="正转" FontSize="18"
Width="120" Height="50" Background="#FF87CEFA" Foreground="White" Margin="5" PreviewMouseLeftButtonDown="Button_Click_ForDown"
PreviewMouseLeftButtonUp="Button_Click_ForUp" />
<!-- 测试 -->
<Button Grid.Row="0" Grid.Column="4" Name="ButtonTest" Grid.RowSpan="2" Content="测试" FontSize="18"
Width="120" Height="50" Background="LightGray" Foreground="White" Margin="5" Click="Button_Click_Test"/>
<!-- 停止 -->
<Button Grid.Row="0" Grid.Column="5" Grid.RowSpan="2" Content="停止" FontSize="18"
Width="120" Height="50" Background="red" Foreground="White" Margin="5" Click="Button_Click_Stop" />
</Grid> </Grid>
<!-- 弹性空间 -->
<Grid Grid.Row="4" Background="Transparent"/>
<!-- 底部导航栏 --> <!-- 底部导航栏 -->
<Grid Grid.Row="5" VerticalAlignment="Bottom"> <Grid Grid.Row="4" Margin="0,0,0,10">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button x:Name="btnNavHome" Style="{StaticResource TabButtonStyle}" Grid.Column="0" Content="主页" Click="GoHome"/> <Button Style="{StaticResource TabButtonStyle}" Grid.Column="0" Content="主页"
<Button x:Name="btnNavTest" Style="{StaticResource TabButtonStyle}" Grid.Column="1" Content="测试界面" Click="GoTest"/> Click="GoHome" />
<Button x:Name="btnNavRecord" Style="{StaticResource TabButtonStyle}" Grid.Column="2" Content="记录画面" Click="GoView"/> <Button Style="{StaticResource TabButtonStyle}" Grid.Column="1" Content="测试界面"
Click="GoTest" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="2" Content="数据记录"
Click="GoRecord" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="3" Content="记录画面"
Click="GoView" />
</Grid> </Grid>
</Grid> </Grid>
</Page> </Page>

File diff suppressed because it is too large Load Diff

View File

@@ -1,244 +0,0 @@
<Page x:Class="头罩视野.Views.RecordDate"
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"
mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1024"
Background="#F5F7FA"
Title="RecordDate" Loaded="Page_Loaded" Unloaded="Page_Unloaded">
<Page.Resources>
<!-- 标题样式 -->
<Style x:Key="MainTitleStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="28"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,15,0,15"/>
</Style>
<!-- DataGrid 样式 -->
<Style x:Key="DataGridStyle" TargetType="DataGrid">
<Setter Property="Background" Value="#FFFFFF"/>
<Setter Property="BorderBrush" Value="#E5E8E8"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="GridLinesVisibility" Value="Horizontal"/>
<Setter Property="HorizontalGridLinesBrush" Value="#ECF0F1"/>
<Setter Property="VerticalGridLinesBrush" Value="#ECF0F1"/>
<Setter Property="HeadersVisibility" Value="Column"/>
<Setter Property="CanUserAddRows" Value="False"/>
<Setter Property="CanUserDeleteRows" Value="False"/>
<Setter Property="AutoGenerateColumns" Value="False"/>
<Setter Property="IsReadOnly" Value="True"/>
<Setter Property="SelectionMode" Value="Single"/>
<Setter Property="SelectionUnit" Value="FullRow"/>
<Setter Property="RowHeight" Value="36"/>
<Setter Property="FontSize" Value="13"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="True"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
</Style>
<!-- DataGrid 列头样式 -->
<Style x:Key="DataGridColumnHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="#E5E5E5"/>
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Height" Value="40"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="10,8"/>
<Setter Property="BorderBrush" Value="#E5E5E5"/>
<Setter Property="BorderThickness" Value="0,0,1,0"/>
</Style>
<!-- DataGrid 行样式 -->
<Style x:Key="DataGridRowStyle" TargetType="DataGridRow">
<Setter Property="Background" Value="White"/>
<Style.Triggers>
<!-- 斑马线效果 -->
<Trigger Property="AlternationIndex" Value="0">
<Setter Property="Background" Value="#FFFFFF"/>
</Trigger>
<Trigger Property="AlternationIndex" Value="1">
<Setter Property="Background" Value="#F8F9F9"/>
</Trigger>
<!-- 鼠标悬停效果 -->
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#EBF5FB"/>
</Trigger>
<!-- 选中效果 -->
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#D6EAF8"/>
<Setter Property="BorderBrush" Value="#3498DB"/>
<Setter Property="BorderThickness" Value="1"/>
</Trigger>
</Style.Triggers>
</Style>
<!-- DataGrid 单元格样式 -->
<Style x:Key="DataGridCellStyle" TargetType="DataGridCell">
<Setter Property="BorderBrush" Value="#ECF0F1"/>
<Setter Property="BorderThickness" Value="0,0,1,1"/>
<Setter Property="Padding" Value="10,8"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="TextBlock.TextAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridCell">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="True">
<ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TabButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#3498DB"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Foreground" Value="#fff"/>
<Setter Property="Height" Value="70"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="BorderBrush" Value="#fff"/>
</Style>
</Page.Resources>
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- 顶部标题栏 -->
<Grid Grid.Row="0" Margin="0 0 0 10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="2" Style="{StaticResource MainTitleStyle}" Text="数据记录"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<Grid Grid.Row="1">
<TextBlock Text="左眼" FontSize="16" Margin="0,0,0,5"/>
</Grid>
<!--表格1-->
<Grid Grid.Row="2" Margin="0 0 0 10">
<DataGrid x:Name="dataGrid1"
Height="190"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
AutoGenerateColumns="False"
CanUserAddRows="False"
IsReadOnly="True"
HeadersVisibility="Column"
GridLinesVisibility="All"
Style="{StaticResource DataGridStyle}"
AlternationCount="2"
ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
CellStyle="{StaticResource DataGridCellStyle}"
>
<!-- 表格列(你要的 6 列) -->
<DataGrid.Columns>
<DataGridTextColumn Header="编号" Binding="{Binding Id}" Width="60"/>
<DataGridTextColumn Header="时间" Binding="{Binding Time}" Width="120"/>
<DataGridTextColumn Header="日期" Binding="{Binding Date}" Width="120"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
<Grid Grid.Row="3">
<TextBlock Text="右眼" FontSize="16" Margin="0,10,0,5"/>
<Button Content="保存" FontSize="18"
Width="120" Height="50" Background="#3498DB" Foreground="White" HorizontalAlignment="Left" Margin="850,0,0,5" Click="btnSaveLeft_Click" />
</Grid>
<!--表格2-->
<Grid Grid.Row="4" Margin="0 0 0 10">
<DataGrid x:Name="dataGrid2"
Height="190"
ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
AutoGenerateColumns="False"
CanUserAddRows="False"
IsReadOnly="True"
HeadersVisibility="Column"
GridLinesVisibility="All"
Style="{StaticResource DataGridStyle}"
AlternationCount="2"
ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
CellStyle="{StaticResource DataGridCellStyle}"
>
<!-- 表格列(你要的 6 列) -->
<DataGrid.Columns>
<DataGridTextColumn Header="编号" Binding="{Binding Id}" Width="80"/>
<DataGridTextColumn Header="时间" Binding="{Binding Time}" Width="120"/>
<DataGridTextColumn Header="日期" Binding="{Binding Date}" Width="120"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
<!--按钮-->
<Grid Grid.Row="5" >
<!-- 停止 -->
<Button Content="保存" FontSize="18"
Width="120" Height="50" Background="#3498DB" Foreground="White" HorizontalAlignment="Left" Margin="850,0,0,0" Click="btnSaveRight_Click"/>
<Button Content="清除" FontSize="18"
Width="120" Height="50" Background="White" BorderBrush="red" Foreground="red" HorizontalAlignment="Left" Margin="14,0,0,0" PreviewMouseLeftButtonDown ="btnClear_MouseDown" PreviewMouseLeftButtonUp ="btnClear_MouseUp" />
<TextBlock HorizontalAlignment="Left" Foreground="red"
FontSize="18"
Width="142" Margin="148,25,0,23" RenderTransformOrigin="0.5,0.5">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform AngleY="-0.614"/>
<RotateTransform/>
<TranslateTransform Y="-0.739"/>
</TransformGroup>
</TextBlock.RenderTransform><Run Language="zh-cn" Text="备注: 清除长按"/></TextBlock>
</Grid>
<!-- 底部导航栏 -->
<Grid Grid.Row="6" VerticalAlignment="Bottom">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="0" Content="主页"
Click="GoHome" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="1" Content="测试界面"
Click="GoTest" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="2" Content="数据记录"
Click="GoRecord" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="3" Content="记录画面"
Click="GoView" />
</Grid>
</Grid>
</Page>

View File

@@ -1,355 +0,0 @@
using Microsoft.Win32;
using Modbus.Device;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Timers;
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;
using .Services;
using .Services.Data;
using static .TestDataStore;
namespace .Views
{
/// <summary>
/// RecordDate.xaml 的交互逻辑
/// </summary>
///
public partial class RecordDate : Page
{
private IModbusMaster _modbusMaster => ModbusResourceManager.Instance.ModbusMaster;
private System.Timers.Timer? _plcReadTimer;
// 表跟数据存储列表
public List<dynamic> LeftEyeDataList = new List<dynamic>();
public List<dynamic> RightEyeDataList = new List<dynamic>();
public List<dynamic> CalLeftData = new List<dynamic>();
public List<dynamic> CalRightData = new List<dynamic>();
// 配置和你PLC地址完全对应 左目
private const int LeftEyeStartAddress = 1362; // D1362
private const int ChannelCount = 72; // 72个通道
private const int RegistersPerChannel = 1; // 每个通道2个寄存器Float
//右目
private const int RightEyeStartAddress = 1218; // D1218
//// 长按清除用
private bool _isClearPressed = false;
private Thread _clearThread;
public RecordDate()
{
InitializeComponent();
DynamicHeader();
// 2. 调用(名字和上面的变量一致)
// 2. 启动定时器定时读取数据每100ms读一次
StartPlcReadTimer(1000);
//// 判断连接
if (!ModbusHelper.IsConnected)
{
MessageBox.Show("未连接");
return;
}
}
//动态生成表头
void DynamicHeader()
{
// 2. 循环生成 72 个 ch 列
for (int i = 1; i <= ChannelCount; i++)
{
dataGrid1.Columns.Add(new DataGridTextColumn
{
Header = $"ch.{i}",
Binding = new System.Windows.Data.Binding($"Ch{i}")
});
dataGrid2.Columns.Add(new DataGridTextColumn
{
Header = $"ch.{i}",
Binding = new System.Windows.Data.Binding($"Ch{i}")
});
}
}
public void StopPlcTimer()
{
if (_plcReadTimer != null)
{
_plcReadTimer.Stop();
_plcReadTimer.Dispose();
_plcReadTimer = null;
}
}
//定时读取 PLC 数据
public void StartPlcReadTimer(int intervalMs)
{
// 防止重复创建
if (_plcReadTimer != null && _plcReadTimer.Enabled)
return;
_plcReadTimer = new System.Timers.Timer(intervalMs);
_plcReadTimer.Elapsed += ReadPlcData;
_plcReadTimer.Start();
}
private void ReadPlcData(object? sender, ElapsedEventArgs e)
{
// 左通道
ReadPlcDataGeneric(
slaveAddress: 1,
startAddress: LeftEyeStartAddress,
count: 72,
dataList: LeftEyeDataList,
dataGrid: dataGrid1);
//// 右通道
//ReadPlcDataGeneric(
// slaveAddress: 1,
// startAddress: RightEyeStartAddress,
// count: (ushort)(ChannelCount * RegistersPerChannel),
// dataList: RightEyeDataList,
// dataGrid: dataGrid2);
}
/// <summary>
/// 读取PLC HoldingRegisters 并更新到列表和DataGrid
/// <param name="slaveAddress">设备站号一般是1</param>
/// <param name="startAddress">起始地址</param>
/// <param name="count">寄存器总数</param>
/// <param name="dataList">数据缓存列表</param>
/// <param name="dataGrid">要更新的DataGrid控件</param>
/// 通用PLC读取方法左右通道通用
/// </summary>
private void ReadPlcDataGeneric(
byte slaveAddress,
ushort startAddress,
ushort count,
List<dynamic> dataList,
DataGrid dataGrid)
{
if (_modbusMaster == null || !ModbusHelper.TcpClient.Connected)
return;
try
{
// 读取寄存器
ushort[] registers = _modbusMaster.ReadHoldingRegisters(
slaveAddress: slaveAddress,
startAddress: startAddress,
numberOfPoints: (ushort)count);
uint[] data32 = ConvertRegistersToUInt32(registers, true);
// 先把变量存为局部变量,解决闭包问题
var regCopy = data32;
var listCopy = dataList;
var gridCopy = dataGrid;
// 交给UI线程更新数据和表格
Dispatcher.Invoke(() =>
{
AddPlcDataRow(regCopy, listCopy, gridCopy);
});
System.Diagnostics.Debug.WriteLine("读取寄存器数据" );
}
catch (Exception ex)
{
Console.WriteLine($"PLC读取失败: {ex.Message}");
}
}
private uint[] ConvertRegistersToUInt32(ushort[] registers, bool isLittleEndian)
{
if (registers == null || registers.Length % 2 != 0)
throw new ArgumentException("寄存器数量必须是偶数");
uint[] result = new uint[registers.Length / 2];
for (int i = 0; i < result.Length; i++)
{
ushort low = registers[i * 2];
ushort high = registers[i * 2 + 1];
if (isLittleEndian)
result[i] = (uint)(low | (high << 16));
else
result[i] = (uint)(high | (low << 16));
}
return result;
}
/// <summary>
/// 把PLC数据添加到动态表格
private int _rowIndex = 1;
private void AddPlcDataRow(uint[] registers, List<dynamic> dataList, DataGrid dg)
{
// 1. 先清空临时列表,不影响历史数据
//dataList.Clear();
// 2. 构建一次采集的单行数据(包含所有通道)
dynamic newRow = new System.Dynamic.ExpandoObject();
var dict = (IDictionary<string, object>)newRow;
// 固定列:编号、时间、日期(每次采集的这一行)
dict["Id"] = _rowIndex++;
dict["Time"] = DateTime.Now.ToString("HH:mm:ss");
dict["Date"] = DateTime.Now.ToString("yyyy-MM-dd");
// 关键:循环给所有通道赋值,一行里包含所有通道值
for (int i = 0; i < registers.Length; i++)
{
// 字段名和你界面列绑定的名称必须完全一致,比如 ch.1 / Ch1
dict[$"Ch{i + 1}"] = registers[i];
//dict[$"ch.{i + 1}"] = registers[i];
}
// 3. 把这一行加到历史列表,实现“读多行”
dataList.Add(newRow);
// 4. 强制刷新DataGrid让界面显示多行
dg.Dispatcher.Invoke(() =>
{
dg.ItemsSource = null;
dg.ItemsSource = dataList;
dg.Items.Refresh(); // 强制刷新视图,避免不渲染
});
}
//面积的计算方法
//public void getAllData(List<dynamic> leftEyeDataList, List<dynamic> RightEyeDataList, int perAngle)
//{
// // 1. 先去除异常值,生成新列表(不修改原列表)
// var filteredLeft = GetArea.RemoveOutliers(leftEyeDataList);
// var filteredRight = GetArea.RemoveOutliers(RightEyeDataList);
// //左目视野面积
// GlobalData.LeftEyeArea = GetArea.CalculateEyeArea(filteredLeft);
// //右目视野面积
// GlobalData.RightEyeArea = GetArea.CalculateEyeArea(filteredRight);
// //双目视野面积
// GlobalData.BinocularArea = GetArea.CalcBinocularArea(filteredLeft, filteredRight);
// //// 总视野面积
// GlobalData.TotalEyeArea = GlobalData.LeftEyeArea + GlobalData.RightEyeArea - GlobalData.BinocularArea;
// //// 空白视野面积
// GlobalData.BlankArea = GetArea.StandardTotal - GlobalData.TotalEyeArea;
// //视野保存率
// // 左眼平均值数组
// double[] leftAvg = GetArea.GetEyeAvgArray(filteredLeft);
// // 右眼平均值数组
// double[] rightAvg = GetArea.GetEyeAvgArray(RightEyeDataList);
// double leftLowerAngle = GetArea.CalcLowerAngle(leftAvg, perAngle);
// double rightLowerAngle = GetArea.CalcLowerAngle(rightAvg, perAngle);
// //下方视野
// GlobalData.LowerVision = Math.Min(leftLowerAngle, rightLowerAngle);
// //视野保存率
// GlobalData.VisionRetentionRate = GetArea.CalcVisionRate(GlobalData.LeftEyeArea, GlobalData.RightEyeArea);
// //打印数值显示在系统上面
// System.Diagnostics.Debug.WriteLine("左目视野面积" + GlobalData.LeftEyeArea);
// System.Diagnostics.Debug.WriteLine("右目视野面积" + GlobalData.RightEyeArea);
// System.Diagnostics.Debug.WriteLine("双目视野面积" + GlobalData.BinocularArea);
// System.Diagnostics.Debug.WriteLine("总视野面积" + GlobalData.TotalEyeArea);
// System.Diagnostics.Debug.WriteLine("下方视野" + GlobalData.LowerVision);
// System.Diagnostics.Debug.WriteLine("视野保存率" + GlobalData.VisionRetentionRate);
//}
//#endregion
// 保存左眼
private void btnSaveLeft_Click(object sender, RoutedEventArgs e)
{
//SaveToCsv(LeftEyeDataList, $"左眼数据_{DateTime.Now:yyyyMMddHHmmss}.csv");
ModbusHelper.SaveToCsv(LeftEyeDataList, $"左眼数据_{DateTime.Now:yyyyMMddHHmmss}.csv");
}
// 保存右眼
private void btnSaveRight_Click(object sender, RoutedEventArgs e)
{
ModbusHelper.SaveToCsv(RightEyeDataList,$"右眼数据_{DateTime.Now:yyyyMMddHHmmss}.csv");
}
//清除
private void btnClear_MouseDown(object sender, MouseButtonEventArgs e)
{
//_isClearPressed = true;
//_clearThread = new Thread(() =>
//{
// Thread.Sleep(500); // 长按1秒触发
// if (_isClearPressed)
// {
// Application.Current.Dispatcher.Invoke(() => ClearAllData());
// }
//});
//_clearThread.Start();
_plcReadTimer?.Stop();
}
// 清除所有数据
private void ClearAllData()
{
LeftEyeDataList.Clear();
dataGrid1.Items.Clear();
RightEyeDataList.Clear();
dataGrid2.Items.Clear();
MessageBox.Show("数据已清除");
}
private void btnClear_MouseUp(object sender, MouseButtonEventArgs e)
{
_isClearPressed = false;
_clearThread?.Join(100); // 等待线程结束最多100毫秒然后强制结束
}
private void Page_Unloaded(object sender, RoutedEventArgs e)
{
_plcReadTimer?.Stop();
_plcReadTimer?.Dispose();
//_modbusMaster?.Dispose();
//ModbusHelper.TcpClient?.Close();
}
private void Page_Loaded(object sender, RoutedEventArgs e)
{
}
private void GoHome(object s, RoutedEventArgs e) => NavigationService.Content = null;
private void GoTest(object s, RoutedEventArgs e) => NavigationService.Content = new Views.PageTest();
private void GoRecord(object s, RoutedEventArgs e) => NavigationService.Content = new Views.RecordDate();
private void GoView(object s, RoutedEventArgs e) => NavigationService.Content = new Views.RecordPage();
//NavigationService.Navigate(new Views.RecordDate()); 页面相互跳转
}
}

View File

@@ -3,21 +3,17 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:头罩视野.Views"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="768" d:DesignWidth="1024" d:DesignHeight="768" d:DesignWidth="1024"
Background="#F0F2F5" Background="#F5F7FA" Loaded="Page_Loaded"
Loaded="Page_Loaded"
Title="RecordPage"> Title="RecordPage">
<Page.Resources> <Page.Resources>
<!-- 全局字体 -->
<FontFamily x:Key="DefaultFont">Segoe UI, Microsoft YaHei</FontFamily>
<!-- 标题样式 --> <!-- 标题样式 -->
<Style x:Key="MainTitleStyle" TargetType="TextBlock"> <Style x:Key="MainTitleStyle" TargetType="TextBlock">
<Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/> <Setter Property="FontSize" Value="28"/>
<Setter Property="FontSize" Value="26"/> <Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Foreground" Value="#2C3E50"/> <Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="HorizontalAlignment" Value="Center"/> <Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,15,0,15"/> <Setter Property="Margin" Value="0,15,0,15"/>
@@ -49,30 +45,33 @@
<!-- DataGrid 列头样式 --> <!-- DataGrid 列头样式 -->
<Style x:Key="DataGridColumnHeaderStyle" TargetType="DataGridColumnHeader"> <Style x:Key="DataGridColumnHeaderStyle" TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="#E5E5E5"/> <Setter Property="Background" Value="#E5E5E5"/>
<Setter Property="Foreground" Value="#2C3E50"/> <Setter Property="Foreground" Value="Black"/>
<Setter Property="FontWeight" Value="SemiBold"/> <Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontSize" Value="13"/> <Setter Property="FontSize" Value="14"/>
<Setter Property="Height" Value="40"/> <Setter Property="Height" Value="40"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/> <Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="8,4"/> <Setter Property="Padding" Value="10,8"/>
<Setter Property="BorderBrush" Value="#E5E8E8"/> <Setter Property="BorderBrush" Value="#E5E5E5"/>
<Setter Property="BorderThickness" Value="0,0,1,1"/> <Setter Property="BorderThickness" Value="0,0,1,0"/>
</Style> </Style>
<!-- DataGrid 行样式 --> <!-- DataGrid 行样式 -->
<Style x:Key="DataGridRowStyle" TargetType="DataGridRow"> <Style x:Key="DataGridRowStyle" TargetType="DataGridRow">
<Setter Property="Background" Value="White"/> <Setter Property="Background" Value="White"/>
<Style.Triggers> <Style.Triggers>
<!-- 斑马线效果 -->
<Trigger Property="AlternationIndex" Value="0"> <Trigger Property="AlternationIndex" Value="0">
<Setter Property="Background" Value="#FFFFFF"/> <Setter Property="Background" Value="#FFFFFF"/>
</Trigger> </Trigger>
<Trigger Property="AlternationIndex" Value="1"> <Trigger Property="AlternationIndex" Value="1">
<Setter Property="Background" Value="#F8F9F9"/> <Setter Property="Background" Value="#F8F9F9"/>
</Trigger> </Trigger>
<!-- 鼠标悬停效果 -->
<Trigger Property="IsMouseOver" Value="True"> <Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#EBF5FB"/> <Setter Property="Background" Value="#EBF5FB"/>
</Trigger> </Trigger>
<!-- 选中效果 -->
<Trigger Property="IsSelected" Value="True"> <Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#D6EAF8"/> <Setter Property="Background" Value="#D6EAF8"/>
<Setter Property="BorderBrush" Value="#3498DB"/> <Setter Property="BorderBrush" Value="#3498DB"/>
@@ -85,127 +84,112 @@
<Style x:Key="DataGridCellStyle" TargetType="DataGridCell"> <Style x:Key="DataGridCellStyle" TargetType="DataGridCell">
<Setter Property="BorderBrush" Value="#ECF0F1"/> <Setter Property="BorderBrush" Value="#ECF0F1"/>
<Setter Property="BorderThickness" Value="0,0,1,1"/> <Setter Property="BorderThickness" Value="0,0,1,1"/>
<Setter Property="Padding" Value="8,4"/> <Setter Property="Padding" Value="10,8"/>
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="TextBlock.TextAlignment" Value="Center"/> <Setter Property="TextBlock.TextAlignment" Value="Center"/>
</Style> <Setter Property="Template">
<!-- 底部导航按钮样式(与测试页面一致) -->
<Style x:Key="TabButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#2C3E50"/>
<Setter Property="FontFamily" Value="{StaticResource DefaultFont}"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="Foreground" Value="#ECF0F1"/>
<Setter Property="Height" Value="52"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="BorderBrush" Value="#34495E"/>
<Setter Property="BorderThickness" Value="0,1,0,0"/>
<Setter Property="Cursor" Value="Hand"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#34495E"/>
<Setter Property="Foreground" Value="#FFFFFF"/>
</Trigger>
</Style.Triggers>
</Style>
<!-- 卡片样式(带阴影) -->
<Style x:Key="CardStyle" TargetType="Border">
<Setter Property="Background" Value="#FFFFFF"/>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="Effect">
<Setter.Value> <Setter.Value>
<DropShadowEffect BlurRadius="12" ShadowDepth="2" Opacity="0.1" Color="#000000"/> <ControlTemplate TargetType="DataGridCell">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="True">
<ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value> </Setter.Value>
</Setter> </Setter>
</Style> </Style>
<Style x:Key="TabButtonStyle" TargetType="Button">
<!-- 按钮样式 --> <Setter Property="Background" Value="#3498DB"/>
<Style x:Key="ActionButtonStyle" TargetType="Button"> <Setter Property="FontSize" Value="20"/>
<Setter Property="Height" Value="40"/> <Setter Property="Foreground" Value="#fff"/>
<Setter Property="Width" Value="100"/> <Setter Property="Height" Value="70"/>
<Setter Property="FontSize" Value="15"/> <Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontWeight" Value="SemiBold"/> <Setter Property="BorderBrush" Value="#fff"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="BorderThickness" Value="0"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="0.85"/>
</Trigger>
</Style.Triggers>
</Style> </Style>
</Page.Resources>
<Grid Margin="20,0,20,10">
</Page.Resources>
<Grid Margin="10">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<!-- 0: 标题栏 --> <RowDefinition Height="Auto"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<!-- 1: 表格区(撑满剩余空间) -->
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<!-- 2: 操作按钮区 -->
<RowDefinition Height="Auto"/>
<!-- 3: 底部导航栏(固定在窗口底部) -->
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- 顶部标题栏 --> <!-- 顶部标题栏 -->
<Grid Grid.Row="0" Margin="0,0,0,15"> <Grid Grid.Row="0" Margin="0 0 0 10">
<TextBlock Style="{StaticResource MainTitleStyle}" Text="历史测试记录" HorizontalAlignment="Center"/> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="2" Style="{StaticResource MainTitleStyle}" Text="记录画面"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid> </Grid>
<!--表格-->
<!-- 表格区(卡片样式,占据剩余高度) --> <Grid Grid.Row="1" Margin="0 0 0 10">
<Border Grid.Row="1" Style="{StaticResource CardStyle}" Padding="5" Margin="0,0,0,15">
<DataGrid x:Name="RecordDataGrid" <DataGrid x:Name="RecordDataGrid"
Style="{StaticResource DataGridStyle}" Height="400"
ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
CellStyle="{StaticResource DataGridCellStyle}"
AlternationCount="2"
AutoGenerateColumns="False"
CanUserAddRows="False"
IsReadOnly="True"
HeadersVisibility="Column"
GridLinesVisibility="All"
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"
ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto"
VerticalAlignment="Stretch"> AutoGenerateColumns="False"
CanUserAddRows="False"
IsReadOnly="True"
HeadersVisibility="Column"
GridLinesVisibility="All"
Style="{StaticResource DataGridStyle}"
AlternationCount="2"
ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}"
RowStyle="{StaticResource DataGridRowStyle}"
CellStyle="{StaticResource DataGridCellStyle}"
>
<!-- 表格列(你要的 6 列) -->
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Header="编号" Binding="{Binding Id}" Width="60" /> <DataGridTextColumn Header="编号" Binding="{Binding Id}" Width="80" IsReadOnly="True" />
<DataGridTextColumn Header="时间" Binding="{Binding Time}" Width="80" /> <DataGridTextColumn Header="时间" Binding="{Binding Time}" Width="120" IsReadOnly="True"/>
<DataGridTextColumn Header="日期" Binding="{Binding Date}" Width="80" /> <DataGridTextColumn Header="日期" Binding="{Binding Date}" Width="120" IsReadOnly="True" />
<DataGridTextColumn Header="左目视野面积" Binding="{Binding LeftEyeArea,StringFormat=F2}" Width="105" /> <DataGridTextColumn Header="左目视野面积" Binding="{Binding LeftEyeArea,StringFormat=F2}" Width="*" IsReadOnly="True" />
<DataGridTextColumn Header="右目视野面积" Binding="{Binding RightEyeArea,StringFormat=F2}" Width="105" /> <DataGridTextColumn Header="右目视野面积" Binding="{Binding RightEyeArea,StringFormat=F2}" Width="*" IsReadOnly="True"/>
<DataGridTextColumn Header="双目视野面积" Binding="{Binding BinocularArea,StringFormat=F2}" Width="105" /> <DataGridTextColumn Header="双目视野面积" Binding="{Binding BinocularArea,StringFormat=F2}" Width="*" IsReadOnly="True"/>
<DataGridTextColumn Header="下方视野" Binding="{Binding LowerVision,StringFormat=F2}" Width="90" /> <DataGridTextColumn Header="下方视野" Binding="{Binding LowerVision,StringFormat=F2}" Width="*" IsReadOnly="True"/>
<DataGridTextColumn Header="视野面积" Binding="{Binding totalVisionArea,StringFormat=F2}" Width="105" /> <DataGridTextColumn Header="视野保存率" Binding="{Binding VisionRetentionRate,StringFormat=F2}" Width="*" IsReadOnly="True"/>
<DataGridTextColumn Header="双目保存率" Binding="{Binding VisionRetentionRate,StringFormat=F2}" Width="100" />
<DataGridTextColumn Header="总保存率" Binding="{Binding GetVisionRetentionRate,StringFormat=F2}" Width="100" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</Border> </Grid>
<!--按钮-->
<!-- 操作按钮区 --> <Grid Grid.Row="2" Margin="0,30,0,0">
<Grid Grid.Row="2" Margin="0,0,0,15"> <!-- 停止 -->
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center"> <Button Content="保存" FontSize="18"
<Button Content="保存" Style="{StaticResource ActionButtonStyle}" Background="#27AE60" Margin="5" Click="btnSave_Click"/> Width="120" Height="50" Background="#3498DB" Foreground="White" Margin="840,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Click="btnSave_Click" />
<Button Content="清除" Style="{StaticResource ActionButtonStyle}" Background="#E74C3C" Margin="5" <Button Content="清除" FontSize="18"
PreviewMouseLeftButtonDown="btnClear_MouseDown" PreviewMouseLeftButtonUp="btnClear_MouseUp"/> Width="120" Height="50" Background="White" BorderBrush="red" Foreground="red" Margin="10,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"
<TextBlock Text="长按清除" VerticalAlignment="Center" Margin="15,0,0,0" FontSize="13" Foreground="#E74C3C" FontStyle="Italic"/> PreviewMouseLeftButtonDown ="btnClear_MouseDown" PreviewMouseLeftButtonUp ="btnClear_MouseUp" />
</StackPanel> <TextBlock HorizontalAlignment="Left" Foreground="red" Margin="139,14,0,0" TextWrapping="Wrap" VerticalAlignment="Top" FontSize="18" Width="202"><Run Language="zh-cn" Text="备注: 清除长按"/></TextBlock>
</Grid> </Grid>
<!-- 底部导航栏(固定在窗口底部) --> <!-- 底部导航栏 -->
<Grid Grid.Row="3" VerticalAlignment="Bottom"> <Grid Grid.Row="3" VerticalAlignment="Bottom">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="0" Content="主页" Click="GoHome"/> <Button Style="{StaticResource TabButtonStyle}" Grid.Column="0" Content="主页"
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="1" Content="测试界面" Click="GoTest"/> Click="GoHome" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="2" Content="记录画面" Click="GoView"/> <Button Style="{StaticResource TabButtonStyle}" Grid.Column="1" Content="测试界面"
Click="GoTest" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="2" Content="数据记录"
Click="GoRecord" />
<Button Style="{StaticResource TabButtonStyle}" Grid.Column="3" Content="记录画面"
Click="GoView" />
</Grid> </Grid>
</Grid> </Grid>
</Page> </Page>

View File

@@ -17,8 +17,6 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using System.Windows.Threading; using System.Windows.Threading;
using System.Linq;
using System.Threading;
using .Services.Data; using .Services.Data;
using static .TestDataStore; using static .TestDataStore;
@@ -40,7 +38,17 @@ namespace 头罩视野.Views
InitializeComponent(); InitializeComponent();
} }
//#region 2. 清除表格数据
//private void btnClear_Click(object sender, RoutedEventArgs e)
//{
// // 确认清除
// if (MessageBox.Show("确定要清除所有记录吗?", "确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
// {
// TestDataStore.Records.Clear();
// RecordDataGrid.ItemsSource = null;
// RecordDataGrid.ItemsSource = TestDataStore.Records;
// }
//}
//清除 //清除
private void btnClear_MouseDown(object sender, MouseButtonEventArgs e) private void btnClear_MouseDown(object sender, MouseButtonEventArgs e)
@@ -80,303 +88,40 @@ namespace 头罩视野.Views
} }
////#endregion
////#region 3. 保存为Excel
//private void btnSave_Click(object sender, RoutedEventArgs e)
//{
// try
// {
// // 1. 构建表格内容
// StringBuilder sb = new StringBuilder();
// sb.AppendLine("编号,日期,时间,左目视野面积,右目视野面积,双目视野面积,空白视野面积,下方视野,视野保存率");
// foreach (var item in TestDataStore.Records)
// {
// sb.AppendLine($"{item.Id},{item.Date},{item.Time},{item.LeftEyeArea},{item.RightEyeArea},{item.BinocularArea},{item.LowerVision},{item.VisionRetentionRate}");
// }
// // 2. 弹出保存框,让用户自己选位置
// Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog();
// saveFileDialog.Filter = "CSV 文件 (*.csv)|*.csv|所有文件 (*.*)|*.*";
// saveFileDialog.FileName = $"测试记录_{DateTime.Now:yyyyMMddHHmmss}";
// if (saveFileDialog.ShowDialog() == true)
// {
// // 3. 保存文件
// File.WriteAllText(saveFileDialog.FileName, sb.ToString(), Encoding.UTF8);
// MessageBox.Show("保存成功!\n文件路径" + saveFileDialog.FileName, "成功");
// }
// }
// catch (Exception ex)
// {
// MessageBox.Show("保存失败:" + ex.Message);
// }
//}
//#endregion //#endregion
//#region 3. 保存为Excel
private List<TestDataStore.TestRecord> GenerateMockRecords()
{
var mockList = new List<TestDataStore.TestRecord>();
Random rand = new Random();
for (int i = 1; i <= 5; i++)
{
double left = rand.Next(6000, 8500);
double right = rand.Next(6000, 8500);
double binocular = (left + right) / 2 * 0.85;
double lower = rand.Next(30, 50);
double totalArea = left + right - binocular; // 总视野面积
double preservation = totalArea / 12000 * 100; // 视野保存率(%
double totalPreserve = preservation * 0.95; // 总视野保存率(示例)
mockList.Add(new TestDataStore.TestRecord
{
Id = i,
Date = DateTime.Now.AddDays(-i).ToString("yyyy-MM-dd"),
Time = DateTime.Now.AddHours(-i).ToString("HH:mm:ss"),
LeftEyeArea = left,
RightEyeArea = right,
BinocularArea = binocular,
LowerVision = lower,
VisionRetentionRate = preservation,
totalVisionArea = totalArea, // ✅ 必须赋值
GetVisionRetentionRate = totalPreserve // ✅ 必须赋值
});
}
return mockList;
}
private void btnSave_Click(object sender, RoutedEventArgs e) private void btnSave_Click(object sender, RoutedEventArgs e)
{ {
//// 判断是否有真实数据
//bool hasRealData = TestDataStore.Records != null && TestDataStore.Records.Count > 0;
//List<TestDataStore.TestRecord> exportRecords;
//if (!hasRealData)
//{
// exportRecords = GenerateMockRecords();
// TestDataStore.Records.AddRange(exportRecords);
//}
//else
//{
// exportRecords = TestDataStore.Records.ToList();
//}
try try
{ {
ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial; // 1. 构建表格内容
StringBuilder sb = new StringBuilder();
sb.AppendLine("编号,日期,时间,左目视野面积,右目视野面积,双目视野面积,空白视野面积,下方视野,视野保存率");
var saveDialog = new Microsoft.Win32.SaveFileDialog foreach (var item in TestDataStore.Records)
{ {
Filter = "Excel 文件 (*.xlsx)|*.xlsx", sb.AppendLine($"{item.Id},{item.Date},{item.Time},{item.LeftEyeArea},{item.RightEyeArea},{item.BinocularArea},{item.LowerVision},{item.VisionRetentionRate}");
FileName = $"视野测试报告_{DateTime.Now:yyyyMMddHHmmss}.xlsx" }
};
if (saveDialog.ShowDialog() != true) return;
using (var package = new OfficeOpenXml.ExcelPackage()) // 2. 弹出保存框,让用户自己选位置
Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog();
saveFileDialog.Filter = "CSV 文件 (*.csv)|*.csv|所有文件 (*.*)|*.*";
saveFileDialog.FileName = $"测试记录_{DateTime.Now:yyyyMMddHHmmss}";
if (saveFileDialog.ShowDialog() == true)
{ {
// ========== 工作表1报告摘要 ========== // 3. 保存文件
var sheet1 = package.Workbook.Worksheets.Add("报告摘要"); File.WriteAllText(saveFileDialog.FileName, sb.ToString(), Encoding.UTF8);
MessageBox.Show("保存成功!\n文件路径" + saveFileDialog.FileName, "成功");
// 标题
sheet1.Cells["A1"].Value = "头罩视野测试报告";
sheet1.Cells["A1"].Style.Font.Size = 22;
sheet1.Cells["A1"].Style.Font.Bold = true;
sheet1.Cells["A1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
sheet1.Cells["A1:G1"].Merge = true;
// 报告编号和日期
sheet1.Cells["A3"].Value = "报告编号:";
sheet1.Cells["B3"].Value = $"REP-{DateTime.Now:yyyyMMddHHmmss}";
sheet1.Cells["D3"].Value = "试验日期:";
sheet1.Cells["E3"].Value = DateTime.Now.ToString("yyyy年MM月dd日");
sheet1.Cells["A3:E3"].Style.Font.Size = 12;
// 测试参数
sheet1.Cells["A5"].Value = "测试参数";
sheet1.Cells["A5"].Style.Font.Bold = true;
sheet1.Cells["A6"].Value = "设备型号";
sheet1.Cells["B6"].Value = "X015";
sheet1.Cells["A7"].Value = "分辨角度";
sheet1.Cells["B7"].Value = GlobalData.JudgmentalPerspective;
sheet1.Cells["A8"].Value = "当前模式";
sheet1.Cells["B8"].Value = GlobalData.CurrentMode;
// 结果表格标题
int rowStart = 10;
string[] headers = { "编号", "日期", "时间", "左目视野(cm²)", "右目视野(cm²)",
"双目视野(cm²)", "下方视野(°)", "双目视野保存率(%)",
"总视野面积(cm²)", "总视野保存率(%)" };
for (int i = 0; i < headers.Length; i++)
sheet1.Cells[rowStart, i + 1].Value = headers[i];
sheet1.Cells[rowStart, 1, rowStart, headers.Length].Style.Font.Bold = true;
sheet1.Cells[rowStart, 1, rowStart, headers.Length].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid;
sheet1.Cells[rowStart, 1, rowStart, headers.Length].Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.LightGray);
// 填充数据
int row = rowStart + 1;
foreach (var item in TestDataStore.Records)
{
sheet1.Cells[row, 1].Value = item.Id;
sheet1.Cells[row, 2].Value = item.Date;
sheet1.Cells[row, 3].Value = item.Time;
sheet1.Cells[row, 4].Value = item.LeftEyeArea;
sheet1.Cells[row, 5].Value = item.RightEyeArea;
sheet1.Cells[row, 6].Value = item.BinocularArea;
sheet1.Cells[row, 7].Value = item.LowerVision;
sheet1.Cells[row, 8].Value = item.VisionRetentionRate;
sheet1.Cells[row, 9].Value = item.totalVisionArea;
sheet1.Cells[row, 10].Value = item.GetVisionRetentionRate;
row++;
}
sheet1.Cells[1, 1, row - 1, headers.Length].AutoFitColumns();
// ========== 插入柱状图展示最近5次左右眼面积对比==========
var records = TestDataStore.Records.TakeLast(5).ToList();
if (records.Count > 0)
{
int chartStartRow = row + 3;
sheet1.Cells[chartStartRow, 1].Value = "最近5次测试视野面积对比图";
sheet1.Cells[chartStartRow, 1].Style.Font.Bold = true;
int dataRowStart = chartStartRow + 1;
sheet1.Cells[dataRowStart, 1].Value = "序号";
sheet1.Cells[dataRowStart, 2].Value = "左眼面积";
sheet1.Cells[dataRowStart, 3].Value = "右眼面积";
for (int i = 0; i < records.Count; i++)
{
sheet1.Cells[dataRowStart + 1 + i, 1].Value = i + 1;
sheet1.Cells[dataRowStart + 1 + i, 2].Value = records[i].LeftEyeArea;
sheet1.Cells[dataRowStart + 1 + i, 3].Value = records[i].RightEyeArea;
}
var chart = sheet1.Drawings.AddChart("AreaChart", OfficeOpenXml.Drawing.Chart.eChartType.ColumnClustered);
chart.SetPosition(chartStartRow, 0, 0, 0);
chart.SetSize(600, 400);
chart.Title.Text = "左右眼视野面积对比";
chart.Legend.Position = OfficeOpenXml.Drawing.Chart.eLegendPosition.Bottom;
var series1 = chart.Series.Add(sheet1.Cells[dataRowStart + 1, 2, dataRowStart + records.Count, 2],
sheet1.Cells[dataRowStart + 1, 1, dataRowStart + records.Count, 1]);
series1.Header = "左眼面积";
var series2 = chart.Series.Add(sheet1.Cells[dataRowStart + 1, 3, dataRowStart + records.Count, 3],
sheet1.Cells[dataRowStart + 1, 1, dataRowStart + records.Count, 1]);
series2.Header = "右眼面积";
}
//// ========== 新增:三个饼图(左眼、右眼、双目)基于最新一次测试数据 ==========
//var latestRecord = TestDataStore.Records.LastOrDefault();
//if (latestRecord != null)
//{
// // 标准总面积(与 GetArea 中定义一致)
// double standardTotalArea = 2 * Math.PI * 330 * 330; // ≈ 684,000可根据实际调整
// // 如果您的 GetArea 中有公开的标准面积字段建议使用GetArea._standardTotalArea
// // 这里为了兼容,直接计算
// // 饼图数据区域起始行(放在柱状图右侧,可根据实际微调)
// int pieStartRow = row + 3;
// int pieStartColLeft = 8; // 左眼饼图起始列 H
// int pieStartColRight = 12; // 右眼饼图起始列 L
// int pieStartColBin = 16; // 双目饼图起始列 P
// // 左眼饼图数据
// double leftArea = latestRecord.LeftEyeArea;
// double leftRemain = standardTotalArea - leftArea;
// if (leftRemain < 0) leftRemain = 0;
// sheet1.Cells[pieStartRow, pieStartColLeft].Value = "左眼视野";
// sheet1.Cells[pieStartRow + 1, pieStartColLeft].Value = leftArea;
// sheet1.Cells[pieStartRow + 2, pieStartColLeft].Value = "剩余区域";
// sheet1.Cells[pieStartRow + 3, pieStartColLeft].Value = leftRemain;
// var pieLeft = sheet1.Drawings.AddChart("PieLeft", OfficeOpenXml.Drawing.Chart.eChartType.Pie);
// pieLeft.SetPosition(pieStartRow - 1, 0, pieStartColLeft - 2, 0);
// pieLeft.SetSize(300, 200);
// pieLeft.Title.Text = "左眼视野占比";
// pieLeft.Legend.Position = OfficeOpenXml.Drawing.Chart.eLegendPosition.Bottom;
// var seriesLeft = pieLeft.Series.Add(sheet1.Cells[pieStartRow + 1, pieStartColLeft, pieStartRow + 3, pieStartColLeft],
// sheet1.Cells[pieStartRow, pieStartColLeft, pieStartRow + 2, pieStartColLeft]);
// seriesLeft.Header = "面积 (cm²)";
// //这里需要加入百分比显示EPPlus 的饼图默认不显示百分比,需要手动设置数据标签
// // 右眼饼图数据
// double rightArea = latestRecord.RightEyeArea;
// double rightRemain = standardTotalArea - rightArea;
// if (rightRemain < 0) rightRemain = 0;
// sheet1.Cells[pieStartRow, pieStartColRight].Value = "右眼视野";
// sheet1.Cells[pieStartRow + 1, pieStartColRight].Value = rightArea;
// sheet1.Cells[pieStartRow + 2, pieStartColRight].Value = "剩余区域";
// sheet1.Cells[pieStartRow + 3, pieStartColRight].Value = rightRemain;
// var pieRight = sheet1.Drawings.AddChart("PieRight", OfficeOpenXml.Drawing.Chart.eChartType.Pie);
// pieRight.SetPosition(pieStartRow - 1, 0, pieStartColRight - 2, 0);
// pieRight.SetSize(300, 200);
// pieRight.Title.Text = "右眼视野占比";
// pieRight.Legend.Position = OfficeOpenXml.Drawing.Chart.eLegendPosition.Bottom;
// var seriesRight = pieRight.Series.Add(sheet1.Cells[pieStartRow + 1, pieStartColRight, pieStartRow + 3, pieStartColRight],
// sheet1.Cells[pieStartRow, pieStartColRight, pieStartRow + 2, pieStartColRight]);
// // 双目饼图数据
// double binArea = latestRecord.BinocularArea;
// double binRemain = standardTotalArea - binArea;
// if (binRemain < 0) binRemain = 0;
// sheet1.Cells[pieStartRow, pieStartColBin].Value = "双目视野";
// sheet1.Cells[pieStartRow + 1, pieStartColBin].Value = binArea;
// sheet1.Cells[pieStartRow + 2, pieStartColBin].Value = "剩余区域";
// sheet1.Cells[pieStartRow + 3, pieStartColBin].Value = binRemain;
// var pieBin = sheet1.Drawings.AddChart("PieBin", OfficeOpenXml.Drawing.Chart.eChartType.Pie);
// pieBin.SetPosition(pieStartRow - 1, 0, pieStartColBin - 2, 0);
// pieBin.SetSize(300, 200);
// pieBin.Title.Text = "双目视野占比";
// pieBin.Legend.Position = OfficeOpenXml.Drawing.Chart.eLegendPosition.Bottom;
// var seriesBin = pieBin.Series.Add(sheet1.Cells[pieStartRow + 1, pieStartColBin, pieStartRow + 3, pieStartColBin],
// sheet1.Cells[pieStartRow, pieStartColBin, pieStartRow + 2, pieStartColBin]);
//}
// 添加备注说明(位置下移避免覆盖饼图)
int noteRow = row + 30; // 原先是 row+20现在下移避免与饼图重叠
sheet1.Cells[noteRow, 1].Value = "备注:";
sheet1.Cells[noteRow, 2].Value = "1. 视野保存率公式依据 GB 2890-2022 计算;";
sheet1.Cells[noteRow + 1, 2].Value = "2. 空白视野面积为标准头模未戴面罩时的理论值;";
sheet1.Cells[noteRow + 2, 2].Value = "3. 测试过程中若出现异常,请参考原始记录。";
sheet1.Cells[noteRow, 1, noteRow + 2, 4].Style.Font.Size = 10;
sheet1.Cells[noteRow, 1, noteRow + 2, 4].Style.Font.Italic = true;
// ========== 工作表2原始数据明细 ==========
var sheet2 = package.Workbook.Worksheets.Add("原始数据");
for (int i = 0; i < headers.Length; i++)
sheet2.Cells[1, i + 1].Value = headers[i];
sheet2.Cells[1, 1, 1, headers.Length].Style.Font.Bold = true;
row = 2;
foreach (var item in TestDataStore.Records)
{
sheet2.Cells[row, 1].Value = item.Id;
sheet2.Cells[row, 2].Value = item.Date;
sheet2.Cells[row, 3].Value = item.Time;
sheet2.Cells[row, 4].Value = item.LeftEyeArea;
sheet2.Cells[row, 5].Value = item.RightEyeArea;
sheet2.Cells[row, 6].Value = item.BinocularArea;
sheet2.Cells[row, 7].Value = item.LowerVision;
sheet2.Cells[row, 8].Value = item.VisionRetentionRate;
sheet2.Cells[row, 9].Value = item.totalVisionArea;
sheet2.Cells[row, 10].Value = item.GetVisionRetentionRate;
row++;
}
sheet2.Cells[1, 1, row - 1, headers.Length].AutoFitColumns();
// 保存文件
package.SaveAs(new FileInfo(saveDialog.FileName));
MessageBox.Show($"报告已成功生成!\n路径{saveDialog.FileName}", "导出成功", MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show($"生成报告失败:{ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show("保存失败:" + ex.Message);
} }
} }
//#endregion
private void Page_Loaded(object sender, RoutedEventArgs e) private void Page_Loaded(object sender, RoutedEventArgs e)
{ {

View File

@@ -24,7 +24,7 @@
<Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,0,10,0"/> <Setter Property="Margin" Value="0,0,10,0"/>
<Setter Property="Margin" Value="0,0,10,0"/> <Setter Property="Margin" Value="0,0,10,0"/>
<Setter Property="Width" Value="105"/> <Setter Property="Width" Value="100"/>
</Style> </Style>
<Style x:Key="TextBoxStyle" TargetType="TextBox"> <Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="Height" Value="40"/> <Setter Property="Height" Value="40"/>

View File

@@ -0,0 +1,84 @@
#pragma checksum "..\..\..\App.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "69F410B786DB1725D40721B4BFA0AF24ADE0F02A"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using ;
namespace {
/// <summary>
/// App
/// </summary>
public partial class App : System.Windows.Application {
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
#line 5 "..\..\..\App.xaml"
this.StartupUri = new System.Uri("MainWindow.xaml", System.UriKind.Relative);
#line default
#line hidden
System.Uri resourceLocater = new System.Uri("/头罩视野;component/app.xaml", System.UriKind.Relative);
#line 1 "..\..\..\App.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
/// <summary>
/// Application Entry Point.
/// </summary>
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
public static void Main() {
.App app = new .App();
app.InitializeComponent();
app.Run();
}
}
}

View File

@@ -0,0 +1,152 @@
#pragma checksum "..\..\..\..\Views\ChangeLanguage.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "988A846E1656D700EA4630C867745AA59A3D0110"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using HandyControl.Controls;
using HandyControl.Data;
using HandyControl.Expression.Media;
using HandyControl.Expression.Shapes;
using HandyControl.Interactivity;
using HandyControl.Media.Animation;
using HandyControl.Media.Effects;
using HandyControl.Properties.Langs;
using HandyControl.Themes;
using HandyControl.Tools;
using HandyControl.Tools.Converter;
using HandyControl.Tools.Extension;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using .Views;
namespace .Views {
/// <summary>
/// ChangeLanguage
/// </summary>
public partial class ChangeLanguage : System.Windows.Controls.Page, System.Windows.Markup.IComponentConnector {
#line 43 "..\..\..\..\Views\ChangeLanguage.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock TX_1;
#line default
#line hidden
#line 47 "..\..\..\..\Views\ChangeLanguage.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock TX_0;
#line default
#line hidden
#line 51 "..\..\..\..\Views\ChangeLanguage.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button SW_1;
#line default
#line hidden
#line 68 "..\..\..\..\Views\ChangeLanguage.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBlock TX_2;
#line default
#line hidden
#line 73 "..\..\..\..\Views\ChangeLanguage.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button SW_2;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/头罩视野;component/views/changelanguage.xaml", System.UriKind.Relative);
#line 1 "..\..\..\..\Views\ChangeLanguage.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.TX_1 = ((System.Windows.Controls.TextBlock)(target));
return;
case 2:
this.TX_0 = ((System.Windows.Controls.TextBlock)(target));
return;
case 3:
this.SW_1 = ((System.Windows.Controls.Button)(target));
#line 51 "..\..\..\..\Views\ChangeLanguage.xaml"
this.SW_1.Click += new System.Windows.RoutedEventHandler(this.BtnGoNextPage_Click);
#line default
#line hidden
return;
case 4:
this.TX_2 = ((System.Windows.Controls.TextBlock)(target));
return;
case 5:
this.SW_2 = ((System.Windows.Controls.Button)(target));
return;
}
this._contentLoaded = true;
}
}
}

View File

@@ -0,0 +1,76 @@
#pragma checksum "..\..\..\..\Views\Help.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "26C55F12F75F47E87465FBE205342822ABB38A23"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using .Views;
namespace .Views {
/// <summary>
/// Help
/// </summary>
public partial class Help : System.Windows.Controls.Page, System.Windows.Markup.IComponentConnector {
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/头罩视野;component/views/help.xaml", System.UriKind.Relative);
#line 1 "..\..\..\..\Views\Help.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
this._contentLoaded = true;
}
}
}

View File

@@ -0,0 +1,277 @@
#pragma checksum "..\..\..\..\Views\SetPassWord.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "CD00A0EB8304DD1C4BC82D7B58CB962188A096F7"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using .Views;
namespace .Views {
/// <summary>
/// SetPassWord
/// </summary>
public partial class SetPassWord : System.Windows.Controls.Page, System.Windows.Markup.IComponentConnector {
#line 34 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_7;
#line default
#line hidden
#line 38 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_8;
#line default
#line hidden
#line 42 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_9;
#line default
#line hidden
#line 55 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_14;
#line default
#line hidden
#line 59 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_15;
#line default
#line hidden
#line 63 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_16;
#line default
#line hidden
#line 74 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_17;
#line default
#line hidden
#line 78 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_18;
#line default
#line hidden
#line 82 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_19;
#line default
#line hidden
#line 93 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_20;
#line default
#line hidden
#line 97 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_21;
#line default
#line hidden
#line 101 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_22;
#line default
#line hidden
#line 112 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_23;
#line default
#line hidden
#line 116 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_24;
#line default
#line hidden
#line 120 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_25;
#line default
#line hidden
#line 131 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.PasswordBox ActiveCode_Password;
#line default
#line hidden
#line 138 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.PasswordBox FullActiveCode_Password;
#line default
#line hidden
#line 144 "..\..\..\..\Views\SetPassWord.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button TS_0;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/头罩视野;component/views/setpassword.xaml", System.UriKind.Relative);
#line 1 "..\..\..\..\Views\SetPassWord.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.NE_7 = ((System.Windows.Controls.TextBox)(target));
return;
case 2:
this.NE_8 = ((System.Windows.Controls.TextBox)(target));
return;
case 3:
this.NE_9 = ((System.Windows.Controls.TextBox)(target));
return;
case 4:
this.NE_14 = ((System.Windows.Controls.TextBox)(target));
return;
case 5:
this.NE_15 = ((System.Windows.Controls.TextBox)(target));
return;
case 6:
this.NE_16 = ((System.Windows.Controls.TextBox)(target));
return;
case 7:
this.NE_17 = ((System.Windows.Controls.TextBox)(target));
return;
case 8:
this.NE_18 = ((System.Windows.Controls.TextBox)(target));
return;
case 9:
this.NE_19 = ((System.Windows.Controls.TextBox)(target));
return;
case 10:
this.NE_20 = ((System.Windows.Controls.TextBox)(target));
return;
case 11:
this.NE_21 = ((System.Windows.Controls.TextBox)(target));
return;
case 12:
this.NE_22 = ((System.Windows.Controls.TextBox)(target));
return;
case 13:
this.NE_23 = ((System.Windows.Controls.TextBox)(target));
return;
case 14:
this.NE_24 = ((System.Windows.Controls.TextBox)(target));
return;
case 15:
this.NE_25 = ((System.Windows.Controls.TextBox)(target));
return;
case 16:
this.ActiveCode_Password = ((System.Windows.Controls.PasswordBox)(target));
return;
case 17:
this.FullActiveCode_Password = ((System.Windows.Controls.PasswordBox)(target));
return;
case 18:
this.TS_0 = ((System.Windows.Controls.Button)(target));
return;
}
this._contentLoaded = true;
}
}
}

View File

@@ -0,0 +1,261 @@
#pragma checksum "..\..\..\..\Views\SetTime.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "51F0FF48EEB069C6AD0669FE96AF3D2EA6F39299"
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Effects;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Media.TextFormatting;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Shell;
using .Views;
namespace .Views {
/// <summary>
/// SetTime
/// </summary>
public partial class SetTime : System.Windows.Controls.Page, System.Windows.Markup.IComponentConnector {
#line 39 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_0;
#line default
#line hidden
#line 43 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_1;
#line default
#line hidden
#line 47 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_5;
#line default
#line hidden
#line 51 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_4;
#line default
#line hidden
#line 55 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_3;
#line default
#line hidden
#line 59 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_2;
#line default
#line hidden
#line 63 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_6;
#line default
#line hidden
#line 69 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox ND_0;
#line default
#line hidden
#line 73 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox ND_1;
#line default
#line hidden
#line 77 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox ND_5;
#line default
#line hidden
#line 81 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox ND_4;
#line default
#line hidden
#line 85 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox ND_3;
#line default
#line hidden
#line 89 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox ND_2;
#line default
#line hidden
#line 93 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.TextBox NE_7;
#line default
#line hidden
#line 96 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button TS_0;
#line default
#line hidden
#line 107 "..\..\..\..\Views\SetTime.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Button FK_0;
#line default
#line hidden
private bool _contentLoaded;
/// <summary>
/// InitializeComponent
/// </summary>
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Uri resourceLocater = new System.Uri("/头罩视野;component/views/settime.xaml", System.UriKind.Relative);
#line 1 "..\..\..\..\Views\SetTime.xaml"
System.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "10.0.6.0")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.NE_0 = ((System.Windows.Controls.TextBox)(target));
#line 40 "..\..\..\..\Views\SetTime.xaml"
this.NE_0.TextChanged += new System.Windows.Controls.TextChangedEventHandler(this.NE_0_TextChanged);
#line default
#line hidden
return;
case 2:
this.NE_1 = ((System.Windows.Controls.TextBox)(target));
return;
case 3:
this.NE_5 = ((System.Windows.Controls.TextBox)(target));
return;
case 4:
this.NE_4 = ((System.Windows.Controls.TextBox)(target));
return;
case 5:
this.NE_3 = ((System.Windows.Controls.TextBox)(target));
return;
case 6:
this.NE_2 = ((System.Windows.Controls.TextBox)(target));
return;
case 7:
this.NE_6 = ((System.Windows.Controls.TextBox)(target));
return;
case 8:
this.ND_0 = ((System.Windows.Controls.TextBox)(target));
return;
case 9:
this.ND_1 = ((System.Windows.Controls.TextBox)(target));
return;
case 10:
this.ND_5 = ((System.Windows.Controls.TextBox)(target));
return;
case 11:
this.ND_4 = ((System.Windows.Controls.TextBox)(target));
return;
case 12:
this.ND_3 = ((System.Windows.Controls.TextBox)(target));
return;
case 13:
this.ND_2 = ((System.Windows.Controls.TextBox)(target));
return;
case 14:
this.NE_7 = ((System.Windows.Controls.TextBox)(target));
return;
case 15:
this.TS_0 = ((System.Windows.Controls.Button)(target));
return;
case 16:
this.FK_0 = ((System.Windows.Controls.Button)(target));
return;
}
this._contentLoaded = true;
}
}
}

View File

@@ -0,0 +1,24 @@
{
"runtimeOptions": {
"tfm": "net10.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "10.0.0"
},
{
"name": "Microsoft.WindowsDesktop.App",
"version": "10.0.0"
}
],
"additionalProbingPaths": [
"C:\\Users\\31119\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\31119\\.nuget\\packages"
],
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
"CSWINRT_USE_WINDOWS_UI_XAML_PROJECTIONS": false,
"Microsoft.NETCore.DotNetHostPolicy.SetAppPaths": true
}
}
}

View File

@@ -0,0 +1,12 @@
FD:\work\hoodFieldOfView\头罩视野slove\头罩视野\App.xaml;;
FD:\work\hoodFieldOfView\头罩视野slove\头罩视野\MainWindow.xaml;;
FD:\work\hoodFieldOfView\头罩视野slove\头罩视野\Views\ChangeLanguage.xaml;;
FD:\work\hoodFieldOfView\头罩视野slove\头罩视野\Views\Help.xaml;;
FD:\work\hoodFieldOfView\头罩视野slove\头罩视野\Views\PageTest.xaml;;
FD:\work\hoodFieldOfView\头罩视野slove\头罩视野\Views\RecordDate.xaml;;
FD:\work\hoodFieldOfView\头罩视野slove\头罩视野\Views\RecordPage.xaml;;
FD:\work\hoodFieldOfView\头罩视野slove\头罩视野\Views\SetPassWord.xaml;;
FD:\work\hoodFieldOfView\头罩视野slove\头罩视野\Views\SetTime.xaml;;
FD:\work\hoodFieldOfView\头罩视野slove\头罩视野\Views\VisiData.xaml;;

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\31119\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">7.0.0</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\31119\.nuget\packages\" />
</ItemGroup>
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<PkgHandyControl Condition=" '$(PkgHandyControl)' == '' ">C:\Users\31119\.nuget\packages\handycontrol\3.5.1</PkgHandyControl>
</PropertyGroup>
</Project>

View File

@@ -8,13 +8,6 @@
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<Compile Remove="ViewModels\**" />
<EmbeddedResource Remove="ViewModels\**" />
<None Remove="ViewModels\**" />
<Page Remove="ViewModels\**" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Remove="Images\bmg.png" /> <None Remove="Images\bmg.png" />
<None Remove="Images\printTime.png" /> <None Remove="Images\printTime.png" />
@@ -26,7 +19,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="EPPlus" Version="7.1.0" /> <Folder Include="ViewModels\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="EPPlus" Version="8.5.3" />
<PackageReference Include="HandyControl" Version="3.5.1" /> <PackageReference Include="HandyControl" Version="3.5.1" />
<PackageReference Include="MathNet.Numerics" Version="5.0.0" /> <PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="NModbus4" Version="2.1.0" /> <PackageReference Include="NModbus4" Version="2.1.0" />

View File

@@ -1,30 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<Compile Update="Views\Help.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\RecordDate.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\RecordPage.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\SetPassWord.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\SetTime.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\ChangeLanguage.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\PageTest.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\VisiData.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
</Project>