Files
New-version-HME-moisture-lo…/Views/MainWindow.xaml

119 lines
6.3 KiB
Plaintext
Raw Normal View History

2026-06-17 15:04:35 +08:00
<Window x:Class="HME_MoistureLossMeter.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:HME_MoistureLossMeter.Views"
xmlns:converters="clr-namespace:HME_MoistureLossMeter.Converters"
Title="HME水分损失测量仪"
Width="1024" Height="768"
WindowStartupLocation="CenterScreen"
Background="#F0F2F5">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="Height" Value="40"/>
<Setter Property="Margin" Value="5"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Background" Value="#2C7DA0"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="#1F5E7A"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Cursor" Value="Hand"/>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="#CCCCCC"/>
<Setter Property="Foreground" Value="#666666"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#1F5E7A"/>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="TextBox">
<Setter Property="Height" Value="35"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="BorderBrush" Value="#CCCCCC"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
</Style>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="14"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style TargetType="GroupBox">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Margin" Value="0,5"/>
</Style>
<Style TargetType="Border" x:Key="CardBorder">
<Setter Property="Background" Value="White"/>
<Setter Property="CornerRadius" Value="8"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="BorderBrush" Value="#DDDDDD"/>
<Setter Property="BorderThickness" Value="1"/>
</Style>
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
<converters:BoolToColorConverter x:Key="BoolToColorConverter"/>
<converters:BoolToStringConverter x:Key="BoolToStringConverter"/>
<converters:InverseBoolConverter x:Key="InverseBoolConverter"/>
</Window.Resources>
<Grid Margin="15">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!-- 顶部状态栏 -->
<Border Grid.Row="0" Background="#2C3E50" CornerRadius="5" Padding="10" Margin="0,0,0,10">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal">
<TextBlock Text="状态:" Foreground="White" FontSize="14" VerticalAlignment="Center"/>
<TextBlock Text="{Binding ConnectionStatus}"
Foreground="{Binding IsConnected, Converter={StaticResource BoolToColorConverter}}"
FontSize="14" FontWeight="Bold" Margin="5,0,20,0"/>
<Separator Background="White" Width="1" Margin="5,0"/>
<TextBlock Text="当前视图:" Foreground="White" FontSize="14" Margin="15,0,0,0"/>
<TextBlock Text="{Binding CurrentViewName}" Foreground="White" FontSize="14" FontWeight="Bold" Margin="5,0,20,0"/>
<Separator Background="White" Width="1" Margin="5,0"/>
<TextBlock Text="测试状态:" Foreground="White" FontSize="14" Margin="15,0,0,0"/>
<TextBlock Text="{Binding IsTesting, Converter={StaticResource BoolToStringConverter}}"
Foreground="White" FontSize="14" FontWeight="Bold" Margin="5,0,0,0"/>
</StackPanel>
<TextBlock Grid.Column="1" Text="{Binding CurrentTime, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}"
Foreground="White" FontSize="14" VerticalAlignment="Center"/>
</Grid>
</Border>
<!-- 主内容 -->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="180"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- 导航 -->
<Border Grid.Column="0" Style="{StaticResource CardBorder}" Margin="0,0,10,0">
<StackPanel Margin="5">
<Button Content="测试画面" Command="{Binding NavigateToTestCommand}" Height="45" Margin="0,5"/>
<Button Content="手动控制" Command="{Binding NavigateToManualCommand}" Height="45" Margin="0,5"/>
<Button Content="记录画面" Command="{Binding NavigateToRecordCommand}" Height="45" Margin="0,5"/>
<Button Content="报表" Command="{Binding NavigateToReportCommand}" Height="45" Margin="0,5"/>
<Separator Margin="0,15"/>
<Button Content="退出" Command="{Binding ExitApplicationCommand}" Height="45" Margin="0,5" Background="#E74C3C"/>
</StackPanel>
</Border>
<!-- 视图 -->
<ContentControl Grid.Column="1" Content="{Binding CurrentView}"/>
</Grid>
<!-- 底部状态 -->
<Border Grid.Row="2" Background="#2C3E50" CornerRadius="5" Padding="5" Margin="0,10,0,0">
<TextBlock Text="{Binding StatusMessage}" Foreground="White" FontSize="12" HorizontalAlignment="Center"/>
</Border>
</Grid>
</Window>