<UserControl x:Class="MainShell.Manual.View.DieBondingView"
             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:mw="http://www.maxwell-gp.com/"
             xmlns:custom="clr-namespace:MainShell.Resources.CustomControl"
             xmlns:conv="clr-namespace:MainShell.Converter"
              xmlns:common="clr-namespace:MainShell.Common"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary>
            <conv:EnumBindingSourceExtension x:Key="TransPathType" UseDescription="True" EnumType="{x:Type common:TransPathType}" />
            <conv:EnumBindingSourceExtension x:Key="DieTransferRowTraversalStrategy" UseDescription="True" EnumType="{x:Type common:DieTransferRowTraversalStrategy}" />

            <Style x:Key="DieBondingTextStyle" TargetType="TextBlock" BasedOn="{StaticResource ProcessReadOnlyValueTextStyle}">
                <Setter Property="Width" Value="128"/>
                <Setter Property="FontWeight" Value="SemiBold"/>
            </Style>

            <Style x:Key="DieBondingComboStyle" TargetType="ComboBox" BasedOn="{StaticResource ProcessComboBoxStyle}">
                <Setter Property="Width" Value="180"/>
            </Style>

            <Style x:Key="DieBondingPathButtonStyle" TargetType="Button" BasedOn="{StaticResource CommonButtonStyle}">
                <Setter Property="Margin" Value="4,2"/>
                <Setter Property="MinWidth" Value="120"/>
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid Background="{StaticResource ProcessPageBackgroundBrush}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Border Style="{StaticResource ProcessCameraHostBorderStyle}">
            <ContentControl Content="{Binding CameraAxisViewModel}" />
        </Border>
        <TabControl Grid.Column="1" Margin="0,4,4,4" Style="{StaticResource ProcessTabControlStyle}">
            <TabItem Header="{DynamicResource DieBondingSet}">
                <Grid Margin="4">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Vertical">
                        <custom:RegionEditorView Title="{DynamicResource SubstrateRegion}" Margin="0,0,0,18"/>
                        <custom:RegionEditorView Title="{DynamicResource WaferRegion}" Margin="0,0,0,18"/>
                        <GroupBox Header="{DynamicResource GenerateSet}" Style="{StaticResource ProcessWideCardGroupBoxStyle}">
                            <StackPanel>
                                <StackPanel Style="{StaticResource ProcessParameterRowStyle}">
                                    <TextBlock Text="{DynamicResource DieBondingGenerateModeLabel}" Style="{StaticResource DieBondingTextStyle}"/>
                                    <ComboBox Style="{StaticResource DieBondingComboStyle}"
                                              SelectedValuePath="Value"
                                              ItemsSource="{StaticResource TransPathType}"
                                              SelectedValue="{Binding DieBondingManualSysItem.TransPathType, Mode=TwoWay}"
                                              DisplayMemberPath="Description"/>
                                </StackPanel>
                                <StackPanel Style="{StaticResource ProcessParameterRowStyle}">
                                    <TextBlock Text="{DynamicResource DieBondingPadRowDirectionLabel}" Style="{StaticResource DieBondingTextStyle}"/>
                                    <ComboBox Style="{StaticResource DieBondingComboStyle}"
                                              SelectedValuePath="Value"
                                              ItemsSource="{StaticResource DieTransferRowTraversalStrategy}"
                                              SelectedValue="{Binding DieBondingManualSysItem.PadRowDirectionStrategy, Mode=TwoWay}"
                                              DisplayMemberPath="Description"/>
                                </StackPanel>
                                <StackPanel Style="{StaticResource ProcessParameterRowStyle}">
                                    <TextBlock Text="{DynamicResource DieBondingDieRowDirectionLabel}" Style="{StaticResource DieBondingTextStyle}"/>
                                    <ComboBox Style="{StaticResource DieBondingComboStyle}"
                                              SelectedValuePath="Value"
                                              ItemsSource="{StaticResource DieTransferRowTraversalStrategy}"
                                              SelectedValue="{Binding DieBondingManualSysItem.DieRowDirectionStrategy, Mode=TwoWay}"
                                              DisplayMemberPath="Description"/>
                                </StackPanel>
                                <StackPanel Style="{StaticResource ProcessParameterRowStyle}">
                                    <TextBlock Text="{DynamicResource DieBondingAutoCalculateDieLabel}" Style="{StaticResource DieBondingTextStyle}"/>
                                    <ToggleButton Style="{StaticResource ProcessSmallToggleStyle}" Content="{DynamicResource EnabledLabel}"
                                                  IsChecked="{Binding DieBondingManualSysItem.AutoDieRegionModeEnable, Mode=TwoWay}"/>
                                </StackPanel>
                            </StackPanel>
                        </GroupBox>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Row="1" Margin="0,8,0,0">
                        <Button Content="{DynamicResource Start}" Click="{mw:Action StartProcess}" Style="{StaticResource StartButtonStyle}"  Margin="5" 
                    IsEnabled="{Binding Runner.IsRunning, Converter={StaticResource boolToInversionConverter}}" />
                        <Button Content="{DynamicResource Stop}" Click="{mw:Action StopProcess}" Style="{StaticResource StopButtonStyle }"  Margin="5" 
                    IsEnabled="{Binding Runner.IsRunning}" />
                        <Button Content="{DynamicResource Save}" Click="{mw:Action SaveDieBondingSetAsync}" Style="{StaticResource SaveButtonStyle}"  Margin="5" 
IsEnabled="{Binding Runner.IsRunning, Converter={StaticResource boolToInversionConverter}}" />
                    </StackPanel>
                </Grid>
            </TabItem>
            <TabItem Header="{DynamicResource DieBondingPath}">
                <Grid Margin="4">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <DataGrid Style="{StaticResource ProcessDataGridStyle}"
                              ItemsSource="{Binding DieTransferPathItems}"
                              SelectedItem="{Binding SelectedDieTransferPathItem, Mode=TwoWay}"
                              IsReadOnly="True"
                              SelectionUnit="FullRow"
                              SelectionMode="Single"
                              LoadingRow="DataGrid_LoadingRow">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="{DynamicResource DieBondingSequenceNumberHeader}" Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGridRow}, 
                       Path=Header}" Width="*"/>
                            <DataGridTextColumn Header="{DynamicResource DieBondingSubstrateRowHeader}" Binding="{Binding PadRow}" Width="*"/>
                            <DataGridTextColumn Header="{DynamicResource DieBondingSubstrateColumnHeader}" Binding="{Binding PadColumn}" Width="*"/>
                            <DataGridTextColumn Header="{DynamicResource DieBondingWaferRowHeader}" Binding="{Binding DieRow}" Width="*"/>
                            <DataGridTextColumn Header="{DynamicResource DieBondingWaferColumnHeader}" Binding="{Binding DieColumn}" Width="*"/>
                            <DataGridTextColumn Header="{DynamicResource DieBondingTypeHeader}" Binding="{Binding TransPathType, Converter={StaticResource EnumDescriptionConverter}}" Width="*"/>
                        </DataGrid.Columns>
                    </DataGrid>
                    <custom:PaginationControl DataContext="{Binding Pagination}" Grid.Row="1" Margin="0,10,0,0"/>
                    <StackPanel HorizontalAlignment="Center" Orientation="Horizontal" Margin="2" Grid.Row="2">
                        <Button Style="{StaticResource DieBondingPathButtonStyle}"
                                Content="{DynamicResource DieBondingMoveToDieButton}"
                                IsEnabled="{Binding SelectedDieTransferPathItem, Converter={StaticResource ObjectToBoolConverter}}" />
                        <Button Style="{StaticResource DieBondingPathButtonStyle}"
                                Content="{DynamicResource DieBondingMoveToPadButton}"
                                IsEnabled="{Binding SelectedDieTransferPathItem, Converter={StaticResource ObjectToBoolConverter}}" />
                        <Button Style="{StaticResource DieBondingPathButtonStyle}"
                                Content="{DynamicResource DieBondingAlignDieToPadButton}"
                                IsEnabled="{Binding SelectedDieTransferPathItem, Converter={StaticResource ObjectToBoolConverter}}" />
                        <Button Style="{StaticResource DieBondingPathButtonStyle}" Content="{DynamicResource DieBondingGeneratePathButton}"/>
                    </StackPanel>
                </Grid>
            </TabItem>
        </TabControl>

    </Grid>
</UserControl>
