<Window x:Class="自救器呼吸器综合检验仪.ParameterSettingsWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="参数设置" Height="730" Width="1024"
        WindowStartupLocation="CenterScreen"
        ResizeMode="NoResize" Loaded="Window_Loaded" Closed="Window_Closed" Closing="Window_Closing">

    <Window.Resources>
        <Style x:Key="GroupBoxStyle" TargetType="GroupBox">
            <Setter Property="BorderBrush" Value="#2E75B6"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Foreground" Value="#2E75B6"/>
            <Setter Property="FontWeight" Value="Bold"/>
            <Setter Property="FontSize" Value="11"/>
            <Setter Property="Margin" Value="3"/>
            <Setter Property="Padding" Value="8,5"/>
        </Style>

        <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>

        <Style x:Key="ButtonStyle" TargetType="Button">
            <Setter Property="FontSize" Value="11"/>
            <Setter Property="Width" Value="60"/>
            <Setter Property="Height" Value="25"/>
            <Setter Property="Margin" Value="5,3"/>
            <Setter Property="Background" Value="#2E75B6"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="BorderThickness" Value="0"/>
        </Style>

        <Style x:Key="TimeLabelStyle" TargetType="TextBlock" BasedOn="{StaticResource LabelStyle}">
            <Setter Property="Width" Value="18"/>
            <Setter Property="TextAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
        </Style>

        <Style x:Key="TimeTextBoxStyle" TargetType="TextBox" BasedOn="{StaticResource TextBoxStyle}">
            <Setter Property="Width" Value="35"/>
        </Style>
    </Window.Resources>

    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <!-- 标题 -->
        <Border Grid.Row="0" Background="#2E75B6" Padding="8" Margin="0,0,0,8">
            <TextBlock Text="参数设置" 
                      FontSize="14" 
                      FontWeight="Bold" 
                      Foreground="White" 
                      HorizontalAlignment="Center"/>
        </Border>

        <!-- 参数设置内容 - 使用Grid均匀分布 -->
        <Grid Grid.Row="1" Margin="0,5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>

            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="135*"/>
                <ColumnDefinition Width="13*"/>
                <ColumnDefinition Width="354*"/>
                <ColumnDefinition Width="502*"/>
            </Grid.ColumnDefinitions>
            <!--<TextBlock  Name="l1" Text="" Style="{StaticResource LabelStyle}" Margin="152,-14,0,0" Grid.Column="2" VerticalAlignment="Top"/>
            <TextBlock  Name="l2" Text="" Style="{StaticResource LabelStyle}" Margin="100,-14,0,0" Grid.ColumnSpan="3" VerticalAlignment="Top"/>-->
            <!-- 第一行：压差设置 -->
            <GroupBox Grid.Row="0" Grid.ColumnSpan="4" Header="压差设置" Style="{StaticResource GroupBoxStyle}" Margin="3,3,3,3">
                <Grid Margin="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <TextBox Name="t0" Width="0" Height="0"></TextBox>
                    <TextBlock Grid.Column="0" Text="压差系数：" Style="{StaticResource LabelStyle}"/>
                    <TextBox Grid.Column="1" Margin="-30 0 0 0" x:Name="txtPressureDiffCoefficient" Text="0.00" Style="{StaticResource TextBoxStyle}"   GotFocus="txtPressureDiffCoefficient_GotFocus" TouchDown="txtPressureDiffCoefficient_TouchDown" />
                    <Button Grid.Column="2" Content="校准" Style="{StaticResource ButtonStyle}" Margin="10,0,0,0" Click="Button_Click"/>

                    <TextBlock Grid.Column="3" Text="压差保护上限：" Style="{StaticResource LabelStyle}" Margin="20,0,0,0"/>
                    <TextBox Grid.Column="4" x:Name="txtUpperLimit" Text="0.0" Margin="-250,0,0,0" Style="{StaticResource TextBoxStyle}" GotFocus="txtUpperLimit_GotFocus"/>

                    <TextBlock Grid.Column="5" Text="压差保护下限：" Style="{StaticResource LabelStyle}" Margin="-240,0,0,0"/>
                    <TextBox Grid.Column="6" x:Name="txtLowerLimit" Text="0.0" Margin="-200,0,0,0" Style="{StaticResource TextBoxStyle}" GotFocus="txtLowerLimit_GotFocus"/>
                    <!--<Button Grid.Column="6" Content="设置" Style="{StaticResource ButtonStyle}" Margin="10,0,0,0"/>-->
                </Grid>
            </GroupBox>


            <!-- 第二行：流量保护设置 -->
            <GroupBox Grid.Row="1" Grid.ColumnSpan="4" Header="流量保护设置" Style="{StaticResource GroupBoxStyle}" Margin="3,3,3,3">
                <Grid Margin="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <TextBlock Grid.Column="0" Text="大流量计保护：" Style="{StaticResource LabelStyle}"/>
                    <TextBox Grid.Column="1" x:Name="txtLargeFlowCoefficient2" Margin="-105 0 0 0" Text="0.00" Style="{StaticResource TextBoxStyle}" GotFocus="txtLargeFlowCoefficient2_GotFocus"/>
                    <TextBlock Grid.Column="1" Text="L/min" Style="{StaticResource LabelStyle}" Margin="185,0,0,0"/>
                    <TextBlock Grid.Column="2" Text="小流量计保护：" Style="{StaticResource LabelStyle}" Margin="10,0,0,0"/>
                    <TextBox Grid.Column="3" x:Name="txtSmallFlowCoefficient2" Text="0.00" Style="{StaticResource TextBoxStyle}" Margin="10,0,0,0" GotFocus="txtSmallFlowCoefficient2_GotFocus"/>
                    <TextBlock Grid.Column="3" Text="L/min" Style="{StaticResource LabelStyle}" Margin="242,0,0,0"/>

                </Grid>
            </GroupBox>




            <!-- 第二行：流量系数设置 -->
            <GroupBox Grid.Row="2" Grid.ColumnSpan="4" Header="流量系数设置" Style="{StaticResource GroupBoxStyle}" Margin="3,3,3,3">
                <Grid Margin="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    <TextBlock Grid.Column="0" Text="大流量系数：" Style="{StaticResource LabelStyle}"/>
                    <TextBox Grid.Column="1" x:Name="txtLargeFlowCoefficient" Text="0.00" Style="{StaticResource TextBoxStyle}" Margin="-26 0 0 0" GotFocus="txtLargeFlowCoefficient_GotFocus"/>
                    <TextBlock Grid.Column="2" Text="小流量系数：" Style="{StaticResource LabelStyle}" Margin="80,0,0,0"/>
                    <TextBox Grid.Column="3" x:Name="txtSmallFlowCoefficient" Text="0.00" Style="{StaticResource TextBoxStyle}" Margin="90,0,0,0" GotFocus="txtSmallFlowCoefficient_GotFocus"/>
                    <Button Grid.Column="4" Content="校准" Style="{StaticResource ButtonStyle}" Margin="10,0,0,0" Click="Button_Click_1"/>
                </Grid>
            </GroupBox>

            <!-- 第三行：时间设置 -->
            <!--
            <GroupBox Grid.Row="3" Grid.ColumnSpan="4" Header="时间设置" Style="{StaticResource GroupBoxStyle}" Margin="3,3,3,3">
                <StackPanel Orientation="Horizontal" Margin="2" HorizontalAlignment="Center">
                    <TextBox x:Name="txtYear" Text="0" Style="{StaticResource TimeTextBoxStyle}"/>
                    <TextBlock Text="年" Style="{StaticResource TimeLabelStyle}"/>
                    <TextBox x:Name="txtMonth" Text="0" Style="{StaticResource TimeTextBoxStyle}"/>
                    <TextBlock Text="月" Style="{StaticResource TimeLabelStyle}"/>
                    <TextBox x:Name="txtDay" Text="0" Style="{StaticResource TimeTextBoxStyle}"/>
                    <TextBlock Text="日" Style="{StaticResource TimeLabelStyle}"/>
                    <TextBox x:Name="txtHour" Text="0" Style="{StaticResource TimeTextBoxStyle}"/>
                    <TextBlock Text="时" Style="{StaticResource TimeLabelStyle}"/>
                    <TextBox x:Name="txtMinute" Text="0" Style="{StaticResource TimeTextBoxStyle}"/>
                    <TextBlock Text="分" Style="{StaticResource TimeLabelStyle}"/>
                    <TextBox x:Name="txtSecond" Text="0" Style="{StaticResource TimeTextBoxStyle}"/>
                    <TextBlock Text="秒" Style="{StaticResource TimeLabelStyle}"/>
                </StackPanel>
            </GroupBox>-->

            <!-- 第四行：左侧 - 质量判定，右侧 - 误差设置 -->
            <GroupBox Grid.Row="4" Grid.Column="0" Header="质量判定" Style="{StaticResource GroupBoxStyle}" Grid.ColumnSpan="3" Margin="3,3,3,3">
                <StackPanel Margin="2">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="正负压大于50帕不合格：" Style="{StaticResource LabelStyle}"/>
                        <TextBox x:Name="txtQualityThreshold" Text="0.00" Style="{StaticResource TextBoxStyle}" GotFocus="txtQualityThreshold_GotFocus"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,3,0,0">
                        <TextBlock Text="排气判定时间：" Style="{StaticResource LabelStyle}"/>
                        <TextBox x:Name="txtExhaustTime" Margin="49,0,0,0" Text="0" Style="{StaticResource TextBoxStyle}" GotFocus="txtExhaustTime_GotFocus"/>
                        <TextBlock Text="ms" Style="{StaticResource LabelStyle}"/>
                    </StackPanel>
                </StackPanel>
            </GroupBox>

            <GroupBox Grid.Row="4" Grid.Column="3" Header="误差设置" Style="{StaticResource GroupBoxStyle}" Margin="3,3,3,3">
                <StackPanel Margin="2">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="正压自身误差：" Style="{StaticResource LabelStyle}"/>
                        <TextBox x:Name="txtPositiveError" Text="0" Style="{StaticResource TextBoxStyle}" GotFocus="txtPositiveError_GotFocus"/>
                        <TextBlock Text="pa" Style="{StaticResource LabelStyle}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,3,0,0">
                        <TextBlock Text="负压自身误差：" Style="{StaticResource LabelStyle}"/>
                        <TextBox x:Name="txtNegativeError" Text="0" Style="{StaticResource TextBoxStyle}" GotFocus="txtNegativeError_GotFocus"/>
                        <TextBlock Text="pa" Style="{StaticResource LabelStyle}"/>
                    </StackPanel>
                </StackPanel>
            </GroupBox>

            <!-- 第五行：左侧 - PID稳定时间，右侧 - 延迟记录 -->
            <GroupBox Grid.Row="5" Grid.Column="0" Header="PID稳定时间" Style="{StaticResource GroupBoxStyle}" Grid.ColumnSpan="3" Margin="3,3,3,3">
                <StackPanel Margin="2">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="正压PID稳定时间：" Style="{StaticResource LabelStyle}"/>
                        <TextBox x:Name="txtPositivePIDTime" Text="0" Style="{StaticResource TextBoxStyle}" GotFocus="txtPositivePIDTime_GotFocus"/>
                        <TextBlock Text="ms" Style="{StaticResource LabelStyle}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,3,0,0">
                        <TextBlock Text="负压PID稳定时间：" Style="{StaticResource LabelStyle}"/>
                        <TextBox x:Name="txtNegativePIDTime" Text="0" Style="{StaticResource TextBoxStyle}" GotFocus="txtNegativePIDTime_GotFocus"/>
                        <TextBlock Text="ms" Style="{StaticResource LabelStyle}"/>
                    </StackPanel>
                </StackPanel>
            </GroupBox>

            <GroupBox Grid.Row="5" Grid.Column="3" Header="延迟记录" Style="{StaticResource GroupBoxStyle}" Margin="3,3,3,3">
                <StackPanel Margin="2">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="正压延迟记录初始值：" Style="{StaticResource LabelStyle}"/>
                        <TextBox x:Name="txtPositiveDelay" Text="0" Style="{StaticResource TextBoxStyle}" GotFocus="txtPositiveDelay_GotFocus"/>
                        <TextBlock Text="ms" Style="{StaticResource LabelStyle}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" Margin="0,3,0,0">
                        <TextBlock Text="负压延迟记录初始值：" Style="{StaticResource LabelStyle}"/>
                        <TextBox x:Name="txtNegativeDelay" Text="0" Style="{StaticResource TextBoxStyle}" GotFocus="txtNegativeDelay_GotFocus"/>
                        <TextBlock Text="ms" Style="{StaticResource LabelStyle}"/>
                    </StackPanel>
                </StackPanel>
            </GroupBox>

            <!-- 第六行：PID稳定压力 -->
            <GroupBox Grid.Row="6" Grid.ColumnSpan="4" Header="PID稳定压力" Style="{StaticResource GroupBoxStyle}" Margin="3,3,3,3">
                <StackPanel Orientation="Horizontal" Margin="2" HorizontalAlignment="Center">
                    <TextBlock Text="正压增加PID稳定压力：" Style="{StaticResource LabelStyle}"/>
                    <TextBox x:Name="txtPositivePIDPressure" Text="0.00" Style="{StaticResource TextBoxStyle}" GotFocus="txtPositivePIDPressure_GotFocus"/>
                    <TextBlock Text="pa" Style="{StaticResource LabelStyle}"/>
                    <TextBlock Text="负压增加PID稳定压力：" Style="{StaticResource LabelStyle}" Margin="15,0,0,0"/>
                    <TextBox x:Name="txtNegativePIDPressure" Text="0.00" Style="{StaticResource TextBoxStyle}" GotFocus="txtNegativePIDPressure_GotFocus"/>
                    <TextBlock Text="pa" Style="{StaticResource LabelStyle}"/>
                </StackPanel>
            </GroupBox>

            <!--//第七行：压差流量显示-->
            <GroupBox Grid.Row="7" Grid.ColumnSpan="4" Header="压差/流量显示" Style="{StaticResource GroupBoxStyle}" Margin="3,3,3,3">
                <StackPanel Orientation="Horizontal" Margin="2" HorizontalAlignment="Center">
                    <TextBlock Text="压差显示：" Style="{StaticResource LabelStyle}"/>
                    <TextBox x:Name="pressureDiff" Text="0.00" Style="{StaticResource TextBoxStyle}" GotFocus="txtPositivePIDPressure_GotFocus"/>
                    <!--<TextBlock Text="pa" Style="{StaticResource LabelStyle}"/>-->
                    <TextBlock Text="流量显示：" Style="{StaticResource LabelStyle}" Margin="200,0,0,0"/>
                    <TextBox x:Name="flow" Text="0.00" Style="{StaticResource TextBoxStyle}" GotFocus="txtNegativePIDPressure_GotFocus"/>
                    <!--<TextBlock Text="pa" Style="{StaticResource LabelStyle}"/>-->
                </StackPanel>
            </GroupBox>

            <!--<GroupBox Grid.Row="8" Grid.ColumnSpan="4" Header="试样编号" Style="{StaticResource GroupBoxStyle}" Margin="3,3,3,3">
                <StackPanel Orientation="Horizontal" Margin="2" HorizontalAlignment="Center">
                    <TextBlock Text="编号：" Style="{StaticResource LabelStyle}"/>
                    <TextBox x:Name="pressureDiff2" Text="" Width="180" Style="{StaticResource TextBoxStyle}" LostFocus="pressureDiff2_GotFocus"/>

                </StackPanel>
            </GroupBox>-->
            <!-- 第八行：语音设置 --><!--
            <GroupBox Grid.Row="8" Grid.ColumnSpan="4" Header="语音设置" Style="{StaticResource GroupBoxStyle}" Margin="3,3,3,3">
                <Grid Margin="2">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>

                    --><!--<TextBlock Grid.Column="0" Text="大流量系数：" Style="{StaticResource LabelStyle}"/>
        <TextBox Grid.Column="1" x:Name="sound" Text="0.00" Style="{StaticResource TextBoxStyle}" Margin="-26 0 0 0" GotFocus="txtLargeFlowCoefficient_GotFocus"/>--><!--
                    <Button Grid.Column="1" Content="关闭音量" Name="closesound"  Style="{StaticResource ButtonStyle}" Margin="-400,0,0,0" Click="Button_Click_2"/>

                    <TextBlock Grid.Column="2" Text="设置音量：" Style="{StaticResource LabelStyle}" Margin="-100,0,90,0"/>
                    <TextBox Grid.Column="3" x:Name="setsound" Text="0" Style="{StaticResource TextBoxStyle}" Margin="-60,0,160,0" GotFocus="setsound_GotFocus"/>
                    <Button Grid.Column="4" Content="确认音量" Name="soundsure"  Style="{StaticResource ButtonStyle}" Margin="-250,0,0,0" Click="Button_Click_3"/>


                </Grid>
            </GroupBox>-->
        </Grid>
        

        <!-- 底部按钮 -->
        <Border Grid.Row="2" Background="#F5F5F5" Padding="8" Margin="0,8,0,0">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <!--<Button Content="保存" Style="{StaticResource ButtonStyle}" Click="SaveButton_Click"/>-->
                <!--<Button Content="重置" Style="{StaticResource ButtonStyle}" Click="ResetButton_Click" Background="#6C757D" Margin="15,0,0,0"/>-->
                <Button Content="返回" Style="{StaticResource ButtonStyle}" Click="ReturnButton_Click" Background="#DC3545" Margin="15,0,0,0"/>
            </StackPanel>
        </Border>
    </Grid>
</Window>