<UserControl x:Class="OnlyProdPartInRawPartListV"
             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">
   
   <EgtBEAMWALLCORE:EgtDataGrid ItemsSource="{Binding Tag.PartVMList,
                                                      RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdPartInRawPartListV}}}"
                                SelectedItem="{Binding Tag.SelPart,
                                                       RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdPartInRawPartListV}}}"
                                CanUserDeleteRows="False"
                                CanUserSortColumns="False"
                                SelectionMode="Single"
                                Margin="2.5,0,0,5"
                                BindingColumns="{Binding PartInRawPartColumns}"
                                BeginningEdit="PartInRawPartList_BeginningEdit"
                                AlternatingRowBackground="{StaticResource BeamWall_LinkWater}"
                                AlternationCount="2"
                                ColumnHeaderBackground="{StaticResource BeamWall_Jaffa}"
                                ColumnHeaderForeground="{StaticResource BeamWall_White}"
                                ColumnHeaderHorizontalContentAlignment="Center"
                                ColumnHeaderFontWeight="Bold"
                                ColumnHeaderFontSize="15"
                                ColumnHeaderPadding="0,2,0,2"
                                CellStyle="{StaticResource CellDataGrid_CustomHighLight_PartList}"
                                Style="{StaticResource DataGrid_OnlyProd}">
      <DataGrid.RowStyle>
         <Style TargetType="DataGridRow" BasedOn="{StaticResource RowDataGrid_CustomHighLight_PartList}">
            <Setter Property="Background" Value="{Binding Background}"/>
            <EventSetter Event="PreviewMouseDown" Handler="PartInRawPartRow_PreviewMouseDown"/>
         </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:OnlyProdPartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
            <DataGridTextColumn.CellStyle>
               <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource CellDataGrid_CustomHighLight_PartList}">
                  <Setter Property="BorderBrush" Value="{Binding Search_Background}"/>
                  <Setter Property="BorderThickness" Value="2,2,0,2"/>
               </Style>
            </DataGridTextColumn.CellStyle>
         </DataGridTextColumn>
         <!--Validità pezzo-->
         <DataGridTemplateColumn x:Key="colCALC">
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Grid>
                     <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="10"/>
                     </Grid.ColumnDefinitions>
                     <TextBlock Text="↓"
                                Foreground="Aqua"
                                TextAlignment="Center"
                                FontWeight="Bold"
                                FontSize="12"
                                Margin="0,-6,0,-2"
                                Visibility="{Binding CALC_FALL_Visibility}"/>
                     <Border Width="{Binding ActualHeight, RelativeSource={RelativeSource self}}"
                             Grid.Column="1"                          
                             Background="{Binding Calc_Background}"/>
                     <Grid Grid.Column="2"
                           HorizontalAlignment="Center">
                        <Grid.RowDefinitions>
                           <RowDefinition Height="1*"/>
                           <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Ellipse Width="5"
                                 Height="5"
                                 Fill="Red"
                                 Visibility="{Binding CALC_ROT_Visibility}"
                                 HorizontalAlignment="Center"/>
                        <TextBlock Grid.Row="1"
                                   Text="{Binding CALC_ERR_Letter}"
                                   Foreground="{Binding CALC_ERR_Foreground}"
                                   TextAlignment="Center"
                                   FontWeight="Bold"
                                   FontSize="12"
                                   Margin="0,-6,0,-2"/>
                     </Grid>
                  </Grid>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <!--NAM - Descrizione-->
         <DataGridTextColumn x:Key="colNAM" Binding="{Binding sNAM}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.NAM_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdPartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--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:OnlyProdPartInRawPartListV}}}"/>
            </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:OnlyProdPartInRawPartListV}}}"/>
            </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:OnlyProdPartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--ROT - Rotazione-->
         <DataGridTemplateColumn x:Key="colROT" SortMemberPath="dROT">
            <DataGridTemplateColumn.HeaderTemplate>
               <DataTemplate>
                  <TextBlock Text="{Binding Path=DataContext.ROTATION_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdPartInRawPartListV}}}"/>
               </DataTemplate>
            </DataGridTemplateColumn.HeaderTemplate>
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Grid>
                     <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="Auto"/>
                     </Grid.ColumnDefinitions>
                     <Button Command="{Binding BackRotation_Command}"
                             Height="15"
                             Width="15"
                             VerticalAlignment="Center"
                             Background="Transparent"
                             BorderBrush="Transparent"
                             Foreground="{StaticResource BeamWall_Kashmir}">
                        <TextBlock Text="&lt;"
                                   FontWeight="Bold"
                                   Margin="0,-5,0,-2"/>
                     </Button>
                     <TextBlock Text="{Binding sROT}" 
                                Grid.Column="1"
                                TextAlignment="Center"/>
                     <Button Command="{Binding ForwardRotation_Command}"
                             Grid.Column="2"
                             Height="15"
                             Width="15"
                             VerticalAlignment="Center"
                             Background="Transparent"
                             BorderBrush="Transparent"
                             Foreground="{StaticResource BeamWall_Kashmir}">
                        <TextBlock Text=">"
                                   FontWeight="Bold"
                                   Margin="0,-5,0,-2"/>
                     </Button>
                  </Grid>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <!--INV - Inversione-->
         <DataGridTemplateColumn x:Key="colFLIP">
            <DataGridTemplateColumn.HeaderTemplate>
               <DataTemplate>
                  <TextBlock Text="{Binding Path=DataContext.INVERSION_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdPartInRawPartListV}}}"/>
               </DataTemplate>
            </DataGridTemplateColumn.HeaderTemplate>
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <CheckBox IsChecked="{Binding bFLIP, UpdateSourceTrigger=PropertyChanged}"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"/>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <!--PosX - Posizione-->
         <DataGridTextColumn x:Key="colPOSX" Binding="{Binding sPOSX}" SortMemberPath="dPOSX">
            <DataGridTextColumn.HeaderTemplate>
               <DataTemplate>
                  <TextBlock Text="{Binding Path=DataContext.PosX_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdPartInRawPartListV}}}"/>
               </DataTemplate>
            </DataGridTextColumn.HeaderTemplate>
            <DataGridTextColumn.EditingElementStyle>
               <Style TargetType="{x:Type TextBox}">
                  <Setter Property="Foreground" Value="Blue" />
               </Style>
            </DataGridTextColumn.EditingElementStyle>
         </DataGridTextColumn>
         <!--PosY - Posizione-->
         <DataGridTextColumn x:Key="colPOSY" Binding="{Binding sPOSY}" SortMemberPath="dPOSY">
            <DataGridTextColumn.HeaderTemplate>
               <DataTemplate>
                  <TextBlock Text="{Binding Path=DataContext.PosY_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdPartInRawPartListV}}}"/>
               </DataTemplate>
            </DataGridTextColumn.HeaderTemplate>
            <DataGridTextColumn.EditingElementStyle>
               <Style TargetType="{x:Type TextBox}">
                  <Setter Property="Foreground" Value="Blue" />
               </Style>
            </DataGridTextColumn.EditingElementStyle>
         </DataGridTextColumn>
         <!--Off - Offset-->
         <DataGridTextColumn x:Key="colOFFSET" Binding="{Binding sOffset}" SortMemberPath="dOffset">
            <DataGridTextColumn.HeaderTemplate>
               <DataTemplate>
                  <TextBlock Text="{Binding Path=DataContext.Offset_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdPartInRawPartListV}}}"/>
               </DataTemplate>
            </DataGridTextColumn.HeaderTemplate>
            <DataGridTextColumn.EditingElementStyle>
               <Style TargetType="{x:Type TextBox}">
                  <Setter Property="Foreground" Value="Blue" />
               </Style>
            </DataGridTextColumn.EditingElementStyle>
         </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:OnlyProdPartInRawPartListV}}}"/>
            </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:OnlyProdPartInRawPartListV}}}"/>
            </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:OnlyProdPartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>

      </DataGrid.Resources>
      <DataGrid.InputBindings>
         <KeyBinding Key="Delete" Command="{Binding Tag.SelPart.DeletePart_Command,
                                                    RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdPartInRawPartListV}}}" />
      </DataGrid.InputBindings>

   </EgtBEAMWALLCORE:EgtDataGrid>
</UserControl>
