<UserControl x:Class="OnlyProdBTLPartListV"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.ViewerOptimizer" 
             xmlns:EgtBEAMWALLCORE="clr-namespace:EgtBEAMWALL.Core;assembly=EgtBEAMWALL.Core">
   <UserControl.Resources>
      <EgtBEAMWALL:DataGridCellBorderThicknessConverter x:Key="DataGridCellBorderThicknessConverter"/>
   </UserControl.Resources>
   <EgtBEAMWALLCORE:EgtDataGrid x:Name="BTLPart_DataGrid"
                                ItemsSource="{Binding Tag.BTLPartVMList,
                                                      RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"
                                SelectionMode="Extended"
                                PreviewMouseDown="DataGrid_PreviewMouseDown"
                                PreviewMouseUp="DataGrid_PreviewMouseUp"
                                PreviewMouseMove="DataGrid_PreviewMouseMove"
                                Margin="0,0,0,5"
                                EgtBEAMWALL:MultiSelectorBehaviours.SynchronizedSelectedItems="{Binding Tag.SelBTLParts,
                                                                                                        RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"
                                BindingColumns="{Binding PartColumns}"
                                IsEnabled="{Binding PartList_IsEnabled}"
                                AlternatingRowBackground="{StaticResource BeamWall_LinkWater}"
                                AlternationCount="2"
                                ColumnHeaderBackground="{StaticResource BeamWall_Teal}"
                                ColumnHeaderForeground="{StaticResource BeamWall_White}"
                                ColumnHeaderHorizontalContentAlignment="Center"
                                ColumnHeaderFontWeight="Bold"
                                ColumnHeaderFontSize="15"
                                ColumnHeaderPadding="0,2,0,2"
                                Style="{StaticResource DataGrid_OnlyProd}">

      <DataGrid.InputBindings>
         <KeyBinding Key="Delete" Command="{Binding Tag.DeletePart_Command,
                                                    RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}" />
      </DataGrid.InputBindings>
      <DataGrid.CellStyle>
         <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource CellDataGrid_CustomHighLight}">
            <Setter Property="BorderBrush" Value="{Binding Search_Background}"/>
            <Setter Property="BorderThickness">
               <Setter.Value>
                  <MultiBinding Converter="{StaticResource DataGridCellBorderThicknessConverter}"
                                ConverterParameter="3">
                     <Binding Path="Column.DisplayIndex" RelativeSource="{RelativeSource Self}"/>
                  </MultiBinding>
               </Setter.Value>
            </Setter>
         </Style>
      </DataGrid.CellStyle>
      <DataGrid.RowStyle>
         <Style TargetType="DataGridRow" BasedOn="{StaticResource RowDataGrid_CustomHighLight}">
            <EventSetter Event="PreviewMouseDown" Handler="PartList_PreviewMouseDown"/>
            <EventSetter Event="PreviewMouseUp" Handler="PartList_PreviewMouseUp"/>
         </Style>
      </DataGrid.RowStyle>
      <DataGrid.Resources>
         <!--PDN - Nome-->
         <DataGridTextColumn x:Key="colPDN" Binding="{Binding nPDN}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.PDN_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--Validità pezzo-->
         <DataGridTemplateColumn x:Key="colCALC" CanUserResize="False"
                                 SortMemberPath="nGlobalState">
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Grid Style="{StaticResource GlobalState_Grid}">
                     <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="25"/>
                        <ColumnDefinition Width="Auto"/>
                     </Grid.ColumnDefinitions>
                     <TextBlock Text="↓"
                                Visibility="{Binding CALC_FALL_Visibility}"
                                Style="{StaticResource CALC_FALL_TextBlock}"/>
                     <Border Grid.Column="1"
                             BorderBrush="{Binding Calc_BorderBrush}"
                             Style="{StaticResource CALC_FALL_Border}">
                        <ItemsControl ItemsSource="{Binding BTLFeatureVMList_View}"
                                      Style="{StaticResource CALC_FALL_ItemsControl}">
                           <ItemsControl.ItemsPanel>
                              <ItemsPanelTemplate>
                                 <UniformGrid Columns="6" Rows="5"
                                              Margin="0"/>
                              </ItemsPanelTemplate>
                           </ItemsControl.ItemsPanel>
                           <ItemsControl.ItemTemplate>
                              <DataTemplate>
                                 <Border Background="{Binding Calc_Background}"/>
                              </DataTemplate>
                           </ItemsControl.ItemTemplate>
                        </ItemsControl>
                     </Border>
                     <Grid Grid.Column="2"
                           HorizontalAlignment="Center">
                        <Grid.ColumnDefinitions>
                           <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                           <RowDefinition Height="1*"/>
                           <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Ellipse Visibility="{Binding CALC_ROT_Visibility}"
                                 Style="{StaticResource CALC_ROT_Ellipse}"/>
                        <TextBlock Grid.Row="1"
                                   Text="{Binding CALC_ERR_Letter}"
                                   Foreground="{Binding CALC_ERR_Foreground}"
                                   Style="{StaticResource CALC_ERR_TextBlock}"/>
                     </Grid>
                  </Grid>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <!--DO - Abilitazione-->
         <DataGridTemplateColumn x:Key="colDO">
            <DataGridTemplateColumn.HeaderTemplate>
               <DataTemplate>
                  <CheckBox IsChecked="{Binding Path=Tag.bDOALL, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"
                            VerticalAlignment="Center"/>
               </DataTemplate>
            </DataGridTemplateColumn.HeaderTemplate>
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <CheckBox IsChecked="{Binding bDO, UpdateSourceTrigger=PropertyChanged}"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Center"/>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <!--W - Larghezza-->
         <DataGridTextColumn x:Key="colW" Binding="{Binding sW}" SortMemberPath="dW">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.W_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--H - Altezza-->
         <DataGridTextColumn x:Key="colH" Binding="{Binding sH}" SortMemberPath="dH">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.H_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--L - Lunghezza-->
         <DataGridTextColumn x:Key="colL" Binding="{Binding sL}" SortMemberPath="dL">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.L_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--NAM - Descrizione-->
         <DataGridTextColumn x:Key="colNAM" Binding="{Binding sNAM}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.NAM_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--MAT - Materiale-->
         <DataGridTextColumn x:Key="colMATERIAL" Binding="{Binding sMATERIAL}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.MAT_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--CNT - Richiesti da BTL-->
         <DataGridTextColumn x:Key="colCNT" Binding="{Binding sCNT}" SortMemberPath="nCNT">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.ShortCNT_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"
                          ToolTip="{Binding Path=DataContext.CNT_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--ADDED - Aggiunti-->
         <DataGridTextColumn x:Key="colADDED" Binding="{Binding sADDED}" SortMemberPath="nADDED">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.ShortADDED_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"
                          ToolTip="{Binding Path=DataContext.ADDED_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
            <DataGridTextColumn.EditingElementStyle>
               <Style TargetType="{x:Type TextBox}">
                  <Setter Property="Foreground" Value="Blue" />
               </Style>
            </DataGridTextColumn.EditingElementStyle>
         </DataGridTextColumn>
         <!--INPROD - IN OTTIMIZZAZIONE-->
         <DataGridTextColumn x:Key="colINPROD" Binding="{Binding nINPROD}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.ShortINPROD_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"
                          ToolTip="{Binding Path=DataContext.INPROD_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--DONE - PRODOTTI-->
         <DataGridTextColumn x:Key="colDONE" Binding="{Binding nDONE}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.ShortDONE_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"
                          ToolTip="{Binding Path=DataContext.DONE_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--GRP - Gruppo-->
         <DataGridTextColumn x:Key="colGROUP" Binding="{Binding sGROUP}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.GRP_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--STOREY - Sottogruppo-->
         <DataGridTextColumn x:Key="colSTOREY" Binding="{Binding sSTOREY}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.STOREY_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdBTLPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
      </DataGrid.Resources>

   </EgtBEAMWALLCORE:EgtDataGrid>

</UserControl>
