<UserControl x:Class="MainShell.Recipe.View.SubstrateRecipeView"
             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.Recipe.View"
             xmlns:mw="http://www.maxwell-gp.com/"
             mc:Ignorable="d" 
             d:DesignHeight="700" d:DesignWidth="800">
    <TabControl mw:TabControlAttach.HeaderWidth="Auto"
                SelectedIndex="{Binding SelectedTabIndex, Mode=TwoWay}">
        <TabItem Header="{DynamicResource BaseSetting}" Style="{StaticResource TabItemHorizontalStyle}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="240"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <GroupBox Header="{DynamicResource SubstrateInfo}" Style="{StaticResource GroupBoxSecondary}">
                    <GroupBox.Resources>
                        <Style TargetType="TextBlock" BasedOn="{StaticResource TextBlockStyle}"></Style>
                    </GroupBox.Resources>
                    <UniformGrid DataContext="{Binding SubstrateRecipe.SubstrateInfo}" Columns="2" Rows="14">
                        <TextBlock  Text="{DynamicResource SubstrateWidth}"/>
                        <mw:NumberBox Value="{Binding SubstrateSize.Width,UpdateSourceTrigger=PropertyChanged}"  mw:NumericKeypadAttach.IsEnabled="True"/>
                        <TextBlock  Text="{DynamicResource SubstrateHeight}"/>
                        <mw:NumberBox Value="{Binding SubstrateSize.Height,UpdateSourceTrigger=PropertyChanged}" mw:NumericKeypadAttach.IsEnabled="True"/>
                        <TextBlock  Text="{DynamicResource SubstrateThickness}"/>
                        <mw:NumberBox Value="{Binding ThickNess,UpdateSourceTrigger=PropertyChanged}" mw:NumericKeypadAttach.IsEnabled="True"/>
                        <TextBlock  Text="{DynamicResource SubstratePiexlWidth}"/>
                        <mw:NumberBox Value="{Binding PadSize.Width,UpdateSourceTrigger=PropertyChanged}" mw:NumericKeypadAttach.IsEnabled="True"/>
                        <TextBlock  Text="{DynamicResource SubstratePiexlHeight}"/>
                        <mw:NumberBox Value="{Binding PadSize.Height,UpdateSourceTrigger=PropertyChanged}" mw:NumericKeypadAttach.IsEnabled="True"/>
                        <TextBlock  Text="{DynamicResource SubstratePitchX}"/>
                        <mw:NumberBox Value="{Binding PitchX,UpdateSourceTrigger=PropertyChanged}" mw:NumericKeypadAttach.IsEnabled="True"/>
                        <TextBlock  Text="{DynamicResource SubstratePitchY}"/>
                        <mw:NumberBox Value="{Binding PitchY,UpdateSourceTrigger=PropertyChanged}" mw:NumericKeypadAttach.IsEnabled="True"/>
                        <TextBlock  Text="{DynamicResource SubstrateRowNum}"/>
                        <mw:NumberBox Value="{Binding RowNumber,UpdateSourceTrigger=PropertyChanged}" mw:NumericKeypadAttach.IsEnabled="True"/>
                        <TextBlock  Text="{DynamicResource SubstrateColNum}"/>
                        <mw:NumberBox Value="{Binding ColNumber,UpdateSourceTrigger=PropertyChanged}" mw:NumericKeypadAttach.IsEnabled="True"/>
                    </UniformGrid>
                </GroupBox>
                <Grid Grid.Column="1">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <GroupBox BorderThickness="0,1,0,1"
          Style="{StaticResource GroupBoxSecondary}"
          Header="{DynamicResource WaferRecipesSelect}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <DataGrid x:Name="waferInfo"
                  AutoGenerateColumns="False"
                  SelectionMode="Single" 
                  ItemsSource="{Binding SubstrateRecipe.WaferSelectInfos}"
                  mw:DataGridAttach.ShowRowNumber="True">
                                <DataGrid.Columns>
                                    <DataGridComboBoxColumn Width="*"  TextBinding="{Binding WaferRecipeName}" Header="{DynamicResource WaferRecipe}">
                                        <DataGridComboBoxColumn.EditingElementStyle>
                                            <Style TargetType="ComboBox">
                                                <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=GroupBox}, Path=DataContext.WaferRecipes}" />
                                                <Setter Property="DisplayMemberPath" Value="RecipeName"/>
                                                <Setter Property="SelectedIndex" Value="0"/>
                                            </Style>
                                        </DataGridComboBoxColumn.EditingElementStyle>
                                    </DataGridComboBoxColumn>
                                    <DataGridTemplateColumn Width="100"  Header="{DynamicResource SubstrateOffsetX}">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Grid>
                                                    <mw:NumberBox BorderBrush="Transparent"
                                              Background="Transparent"
                                              HorizontalAlignment="Center"
                                              HorizontalContentAlignment="Center"
                                              Value="{Binding OffsetX}"
                                              mw:NumericKeypadAttach.IsEnabled="True"/>
                                                </Grid>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="100" Header="{DynamicResource SubstrateOffsetY}">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Grid>
                                                    <mw:NumberBox BorderBrush="Transparent"
                                 Background="Transparent"
                                 HorizontalAlignment="Center"
                                 HorizontalContentAlignment="Center"
                                 Value="{Binding OffsetY}"
                                 mw:NumericKeypadAttach.IsEnabled="True"/>
                                                </Grid>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>
                                    <DataGridTemplateColumn Width="100" 
                                        Header="{DynamicResource InUse}">
                                        <DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <CheckBox Style="{StaticResource ModernCheckBoxStyle}" IsChecked="{Binding IsUse, UpdateSourceTrigger=PropertyChanged}"/>
                                            </DataTemplate>
                                        </DataGridTemplateColumn.CellTemplate>
                                    </DataGridTemplateColumn>


                                </DataGrid.Columns>
                            </DataGrid>
                            <Border Grid.Row="1" Background="#F0F6F7">
                                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                    <Button Style="{StaticResource StartButtonStyle}" Click="{mw:Action AddWaferSelectInfo}" Content="{DynamicResource Add}"  Margin="4,2"/>
                                    <Button Style="{StaticResource CloseButtonStyle}"
                        Command="{Binding DeleteSelectWaferInfoCmd}"
                        CommandParameter="{Binding ElementName=waferInfo, Path=SelectedItem}"
                        Content="{DynamicResource Delete}"  Margin="4,2"/>
                                </StackPanel>
                            </Border>
                        </Grid>

                    </GroupBox>
                    <GroupBox Grid.Row="1" Header="{DynamicResource LogisticsInfo}">

                    </GroupBox>
                </Grid>
            </Grid>
        </TabItem>
        <TabItem Header="参数示教">
            <ContentControl mw:View.Model="{Binding SubstrateTeachViewModel}"/>
        </TabItem>
        <TabItem Header="测高设置">
            <local:SubstrateHeightMeasureView DataContext="{Binding SubstrateHeightMeasureViewModel}"/>
        </TabItem>
    </TabControl>
</UserControl>
