<Page x:Class="CCDCountWpf.WpfPage.SettingPage"
      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:CCDCountWpf.WpfPage"
      mc:Ignorable="d" 
      d:DesignHeight="550" d:DesignWidth="800"
      Title="SettingPage" Loaded="Page_Loaded">

    <Grid>
        <Grid Margin="0,0,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="330"/>
            </Grid.ColumnDefinitions>
            <Border Grid.Column="0" BorderBrush="Black" BorderThickness="1" Margin="2,2,2,2">
                <Image x:Name="ShowBox"  Source="{Binding DebugImage}" Margin="0,0,0,0"/>
            </Border>

            <Grid Grid.Column="1"  Margin="2,2,2,2">
                <Border BorderBrush="Black" BorderThickness="1"/>
                <Grid x:Name="SettingGrid" Margin="0,0,0,0">
                    <Grid x:Name ="BtnList" Height="40" VerticalAlignment="Top">
                        <Button x:Name="CameraSettingBtn" Content="相机参数设置" HorizontalAlignment="Left" Margin="0,0,0,0" Width="165" Background="{x:Null}" Click="CameraSettingBtn_Click"/>
                        <Button x:Name="ShuLiSettingBtn" Content="数粒参数设置" HorizontalAlignment="Left" Margin="165,0,0,0" Width="165" Background="{x:Null}" Click="ShuLiSettingBtn_Click"/>
                    </Grid>
                    <Grid x:Name="CameraSettingGrid" Margin="0,40,0,0" Visibility="Collapsed">
                        <Label x:Name="CameraSelectLab"  Content="选择相机：" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0" FontSize="15" Height="30" Width="85"/>
                        <ComboBox x:Name="CamSelectConBox" ItemsSource="{Binding CameraItems}" DisplayMemberPath="Name" SelectedValuePath="SNValue" Background="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="105,10,0,0" Height="30" Width="180" FontSize="12" HorizontalContentAlignment="Center" Padding="6,6,5,3" SelectionChanged="CamSelectConBox_SelectionChanged" />
                        <Button x:Name="CamListFlushBtn" HorizontalAlignment="Right" VerticalAlignment="Top" Width="30" Height="30" Margin="0,10,5,0" Background="#FF1709AF" Click="CamListFlushBtn_Click">
                            <Button.Template>
                                <ControlTemplate TargetType="Button">
                                    <Border CornerRadius="5" 
                                            Background="{TemplateBinding Background}"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="{TemplateBinding BorderThickness}">
                                        <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
                                    </Border>
                                </ControlTemplate>
                            </Button.Template>
                            <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
                                <Image  Source="/FromImage/刷新.png" Width="25" Height="25" />
                            </StackPanel>
                        </Button>
                        <StackPanel Orientation="Horizontal" Margin="0,50,0,0" VerticalAlignment="Top">
                            <StackPanel x:Name="CameraParameLab" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0">
                                <Label x:Name="ExposureTimeLab" Content="曝光：" Width="85" Height="30" FontSize="15" />
                                <Label x:Name="AcquistionLineRateLab" Content="行频：" Width="85" Height="30" FontSize="15" Margin="0,10,0,0" />
                                <Label x:Name="ImageWidthLab" Content="图像宽：" Width="85" Height="30" FontSize="15" Margin="0,10,0,0" />
                                <Label x:Name="CamUserNameLab" Content="用户设定名：" Width="85" Height="30" FontSize="15" Margin="0,10,0,0" />
                                <Label x:Name="CamOffsetXLab" Content="视野偏移：" Width="85" Height="30" FontSize="15" Margin="0,10,0,0" />
                            </StackPanel>
                            <StackPanel x:Name="CameraParameTbx" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,10,0,0">
                                <TextBox x:Name="ExposureTimeTbx" Width="100" Text="{Binding ExposureTimeValue,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Height="30" FontSize="15" KeyDown="TextBox_KeyDown" />
                                <TextBox x:Name="AcquistionLineRateTbx" Text="{Binding AcquistionLineRate,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Width="100" Height="30" FontSize="15" Margin="0,10,0,0" KeyDown="TextBox_KeyDown" />
                                <TextBox x:Name="ImageWidthTbx" Text="{Binding ImageWidth,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Width="100" Height="30" FontSize="15" Margin="0,10,0,0" KeyDown="TextBox_KeyDown" />
                                <TextBox x:Name="CamUserNameTbx" Text="{Binding CamUserName,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Width="100" Height="30" FontSize="15" Margin="0,10,0,0" KeyDown="TextBox_KeyDown" />
                                <TextBox x:Name="CamOffsetXTbx" Text="{Binding CamOffsetX,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Width="100" Height="30" FontSize="15" Margin="0,10,0,0" KeyDown="TextBox_KeyDown" />
                            </StackPanel>
                        </StackPanel>
                    </Grid>
                    <Grid x:Name="ShuLiSettingGrid" Margin="0,40,0,0" Visibility="Visible">
                        <StackPanel Orientation="Horizontal" Height="160" VerticalAlignment="Top">
                            <StackPanel Orientation="Vertical" Margin="10,10,0,0">
                                <Label Content="配方名：" Width="90" Height="30" FontSize="15" />
                                <Label x:Name="RegionThresholdLab" Content="预处理阈值：" Width="90" Height="30" FontSize="15" Margin="0,10,0,0" />
                                <Label x:Name="ChannelLab" Content="阀门通道数：" Width="90" Height="30" FontSize="15" Margin="0,10,0,0" />
                                <Label x:Name="NoiseFilterLab" Content="噪点过滤：" Width="90" Height="30" FontSize="15" Margin="0,10,0,0" />
                            </StackPanel>
                            <StackPanel Orientation="Vertical" Margin="10,10,0,0">
                                <TextBox x:Name="FormulationNameTbx" Width="100" Text="{Binding FormulationName,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Height="30" FontSize="15" KeyDown="TextBox_KeyDown" />
                                <TextBox x:Name="RegionThresholdTbx" Width="100" Text="{Binding RegionThreshold,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Height="30" FontSize="15" Margin="0,10,0,0" KeyDown="TextBox_KeyDown" />
                                <TextBox x:Name="ChannelTbx" Width="100" Text="{Binding Channel,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Height="30" FontSize="15" Margin="0,10,0,0" KeyDown="TextBox_KeyDown" />
                                <TextBox x:Name="NoiseFilterTbx" Width="100" Text="{Binding NoiseFilter,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Height="30" FontSize="15" Margin="0,10,0,0" KeyDown="TextBox_KeyDown" />
                            </StackPanel>
                        </StackPanel>
                        <Label Content="合格检测类型" Margin="10,170,0,0" FontSize="15" Height="30" VerticalAlignment="Top"/>
                        <RadioButton x:Name="CheckModel1RadBtn" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="40,205,0,0" Content="不检测" FontSize="15" Checked="CheckModel1RadBtn_Checked" />
                        <RadioButton x:Name="CheckModel2RadBtn" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="40,235,0,0" Content="通过长度检测" FontSize="15" Checked="CheckModel2RadBtn_Checked" />
                        <RadioButton x:Name="CheckModel3RadBtn" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="40,265,0,0" Content="通过面积" FontSize="15" Checked="CheckModel3RadBtn_Checked" />
                        <RadioButton x:Name="CheckModel4RadBtn" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="40,295,0,0" Content="通过长度面积检测" FontSize="15" Checked="CheckModel4RadBtn_Checked" />
                        <StackPanel Orientation="Vertical" Height="60" VerticalAlignment="Top" Margin="0,320,0,0">
                            <StackPanel x:Name="WHParaPanel" Orientation="Horizontal">
                                <Label HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="120" Content="合格长度范围:" FontSize="15" Margin="10,0,0,0"/>
                                <TextBox x:Name="MIN_OBJECT_HEIGHT_TBX" Text="{Binding MIN_OBJECT_LENGTH,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="15" Margin="10,5,0,0" Width="70" KeyDown="TextBox_KeyDown"/>
                                <Label HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="15" Content="-" FontSize="15" Margin="10,0,0,0"/>
                                <TextBox x:Name="MAX_OBJECT_HEIGHT_TBX" Text="{Binding MAX_OBJECT_LENGTH,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="15" Margin="10,5,0,0" Width="70" KeyDown="TextBox_KeyDown"/>
                            </StackPanel>
                            <StackPanel x:Name="AreaParaPanel" Orientation="Horizontal">
                                <Label HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="120" Content="合格粒面积范围:" FontSize="15" Margin="10,0,0,0"/>
                                <TextBox x:Name="MinArea_TBX" Text="{Binding MinArea,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="15" Margin="10,4,0,0" Width="70" KeyDown="TextBox_KeyDown"/>
                                <Label HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="15" Content="-" FontSize="15" Margin="10,0,0,0"/>
                                <TextBox x:Name="MaxArea_TBX" Text="{Binding MaxArea,Mode=TwoWay,UpdateSourceTrigger=LostFocus}" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="15" Margin="10,4,0,0" Width="70" KeyDown="TextBox_KeyDown"/>
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Height="100" VerticalAlignment="Top" Margin="0,380,0,0">
                            <StackPanel Orientation="Horizontal">
                                <Label HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="120" Content="标准药粒宽高:" FontSize="15" Margin="10,0,0,0"/>
                            </StackPanel>
                            <StackPanel x:Name="KeliLWPanel" Orientation="Horizontal">
                                <Label HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="30" Content="宽：" FontSize="15" Margin="10,0,0,0"/>
                                <TextBox x:Name="KeLiW_TBX" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="15" Margin="10,4,0,0" Width="100" KeyDown="TextBox_KeyDown"/>
                                <Label HorizontalAlignment="Left" VerticalAlignment="Top" Height="30" Width="30" Content="高：" FontSize="15" Margin="10,0,0,0"/>
                                <TextBox x:Name="KeLiL_TBX" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="15" Margin="10,4,0,0" Width="100" KeyDown="TextBox_KeyDown"/>
                            </StackPanel>
                            <StackPanel x:Name="ParametricTrainingPanel" Orientation="Horizontal" HorizontalAlignment="Right">
                                <Button x:Name="ParametricTrainingBtn" Content="参数训练" Width="80" Height="35" Margin="0,2,10,0" Click="ParametricTrainingBtn_Click"/>
                            </StackPanel>
                        </StackPanel>
                    </Grid>
                </Grid>
            </Grid>
        </Grid>
    </Grid>
</Page>
