Files

381 lines
19 KiB
Plaintext
Raw Permalink Normal View History

2026-04-20 11:51:33 +08:00
<Window x:Class="EmptyLoadTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:EmptyLoadTest"
mc:Ignorable="d"
Title="空载测试系统" Height="750" Width="1000"
WindowStartupLocation="CenterScreen"
Background="#F5F7FA" Loaded="Window_Loaded">
<Window.Resources>
<!-- 菜单项样式 -->
<Style x:Key="MenuStyle" TargetType="Menu">
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="Height" Value="30"/>
</Style>
<Style x:Key="MenuItemStyle" TargetType="MenuItem">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Foreground" Value="Blue"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Padding" Value="10,5"/>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#34495E"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="TitleStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="32"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,20,0,30"/>
</Style>
<Style x:Key="SectionTitleStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="20"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Foreground" Value="#34495E"/>
<Setter Property="Margin" Value="0,0,0,15"/>
</Style>
<Style x:Key="LabelStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="16"/>
<Setter Property="Foreground" Value="#5D6D7E"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="0,0,10,0"/>
</Style>
<Style x:Key="UnitStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="14"/>
<Setter Property="Foreground" Value="#7F8C8D"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Margin" Value="10,0,0,0"/>
<Setter Property="FontStyle" Value="Italic"/>
</Style>
<Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="180"/>
<Setter Property="FontSize" Value="18"/>
<Setter Property="TextAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderBrush" Value="#D5D8DC"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Background" Value="#FFFFFF"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="Padding" Value="10,5"/>
<Style.Triggers>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" Value="#3498DB"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="ButtonStyle" TargetType="Button">
<Setter Property="Height" Value="45"/>
<Setter Property="Width" Value="150"/>
<Setter Property="FontSize" Value="16"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border" Background="{TemplateBinding Background}"
CornerRadius="8">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#27AE60"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Margin" Value="10"/>
</Style>
<Style x:Key="ResultBoxStyle" TargetType="TextBox">
<Setter Property="FontSize" Value="16"/>
<Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="HorizontalScrollBarVisibility" Value="Disabled"/>
<Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property="AcceptsReturn" Value="True"/>
<Setter Property="BorderBrush" Value="#D5D8DC"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Background" Value="#FFFFFF"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="Padding" Value="15"/>
<Setter Property="IsReadOnly" Value="True"/>
</Style>
<!-- 修改StatusLabelStyle使用Border包裹TextBlock -->
<Style x:Key="StatusBorderStyle" TargetType="Border">
<Setter Property="Background" Value="#F8F9F9"/>
<Setter Property="BorderBrush" Value="#D5D8DC"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="Padding" Value="15,8"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style>
<Style x:Key="StatusTextStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="18"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Foreground" Value="#2C3E50"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<!-- 开始按钮样式 -->
<Style x:Key="StartButtonStyle" TargetType="Button" BasedOn="{StaticResource ButtonStyle}">
<Setter Property="Background" Value="#2ECC71"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border" Background="#2ECC71" CornerRadius="8">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#27AE60"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 停止按钮样式 -->
<Style x:Key="StopButtonStyle" TargetType="Button" BasedOn="{StaticResource ButtonStyle}">
<Setter Property="Background" Value="#E74C3C"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border" Background="#E74C3C" CornerRadius="8">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#C0392B"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 记录结果按钮样式 -->
<Style x:Key="RecordButtonStyle" TargetType="Button" BasedOn="{StaticResource ButtonStyle}">
<Setter Property="Background" Value="#3498DB"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="border" Background="#3498DB" CornerRadius="8">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="Background" Value="#2980B9"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid Cursor="">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 菜单栏 -->
<Menu Grid.Row="0" Style="{StaticResource MenuStyle}">
<MenuItem Header="退出" Style="{StaticResource MenuItemStyle}" Click="MenuItem_Click">
<!--<MenuItem Header="新建测试" Style="{StaticResource MenuItemStyle}"/>
<MenuItem Header="打开测试" Style="{StaticResource MenuItemStyle}"/>
<Separator/>
<MenuItem Header="保存" Style="{StaticResource MenuItemStyle}"/>
<MenuItem Header="另存为" Style="{StaticResource MenuItemStyle}"/>
<Separator/>
<MenuItem Header="退出" Style="{StaticResource MenuItemStyle}"/>-->
</MenuItem>
<MenuItem Header="测试" Style="{StaticResource MenuItemStyle}">
<MenuItem Header="空载测试" Style="{StaticResource MenuItemStyle}"/>
<MenuItem Header="负载测试" Style="{StaticResource MenuItemStyle}" Click="LoadTestMenuItem_Click"/>
2026-04-20 14:03:34 +08:00
<MenuItem Header="跳动测试" Style="{StaticResource MenuItemStyle}" Click="JumpingTest_Click"/>
2026-04-20 11:51:33 +08:00
<MenuItem Header="报表" Style="{StaticResource MenuItemStyle}" Click="ReportMenuItem_Click"/>
</MenuItem>
<!--<MenuItem Header="报告" Style="{StaticResource MenuItemStyle}">
<MenuItem Header="生成报表" Style="{StaticResource MenuItemStyle}" Click="ReportMenuItem_Click"/>
<MenuItem Header="导出数据" Style="{StaticResource MenuItemStyle}"/>
<MenuItem Header="打印报告" Style="{StaticResource MenuItemStyle}"/>
</MenuItem>
<MenuItem Header="设置" Style="{StaticResource MenuItemStyle}">
<MenuItem Header="系统设置" Style="{StaticResource MenuItemStyle}"/>
<MenuItem Header="测试参数" Style="{StaticResource MenuItemStyle}"/>
<MenuItem Header="设备配置" Style="{StaticResource MenuItemStyle}"/>
</MenuItem>
<MenuItem Header="帮助" Style="{StaticResource MenuItemStyle}">
<MenuItem Header="使用手册" Style="{StaticResource MenuItemStyle}"/>
<MenuItem Header="关于" Style="{StaticResource MenuItemStyle}"/>
</MenuItem>-->
</Menu>
<!-- 标题区域 -->
<TextBlock Text="空载测试" Style="{StaticResource TitleStyle}" Grid.Row="1"/>
<Button Content="隐藏"
Style="{StaticResource RecordButtonStyle}"
Width="200"
HorizontalAlignment="Right"
Opacity="0"
Background="Transparent"
Foreground="Transparent"
BorderBrush="Transparent"
Margin="0 -20 0 0"
Click="Button_Click_3"
IsHitTestVisible="True"
Focusable="True"/>
<!-- 主要内容区域 -->
<Grid Grid.Row="2" Margin="40,0,40,20" Cursor="">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- 左侧:控制区域 -->
<Grid Grid.Column="0" Margin="0,0,30,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 设置转速区域 -->
<Border Grid.Row="0" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="25,20" Margin="0,0,0,25">
<StackPanel Cursor="">
<TextBox Name="t0" Width="0" Height="0"></TextBox>
<TextBlock Text="设置转速:" Style="{StaticResource SectionTitleStyle}"/>
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="设置转速:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="settingspeed" GotFocus="settingspeed_GotFocus" Text="1500" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="Rad/Min" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="实时转速:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="actualspeed" Text="1200" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="Rad/Min" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<Button Grid.Row="2" Content="记录结果"
Style="{StaticResource RecordButtonStyle}"
Width="200" HorizontalAlignment="Center" Click="Button_Click"/>
</StackPanel>
</Border>
<!-- 往复频率区域 -->
<Border Grid.Row="1" Background="#FFFFFF" CornerRadius="10"
BorderBrush="#E5E8E8" BorderThickness="1"
Padding="25,20" Margin="0,0,0,25">
<StackPanel>
<TextBlock Text="往复频率:" Style="{StaticResource SectionTitleStyle}"/>
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="往复频率:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="interval" Text="" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="次/Min" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,0,0,15">
<TextBlock Text="往复频率:" Style="{StaticResource LabelStyle}"/>
<TextBox Name="intrval2" GotFocus="intrval2_GotFocus" Text="45" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="次/Min" Style="{StaticResource UnitStyle}"/>
</StackPanel>
<!--<StackPanel Orientation="Horizontal">
<TextBlock Text="频率 " Style="{StaticResource LabelStyle}"/>
<TextBox Name="pinlv" Text="30" Style="{StaticResource TextBoxStyle}"/>
<TextBlock Text="次/Min" Style="{StaticResource UnitStyle}"/>
</StackPanel>-->
</StackPanel>
</Border>
<Button Grid.Row="2" Content="记录结果"
Style="{StaticResource RecordButtonStyle}"
Width="200" HorizontalAlignment="Center" Margin="0 -10 0 0" Click="Button_Click_4" />
</Grid>
<!-- 右侧:结果显示区域 -->
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
2026-04-20 14:03:34 +08:00
<!-- 按钮区域 -->
<!--
2026-04-20 11:51:33 +08:00
<StackPanel Grid.Row="1" Orientation="Horizontal" Grid.Column="1"
HorizontalAlignment="Center" Margin="0,300,0,0" Cursor="">
<Button Content="开始" Style="{StaticResource StartButtonStyle}" Click="Button_Click_1"/>
<Button Content="停止" Style="{StaticResource StopButtonStyle}" Click="Button_Click_2"/>
</StackPanel>-->
</Grid>
</Grid>
<!-- 底部状态栏 -->
<Border Grid.Row="3" Background="#2C3E50" Padding="15,10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="空载测试系统 v1.0" Foreground="#ECF0F1"
VerticalAlignment="Center" FontSize="14" />
<StackPanel Grid.Column="1" Orientation="Horizontal">
<TextBlock Text="状态:" Foreground="#ECF0F1"
VerticalAlignment="Center" Margin="0,0,10,0"/>
<Border Name="statusB" Background="Blue" CornerRadius="4"
Padding="8,4" VerticalAlignment="Center">
<TextBlock Name="status" Text="空闲" Foreground="White"
FontWeight="SemiBold"/>
</Border>
<TextBlock Text=" | " Foreground="#7F8C8D"
VerticalAlignment="Center" Margin="10,0"/>
2026-04-20 14:03:34 +08:00
2026-04-20 11:51:33 +08:00
</StackPanel>
</Grid>
</Border>
</Grid>
</Window>