<DockPanel x:Class="ConfigurationPageV"
                                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                                xmlns:EgtFloating="clr-namespace:EgtWPFLib5.EgtFloating;assembly=EgtWPFLib5"
                                xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"
                                xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.ViewerOptimizer">

   <Grid>
      <Grid.ColumnDefinitions>
         <ColumnDefinition Width="10*"/>
         <ColumnDefinition Width="1*"/>
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
         <RowDefinition Height="6*"/>
         <RowDefinition Height="1*"/>
      </Grid.RowDefinitions>
      <TabControl Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="2"
                    SelectedIndex="{Binding SelConfigSubPage}">
         <TabItem Header="General">
            <TabItem.Content>
               <Grid>
                  <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="1*"/>
                     <ColumnDefinition Width="1*"/>
                     <ColumnDefinition Width="1*"/>
                  </Grid.ColumnDefinitions>
                  <Grid.RowDefinitions>
                     <RowDefinition Height="1*"/>
                     <RowDefinition Height="1*"/>
                  </Grid.RowDefinitions>
                  <StackPanel Grid.Row="0" Grid.Column="0" Margin="5,5,5,0">
                     <GroupBox Header="{Binding CurrentLanguage_Msg}"
                      Margin="0,0,0,5">
                        <UniformGrid Rows="2" Margin="3,3,3,3">
                           <ComboBox ItemsSource="{Binding LanguageList, Mode=OneWay}" Height="25"
                            DisplayMemberPath="Name" SelectedItem="{Binding SelectedLanguage}"
                            Margin="0,0,0,5"/>
                           <TextBlock Text="{Binding LanguageAdvert_Msg}" TextWrapping="Wrap"
                  TextAlignment="Center"/>
                        </UniformGrid>
                     </GroupBox>
                     <UniformGrid Columns="2"
                         Margin="0,0,0,5">
                        <TextBlock Text="{Binding MMUnits_Msg}" VerticalAlignment="Center"/>
                        <ComboBox ItemsSource="{Binding UnitMeasureList, Mode=OneWay}"
                                 SelectedIndex="{Binding SelMeasureUnit}" Height="25"
                                 Margin="0,5,0,0"/>
                     </UniformGrid>
                     <GroupBox Header="{Binding Nesting_Msg}"
                      Margin="0,0,0,5">
                        <StackPanel>
                           <UniformGrid Columns="2"
                         Margin="0,0,0,5">
                              <TextBlock Text="{Binding SectionTime_Msg}"
                          Grid.Row="0" Grid.Column="0"/>
                              <EgtWPFLib5:EgtTextBox Text="{Binding SectionTime, UpdateSourceTrigger=Explicit}"
                                      Grid.Row="0" Grid.Column="1"/>
                           </UniformGrid>
                           <UniformGrid Columns="2"
                         Margin="0,0,0,5">
                              <TextBlock Text="{Binding PartTime_Msg}"
                          Grid.Row="1" Grid.Column="0"/>
                              <EgtWPFLib5:EgtTextBox Text="{Binding PartTime, UpdateSourceTrigger=Explicit}"
                                      Grid.Row="1" Grid.Column="1"/>
                           </UniformGrid>
                        </StackPanel>
                     </GroupBox>
                     <UniformGrid Columns="2"
                         Margin="0,0,0,5">
                        <TextBlock Text="{Binding PrintLabel_Msg}" VerticalAlignment="Center"/>
                        <CheckBox IsChecked="{Binding bPrintLabel_IsChecked}"
                                 Margin="0,5,0,0"/>
                     </UniformGrid>
                     <GroupBox Header="Backup And Restore">
                        <Grid>
                           <Grid.RowDefinitions>
                              <RowDefinition Height="Auto"/>
                              <RowDefinition Height="Auto"/>
                              <RowDefinition Height="Auto"/>
                              <RowDefinition Height="Auto"/>
                           </Grid.RowDefinitions>
                           <Grid Grid.Row="0"
                                 Margin="0,2,0,5">
                              <Grid.ColumnDefinitions>
                                 <ColumnDefinition Width="Auto"/>
                                 <ColumnDefinition Width="1*"/>
                              </Grid.ColumnDefinitions>
                              <CheckBox x:Name="ExternalBackup_CheckBox"
                                        IsChecked="{Binding bExternalBackupActive}"
                                        VerticalAlignment="Center"/>
                              <TextBlock Grid.Column="1"
                                         Text="External file path:"
                                         VerticalAlignment="Center"/>
                           </Grid>
                           <Grid Grid.Row="1"
                                 Margin="0,2,0,5">
                              <Grid.ColumnDefinitions>
                                 <ColumnDefinition Width="1*"/>
                                 <ColumnDefinition Width="Auto"/>
                              </Grid.ColumnDefinitions>
                              <TextBox Text="{Binding ExternalBackupFolderPath}"
                                       IsEnabled="{Binding IsChecked, ElementName=ExternalBackup_CheckBox}"
                                       Margin="0,0,2.5,0"/>
                              <Button Grid.Column="1"
                                      Content="..."
                                      Width="18"
                                      Command="{Binding ChooseExternalBackupFolderPath_Command}"
                                      IsEnabled="{Binding IsChecked, ElementName=ExternalBackup_CheckBox}"
                                      Margin="2.5,0,0,0"/>
                           </Grid>
                           <Grid Grid.Row="2">
                              <Grid.ColumnDefinitions>
                                 <ColumnDefinition Width="1*"/>
                                 <ColumnDefinition Width="Auto"/>
                              </Grid.ColumnDefinitions>
                              <TextBlock Text="Reminder Frequency"/>
                              <ComboBox Grid.Column="1"
                                        ItemsSource="{Binding ReminderList}"
                                        SelectedItem="{Binding SelReminder}"/>
                           </Grid>
                           <StackPanel Grid.Row="3"
                                       Orientation="Horizontal">
                              <Button Content="Backup"
                                      Command="{Binding Backup_Command}"
                                      Style="{StaticResource ToolBar_TextButton}"/>
                              <Button Content="Restore"
                                      Command="{Binding Restore_Command}"
                                      Style="{StaticResource ToolBar_TextButton}"/>
                           </StackPanel>
                        </Grid>
                     </GroupBox>
                  </StackPanel>
               </Grid>
            </TabItem.Content>
         </TabItem>
         <TabItem Header="Parametri Q">
            <TabItem.Content>
               <Grid>
                  <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="2*"/>
                     <ColumnDefinition Width="1*"/>
                  </Grid.ColumnDefinitions>
                  <Grid.RowDefinitions>
                     <RowDefinition Height="1*"/>
                  </Grid.RowDefinitions>
                  <EgtBEAMWALL:QParamListV DataContext="{Binding}" 
                                           ItemsSource="{Binding QBTLParamVMList}"
                                           SelectedItem="{Binding SelQParam}"
                                           Grid.Column="0"
                                           Margin="5">
                     <DataGrid.GroupStyle>
                        <GroupStyle>
                           <GroupStyle.Panel>
                              <ItemsPanelTemplate>
                                 <DataGridRowsPresenter/>
                              </ItemsPanelTemplate>
                           </GroupStyle.Panel>
                           <GroupStyle.HeaderTemplate>
                              <DataTemplate>
                                 <StackPanel>
                                    <TextBlock Text="{Binding Path=Name}"/>
                                 </StackPanel>
                              </DataTemplate>
                           </GroupStyle.HeaderTemplate>
                           <GroupStyle.ContainerStyle>
                              <Style TargetType="{x:Type GroupItem}">
                                 <Setter Property="Template">
                                    <Setter.Value>
                                       <ControlTemplate TargetType="{x:Type GroupItem}">
                                          <Expander IsExpanded="True">
                                             <Expander.Background>
                                                <SolidColorBrush Color="#FFBABABA"></SolidColorBrush>
                                             </Expander.Background>
                                             <Expander.Header>
                                                <StackPanel Orientation="Horizontal">
                                                   <TextBlock Text="{Binding Path=Name}" />
                                                </StackPanel>
                                             </Expander.Header>
                                             <ItemsPresenter />
                                          </Expander>
                                       </ControlTemplate>
                                    </Setter.Value>
                                 </Setter>
                              </Style>
                           </GroupStyle.ContainerStyle>
                        </GroupStyle>
                        <GroupStyle>
                           <GroupStyle.ContainerStyle>
                              <Style TargetType="{x:Type GroupItem}">
                                 <Setter Property="Template">
                                    <Setter.Value>
                                       <ControlTemplate TargetType="{x:Type GroupItem}">
                                          <Expander IsExpanded="True">
                                             <Expander.Background>
                                                <SolidColorBrush Color="LightGray"></SolidColorBrush>
                                             </Expander.Background>
                                             <Expander.Header>
                                                <StackPanel Orientation="Horizontal">
                                                   <TextBlock Text="{Binding Path=Name}" />
                                                </StackPanel>
                                             </Expander.Header>
                                             <ItemsPresenter />
                                          </Expander>
                                       </ControlTemplate>
                                    </Setter.Value>
                                 </Setter>
                              </Style>
                           </GroupStyle.ContainerStyle>
                        </GroupStyle>
                     </DataGrid.GroupStyle>
                  </EgtBEAMWALL:QParamListV>
               </Grid>
            </TabItem.Content>
         </TabItem>
         <TabItem Header="Macchina">
            <TabItem.Content>
               <Grid>
                  <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="Auto"/>
                     <ColumnDefinition Width="1*"/>
                     <ColumnDefinition Width="1*"/>
                     <ColumnDefinition Width="1*"/>
                  </Grid.ColumnDefinitions>
                  <Grid.RowDefinitions>
                     <RowDefinition Height="Auto"/>
                     <RowDefinition Height="10*"/>
                  </Grid.RowDefinitions>

                  <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal">
                     <GroupBox Style="{StaticResource GroupBoxStyle_NoHeader}" Padding="5,10,5,5">
                        <EgtBEAMWALL:MachinePanelV  DataContext="{Binding MachinePanelVM}" VerticalAlignment="Center"/>
                     </GroupBox>
                  </StackPanel>

                  <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal">
                     <ItemsControl ItemsSource="{Binding ConfigMachTableList}">
                        <ItemsControl.ItemsPanel>
                           <ItemsPanelTemplate>
                              <StackPanel x:Name="GroupStackPanel" Orientation="Horizontal"/>
                           </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                           <DataTemplate>
                              <GroupBox Header="{Binding sName}"  Width="Auto" VerticalAlignment="Top" Height="Auto">
                                 <ItemsControl Name="MachParamsItemsControl" ItemsSource="{Binding MachParamList}" Margin="0,5,0,0">
                                    <ItemsControl.ItemsPanel>
                                       <ItemsPanelTemplate>
                                          <WrapPanel Orientation="Vertical"/>
                                       </ItemsPanelTemplate>
                                    </ItemsControl.ItemsPanel>
                                    <ItemsControl.ItemTemplate>
                                       <DataTemplate>
                                          <Grid Margin="0,0,5,5">
                                             <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="*" />
                                                <ColumnDefinition Width="*" />
                                                <ColumnDefinition Width="*" />
                                             </Grid.ColumnDefinitions>
                                             <TextBlock Text="{Binding sName}"
                                                        TextWrapping="WrapWithOverflow"
                                                        Width="100"
                                                        Style="{StaticResource MachParamTextBlock}"/>
                                             <EgtWPFLib5:EgtTextBox Text="{Binding sValue, UpdateSourceTrigger=Explicit}"
                                                                    Grid.Column="1"
                                                                    Width="70"/>
                                             <TextBlock Text="{Binding sDescription}"
                                                        TextWrapping="WrapWithOverflow"
                                                        Width="200"
                                                        Style="{StaticResource MachParamTextBlock}"
                                                        Grid.Column="2"/>
                                          </Grid>
                                       </DataTemplate>
                                    </ItemsControl.ItemTemplate>
                                 </ItemsControl>
                              </GroupBox>
                           </DataTemplate>
                        </ItemsControl.ItemTemplate>
                     </ItemsControl>
                  </StackPanel>
               </Grid>
            </TabItem.Content>
         </TabItem>
      </TabControl>

      <Button Command="{Binding SaveCommand}"
                ToolTip="{Binding SaveToolTip}"
                Grid.Row="1" 
                Grid.Column="1"
                Style="{StaticResource OptionPanel_Button}">
         <Image Source="/Resources/ProjectManager/Save.png" Stretch="Uniform"/>
      </Button>

   </Grid>
</DockPanel>
