<Window x:Class="MainShell.Common.View.CameraSettingsView"
             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:local="clr-namespace:MainShell.Common.View"
             xmlns:custom="clr-namespace:MainShell.Resources.CustomControl" xmlns:mw="http://www.maxwell-gp.com/"
             mc:Ignorable="d" 
             Title="相机设置"
             Width="450" SizeToContent="Height"
             WindowStartupLocation="CenterScreen"
             ResizeMode="NoResize"
             WindowStyle="ToolWindow"
             d:DesignHeight="300" d:DesignWidth="350">
    <StackPanel Margin="5">
        <!-- 相机参数设置 -->
        <GroupBox Header="{DynamicResource CameraPar}" Margin="0,0,0,5" Style="{StaticResource GroupBoxSecondary}">
            <Grid Margin="5">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <!-- 曝光时间 -->
                <TextBlock Grid.Row="0" Grid.Column="0"  Text="曝光时间:" VerticalAlignment="Center" Style="{StaticResource LabelStyle}"/>
                <mw:IntNumberBox Grid.Row="0" Grid.Column="1" 
                             Value="{Binding CameraConfig.ExposureTime}" 
                             Minimum="10" Maximum="1000000"
                             mw:NumericKeypadAttach.IsEnabled="True"
                             HorizontalContentAlignment="Right" Margin="5,2,0,2"/>

                <!-- 增益 -->
                <TextBlock Grid.Row="1" Grid.Column="0" Text="增益:" VerticalAlignment="Center" Style="{StaticResource LabelStyle}"/>
                <mw:IntNumberBox Grid.Row="1" Grid.Column="1" 
                             Value="{Binding CameraConfig.Gain}" 
                             Minimum="1" Maximum="100"
                             mw:NumericKeypadAttach.IsEnabled="True"
                             HorizontalContentAlignment="Right" Margin="5,2,0,2"/>
            </Grid>
        </GroupBox>

        <!-- 光源参数设置 -->
        <!-- 使用 ItemsControl 动态生成 LightControl，需要 ViewModel 提供光源通道列表 -->
        <GroupBox Header="{DynamicResource LightSetting}" Style="{StaticResource GroupBoxSecondary}">
            <ItemsControl ItemsSource="{Binding LightChannels}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <custom:LightControl Header="{Binding Name}" 
                                         Value="{Binding Value, Mode=TwoWay}" 
                                         Min="0" Max="255" Margin="0,2"/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </GroupBox>
        <StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
            <Button Content="{DynamicResource GetParameter}" Style="{StaticResource TeachButtonStyle}" Margin="5" IsDefault="True" Command="{Binding ReadFromHardwareCommand}"/>
        </StackPanel>
    </StackPanel>
</Window>
