<EgtWPFLib5:EgtCustomWindow x:Class="NewOpenProjectFileDialogV"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"
                            xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.Core"
                            Title="{Binding Title}"
                            Style="{DynamicResource {x:Type EgtWPFLib5:EgtCustomWindow}}"
                            WindowStyle="None" ResizeMode="NoResize" TitleBarHeight="30" IsResizable="True"
                            IsMinimizable="False" WindowStartupLocation="CenterScreen" ShowInTaskbar="False"
                            IsClosable="False"
                            MinHeight="500" MinWidth="500"
                            DataContext="{Binding RelativeSource={RelativeSource Self}}">

   <EgtWPFLib5:EgtCustomWindow.Resources>
      <EgtWPFLib5:FileNameConverter x:Key="FileNameConverter"/>
   </EgtWPFLib5:EgtCustomWindow.Resources>

   <Grid>
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto"/>
         <RowDefinition Height="5*"/>
         <RowDefinition Height="1*"/>
      </Grid.RowDefinitions>

      <GroupBox Header="{Binding Filters_Msg}"
                Margin="5"
                Visibility="{Binding Filters_Visibility}">
         <Grid>
            <Grid.RowDefinitions>
               <RowDefinition Height="Auto"/>
               <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid>
               <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="Auto"/>
                  <ColumnDefinition Width="1*"/>
                  <ColumnDefinition Width="Auto"/>
               </Grid.ColumnDefinitions>
               <ComboBox ItemsSource="{Binding BTLDateTypeList}"
                         SelectedIndex="{Binding SelBTLDateType}"
                         Width="105"
                         Margin="5"
                         Style="{StaticResource FeatureComboBox}"/>
               <StackPanel Grid.Column="1" Orientation="Horizontal">
                  <ComboBox ItemsSource="{Binding DayTypeList}"
                            SelectedIndex="{Binding SelDayType}"
                            Width="105"
                            Margin="0,0,2.5,0"
                            Style="{StaticResource PartParam_ComboBox}"/>
                  <StackPanel Orientation="Horizontal" Visibility="{Binding Date_Visibility}">
                     <TextBlock Text="{Binding From_Msg}"
                                Style="{StaticResource Filter_TextBlock}"/>
                     <DatePicker SelectedDate="{Binding dtStartDate}"
                                 Style="{StaticResource Filter_DatePicker}"/>
                     <TextBlock Text="{Binding To_Msg}"
                                Style="{StaticResource Filter_TextBlock}"/>
                     <DatePicker SelectedDate="{Binding dtEndDate}"
                                 Style="{StaticResource Filter_DatePicker}"/>
                  </StackPanel>
               </StackPanel>
               <CheckBox Grid.Column="2"
                         IsChecked="{Binding bViewArchived}"
                         Content="{Binding ViewArchived_Msg}"
                         VerticalAlignment="Center"/>
            </Grid>
            <Grid Grid.Row="1">
               <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="Auto"/>
                  <ColumnDefinition Width="1*"/>
                  <ColumnDefinition Width="Auto"/>
               </Grid.ColumnDefinitions>
               <ComboBox ItemsSource="{Binding FilterTypeList}"
                         SelectedItem="{Binding SelFilterType}"
                         Width="105"
                         Margin="5"
                         Style="{StaticResource FeatureComboBox}"/>
               <EgtWPFLib5:EgtTextBox Grid.Column="1"
                                      Text="{Binding SearchText}"
                                      Margin="5"
                                      Visibility="{Binding SearchText_Visibility}"/>
               <StackPanel Grid.Column="2" 
                           Orientation="Horizontal">
                  <TextBlock Text="{Binding Rows_Msg}"
                             Style="{StaticResource OptionTextBlock}"/>
                  <ComboBox ItemsSource="{Binding RowQuantityList}"
                            SelectedIndex="{Binding SelRowQuantity}"
                            Style="{StaticResource FeatureComboBox}"/>
               </StackPanel>
            </Grid>
         </Grid>
      </GroupBox>

      <EgtBEAMWALL:EgtDataGrid x:Name="MainDataGrid"
                               Grid.Row="1"
                               ItemsSource="{Binding ProjectList}" 
                               SelectedItem="{Binding SelProject}"
                               CanUserAddRows="False"
                               AutoGenerateColumns="False"
                               CanUserResizeRows="False"
                               SelectionMode="Single"
                               ScrollViewer.CanContentScroll="True" 
                               ScrollViewer.VerticalScrollBarVisibility="Auto"
                               ScrollViewer.HorizontalScrollBarVisibility="Auto"
                               Margin="5"
                               RowDetailsVisibilityMode="Visible"
                               CellEditEnding="MainDataGrid_CellEditEnding"
                               BindingColumns="{Binding ProdColumns}">
         <DataGrid.Resources>
            <!-- ProdId -->
            <DataGridTextColumn x:Key="colPRODID" Binding="{Binding sProdId}">
               <DataGridTextColumn.HeaderTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=DataContext.Id_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:NewOpenProjectFileDialogV}}}"/>
                  </DataTemplate>
               </DataGridTextColumn.HeaderTemplate>
            </DataGridTextColumn>
            <!--Name-->
            <DataGridTextColumn x:Key="colNAME" Binding="{Binding sName}">
               <DataGridTextColumn.Header>
                  <Grid>
                     <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="Auto"/>
                     </Grid.ColumnDefinitions>
                     <TextBlock Text="{Binding Path=DataContext.Name_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:NewOpenProjectFileDialogV}}}"/>
                     <ToggleButton Grid.Column="1"
                                   Margin="5,0,0,0"
                                   IsChecked="{Binding Path=DataContext.bIsEditNameActive,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:NewOpenProjectFileDialogV}}}"
                                   Style="{StaticResource ToolBar_SmallToggleButton}">
                        <Image Source="\Resources\CalcPanel\Edit.png"
                               Style="{StaticResource LockImage}"/>
                     </ToggleButton>
                  </Grid>
               </DataGridTextColumn.Header>
            </DataGridTextColumn>
            <!-- Creation date -->
            <DataGridTextColumn x:Key="colCRTDATE" Binding="{Binding dtCreateDate}">
               <DataGridTextColumn.Header>
                  <TextBlock Text="{Binding Path=DataContext.CreateDate_Msg, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:NewOpenProjectFileDialogV}}}"/>
               </DataGridTextColumn.Header>
            </DataGridTextColumn>
            <!-- Machine -->
            <DataGridTextColumn x:Key="colMACHINE" Binding="{Binding sMachine}">
               <DataGridTextColumn.Header>
                  <TextBlock Text="{Binding Path=DataContext.Machine_Msg, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:NewOpenProjectFileDialogV}}}"/>
               </DataGridTextColumn.Header>
            </DataGridTextColumn>
            <!-- Archived -->
            <DataGridTemplateColumn x:Key="colARCHIVED">
               <DataGridTemplateColumn.CellTemplate>
                  <DataTemplate>
                     <Image Source="\Resources\OpenProjectFileDialog\Archived.png"
                            Visibility="{Binding Archived_Visibility}"
                            Height="15"
                            Width="15"
                            Stretch="UniformToFill"/>
                  </DataTemplate>
               </DataGridTemplateColumn.CellTemplate>
               <DataGridTemplateColumn.Header>
                  <TextBlock Text="{Binding Path=DataContext.Archived_Msg, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:NewOpenProjectFileDialogV}}}"/>
               </DataGridTemplateColumn.Header>
            </DataGridTemplateColumn>
         </DataGrid.Resources>
         <DataGrid.RowStyle>
            <Style TargetType="DataGridRow">
               <Setter Property="FontWeight" Value="DemiBold"/>
               <Setter Property="VerticalContentAlignment" Value="Center"/>
               <EventSetter Event="MouseDoubleClick" Handler="ProjectList_MouseDoubleClick"/>
            </Style>
         </DataGrid.RowStyle>
         <DataGrid.RowDetailsTemplate>
            <DataTemplate>
               <ItemsControl ItemsSource="{Binding ProjFileList}"
                             BorderThickness="0"
                             Margin="0,-1,0,0"
                             Padding="0">
                  <ItemsControl.ItemTemplate>
                     <DataTemplate>
                        <Grid TextBlock.FontSize="12"
                              TextBlock.FontWeight="Normal">
                           <Grid.ColumnDefinitions>
                              <ColumnDefinition Width="{Binding Path=DataContext.ProdColumns[0].ActualWidth, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:NewOpenProjectFileDialogV}}}"/>
                              <ColumnDefinition Width="1*"/>
                           </Grid.ColumnDefinitions>
                           <Grid.RowDefinitions>
                              <RowDefinition Height="1"/>
                              <RowDefinition Height="1*"/>
                           </Grid.RowDefinitions>
                           <Grid Grid.Row="0"
                                 Grid.ColumnSpan="2"
                                 Background="Gray"
                                 Margin="40,0,40,0"/>
                           <Grid Grid.Column="1"
                                 Grid.Row="1"
                                 Margin="2">
                              <Grid.ColumnDefinitions>
                                 <ColumnDefinition Width="Auto"/>
                                 <ColumnDefinition Width="1*"/>
                                 <ColumnDefinition Width="Auto"/>
                                 <ColumnDefinition Width="1*"/>
                              </Grid.ColumnDefinitions>
                              <Grid.RowDefinitions>
                                 <RowDefinition Height="1*"/>
                                 <RowDefinition Height="1*"/>
                              </Grid.RowDefinitions>
                              <TextBlock Text="{Binding Path=DataContext.BTLFileName_Msg, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:NewOpenProjectFileDialogV}}}"
                                         Style="{StaticResource OpenWnd_TextBlock}"/>
                              <TextBlock Grid.Column="1"
                                         Text="{Binding sBTLFileName}"/>
                              <TextBlock Grid.Row="1"
                                         Text="{Binding Path=DataContext.ListName_Msg, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:NewOpenProjectFileDialogV}}}"
                                         Style="{StaticResource OpenWnd_TextBlock}"/>
                              <TextBlock Grid.Column="1"
                                         Grid.Row="1"
                                         Text="{Binding sListName}"/>
                              <TextBlock Grid.Column="2"
                                         Text="{Binding Path=DataContext.ExportDate_Msg, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:NewOpenProjectFileDialogV}}}"
                                         Style="{StaticResource OpenWnd_TextBlock}"/>
                              <TextBlock Grid.Column="3"
                                         Text="{Binding dtExportDate}"/>
                           </Grid>
                        </Grid>
                     </DataTemplate>
                  </ItemsControl.ItemTemplate>
               </ItemsControl>
            </DataTemplate>
         </DataGrid.RowDetailsTemplate>
      </EgtBEAMWALL:EgtDataGrid>

      <UniformGrid Columns="4" Grid.Row="2" Margin="0,0,0,5">
         <Button IsDefault="True" Name="OpenBtn"
                 Content="{Binding Open_Msg}" 
                 Style="{DynamicResource EgtWPFLib5_InputButton}"/>
         <Button Content="{Binding Archive_Msg}"
                 Command="{Binding Archive_Command}"
                 IsEnabled="{Binding bArchived_IsEnabled}"
                 Style="{DynamicResource EgtWPFLib5_InputButton}"/>
         <Button Content="{Binding Delete_Msg}"
                 Command="{Binding Delete_Command}"
                 IsEnabled="{Binding bDelete_IsEnabled}"
                 Style="{DynamicResource EgtWPFLib5_InputButton}"/>
         <Button Command="{Binding Cancel_Command}"
                 Content="{Binding Cancel_Msg}" 
                 Style="{DynamicResource EgtWPFLib5_InputButton}"/>
      </UniformGrid>

   </Grid>

</EgtWPFLib5:EgtCustomWindow>
