<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.Supervisor"
           xmlns:EgtBEAMWALLCORE="clr-namespace:EgtBEAMWALL.Core;assembly=EgtBEAMWALL.Core">

    <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">
            <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>
                        </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="70"
                                                        Style="{StaticResource MachParamTextBlock}"/>
                                                            <EgtWPFLib5:EgtTextBox Text="{Binding sValue, UpdateSourceTrigger=Explicit}"
                                                                    Grid.Column="1"
                                                                    Width="70"/>
                                                            <TextBlock Text="{Binding sDescription}"
                                                        TextWrapping="WrapWithOverflow"
                                                        Width="70"
                                                        Style="{StaticResource MachParamTextBlock}"
                                                        Grid.Column="2"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </ItemsControl.ItemTemplate>
                                            </ItemsControl>
                                        </GroupBox>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </StackPanel>
                    </Grid>
                </TabItem.Content>
            </TabItem>-->
            <TabItem Header="Variabili">
                <TabItem.Content>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="1*"/>
                        </Grid.RowDefinitions>
                        <Grid Grid.Row="0" Margin="5">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="1*"/>
                                <ColumnDefinition Width="1*"/>
                            </Grid.ColumnDefinitions>
                            <Grid Grid.Column="0" Margin="5">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="1*"/>
                                    <ColumnDefinition Width="1*"/>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Button Content="+" 
                                    Grid.Column="2"
                                    Command="{Binding AddVariable_Command}"
                                    Style="{StaticResource ToolBar_SmallButton}"/>
                                <Button Content="-" 
                                        Grid.Column="3"
                                        Command="{Binding RemoveVariable_Command}"
                                        Style="{StaticResource ToolBar_SmallButton}"/>
                            </Grid>
                        </Grid>
                        <Grid Grid.Row="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="1*"/>
                                <ColumnDefinition Width="1*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="1*"/>
                            </Grid.RowDefinitions>
                            <EgtBEAMWALLCORE:EgtDataGrid 
                                       ItemsSource="{Binding VariablesList}" 
                                       SelectedItem="{Binding SelVariable}"
                                       CanUserAddRows="False"
                                       AutoGenerateColumns="False"
                                       CanUserResizeRows="False"
                                       SelectionMode="Single"
                                       ScrollViewer.CanContentScroll="True" 
                                       ScrollViewer.VerticalScrollBarVisibility="Auto"
                                       ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                       Margin="5"
                                       BindingColumns="{Binding VariablesColumns}">
                                <DataGrid.Resources>
                                    <!-- Name -->
                                    <DataGridTextColumn x:Key="colNAME" Binding="{Binding sName}">
                                        <DataGridTextColumn.HeaderTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Path=DataContext.Name_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:ConfigurationPageV}}}"/>
                                            </DataTemplate>
                                        </DataGridTextColumn.HeaderTemplate>
                                    </DataGridTextColumn>
                                    <!-- VariablePath -->
                                    <DataGridTextColumn x:Key="colVARPATH" Binding="{Binding sVarPath}">
                                        <DataGridTextColumn.HeaderTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Path=DataContext.VarPath_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:ConfigurationPageV}}}"/>
                                            </DataTemplate>
                                        </DataGridTextColumn.HeaderTemplate>
                                    </DataGridTextColumn>
                                    <!-- Type -->
                                    <DataGridComboBoxColumn x:Key="colTYPE">
                                        <DataGridComboBoxColumn.HeaderTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Path=DataContext.Type_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:ConfigurationPageV}}}"/>
                                            </DataTemplate>
                                        </DataGridComboBoxColumn.HeaderTemplate>
                                        <DataGridComboBoxColumn.ElementStyle>
                                            <Style TargetType="ComboBox">
                                                <Setter Property="ItemsSource" Value="{Binding TypeList}"/>
                                                <Setter Property="SelectedItem" Value="{Binding SelType, UpdateSourceTrigger=PropertyChanged}" />
                                            </Style>
                                        </DataGridComboBoxColumn.ElementStyle>
                                        <DataGridComboBoxColumn.EditingElementStyle>
                                            <Style TargetType="ComboBox">
                                                <Setter Property="ItemsSource" Value="{Binding TypeList}"/>
                                                <Setter Property="SelectedItem" Value="{Binding SelType, UpdateSourceTrigger=PropertyChanged}" />
                                            </Style>
                                        </DataGridComboBoxColumn.EditingElementStyle>
                                    </DataGridComboBoxColumn>
                                </DataGrid.Resources>
                            </EgtBEAMWALLCORE:EgtDataGrid>
                        </Grid>
                    </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>
