<Window x:Class="ShanghaiEnvironmentalTechnology.Window4"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="{DynamicResource setFlow2}" WindowState="Maximized"   Height="768" Width="1024"
        Loaded="Window_Loaded" 
        WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <!-- 原有样式保持不变 -->
        <Style x:Key="MyButtonStyle" TargetType="Button">
            <Setter Property="Background" Value="#4A90E2"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="FontSize" Value="16"/>
            <Setter Property="Margin" Value="10"/>
            <Setter Property="Padding" Value="10,5"/>
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Cursor" Value="Hand"/>
            <Setter Property="Height" Value="40"/>
            <Setter Property="Width" Value="180"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Border Background="{TemplateBinding Background}" CornerRadius="20">
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#3A7BBE"/>
                </Trigger>
                <Trigger Property="IsPressed" Value="True">
                    <Setter Property="Background" Value="#2A5E9A"/>
                </Trigger>
            </Style.Triggers>
        </Style>

        <Style x:Key="MyTextBoxStyle" TargetType="TextBox">
            <Setter Property="Background" Value="#FFFFFF"/>
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="BorderBrush" Value="#4A90E2"/>
            <Setter Property="BorderThickness" Value="2"/>
            <Setter Property="Padding" Value="10,10"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="Height" Value="50"/>
            <Setter Property="Width" Value="120"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="TextBox">
                        <Border Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                CornerRadius="20">
                            <ScrollViewer x:Name="PART_ContentHost"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="MyComboBoxStyle" TargetType="ComboBox">
            <Setter Property="Background" Value="#FFFFFF"/>
            <Setter Property="Foreground" Value="Black"/>
            <Setter Property="BorderBrush" Value="#4A90E2"/>
            <Setter Property="BorderThickness" Value="2"/>
            <Setter Property="FontSize" Value="16"/>
            <Setter Property="Height" Value="40"/>
            <Setter Property="Width" Value="150"/>
            <Setter Property="Margin" Value="10"/>
            <Setter Property="Padding" Value="5"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ComboBox">
                        <Border Background="{TemplateBinding Background}" 
                                BorderBrush="{TemplateBinding BorderBrush}" 
                                BorderThickness="{TemplateBinding BorderThickness}" 
                                CornerRadius="5">
                            <Grid>
                                <ToggleButton IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                              Focusable="False"
                                              ClickMode="Press">
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="20"/>
                                        </Grid.ColumnDefinitions>
                                        <ContentPresenter HorizontalAlignment="Left" 
                                                          VerticalAlignment="Center" 
                                                          Margin="5,0,0,0"
                                                          Content="{TemplateBinding SelectionBoxItem}"
                                                          ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
                                                          ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"/>
                                        <Path Grid.Column="1"
                                              HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              Data="M 0 0 L 4 4 L 8 0 Z"
                                              Fill="Black"/>
                                    </Grid>
                                </ToggleButton>
                                <Popup IsOpen="{TemplateBinding IsDropDownOpen}"
                                       Placement="Bottom"
                                       AllowsTransparency="True"
                                       Focusable="False"
                                       PopupAnimation="Slide">
                                    <Grid MinWidth="{TemplateBinding ActualWidth}"
                                          MaxHeight="{TemplateBinding MaxDropDownHeight}">
                                        <Border Background="White"
                                                BorderBrush="#4A90E2"
                                                BorderThickness="2"
                                                CornerRadius="5"/>
                                        <ScrollViewer Margin="1">
                                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                        </ScrollViewer>
                                    </Grid>
                                </Popup>
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>


    <ScrollViewer VerticalScrollBarVisibility="Auto" Margin="0">
        <Grid Margin="20">
            <StackPanel>

                <TextBlock Text="{DynamicResource setFlow}" 
                           FontSize="24" 
                           FontWeight="Bold" 
                           HorizontalAlignment="Center" 
                           Margin="0,0,0,10"/>


                <ComboBox x:Name="CaptureModeComboBox" 
                          Style="{StaticResource MyComboBoxStyle}" 
                          HorizontalAlignment="Center" 
                          SelectionChanged="CaptureModeComboBox_SelectionChanged"
                          Margin="0,0,0,10">
                    <ComboBoxItem  Content="{DynamicResource setFlow111}" IsEnabled="False"/>
                    <ComboBoxItem Content="{DynamicResource setFlow1}" IsSelected="True"/>
                    <ComboBoxItem Content="{DynamicResource setFlow11}"/>
                </ComboBox>

                <TextBlock Text="{DynamicResource setFlow2}" 
                           FontSize="24" 
                           FontWeight="Bold" 
                           HorizontalAlignment="Center" 
                           Margin="0,10,0,10"/>





                <Grid Margin="10" HorizontalAlignment="Center" MinWidth="400" Width="728">

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="203"/>
                        <!-- 标签列 -->
                        <ColumnDefinition Width="142"/>

                        <ColumnDefinition/>
                        <!-- 按钮列 -->
                    </Grid.ColumnDefinitions>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" MinHeight="35"/>

                        <RowDefinition Height="Auto" MinHeight="35"/>
                        <RowDefinition Height="Auto" MinHeight="35"/>
                        <RowDefinition Height="Auto" MinHeight="35"/>
                    </Grid.RowDefinitions>

                    <!-- 设置流量行 -->
                    <TextBlock Text="{DynamicResource setFlow3}" 
               VerticalAlignment="Center" 
               FontWeight="Bold"
               FontSize="16"
               Margin="0,0,1,0" Height="20"/>

                    <StackPanel Grid.Column="1" 
                Orientation="Horizontal" 
                VerticalAlignment="Center"
                Margin="0,0,196,0" Grid.ColumnSpan="2" Height="50">

                        <TextBox Name="clostTxt" 
                 Style="{StaticResource MyTextBoxStyle}" 
                 IsReadOnly="True"
                 PreviewTextInput="ClostTxt_PreviewTextInput"
                 Width="80"/>

                        <TextBlock Text="L/min" 
                   VerticalAlignment="Center" 
                   Margin="10,0,0,0"
                   MinWidth="50"/>

                    </StackPanel>

                    <Button Name="btnsetting" Grid.Row="0" Grid.Column="2" 
            Content="{DynamicResource setFlow4}" 
            Style="{StaticResource MyButtonStyle}" 
            Click="Button_Click"
            Margin="42,10,161,10"/>

                    <!-- 鼻口压力行 -->
                    <TextBlock Grid.Row="1" Text="{DynamicResource setFlow5}" 
               VerticalAlignment="Center" 
               FontWeight="Bold" 
               FontSize="16"
               Margin="0,0,15,0" Height="20"/>

                    <StackPanel Grid.Row="1" Grid.Column="1" 
                Orientation="Horizontal" 
                VerticalAlignment="Center"
                Margin="0,0,196,0" Grid.ColumnSpan="2" Height="50">
                        <TextBox Name="NoseTxt" 
                 Style="{StaticResource MyTextBoxStyle}" 
                 Text="???" 
                 IsEnabled="False"
                 Width="80"/>
                        <TextBlock Text="pa" 
                   VerticalAlignment="Center" 
                   Margin="10,0,0,0"
                   MinWidth="50"/>
                    </StackPanel>

                    <Button Name="btnsetting2" Grid.Row="1" Grid.Column="2" 
            Content="{DynamicResource setFlow6}" 
            Style="{StaticResource MyButtonStyle}" 
            Click="Button_Click_1"
            Margin="42,10,161,10"/>

                    <!-- 呼流量行 -->
                    <TextBlock Grid.Row="2" Text="{DynamicResource setFlow7}" 
               VerticalAlignment="Center" 
               FontWeight="Bold" 
               FontSize="16"
               Margin="0,0,15,0" Height="20"/>

                    <StackPanel Grid.Row="2" Grid.Column="1" 
                Orientation="Horizontal" 
                VerticalAlignment="Center"
                Margin="0,0,196,0" Grid.ColumnSpan="2" Height="50">
                        <TextBox Name="outTxt" 
                 Style="{StaticResource MyTextBoxStyle}" 
                 Text="???"  
                 IsEnabled="False"
                 Width="80"/>
                        <TextBlock Text="L/min" 
                   VerticalAlignment="Center" 
                   Margin="10,0,0,0"
                   MinWidth="50"/>
                    </StackPanel>

                    <Button Grid.Row="2" Grid.Column="2" 
            Content="{DynamicResource setFlow8}" 
            Style="{StaticResource MyButtonStyle}" 
            Click="Button_Click_5"
                            Width="300"
            Margin="32,10,32,10"/>

                    <!-- 吸流量行 -->
                    <TextBlock Grid.Row="3" Text="{DynamicResource setFlow9}" 
               VerticalAlignment="Center" 
               FontWeight="Bold" 
               FontSize="16"
               Margin="0,0,15,0" Height="20"/>

                    <StackPanel Grid.Row="3" Grid.Column="1" 
                Orientation="Horizontal" 
                VerticalAlignment="Center"
                Margin="0,0,196,0" Grid.ColumnSpan="2" Height="50">
                        <TextBox Name="InTxt" 
                 Style="{StaticResource MyTextBoxStyle}" 
                 Text="???" 
                 IsEnabled="False"
                 Width="80"/>
                        <TextBlock Text="L/min" 
                   VerticalAlignment="Center" 
                   Margin="10,0,0,0"
                   MinWidth="50"/>
                    </StackPanel>

                    <Button Grid.Row="3" Grid.Column="2" 
            Content="{DynamicResource setFlow10}" 
            Style="{StaticResource MyButtonStyle}" 
            Click="Button_Click_6"
                            Width="NaN"
            Margin="42,10,42,10"/>
                </Grid>





                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10">
                    <TextBlock Text="{DynamicResource setFlow112}"  VerticalAlignment="Center" FontWeight="Bold" FontSize="16" Margin="20 0 50 0"/>
                    <TextBox Name="saveFlowOutTxt" Style="{StaticResource MyTextBoxStyle}" Text="???" Width="120" IsEnabled="False"/>
                    <TextBlock Text="pa" VerticalAlignment="Center" Margin="10,0,0,0"/>
                    <TextBlock Text="{DynamicResource setFlow12}"  VerticalAlignment="Center" FontWeight="Bold" FontSize="16" Margin="20 0 50 0"/>
                    <TextBox Name="saveFlowInTxt"  Style="{StaticResource MyTextBoxStyle}" Text="???" Width="120" IsEnabled="False"/>
                    <TextBlock Text="pa" VerticalAlignment="Center" Margin="10,0,0,0"/>
                </StackPanel>

                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10">
                    <!-- 减少边距（原20→10） -->
                    <Button Content="{DynamicResource Deformation}" Style="{StaticResource MyButtonStyle}" Click="Button_Click_2"/>
                    <Button Name="TestStartButton"  Content="{DynamicResource Maximumforcevaluetestresult(N)}" Style="{StaticResource MyButtonStyle}" Click="Button_Click_4"/>
                    <Button Content="{DynamicResource Deformation test results}" Style="{StaticResource MyButtonStyle}" Click="Button_Click_3"/>
                    <Button Content="{DynamicResource ViewReport}" Style="{StaticResource MyButtonStyle}" Click="Button_Click_7" Width="201"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,10,0,20">
                    <!-- 增加底部边距，避免被窗口边缘遮挡 -->
                    <!--<Button Content="记录呼气阻力" Style="{StaticResource MyButtonStyle}" Click="Button_Click_5"/>
                    <Button Content="记录吸气阻力" Style="{StaticResource MyButtonStyle}" Click="Button_Click_5"/>-->
                </StackPanel>
            </StackPanel>
        </Grid>
    </ScrollViewer>
</Window>