<Grid x:Class="DoorListPageV"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="clr-namespace:Effector.Plugin.StoneCut">
   <Grid.Resources>
      <local:StateToSelColorConverter x:Key="StateToSelColorConverter"/>
      <local:DDTListToBooleanConverter x:Key="DDTListToBooleanConverter"/>
   </Grid.Resources>
   <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="3"/>
      <RowDefinition Height="1*"/>
   </Grid.RowDefinitions>
   <Border BorderThickness="0"
           Padding="3"
           BorderBrush="Transparent"
           Background="{StaticResource Omag_DarkGray}">
      <StackPanel Orientation="Horizontal"
                  IsEnabled="{Binding bExecButton_IsEnabled}">
         <Button ToolTip="Mette in coda di produzione tutte le porte"
                 Command="{Binding ProduceAll_Command}"
                 IsEnabled="{Binding bExecButton_IsEnabled}"
                 Style="{StaticResource Table_Button}">
            <Image Source="../Resources/DoorListPage/ProduceAll.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>
         <Button ToolTip="Riporta tutte le porte pronte per essere lavorate allo stato Verificate state"
                 Command="{Binding ResetProductionQueue_Command}"
                 Style="{StaticResource Table_Button}">
            <Image Source="../Resources/DoorListPage/ResetProduction.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>
         <Button ToolTip="Cancella tutte le porte presenti in lista"
                 Command="{Binding DeleteAll_Command}"
                 IsEnabled="{Binding bExecButton_IsEnabled}"   
                 Style="{StaticResource Table_Button}">
            <Image Source="../Resources/DoorListPage/DeleteAll.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>
         <!--<Button ToolTip="Mette in coda di produzione la porta selezionata"
                 Command="{Binding Produce_Command}"
                 Style="{StaticResource Button.DoorList}">
            <Image Source="../Resources/DoorListPage/Produce.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>-->
         <!--<Button ToolTip="Sposta su"
                 Command="{Binding MoveUp_Command}"
                 Style="{StaticResource Button.DoorList}">
            <Image Source="../Resources/DoorListPage/MoveUp.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>
         <Button ToolTip="Sposta giù"
                 Command="{Binding MoveDown_Command}"
                 Style="{StaticResource Button.DoorList}">
            <Image Source="../Resources/DoorListPage/MoveDown.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>-->
         <!--<Button ToolTip="Mark the selected door as not to be produced"
                 Command="{Binding NotProduceDoor_Command}"
                 IsEnabled="{Binding bExecButton_IsEnabled}"   
                 Style="{StaticResource Button.DoorList}">
            <Image Source="../Resources/DoorListPage/NotProduce.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>-->
         <!--<Button ToolTip="Aggiunge una porta alla lista"
                 Command="{Binding AddDoor_Command}"
                 IsEnabled="{Binding bExecButton_IsEnabled}"   
                 Style="{StaticResource Button.DoorList}">
            <Image Source="../Resources/DoorListPage/Add.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>-->
         <!--<Button ToolTip="Copia la porta selezionata"
                 Command="{Binding CopyDoor_Command}"
                 IsEnabled="{Binding bExecButton_IsEnabled}"   
                 Style="{StaticResource Button.DoorList}">
            <Image Source="../Resources/DoorListPage/Copy.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>-->
         <!--<Button ToolTip="Copia Multipla della porta selezionata"
                 Command="{Binding MultipleCopyDoor_Command}"
                 IsEnabled="{Binding bExecButton_IsEnabled}"   
                 Style="{StaticResource Button.DoorList}">
            <Image Source="../Resources/DoorListPage/MultipleCopy.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>-->
         <!--<Button ToolTip="Cancella porta selezionata"
                 Command="{Binding Delete_Command}"
                 IsEnabled="{Binding bExecButton_IsEnabled}"   
                 Style="{StaticResource Button.DoorList}">
            <Image Source="../Resources/DoorListPage/Delete.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>-->
         <!--<Button ToolTip="Verifica tutte le porte in stato Non Verificata"
                 Command="{Binding Verify_Command}"
                 IsEnabled="{Binding bExecButton_IsEnabled}"
                 Style="{StaticResource Button.DoorList}">
            <Image Source="../Resources/DoorListPage/Verify.png"
                   Style="{StaticResource Button.Image.DoorList}"/>
         </Button>-->
         <!--<TextBlock Text="{Binding sExecPercentage}"
                    VerticalAlignment="Center"
                    Margin="10,0,5,0"
                    Visibility="{Binding ExecPercentage_Visibility, Mode=OneWay}"/>
         <ProgressBar Minimum="0"
                      Maximum="100"
                      Value="{Binding dExecPercentage, Mode=OneWay}"
                      Height="15"
                      Width="100"
                      Margin="5,0,0,0"
                      Visibility="{Binding ExecPercentage_Visibility}"/>-->
      </StackPanel>
   </Border>
   <FrameworkElement x:Name="dummyElement" Visibility="Collapsed"/>
   <DataGrid Grid.Row="2"
             ItemsSource="{Binding DoorList}"
             SelectedItem="{Binding SelDoor}"
             AutoGenerateColumns="False"
             CanUserDeleteRows="False"
             CanUserResizeRows="False"
             SelectionMode="Single"
             SelectionUnit="FullRow"
             CanUserSortColumns="False"
             ScrollViewer.VerticalScrollBarVisibility="Auto"
             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
             BeginningEdit="DoorList_BeginningEdit"
             HorizontalGridLinesBrush="Transparent"
             VerticalGridLinesBrush="Transparent"
             ColumnHeaderHeight="32"
             HeadersVisibility="Column"
             FontSize="12"
             FontFamily="/Resources/Fonts/#Roboto"
             FontWeight="Regular"
             RowHeight="32"
             BorderThickness="0"
             Background="{StaticResource Omag_LightGray}">
      <DataGrid.ColumnHeaderStyle>
         <Style TargetType="{x:Type DataGridColumnHeader}">
            <Setter Property="Background" Value="{StaticResource Omag_DarkGray}"/>
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="FontSize" Value="15"/>
            <Setter Property="Padding" Value="10,0,10,0"/>
         </Style>
      </DataGrid.ColumnHeaderStyle>
      <DataGrid.Columns>
         <DataGridTextColumn Header="ID"
                             Binding="{Binding nId}"
                             Width="Auto"
                             IsReadOnly="True"
                             ElementStyle="{StaticResource TextBlock.DataGridTextColumn.DoorList}"
                             EditingElementStyle="{StaticResource TextBox.DataGridTextColumn.DoorList}"/>
         <DataGridTextColumn Header="File Name"
                             Binding="{Binding sFileNameWithoutExtension}"
                             Width="Auto"
                             IsReadOnly="True"
                             ElementStyle="{StaticResource TextBlock.DataGridTextColumn.DoorList}"
                             EditingElementStyle="{StaticResource TextBox.DataGridTextColumn.DoorList}"/>
         <DataGridTemplateColumn Width="Auto">
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Button Command="{Binding DataContext.Produce_Command, RelativeSource={RelativeSource AncestorType={x:Type local:DoorListPageV}}}"
                          CommandParameter="{Binding}"
                          Style="{StaticResource Table_Button}">
                     <Image Source="../Resources/DoorListPage/Produce.png"/>
                  </Button>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <DataGridTextColumn Header="# Table"
                             Binding="{Binding nTable}"
                             Width="Auto"
                             IsReadOnly="True"
                             ElementStyle="{StaticResource TextBlock.DataGridTextColumn.DoorList}"
                             EditingElementStyle="{StaticResource TextBox.DataGridTextColumn.DoorList}"/>
         <DataGridTextColumn Header="File Dimension"
                             Binding="{Binding sFileDimension}"
                             Width="Auto"
                             IsReadOnly="True"
                             ElementStyle="{StaticResource TextBlock.DataGridTextColumn.DoorList}"
                             EditingElementStyle="{StaticResource TextBox.DataGridTextColumn.DoorList}"/>
         <DataGridTextColumn Header="State"
                             Binding="{Binding nState}"
                             Width="Auto"
                             IsReadOnly="True"
                             ElementStyle="{StaticResource TextBlock.DataGridTextColumn.DoorList}"
                             EditingElementStyle="{StaticResource TextBox.DataGridTextColumn.DoorList}"/>
         <DataGridTextColumn Header="Machining Start"
                             Binding="{Binding sMachiningStart}"
                             Width="Auto"
                             IsReadOnly="True"
                             ElementStyle="{StaticResource TextBlock.DataGridTextColumn.DoorList}"
                             EditingElementStyle="{StaticResource TextBox.DataGridTextColumn.DoorList}"/>
         <DataGridTextColumn Header="Machining End"
                             Binding="{Binding sMachiningEnd}"
                             Width="Auto"
                             IsReadOnly="True"
                             ElementStyle="{StaticResource TextBlock.DataGridTextColumn.DoorList}"
                             EditingElementStyle="{StaticResource TextBox.DataGridTextColumn.DoorList}"/>
         <DataGridTextColumn Header="Machining Time"
                             Binding="{Binding sMachiningTime}"
                             Width="Auto"
                             IsReadOnly="True"
                             ElementStyle="{StaticResource TextBlock.DataGridTextColumn.DoorList}"
                             EditingElementStyle="{StaticResource TextBox.DataGridTextColumn.DoorList}"/>
         <DataGridTemplateColumn Width="Auto">
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Button Command="{Binding DataContext.MoveUp_Command, RelativeSource={RelativeSource AncestorType={x:Type local:DoorListPageV}}}"
                          CommandParameter="{Binding}"
                          Style="{StaticResource Table_Button}">
                     <Image Source="../Resources/DoorListPage/MoveUp.png"/>
                  </Button>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <DataGridTemplateColumn Width="Auto">
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Button Command="{Binding DataContext.MoveDown_Command, RelativeSource={RelativeSource AncestorType={x:Type local:DoorListPageV}}}"
                          CommandParameter="{Binding}"
                          Style="{StaticResource Table_Button}">
                     <Image Source="../Resources/DoorListPage/MoveDown.png"/>
                  </Button>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <DataGridTemplateColumn Width="Auto">
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Button Command="{Binding NotProduce_Command}"
                          Style="{StaticResource Table_Button}">
                     <Image Source="../Resources/DoorListPage/NotProduce.png"/>
                  </Button>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <DataGridTemplateColumn Width="Auto">
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Button Command="{Binding DataContext.Copy_Command, RelativeSource={RelativeSource AncestorType={x:Type local:DoorListPageV}}}"
                          CommandParameter="{Binding}"
                          Style="{StaticResource Table_Button}">
                     <Image Source="../Resources/DoorListPage/Copy.png"/>
                  </Button>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <DataGridTemplateColumn Width="Auto">
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Button Command="{Binding DataContext.Delete_Command, RelativeSource={RelativeSource AncestorType={x:Type local:DoorListPageV}}}"
                          CommandParameter="{Binding}"
                          Style="{StaticResource Table_Button}">
                     <Image Source="../Resources/DoorListPage/Delete.png"/>
                  </Button>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
      </DataGrid.Columns>
      <!--<DataGrid.InputBindings>
         <KeyBinding Key="Delete" Command="{Binding Tag.SelectedMachGroup.DeleteMachGroup_Command,
                                                    RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"/>
      </DataGrid.InputBindings>-->
      <DataGrid.RowStyle>
         <Style TargetType="DataGridRow" BasedOn="{StaticResource RowDataGrid_CustomHighLight}">
            <Setter Property="Background" Value="{Binding Background}"/>
            <Setter Property="Foreground" Value="{Binding Foreground}"/>
            <Setter Property="BorderBrush" Value="{Binding nState, Converter={StaticResource StateToSelColorConverter}}"/>
         </Style>
      </DataGrid.RowStyle>
   </DataGrid>
</Grid>
