<Window x:Class="自救器呼吸器综合检验仪.MainWindow2"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:自救器呼吸器综合检验仪"
        Title="自救器呼吸器综合检验仪" Height="730" Width="1024"
        WindowStartupLocation="CenterScreen"
        Background="Transparent"
        FontFamily="Microsoft YaHeui"  Loaded="Window_Loaded" Closed="Window_Closed" Closing="Window_Closing">

    <Window.DataContext>
        <local:MainViewModel />
    </Window.DataContext>


    <!--<Window.Resources>

        <Style x:Key="LabelStyle" TargetType="TextBlock">
            <Setter Property="FontSize" Value="11"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="Margin" Value="3,2"/>
        </Style>

        <Style x:Key="TextBoxStyle" TargetType="TextBox">
            <Setter Property="FontSize" Value="11"/>
            <Setter Property="Height" Value="22"/>
            <Setter Property="Width" Value="65"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="Margin" Value="3,2"/>
            <Setter Property="BorderBrush" Value="#CCCCCC"/>
            <Setter Property="BorderThickness" Value="1"/>
        </Style>


    </Window.Resources>-->

    <!-- 背景层 -->
    <Grid>
        <!-- 背景图片 -->
        <Grid.Background>
            <ImageBrush ImageSource="/Resources/sleep2.jpg" Stretch="UniformToFill" Opacity="0.15"/>
        </Grid.Background>

        <!-- 背景遮罩层 -->
        <Rectangle Fill="#1E3A5F" Opacity="0.85"/>

        <!-- 主内容容器 -->
        <Grid Margin="20">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>

            <!-- 顶部标题栏 -->
            <Border Grid.Row="0" Background="#2A4B6D" BorderBrush="#3A5B8C" BorderThickness="0,0,0,2" 
                    Margin="0,0,0,15" Padding="20,12">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <!-- 主标题 -->
                    <StackPanel Grid.Column="0" VerticalAlignment="Center">
                        <TextBlock Text="负压气密性检验系统" 
                                   FontSize="22" FontWeight="Bold" Foreground="White"/>
                        <!--<TextBlock Text="负压气密性检验系统" 
                                   FontSize="12" Foreground="#CCFFFFFF" Margin="0,3,0,0"/>-->
                    </StackPanel>

                    <!--<StackPanel Orientation="Horizontal" Margin="2" HorizontalAlignment="Center">
                        <TextBlock Text="样品编号：" FontSize="26" FontWeight="Bold" Foreground="White" Style="{StaticResource LabelStyle}"/>
                        <TextBox x:Name="pressureDiff2" Text="" Width="180" Style="{StaticResource TextBoxStyle}" LostFocus="pressureDiff2_GotFocus"/>

                    </StackPanel>-->

                    <!-- 状态指示 -->
                    <StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,0,20,0">
                        <Border Background="#27AE60" Padding="10,5" Margin="0,0,10,0">
                            <TextBlock Text="系统状态：" FontSize="11" Foreground="White" FontWeight="Bold"/>
                        </Border>
                        <Border x:Name="statusPanel" Background="#3498DB" Padding="10,5">
                            <TextBlock x:Name="status" Text="空闲" FontSize="11" Foreground="White" FontWeight="Bold"/>
                        </Border>
                    </StackPanel>

                    <!-- 系统时间 -->
                    <Border Grid.Column="2" Background="White" Padding="12,6">
                        <TextBlock Text="{Binding CurrentTime, StringFormat='yyyy-MM-dd HH:mm:ss'}" 
                                   FontSize="11" FontWeight="Bold" Foreground="#2C3E50"/>
                    </Border>
                </Grid>
            </Border>

            <!-- 主内容区域 -->
            <Grid Grid.Row="1" Margin="0,0,0,15">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="280"/>
                </Grid.ColumnDefinitions>

                <!-- 左侧：配置与监控区 -->
                <Grid Grid.Column="0" Margin="0,0,15,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>

                    <!-- 参数配置区 -->
                    <Border Grid.Row="0" Background="White" Margin="0,0,0,15" 
                            BorderBrush="#E1E8ED" BorderThickness="1">
                        <StackPanel Margin="20,15">
                            <TextBlock Text="⚙️ 压力参数配置" FontSize="16" FontWeight="Bold" 
                                       Foreground="#2C3E50" Margin="0,0,0,15"/>

                            <!-- 第一行设置 -->
                            <StackPanel Orientation="Horizontal" Margin="0,0,0,12">
                                <TextBlock Text="压力设置：" Width="80" VerticalAlignment="Center" 
                                           FontSize="13" FontWeight="SemiBold" Foreground="#2C3E50"/>
                                <TextBox x:Name="settingtime" Text="0" Width="80" Height="32" 
                                         VerticalContentAlignment="Center" TextAlignment="Center"
                                         BorderBrush="#DCDFE6" BorderThickness="1" Background="#FAFBFC"
                                         FontSize="13"/>
                                <TextBlock Text="Pa" Margin="8,0,20,0" VerticalAlignment="Center" 
                                           FontSize="13" Foreground="#7F8C8D"/>

                                <Button Content="设置压力" Click="BtnWrite401_Click" 
                                        Background="#3498DB" Foreground="White" FontSize="12" FontWeight="Bold"
                                        Width="90" Height="32" BorderThickness="0" Margin="0,0,25,0"
                                        Cursor="Hand"/>

                                <TextBlock Text="检验时间：" Width="70" VerticalAlignment="Center" 
                                           FontSize="13" FontWeight="SemiBold" Foreground="#2C3E50"/>
                                <TextBox x:Name="settingtime2" Text="0" Width="80" Height="32" 
                                         VerticalContentAlignment="Center" TextAlignment="Center"
                                         BorderBrush="#DCDFE6" BorderThickness="1" Background="#FAFBFC"
                                         FontSize="13"/>
                                <TextBlock Text="秒" Margin="8,0,20,0" VerticalAlignment="Center" 
                                           FontSize="13" Foreground="#7F8C8D"/>

                                <Button Content="设置时间" Click="BtnWrite402_Click" 
                                        Background="#3498DB" Foreground="White" FontSize="12" FontWeight="Bold"
                                        Width="90" Height="32" BorderThickness="0" Cursor="Hand"/>
                            </StackPanel>

                            <!-- 第二行设置 -->
                            <!--<StackPanel Orientation="Horizontal">
                                <TextBlock Text="试验时间：" Width="80" VerticalAlignment="Center" 
                                           FontSize="13" FontWeight="SemiBold" Foreground="#2C3E50"/>
                                <TextBox Text="0" Width="60" Height="32" VerticalContentAlignment="Center" 
                                         TextAlignment="Center" BorderBrush="#DCDFE6" BorderThickness="1" 
                                         Background="#FAFBFC" FontSize="13"/>
                                <TextBlock Text="分" Margin="5,0,15,0" VerticalAlignment="Center" 
                                           FontSize="13" Foreground="#7F8C8D"/>
                                <TextBox Text="0" Width="60" Height="32" VerticalContentAlignment="Center" 
                                         TextAlignment="Center" BorderBrush="#DCDFE6" BorderThickness="1" 
                                         Background="#FAFBFC" FontSize="13"/>
                                <TextBlock Text="秒" Margin="5,0,0,0" VerticalAlignment="Center" 
                                           FontSize="13" Foreground="#7F8C8D"/>
                            </StackPanel>-->
                        </StackPanel>
                    </Border>

                    <!-- 实时数据监控 -->
                    <Border Grid.Row="1" Background="White" BorderBrush="#E1E8ED" BorderThickness="1">
                        <StackPanel Margin="20,15">
                            <TextBlock Text="📊 压力数据监控" FontSize="16" FontWeight="Bold" 
                                       Foreground="#2C3E50" Margin="0,0,0,15"/>

                            <!-- 第一行数据 -->
                            <Grid Margin="0,0,0,10">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>

                                <!-- 当前压力 -->
                                <Border Grid.Column="0" Background="#F8F9FA" Margin="8" Padding="15,12" 
                                        BorderBrush="#E1E8ED" BorderThickness="1">
                                    <StackPanel>
                                        <TextBlock Text="当前压力" FontSize="12" Foreground="#7F8C8D" 
                                                   FontWeight="SemiBold" Margin="0,0,0,8"/>
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                            <TextBlock x:Name="min" Text="0.00" FontSize="18" FontWeight="Bold" 
                                                       Foreground="#2C3E50"/>
                                            <TextBlock Text="Pa" FontSize="12" Foreground="#7F8C8D" 
                                                       VerticalAlignment="Bottom" Margin="5,0,0,2"/>
                                        </StackPanel>
                                    </StackPanel>
                                </Border>

                                <!-- 试验时间 -->
                                <Border Grid.Column="1" Background="#F8F9FA" Margin="8" Padding="15,12" 
                                        BorderBrush="#E1E8ED" BorderThickness="1">
                                    <StackPanel>
                                        <TextBlock Text="试验时间" FontSize="12" Foreground="#7F8C8D" 
                                                   FontWeight="SemiBold" Margin="0,0,0,8"/>
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                            <TextBlock x:Name="min2" Text="0.00" FontSize="18" FontWeight="Bold" 
                                                       Foreground="#2C3E50"/>
                                            <TextBlock Text="秒" FontSize="12" Foreground="#7F8C8D" 
                                                       VerticalAlignment="Bottom" Margin="5,0,0,2"/>
                                        </StackPanel>
                                    </StackPanel>
                                </Border>

                                <!-- 初始压力 -->
                                <Border Grid.Column="2" Background="#F8F9FA" Margin="8" Padding="15,12" 
                                        BorderBrush="#E1E8ED" BorderThickness="1">
                                    <StackPanel>
                                        <TextBlock Text="初始压力" FontSize="12" Foreground="#7F8C8D" 
                                                   FontWeight="SemiBold" Margin="0,0,0,8"/>
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                            <TextBlock x:Name="min3" Text="0.00" FontSize="18" FontWeight="Bold" 
                                                       Foreground="#2C3E50"/>
                                            <TextBlock Text="Pa" FontSize="12" Foreground="#7F8C8D" 
                                                       VerticalAlignment="Bottom" Margin="5,0,0,2"/>
                                        </StackPanel>
                                    </StackPanel>
                                </Border>
                            </Grid>

                            <!-- 第二行数据 -->
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>

                                <!-- 结束压力 -->
                                <Border Grid.Column="0" Background="#F8F9FA" Margin="8" Padding="15,12" 
                                        BorderBrush="#E1E8ED" BorderThickness="1">
                                    <StackPanel>
                                        <TextBlock Text="结束压力" FontSize="12" Foreground="#7F8C8D" 
                                                   FontWeight="SemiBold" Margin="0,0,0,8"/>
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                            <TextBlock x:Name="min4" Text="0.00" FontSize="18" FontWeight="Bold" 
                                                       Foreground="#2C3E50"/>
                                            <TextBlock Text="Pa" FontSize="12" Foreground="#7F8C8D" 
                                                       VerticalAlignment="Bottom" Margin="5,0,0,2"/>
                                        </StackPanel>
                                    </StackPanel>
                                </Border>

                                <!-- 压差 -->
                                <Border Grid.Column="1" Background="#F8F9FA" Margin="8" Padding="15,12" 
                                        BorderBrush="#E1E8ED" BorderThickness="1">
                                    <StackPanel>
                                        <TextBlock Text="压差" FontSize="12" Foreground="#7F8C8D" 
                                                   FontWeight="SemiBold" Margin="0,0,0,8"/>
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                            <TextBlock x:Name="min5" Text="0.00" FontSize="18" FontWeight="Bold" 
                                                       Foreground="#2C3E50"/>
                                            <TextBlock Text="Pa" FontSize="12" Foreground="#7F8C8D" 
                                                       VerticalAlignment="Bottom" Margin="5,0,0,2"/>
                                        </StackPanel>
                                    </StackPanel>
                                </Border>

                                <!-- 状态指示 -->
                                <Border Grid.Column="2" Background="#F8F9FA" Margin="8" Padding="15,12" 
                                        BorderBrush="#E1E8ED" BorderThickness="1">
                                    <!--<StackPanel>
                                        <TextBlock Text="检验状态" FontSize="12" Foreground="#7F8C8D" 
                                                   FontWeight="SemiBold" Margin="0,0,0,8"/>
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                            <TextBlock Text="正常" FontSize="18" FontWeight="Bold" 
                                                       Foreground="#27AE60"/>
                                        </StackPanel>
                                    </StackPanel>-->
                                </Border>
                            </Grid>
                        </StackPanel>
                    </Border>
                </Grid>

                <!-- 右侧：操作控制区 -->
                <StackPanel Grid.Column="1">
                    <!-- 数据管理 -->
                    <Border Background="White" Margin="0,0,0,15" BorderBrush="#E1E8ED" BorderThickness="1">
                        <StackPanel Margin="15,15">
                            <TextBlock Text="💾 数据管理" FontSize="15" FontWeight="Bold" Foreground="#2C3E50" 
                                       HorizontalAlignment="Center" Margin="0,0,0,15"/>
                            <Button Content="📝 记录数据" Click="Button_Click" 
                                    Background="#3498DB" Foreground="White" FontSize="13" FontWeight="Bold"
                                    Height="42" BorderThickness="0" Cursor="Hand"/>
                        </StackPanel>
                    </Border>

                    <!-- 测试控制 -->
                    <Border Background="White" BorderBrush="#E1E8ED" BorderThickness="1">
                        <StackPanel Margin="15,15">
                            <TextBlock Text="🎛️ 测试控制" FontSize="15" FontWeight="Bold" Foreground="#2C3E50" 
                                       HorizontalAlignment="Center" Margin="0,0,0,15"/>

                            <Button Content="🚀 启动测试" Click="Button_Click_1" 
                                    Background="#27AE60" Foreground="White" FontSize="13" FontWeight="Bold"
                                    Height="42" BorderThickness="0" Margin="0,0,0,10" Cursor="Hand"/>

                            <Button Content="🛑 停止测试" Click="Button_Click_2" 
                                    Background="#E74C3C" Foreground="White" FontSize="13" FontWeight="Bold"
                                    Height="42" BorderThickness="0" Margin="0,0,0,10" Cursor="Hand"/>

                            <Button Content="⏱️ 开始计时" Click="Button_Click_3" 
                                    Background="#3498DB" Foreground="White" FontSize="12" FontWeight="Bold"
                                    Height="38" BorderThickness="0" Cursor="Hand"/>
                        </StackPanel>
                    </Border>
                </StackPanel>
            </Grid>

            <!-- 底部导航 -->
            <Border Grid.Row="2" Background="White" BorderBrush="#E1E8ED" BorderThickness="1,0,0,0">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="10,8">
                    <Button Content="定量供应检验" Click="Button_Click_4"
                            Background="White" Foreground="#2C3E50" FontSize="11" FontWeight="Bold"
                            Width="120" Height="35" BorderBrush="#3498DB" BorderThickness="1" Margin="5,3"
                            Cursor="Hand"/>

                    <Button Content="负压气密性检验" 
                            Background="#3498DB" Foreground="White" FontSize="11" FontWeight="Bold"
                            Width="120" Height="35" BorderThickness="0" Margin="5,3" Cursor="Hand"/>

                    <Button Content="正压气密性检验" Click="Button_Click_6"
                            Background="White" Foreground="#2C3E50" FontSize="11" FontWeight="Bold"
                            Width="120" Height="35" BorderBrush="#3498DB" BorderThickness="1" Margin="5,3"
                            Cursor="Hand"/>

                    <Button Content="排气阀压力测试" Click="Button_Click_7"
                            Background="White" Foreground="#2C3E50" FontSize="11" FontWeight="Bold"
                            Width="120" Height="35" BorderBrush="#3498DB" BorderThickness="1" Margin="5,3"
                            Cursor="Hand"/>
                </StackPanel>
            </Border>
        </Grid>
    </Grid>
</Window>