<UserControl x:Class="WaterJetPageUC"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:EgtWPFLib="clr-namespace:EgtWPFLib;assembly=EgtWPFLib" 
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:self="clr-namespace:OmagCUT.TreeViewItem"
   mc:Ignorable="d" 
   d:DesignHeight="768" d:DesignWidth="1280" Initialized="WaterJetPage_Initialized">

    <!-- Definizione della PolishingsPage -->
    <Border Style="{DynamicResource OmagCut_PageBorder}">

        <Grid Name="WaterJetPageGrid" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="8*"/>
                <ColumnDefinition Width="4*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="8*"/>
                <RowDefinition Height="1*"/>
            </Grid.RowDefinitions>

            <!--Lista dei materiali-->
            <GroupBox Name="MaterialGpBx" Style="{DynamicResource OmagCut_GroupBox}" Grid.Column="0"
                      Header="{Binding Material_Msg}"
                      Grid.Row="0" BorderThickness="0">

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

                    <!--Lista dei materiali-->
                    <ListBox Name="MaterialsLstBx" 
                             ItemsSource="{Binding MaterialList}" SelectedItem="{Binding SelMaterial}"
                             Grid.RowSpan="2">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Name}" Style="{StaticResource OmagCut_LowerCaseCharacterTextBlock}"/>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                    <!--Campo visualizzato solo per aggiungere un nuovo materiale-->
                    <EgtWPFLib:EgtTextBox Name="NewMaterialNameTxBx" Grid.Row="1" 
                                          Width="220"
                                          Text="{Binding sNewMaterial}"
                                          Visibility="{Binding NewMaterial_Visibility}"
                                          Style="{DynamicResource OmagCut_KeyboardTextBox}" 
                                          KeyboardPosition="Top"/>
                    <!--Pulsanti per aggiungere/rimuovere/salvare la lista-->
                    <UniformGrid Grid.Row="2" Columns="3">
                        <Button Name="NewMaterialBtn" Grid.Column="0"
                                Content="{Binding New_Msg}"
                                Command="{Binding NewMaterialCommand}"
                                Style="{DynamicResource OmagCut_WjDbRightGrayGradientYellowTextButton}"/>
                        <Button Name="DeleteMaterialBtn" Grid.Column="1"
                                Content="{Binding Delete_Msg}"
                                Command="{Binding DeleteMaterialCommand}"
                                Style="{DynamicResource OmagCut_WjDbRightGrayGradientYellowTextButton}"/>
                        <Button Name="ModifyMaterialBtn" Grid.Column="1"
                                Content="{Binding Modify_Msg}"
                                Command="{Binding ModifyMaterialCommand}"
                                Style="{DynamicResource OmagCut_WjDbRightGrayGradientYellowTextButton}"/>
                    </UniformGrid>

                </Grid>

            </GroupBox>

            <!--Raggruppo all'interno della stessa cornice le sottocatogorie e i parametri-->
            <Border Style="{DynamicResource OmagCut_Border}" 
                    Grid.Column="1" Grid.Row="0" 
                    Grid.ColumnSpan="2" Grid.RowSpan="1">

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

                    <!--Sottocategoria dei materiali associata alla lista precedente-->
                    <GroupBox Name="SubMaterialGpBx" Style="{DynamicResource OmagCut_GroupBox}" 
                              Header="{Binding SubMaterial_Msg}"
                              Grid.Column="0" Grid.Row="0" 
                              Grid.ColumnSpan="1" Grid.RowSpan="8" BorderThickness="0">

                        <Grid Grid.Column="1">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="7*"/>
                                <RowDefinition Height="1*"/>
                                <RowDefinition Height="1*"/>
                            </Grid.RowDefinitions>

                            <!--Lista dei materiali-->
                            <ListBox Name="SubMaterialsLstBx" ItemsSource="{Binding Path=SelectedItem.SubMaterialList, ElementName=MaterialsLstBx}"
                                     SelectedItem="{Binding Path=SelectedItem.SelSubMaterial, ElementName=MaterialsLstBx}"
                                     Grid.RowSpan="2">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Name}" Style="{StaticResource OmagCut_LowerCaseCharacterTextBlock}"/>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>

                            <!--Campo visualizzato solo per aggiungere un nuovo materiale-->
                            <EgtWPFLib:EgtTextBox Name="NewSubMaterialNameTxBx" Grid.Row="1" 
                                                  Width="220"
                                                  Text="{Binding sNewSubMaterial}"
                                                  Visibility="{Binding NewSubMaterial_Visibility}"
                                                  Style="{DynamicResource OmagCut_KeyboardTextBox}" 
                                                  KeyboardPosition="Top"/>

                            <!--Pulsanti per aggiungere/rimuovere/salvare la lista-->
                            <UniformGrid Grid.Row="2" Columns="3">
                                <Button Name="NewSubMaterialBtn" Grid.Column="0"
                                        Content="{Binding New_Msg}"
                                        Command="{Binding NewSubMaterialCommand}"
                                        Style="{DynamicResource OmagCut_WjDbRightGrayGradientYellowTextButton}"/>
                                <Button Name="RemoveSubMaterialBtn" Grid.Column="1"
                                        Content="{Binding Delete_Msg}"
                                        Command="{Binding DeleteSubMaterialCommand}"
                                        Style="{DynamicResource OmagCut_WjDbRightGrayGradientYellowTextButton}"/>
                                <Button Name="ModifySubMaterialBtn" Grid.Column="1"
                                        Content="{Binding Modify_Msg}"
                                        Command="{Binding ModifySubMaterialCommand}"
                                        Style="{DynamicResource OmagCut_WjDbRightGrayGradientYellowTextButton}"/>
                            </UniformGrid>

                        </Grid>

                    </GroupBox>

                    <!--Lista dei parametri associata alla sottovcategoria dei materiali-->
                    <GroupBox Name="ParamsGpBx" 
                              Grid.Column="1" Grid.Row="0" Margin="0,0,0,3"
                              Grid.ColumnSpan="3" Grid.RowSpan="8" BorderThickness="0">
                        
                        <!--Titolazione delle colonne della tabella-->
                        <GroupBox.Header >
                            <Grid Width="700">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="1*"/>
                                    <ColumnDefinition Width="1*"/>
                                    <ColumnDefinition Width="1*"/>
                                    <ColumnDefinition Width="1*"/>
                                    <ColumnDefinition Width="1*"/>
                                    <ColumnDefinition Width="1*"/>
                                    <ColumnDefinition Width="1*"/>
                                </Grid.ColumnDefinitions>

                                <TextBlock Text="{Binding Thickness_Msg}" Grid.Column="0" HorizontalAlignment="Center"
                                           Style="{StaticResource OmagCut_LowerCaseCharacterTextBlock}" 
                                           FontSize="{DynamicResource FontSize_GroupBoxHeader}"/>
                                <TextBlock Text="{Binding Q1_Msg}" Grid.Column="1" HorizontalAlignment="Center"
                                           Style="{StaticResource OmagCut_LowerCaseCharacterTextBlock}"
                                           FontSize="{DynamicResource FontSize_GroupBoxHeader}"/>
                                <TextBlock Text="{Binding Q2_Msg}" Grid.Column="2" HorizontalAlignment="Center"
                                           Style="{StaticResource OmagCut_LowerCaseCharacterTextBlock}" 
                                           FontSize="{DynamicResource FontSize_GroupBoxHeader}"/>
                                <TextBlock Text="{Binding Q3_Msg}" Grid.Column="3" HorizontalAlignment="Center"
                                           Style="{StaticResource OmagCut_LowerCaseCharacterTextBlock}" 
                                           FontSize="{DynamicResource FontSize_GroupBoxHeader}"/>
                                <TextBlock Text="{Binding Q4_Msg}" Grid.Column="4" HorizontalAlignment="Center"
                                           Style="{StaticResource OmagCut_LowerCaseCharacterTextBlock}" 
                                           FontSize="{DynamicResource FontSize_GroupBoxHeader}"/>
                                <TextBlock Text="{Binding Q5_Msg}" Grid.Column="5" HorizontalAlignment="Center"
                                           Style="{StaticResource OmagCut_LowerCaseCharacterTextBlock}" 
                                           FontSize="{DynamicResource FontSize_GroupBoxHeader}"/>
                                <TextBlock Text="{Binding QExtra_Msg}" Grid.Column="6" HorizontalAlignment="Center"
                                           Style="{StaticResource OmagCut_LowerCaseCharacterTextBlock}" 
                                           FontSize="{DynamicResource FontSize_GroupBoxHeader}"/>
                            </Grid>
                            
                        </GroupBox.Header>
                        
                        <!--Definizione della Grid dei parametri delle lavorazioni-->
                        <Grid Grid.Column="2">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="7*"/>
                                <RowDefinition Height="1*"/>
                                <RowDefinition Height="1*"/>
                            </Grid.RowDefinitions>

                            <ListBox Name="ParamLstBx"
                                     ItemsSource="{Binding Path=SelectedItem.ParamList , ElementName=SubMaterialsLstBx}"
                                     SelectedItem="{Binding Path=SelectedItem.SelWjParam , ElementName=SubMaterialsLstBx}"
                                     Margin="0,0,0,0"
                                     Grid.RowSpan="2">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Grid Width="700">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="1*"/>
                                                <ColumnDefinition Width="1*"/>
                                                <ColumnDefinition Width="1*"/>
                                                <ColumnDefinition Width="1*"/>
                                                <ColumnDefinition Width="1*"/>
                                                <ColumnDefinition Width="1*"/>
                                                <ColumnDefinition Width="1*"/>
                                            </Grid.ColumnDefinitions>

                                            <EgtWPFLib:EgtTextBox Text="{Binding Thickness}" Grid.Column="0"
                                                       Style="{DynamicResource OmagCut_CalculatorParamWjTextBox}" />
                                            <EgtWPFLib:EgtTextBox Text="{Binding Q1}" Grid.Column="1"
                                                       Style="{DynamicResource OmagCut_CalculatorParamWjTextBox}" />
                                            <EgtWPFLib:EgtTextBox Text="{Binding Q2}" Grid.Column="2"
                                                       Style="{DynamicResource OmagCut_CalculatorParamWjTextBox}" />
                                            <EgtWPFLib:EgtTextBox Text="{Binding Q3}" Grid.Column="3"
                                                       Style="{DynamicResource OmagCut_CalculatorParamWjTextBox}" />
                                            <EgtWPFLib:EgtTextBox Text="{Binding Q4}" Grid.Column="4"
                                                       Style="{DynamicResource OmagCut_CalculatorParamWjTextBox}" />
                                            <EgtWPFLib:EgtTextBox Text="{Binding Q5}" Grid.Column="5"
                                                       Style="{DynamicResource OmagCut_CalculatorParamWjTextBox}" />
                                            <EgtWPFLib:EgtTextBox Text="{Binding QExtra}" Grid.Column="6"
                                                       Style="{DynamicResource OmagCut_CalculatorParamWjTextBox}" />

                                        </Grid>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>

                            <UniformGrid Grid.Row="2" Columns="9" Grid.ColumnSpan="3">
                                <Button Name="NewParamBtn" Grid.Column="0"
                                        Command="{Binding NewWjParamCommand}"
                                        Content="{Binding New_Msg}"
                                        Style="{DynamicResource OmagCut_WjDbRightGrayGradientYellowTextButton}"/>
                                <Button Name="RemoveParamBtn" Grid.Column="1"
                                        Command="{Binding DeleteWjParamCommand}"
                                        Content="{Binding Delete_Msg}"
                                        Style="{DynamicResource OmagCut_WjDbRightGrayGradientYellowTextButton}"/>
                            </UniformGrid>

                        </Grid>

                    </GroupBox>

                </Grid>
            </Border>
            <Button Name="SaveKitBtn" Grid.Row="2" Grid.Column="2"
                    Command="{Binding SaveCommand}"
                    Content="{Binding Save_Msg}"
                    Style="{DynamicResource OmagCut_RightGrayGradientYellowTextButton}"/>
        </Grid>

    </Border>

</UserControl>