<EgtWPFLib5:EgtCustomWindow x:Class="OpenProjectFileDialogV"
                            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"
                            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="Filters"
                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*"/>
               </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>
            </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="Rows"
                             Style="{StaticResource OptionTextBlock}"/>
                  <ComboBox ItemsSource="{Binding RowQuantityList}"
                            SelectedIndex="{Binding SelRowQuantity}"
                            Style="{StaticResource FeatureComboBox}"/>
               </StackPanel>
            </Grid>
         </Grid>
      </GroupBox>


      <!--<StackPanel>
         <Grid Grid.Row="0" Margin="5">
            <Grid.RowDefinitions>
               <RowDefinition Height="1*" />
               <RowDefinition Height="1*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="1*" />
               <ColumnDefinition Width="1*" />
            </Grid.ColumnDefinitions>

            <TextBlock Text="{Binding FilterType_Msg}"
                           Grid.Row="0" Grid.Column="0"
                           Style="{StaticResource OptionTextBlock}"/>
            <ComboBox ItemsSource="{Binding SearchColumnList}"
                          SelectedItem="{Binding SelSearchColumn}"
                          Width="Auto"
                          Margin="5"
                          Grid.Row="0" Grid.Column="1"
                          Style="{StaticResource FeatureComboBox}"/>
            <TextBlock Text="{Binding Search_Msg}"
                           Margin="0,5,0,0"
                           Grid.Row="1" Grid.Column="0"
                           Style="{StaticResource OptionTextBlock}"/>
            <EgtWPFLib5:EgtTextBox Text="{Binding SearchText}"
                                       Margin="5"
                                       Grid.Row="1" Grid.Column="1"
                                       Visibility="{Binding SearchText_Visibility}"/>
            <Calendar SelectedDatesChanged="Calendar_SelectedDatesChanged"
                          SelectionMode="MultipleRange" 
                          Grid.Row="1" Grid.Column="1"
                          Visibility="{Binding SearchDate_Visibility}"/>
         </Grid>
      </StackPanel>-->

      <EgtBEAMWALL:EgtDataGrid 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"
               BindingColumns="{Binding ProjectColumns}">
         <DataGrid.Resources>
            <!-- ProjId -->
            <DataGridTextColumn x:Key="colPROJID" Binding="{Binding sProjId}">
               <DataGridTextColumn.HeaderTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=DataContext.Id_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OpenProjectFileDialogV}}}"/>
                  </DataTemplate>
               </DataGridTextColumn.HeaderTemplate>
            </DataGridTextColumn>
            <!-- ProdId -->
            <DataGridTextColumn x:Key="colPRODID" Binding="{Binding sProdId}">
               <DataGridTextColumn.HeaderTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=DataContext.Id_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OpenProjectFileDialogV}}}"/>
                  </DataTemplate>
               </DataGridTextColumn.HeaderTemplate>
            </DataGridTextColumn>
            <!-- Project Name -->
            <DataGridTextColumn x:Key="colPROJNAME" Binding="{Binding sDescription}">
               <DataGridTextColumn.HeaderTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=DataContext.BTLFileName_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OpenProjectFileDialogV}}}"/>
                  </DataTemplate>
               </DataGridTextColumn.HeaderTemplate>
            </DataGridTextColumn>
            <!-- BTL FileName -->
            <DataGridTextColumn x:Key="colBTLNAME" Binding="{Binding sBTLFileName}">
               <DataGridTextColumn.HeaderTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=DataContext.BTLFileName_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OpenProjectFileDialogV}}}"/>
                  </DataTemplate>
               </DataGridTextColumn.HeaderTemplate>
            </DataGridTextColumn>
            <!-- ListName -->
            <DataGridTextColumn x:Key="colLISTNAME" Binding="{Binding sListName}">
               <DataGridTextColumn.HeaderTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=DataContext.ListName_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OpenProjectFileDialogV}}}"/>
                  </DataTemplate>
               </DataGridTextColumn.HeaderTemplate>
            </DataGridTextColumn>
            <!-- Exported date -->
            <DataGridTextColumn x:Key="colEXPDATE" Binding="{Binding dtExportDate}">
               <DataGridTextColumn.HeaderTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=DataContext.ExportDate_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OpenProjectFileDialogV}}}"/>
                  </DataTemplate>
               </DataGridTextColumn.HeaderTemplate>
            </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:OpenProjectFileDialogV}}}"/>
               </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:OpenProjectFileDialogV}}}"/>
               </DataGridTextColumn.Header>
            </DataGridTextColumn>
            <!-- Name (per Prod) -->
            <DataGridTextColumn x:Key="colNAME" Binding="{Binding sName}">
               <DataGridTextColumn.Header>
                  <TextBlock Text="{Binding Path=DataContext.Name_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OpenProjectFileDialogV}}}"/>
               </DataGridTextColumn.Header>
            </DataGridTextColumn>
            <!-- Delete -->
            <!--
            <DataGridTemplateColumn x:Key="colDELETE"
                             Width="Auto"
                             IsReadOnly="True">
               <DataGridTemplateColumn.CellTemplate>
                  <DataTemplate>
                     <Button Content="X"
                             Command="{Binding Delete_Command}"/>
                  </DataTemplate>
               </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>-->
         </DataGrid.Resources>
         <!--<ListBox.ItemTemplate>
            <DataTemplate>
               <TextBlock Text="{Binding OpenFileName}"
                          Padding="4,1,4,1">
                  <TextBlock.InputBindings>
                     <MouseBinding MouseAction="LeftDoubleClick"
                                  Command="{Binding DataContext.ProjectDoubleClick_Command, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
                                  CommandParameter="{Binding nProjId}" />
                  </TextBlock.InputBindings>
               </TextBlock>
            </DataTemplate>
         </ListBox.ItemTemplate>-->
         <DataGrid.RowStyle>
            <Style TargetType="DataGridRow">
               <Setter Property="IsEnabled" Value="{Binding bIsEnabled}"/>
               <EventSetter Event="MouseDoubleClick" Handler="ProjectList_MouseDoubleClick"/>
            </Style>
         </DataGrid.RowStyle>
      </EgtBEAMWALL:EgtDataGrid>

      <!--<ListBox Grid.Row="0"
               ItemsSource="{Binding ProjectList}" 
               SelectedItem="{Binding SelProject}"
               Margin="5">
         -->
      <!--<ListBox.ItemTemplate>
            <DataTemplate>
               <TextBlock Text="{Binding ProjFileName}"/>
            </DataTemplate>
         </ListBox.ItemTemplate>-->
      <!--
         <ListBox.ItemContainerStyle>
            <Style TargetType="ListBoxItem">
               <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
               <Setter Property="Padding" Value="0"></Setter>
            </Style>
         </ListBox.ItemContainerStyle>
         <ListBox.ItemTemplate>
            <DataTemplate>
               <TextBlock Text="{Binding OpenFileName}"
                          Padding="4,1,4,1">
                  <TextBlock.InputBindings>
                     <MouseBinding MouseAction="LeftDoubleClick"
                                  Command="{Binding DataContext.ProjectDoubleClick_Command, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"
                                  CommandParameter="{Binding nProjId}" />
                  </TextBlock.InputBindings>
               </TextBlock>
            </DataTemplate>
         </ListBox.ItemTemplate>
      </ListBox>-->


      <UniformGrid Columns="3" Grid.Row="2" Margin="0,0,0,5">
         <Button IsDefault="True" Name="OpenBtn"
                 Content="{Binding Open_Msg}" Style="{DynamicResource EgtWPFLib5_InputButton}"/>
         <Button Content="{Binding Delete_Msg}"
                 Command="{Binding Delete_Command}"
                 Style="{DynamicResource EgtWPFLib5_InputButton}"/>
         <Button IsCancel="True"
                 Content="{Binding Cancel_Msg}" 
                 Style="{DynamicResource EgtWPFLib5_InputButton}"/>
      </UniformGrid>

   </Grid>

</EgtWPFLib5:EgtCustomWindow>
