<Window x:Class="自救器呼吸器综合检验仪.MainWindow4"
        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>

    <!-- 背景层 -->
    <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 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="*"/>
                    </Grid.RowDefinitions>

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

                            <!-- 压力设置行 -->
                            <Grid Margin="0,0,0,25">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>

                                <!-- 当前压力设置 -->
                                <Border Grid.Column="0" Background="#F8F9FA" Margin="10" Padding="20,15" 
                                        BorderBrush="#E1E8ED" BorderThickness="1">
                                    <StackPanel>
                                        <TextBlock Text="当前压力" FontSize="13" Foreground="#7F8C8D" 
                                                   FontWeight="SemiBold" Margin="0,0,0,10"/>
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,12">
                                            <TextBlock x:Name="settingtime" Text="0.00" FontSize="20" FontWeight="Bold" 
                                                       Foreground="#2C3E50" VerticalAlignment="Center"/>
                                            <TextBlock Text="Pa" FontSize="13" Foreground="#7F8C8D" 
                                                       VerticalAlignment="Center" Margin="8,0,15,0"/>
                                        </StackPanel>
                                        <!--<Button Content="设置压力" Click="BtnWrite401_Click" 
                                                Background="#3498DB" Foreground="White" FontSize="12" FontWeight="Bold"
                                                Width="100" Height="32" BorderThickness="0" Cursor="Hand"/>-->
                                    </StackPanel>
                                </Border>

                                <!-- 开启压力设置 -->
                                <Border Grid.Column="1" Background="#F8F9FA" Margin="10" Padding="20,15" 
                                        BorderBrush="#E1E8ED" BorderThickness="1">
                                    <StackPanel>
                                        <TextBlock Text="开启压力" FontSize="13" Foreground="#7F8C8D" 
                                                   FontWeight="SemiBold" Margin="0,0,0,10"/>
                                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,12">
                                            <TextBlock x:Name="settingtime2" Text="0.00" FontSize="20" FontWeight="Bold" 
                                                       Foreground="#2C3E50" VerticalAlignment="Center"/>
                                            <TextBlock Text="Pa" FontSize="13" Foreground="#7F8C8D" 
                                                       VerticalAlignment="Center" Margin="8,0,15,0"/>
                                        </StackPanel>
                                        <!--<Button Content="设置压力" Click="BtnWrite402_Click" 
                                                Background="#3498DB" Foreground="White" FontSize="12" FontWeight="Bold"
                                                Width="100" Height="32" BorderThickness="0" Cursor="Hand"/>-->
                                    </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 Text="待机" FontSize="16" FontWeight="Bold" 
                                                       Foreground="#3498DB"/>
                                        </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 Text="正常" FontSize="16" 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"/>
                        </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="负压气密性检验" Click="Button_Click_5"
                            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_6"
                            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"/>
                </StackPanel>
            </Border>
        </Grid>
    </Grid>
</Window>