<EgtWPFLib5:EgtCustomWindow x:Class="WarehouseWndV"
                            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"
                            Width="{Binding WarehouseWnd_Width, Mode=TwoWay}"
                            xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.ViewerOptimizer"
                            xmlns:EgtBEAMWALLCORE="clr-namespace:EgtBEAMWALL.Core;assembly=EgtBEAMWALL.Core"
                            Style="{DynamicResource {x:Type EgtWPFLib5:EgtCustomWindow}}"
                            WindowStyle="None" ResizeMode="NoResize"
                            SizeToContent="Height"
                            MinHeight="300"
                            MinWidth="300"
                            MaxHeight="700"
                            ShowInTaskbar="False"
                            WindowStartupLocation="CenterOwner"
                            IsClosable="True"
                            IsMinimizable="False"
                            IsResizable="True"
                            Title="WarehouseWndV"
                            Name="WarehouseWndV">

   <Grid Margin="5,5,5,0">
      <Grid.ColumnDefinitions>
         <ColumnDefinition Width="1*"/>
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto"/>
         <RowDefinition Height="1*"/>
         <RowDefinition Height="Auto"/>
         <RowDefinition Height="Auto"/>
         <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>

      <Grid >
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="2*"/>
            <ColumnDefinition Width="1*"/>
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
         </Grid.RowDefinitions>

         <TextBlock Text="{Binding CurrentS_Msg}"
                    Grid.Row="0"
                    Style="{StaticResource PartParam_TextBlock}"
                    Visibility="{Binding Basic_Visibility}"/>
         <ComboBox ItemsSource="{Binding Path=SParamList, 
                                         Mode=OneWay}"
                   SelectedItem="{Binding Path=SelCurrentS, 
                                           Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                   DisplayMemberPath="sValue"
                   Grid.Row="0"
                   Grid.Column="1"
                   Style="{StaticResource Warehouse_ComboBox}"
                   Visibility="{Binding Basic_Visibility}"/>

         <TextBlock Text="{Binding StartOffset_Msg}"
                    Grid.Row="1"
                    Style="{StaticResource PartParam_TextBlock}"
                    Visibility="{Binding StartOffset_Visibility}"/>
         <EgtWPFLib5:EgtTextBox Text="{Binding dStartOffset, UpdateSourceTrigger=PropertyChanged}"
                                Grid.Row="1"
                                Grid.Column="1"
                                Style="{StaticResource Warehouse_TextBox}"
                                Visibility="{Binding StartOffset_Visibility}"/>

         <TextBlock Text="{Binding Kerf_Msg}"
                    Grid.Row="1"
                    Style="{StaticResource PartParam_TextBlock}"
                    Visibility="{Binding Kerf_Visibility}"/>
         <EgtWPFLib5:EgtTextBox Text="{Binding dKerf, UpdateSourceTrigger=PropertyChanged}"
                                Grid.Row="1"
                                Grid.Column="1"
                                Style="{StaticResource Warehouse_TextBox}"
                                Visibility="{Binding Kerf_Visibility}"/>

         <TextBlock Text="{Binding Offset_Msg}"
                    Grid.Row="2"
                    Style="{StaticResource PartParam_TextBlock}"
                    Visibility="{Binding Offset_Visibility}"/>
         <EgtWPFLib5:EgtTextBox Text="{Binding dOffset, Mode=TwoWay, UpdateSourceTrigger=LostFocus}"
                                Grid.Row="2"
                                Grid.Column="1"
                                Style="{StaticResource Warehouse_TextBox}"
                                Visibility="{Binding Offset_Visibility}"/>

         <TextBlock Text="{Binding Quantity_Msg}"
                    Grid.Row="3"
                    Style="{StaticResource PartParam_TextBlock}"
                    Visibility="{Binding Basic_Visibility}"/>
         <EgtWPFLib5:EgtTextBox Text="{Binding nQuantity, UpdateSourceTrigger=PropertyChanged}"
                                Grid.Row="3"
                                Grid.Column="1"
                                Style="{StaticResource Warehouse_TextBox}"
                                Visibility="{Binding Basic_Visibility}"/>

         <GroupBox Grid.Row="3" Grid.ColumnSpan="3"
                   Margin="0,0,0,5" 
                   Header="{Binding Offset_Msg}"
                   Visibility="{Binding MediumWall_Visibility}">
            <Grid Grid.Row="3" Grid.ColumnSpan="3">
               <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="1*"/>
                  <ColumnDefinition Width="Auto"/>
                  <ColumnDefinition Width="Auto"/>
               </Grid.ColumnDefinitions>
               <Grid.RowDefinitions>
                  <RowDefinition Height="Auto"/>
                  <RowDefinition Height="1*"/>
               </Grid.RowDefinitions>

               <Grid Grid.Row="0" Grid.Column="0">
                  <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="1*"/>
                     <ColumnDefinition Width="1*"/>
                     <ColumnDefinition Width="1*"/>
                  </Grid.ColumnDefinitions>
                  <TextBlock Text="{Binding MinThickness_Msg}"
                             Grid.Column="0"
                             HorizontalAlignment="Center"/>
                  <TextBlock Text="{Binding Value_Msg}"
                             Grid.Column="1"
                             HorizontalAlignment="Center"/>
                  <TextBlock Text="{Binding MaxThickness_Msg}"
                             Grid.Column="2"
                             HorizontalAlignment="Center"/>
               </Grid>

               <Button Content="+" 
                       Grid.Column="1"
                       Command="{Binding AddWhWallParam_Command}"
                       Style="{StaticResource ToolBar_SmallButton}"/>
               <Button Content="-" 
                       Grid.Column="2"
                       Command="{Binding RemoveWhWallParam_Command}"
                       Style="{StaticResource ToolBar_SmallButton}"/>

               <Grid Grid.Row="1" Grid.Column="0">
                  <EgtWPFLib5:EgtScrollViewer Focusable="False" MaxHeight="200" VerticalScrollBarVisibility="Auto">
                     <ItemsControl ItemsSource="{Binding WhWallParamList}">
                        <ItemsControl.ItemTemplate>
                           <DataTemplate>
                              <Grid>
                                 <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="1*" />
                                    <ColumnDefinition Width="1*" />
                                    <ColumnDefinition Width="1*" />
                                 </Grid.ColumnDefinitions>
                                 <TextBlock Text="{Binding dMinThickness, Mode=OneWay}"
                                            Grid.Column="0"
                                            Width="70"
                                            Margin="15,5"
                                            HorizontalAlignment="Center"/>
                                 <EgtWPFLib5:EgtTextBox Text="{Binding dOffset, UpdateSourceTrigger=Explicit}"
                                                        Grid.Column="1"
                                                        Width="70"
                                                        Margin="15,5"/>
                                 <EgtWPFLib5:EgtTextBox Text="{Binding dMaxThickness, UpdateSourceTrigger=Explicit}"
                                                        Grid.Column="2"
                                                        Width="70"
                                                        Margin="15,5"/>
                              </Grid>
                           </DataTemplate>
                        </ItemsControl.ItemTemplate>
                     </ItemsControl>
                  </EgtWPFLib5:EgtScrollViewer>
               </Grid>
            </Grid>
         </GroupBox>

      </Grid>

      <GroupBox Header="{Binding SParams_Msg}" Grid.Row="1" Grid.Column="0" Margin="0,0,0,5" Visibility="{Binding Basic_Visibility}">
         <ListBox ItemsSource="{Binding SParamList}" 
                  SelectedItem="{Binding SelSParam}"
                  DisplayMemberPath="sValue"
                  Margin="5"
                  MinHeight="40"/>
      </GroupBox>

      <GroupBox Header="{Binding SParams_Msg}" Grid.Row="1" Grid.Column="0" Margin="0,0,0,5" Visibility="{Binding Medium_Visibility}">
         <Grid>
            <Grid.RowDefinitions>
               <RowDefinition Height="Auto"/>
               <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0"
                  Margin="0,0,0,5">
               <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="1*"/>
                  <ColumnDefinition Width="1*"/>
                  <ColumnDefinition Width="Auto"/>
                  <ColumnDefinition Width="Auto"/>
               </Grid.ColumnDefinitions>
               <Button Content="+" 
                       Grid.Column="2"
                       Command="{Binding AddMediumParam_Command}"
                       Style="{StaticResource ToolBar_SmallButton}"/>
               <Button Content="-" 
                       Grid.Column="3"
                       Command="{Binding RemoveMediumParam_Command}"
                       Style="{StaticResource ToolBar_SmallButton}"/>
            </Grid>
            <EgtBEAMWALLCORE:EgtDataGrid Grid.Row="1"
                                       ItemsSource="{Binding SParamList}" 
                                       SelectedItem="{Binding SelSParam}"
                                       CanUserAddRows="False"
                                       AutoGenerateColumns="False"
                                       CanUserResizeRows="False"
                                       SelectionMode="Single"
                                       ScrollViewer.CanContentScroll="True" 
                                       ScrollViewer.VerticalScrollBarVisibility="Auto"
                                       ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                       BindingColumns="{Binding SParamColumns}">
               <DataGrid.Resources>
                  <!-- Active -->
                  <DataGridTemplateColumn x:Key="colACTIVE" >
                     <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                           <CheckBox IsChecked="{Binding bActive, UpdateSourceTrigger=PropertyChanged}"
                                     VerticalAlignment="Center"/>
                        </DataTemplate>
                     </DataGridTemplateColumn.CellTemplate>
                  </DataGridTemplateColumn>
                  <!-- SectionXMaterial -->
                  <DataGridComboBoxColumn x:Key="colSECTXMAT"
                                          DisplayMemberPath="sSectionXMaterial"
                                          SortMemberPath="SectionXMaterialDisplayOrder">
                     <DataGridComboBoxColumn.HeaderTemplate>
                        <DataTemplate>
                           <TextBlock Text="{Binding Path=DataContext.SectionXMaterial_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:WarehouseWndV}}}"/>
                        </DataTemplate>
                     </DataGridComboBoxColumn.HeaderTemplate>
                     <DataGridComboBoxColumn.ElementStyle>
                        <Style TargetType="ComboBox">
                           <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type EgtBEAMWALL:WarehouseWndV}}, Path=DataContext.SectionXMaterialList}"/>
                           <Setter Property="SelectedItem" Value="{Binding SectXMat, UpdateSourceTrigger=PropertyChanged}" />
                        </Style>
                     </DataGridComboBoxColumn.ElementStyle>
                     <DataGridComboBoxColumn.EditingElementStyle>
                        <Style TargetType="ComboBox">
                           <Setter Property="ItemsSource" Value="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type EgtBEAMWALL:WarehouseWndV}}, Path=DataContext.SectionXMaterialList}"/>
                           <Setter Property="SelectedItem" Value="{Binding SectXMat, UpdateSourceTrigger=PropertyChanged}" />
                        </Style>
                     </DataGridComboBoxColumn.EditingElementStyle>
                  </DataGridComboBoxColumn>
                  <!-- W -->
                  <DataGridTextColumn x:Key="colW" Binding="{Binding dW}">
                     <DataGridTextColumn.HeaderTemplate>
                        <DataTemplate>
                           <TextBlock Text="{Binding Path=DataContext.W_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:WarehouseWndV}}}"/>
                        </DataTemplate>
                     </DataGridTextColumn.HeaderTemplate>
                  </DataGridTextColumn>
                  <!-- L -->
                  <DataGridTextColumn x:Key="colL" Binding="{Binding dL}">
                     <DataGridTextColumn.HeaderTemplate>
                        <DataTemplate>
                           <TextBlock Text="{Binding Path=DataContext.L_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:WarehouseWndV}}}"/>
                        </DataTemplate>
                     </DataGridTextColumn.HeaderTemplate>
                  </DataGridTextColumn>
                  <!-- Quantity -->
                  <DataGridTextColumn x:Key="colQTY" Binding="{Binding nQuantity}">
                     <DataGridTextColumn.HeaderTemplate>
                        <DataTemplate>
                           <TextBlock Text="{Binding Path=DataContext.Quantity_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:WarehouseWndV}}}"/>
                        </DataTemplate>
                     </DataGridTextColumn.HeaderTemplate>
                  </DataGridTextColumn>
               </DataGrid.Resources>
            </EgtBEAMWALLCORE:EgtDataGrid>
         </Grid>
      </GroupBox>

      <Grid Grid.Row="2" Margin="0,0,0,5" Visibility="{Binding AddRemoveBtns_Visibility}">
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="1*"/>
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
            <RowDefinition Height="1*"/>
         </Grid.RowDefinitions>
         <Button Content="+"
           FontSize="20"
           FontWeight="Light"
              Grid.Row="1"
                 Grid.Column="0"
           Style="{StaticResource ToolBar_Button}"
           Command="{Binding AddParam_Command}">
         </Button>

         <Button Content="-"
           FontSize="20"
           FontWeight="Light"
              Grid.Row="1"
                 Grid.Column="1"
           Style="{StaticResource ToolBar_Button}"
           Command="{Binding RemoveParam_Command}">
         </Button>
      </Grid>

      <GroupBox Header="{Binding NewParam_Msg}" Margin="0,0,0,5"  Grid.Row="3" Visibility="{Binding NewBeamParam_Visibility}">
         <Grid>
            <Grid.RowDefinitions>
               <RowDefinition Height="1*"/>
               <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="1*"/>
               <ColumnDefinition Width="2*"/>
            </Grid.ColumnDefinitions>
            <TextBlock Text="{Binding L_Msg}"
                    Style="{StaticResource PartParam_TextBlock}"/>
            <EgtWPFLib5:EgtTextBox Text="{Binding sNewL, UpdateSourceTrigger=PropertyChanged}"
                                Grid.Column="1"
                                HorizontalAlignment="Right"
                                Style="{StaticResource Warehouse_TextBox}"/>
            <Grid Grid.Row="1" Grid.ColumnSpan="2">
               <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="1*"/>
                  <ColumnDefinition Width="1*"/>
               </Grid.ColumnDefinitions>
               <Button Content="{Binding OkAddParam_Msg}"
                    Grid.Column="0"
                    Height="30"
                    Margin="0,0,2.5,0"
                    Command="{Binding OkAddParam_Command}">
               </Button>
               <Button Content="{Binding Cancel_Msg}"
                    Grid.Column="1"
                    Height="30"
                    Margin="2.5,0,0,0"
                    Command="{Binding CancelAddParam_Command}">
               </Button>
            </Grid>
         </Grid>
      </GroupBox>

      <GroupBox Header="{Binding NewParam_Msg}" Margin="0,0,0,5" Grid.Row="3" Visibility="{Binding NewWallParam_Visibility}">
         <Grid >
            <Grid.RowDefinitions>
               <RowDefinition Height="1*"/>
               <RowDefinition Height="1*"/>
               <RowDefinition Height="1.2*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="1*"/>
               <ColumnDefinition Width="2*"/>
            </Grid.ColumnDefinitions>
            <TextBlock Text="{Binding W_Msg}"
                    Style="{StaticResource PartParam_TextBlock}"/>
            <EgtWPFLib5:EgtTextBox Text="{Binding sNewW, UpdateSourceTrigger=PropertyChanged}"
                                   Grid.Column="1"
                                   HorizontalAlignment="Right"
                                   Style="{StaticResource Warehouse_TextBox}"/>
            <TextBlock Text="{Binding L_Msg}"
                       Grid.Row="1"
                    Style="{StaticResource PartParam_TextBlock}"/>
            <EgtWPFLib5:EgtTextBox Text="{Binding sNewL, UpdateSourceTrigger=PropertyChanged}"
                                   Grid.Row="1"
                                   Grid.Column="1"
                                   HorizontalAlignment="Right"
                                   Style="{StaticResource Warehouse_TextBox}"/>
            <Grid Grid.Row="2" Grid.ColumnSpan="2">
               <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="368*"/>
                  <ColumnDefinition Width="117*"/>
                  <ColumnDefinition Width="251*"/>
               </Grid.ColumnDefinitions>
               <Button Content="{Binding OkAddParam_Msg}"
                    Grid.Column="0"
                    Height="30"
                    Margin="0,0,2,0"
                    Command="{Binding OkAddParam_Command}">
               </Button>
               <Button Content="{Binding Cancel_Msg}"
                    Grid.Column="1"
                    Height="30"
                    Margin="2,0,0,0"
                    Command="{Binding CancelAddParam_Command}" Grid.ColumnSpan="2">
               </Button>
            </Grid>
         </Grid>
      </GroupBox>

      <Grid Grid.Row="4"
            Margin="0,0,0,5">
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="1*"/>
         </Grid.ColumnDefinitions>
         <Button Content="{Binding Save_Msg}"
                    Grid.Column="0"
                    Height="30"
                    Margin="0,0,2.5,0"
                    Command="{Binding Save_Command}">
         </Button>
         <Button Content="{Binding Cancel_Msg}"
                    Grid.Column="1"
                    Height="30"
                    Margin="2.5,0,0,0"
                    Command="{Binding Cancel_Command}">
         </Button>
      </Grid>

   </Grid>

</EgtWPFLib5:EgtCustomWindow>
