<UserControl x:Class="XP.Hardware.Detector.Views.DetectorConfigView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:prism="http://prismlibrary.com/"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:loc="clr-namespace:XP.Common.Localization.Extensions;assembly=XP.Common"
             mc:Ignorable="d"
             d:DesignWidth="420" d:DesignHeight="210"
             prism:ViewModelLocator.AutoWireViewModel="True"
             Background="White">

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

        <!-- 第1行：灵敏度 + 帧率 | Row 1: Sensitivity (PGA) + Frame rate -->
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="20"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Column="0" Text="{loc:Localization Detector_SensitivityLabel}"
                       FontSize="12" Foreground="#616161" VerticalAlignment="Center" Width="60"/>
            <telerik:RadComboBox Grid.Column="1"
                                 ItemsSource="{Binding PgaItems}"
                                 SelectedItem="{Binding SelectedPga, Mode=TwoWay}"
                                 Height="26" HorizontalAlignment="Stretch"
                                 telerik:StyleManager.Theme="Crystal"/>

            <TextBlock Grid.Column="3" Text="{loc:Localization Detector_FrameRateLabel}"
                       FontSize="12" Foreground="#616161" VerticalAlignment="Center" Width="60"/>
            <telerik:RadNumericUpDown Grid.Column="4"
                                      Value="{Binding FrameRate, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
                                      Minimum="{Binding FrameRateMinimum}"
                                      Maximum="{Binding FrameRateMaximum}"
                                      NumberDecimalDigits="2"
                                      SmallChange="0.1"
                                      Height="26" HorizontalAlignment="Stretch"
                                      telerik:StyleManager.Theme="Crystal"/>
        </Grid>

        <!-- 第2行：像素合并 + 帧合并 | Row 2: Binning + Average frames -->
        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="20"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <TextBlock Grid.Column="0" Text="{loc:Localization Detector_BinningLabel}"
                       FontSize="12" Foreground="#616161" VerticalAlignment="Center" Width="60"/>
            <telerik:RadComboBox Grid.Column="1"
                                 ItemsSource="{Binding BinningItems}"
                                 DisplayMemberPath="DisplayName"
                                 SelectedIndex="{Binding SelectedBinningIndex, Mode=TwoWay}"
                                 Height="26" HorizontalAlignment="Stretch"
                                 telerik:StyleManager.Theme="Crystal"/>

            <TextBlock Grid.Column="3" Text="{loc:Localization Detector_AvgFramesLabel}"
                       FontSize="12" Foreground="#616161" VerticalAlignment="Center" Width="60"/>
            <telerik:RadNumericUpDown Grid.Column="4"
                                      Value="{Binding AvgFrames, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
                                      Minimum="1"
                                      Maximum="100"
                                      NumberDecimalDigits="0"
                                      SmallChange="1"
                                      Height="26" HorizontalAlignment="Stretch"
                                      telerik:StyleManager.Theme="Crystal"/>
        </Grid>

        <!-- 第3行：应用参数按钮（右对齐占一半）| Row 3: Apply parameters button (right-aligned, half width) -->
        <Grid Grid.Row="4">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <telerik:RadButton Grid.Column="1"
                               Content="{loc:Localization Detector_ApplyParametersButton}"
                               Command="{Binding ApplyParametersCommand}"
                               Height="32" HorizontalAlignment="Stretch"
                               telerik:StyleManager.Theme="Crystal" Margin="4 0 0 0"/>
        </Grid>

        <!-- 第4行：分隔线 | Row 4: Separator -->
        <Separator Grid.Row="6" Margin="0 0 0 0"/>

        <!-- 第5行：暗场校正 + 亮场校正按钮 | Row 5: Dark + Light correction buttons -->
        <Grid Grid.Row="8">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <!-- 暗场校正 | Dark correction -->
            <telerik:RadButton Grid.Column="0"
                               Content="{loc:Localization Detector_DarkCorrectionButton}"
                               Command="{Binding DarkCorrectionCommand}"
                               Height="32" Margin="0 0 4 0" HorizontalAlignment="Stretch"
                               telerik:StyleManager.Theme="Crystal">
                <telerik:RadButton.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="White"/>
                        <GradientStop Color="#FF62B8E0" Offset="1"/>
                    </LinearGradientBrush>
                </telerik:RadButton.Background>
            </telerik:RadButton>

            <!-- 亮场校正 | Light correction -->
            <telerik:RadButton Grid.Column="1"
                               Content="{loc:Localization Detector_LightCorrectionButton}"
                               Command="{Binding LightCorrectionCommand}"
                               Height="32" Margin="4 0 0 0" HorizontalAlignment="Stretch"
                               telerik:StyleManager.Theme="Crystal">
                <telerik:RadButton.Background>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                        <GradientStop Color="White"/>
                        <GradientStop Color="#FF77E062" Offset="1"/>
                    </LinearGradientBrush>
                </telerik:RadButton.Background>
            </telerik:RadButton>
        </Grid>
    </Grid>
</UserControl>
