<EgtWPFLib5:EgtCustomWindow x:Class="OnlyProdToolDbWindowV"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:sys="clr-namespace:System;assembly=mscorlib"
                            xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"
                            Title="{Binding Title}"
                            WindowStyle="None" ResizeMode="NoResize" TitleBarHeight="30" IsResizable="False"
                            IsMinimizable="False" WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
                            CloseCommand="{Binding CloseToolsDbCommand,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}"
                            CloseCommandParameter="{Binding Path=SelectedItem, ElementName=ToolsTreeView}"
                            Style="{StaticResource OnlyProd_EgtCustomWindow}">
   <EgtWPFLib5:EgtCustomWindow.InputBindings>
      <KeyBinding Key="Escape" Command="{Binding ReloadToolCommand}"
                  CommandParameter="{Binding Path=SelectedItem,ElementName=ToolsTreeView}"/>
   </EgtWPFLib5:EgtCustomWindow.InputBindings>

   <EgtWPFLib5:EgtCustomWindow.Resources>
      <EgtWPFLib5:ToolDrawUUIDConverter x:Key="ToolDrawUUIDConverter"/>
      <EgtWPFLib5:ErrorVisibilityConverter x:Key="ErrorVisibilityConverter"/>
   </EgtWPFLib5:EgtCustomWindow.Resources>

   <Grid>
      <Grid.ColumnDefinitions>
         <ColumnDefinition Width="0.75*"/>
         <ColumnDefinition Width="2*"/>
         <ColumnDefinition Width="1*"/>
      </Grid.ColumnDefinitions>

      <Grid>
         <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="10*"/>
            <RowDefinition Height="Auto"/>
         </Grid.RowDefinitions>

         <UniformGrid Grid.Row="0" Columns="3">
            <Button Content="{Binding NewMsg}" Command="{Binding NewCommand}"
                    CommandParameter="{Binding Path=SelectedItem, ElementName=ToolsTreeView}"
                    IsEnabled="{Binding IsEnabledNewBtn, Mode=OneWay}" Height="30"
                    Style="{StaticResource OnlyRightPanel_HalfRound_Button}"/>
            <Button Content="{Binding SaveMsg}" Command="{Binding SaveCommand}"
                    CommandParameter="{Binding Path=SelectedItem, ElementName=ToolsTreeView}"
                    IsEnabled="{Binding IsEnabledSaveBtn, Mode=OneWay}" Height="30"
                    Style="{StaticResource OnlyRightPanel_HalfRound_Button}"/>
            <Button Content="{Binding RemoveMsg}" Command="{Binding RemoveCommand}"
                    CommandParameter="{Binding Path=SelectedItem, ElementName=ToolsTreeView}"
                    IsEnabled="{Binding IsEnabledRemoveBtn, Mode=OneWay}" Height="30"
                    Style="{StaticResource OnlyRightPanel_HalfRound_Button}"/>
         </UniformGrid>

         <TreeView Name="ToolsTreeView" Grid.Row="1" ItemsSource="{Binding ToolsList}">
            <TreeView.Style>
               <Style TargetType="{x:Type TreeView}">
                  <Setter Property="Background">
                     <Setter.Value>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.35,0">
                           <GradientStop Color="{StaticResource BeamWall_Mercury_Color}" Offset="0"/>
                           <GradientStop Color="{StaticResource BeamWall_Concrete_Color}" Offset="0.45"/>
                           <GradientStop Color="{StaticResource BeamWall_White_Color}" Offset="1"/>
                        </LinearGradientBrush>
                     </Setter.Value>
                  </Setter>
               </Style>
            </TreeView.Style>

            <TreeView.ItemContainerStyle>
               <Style TargetType="{x:Type TreeViewItem}">
                  <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                  <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                  <Setter Property="IsEnabled" Value="{Binding IsEnabled, Mode=TwoWay}" />
               </Style>
            </TreeView.ItemContainerStyle>

            <TreeView.Resources>
               <HierarchicalDataTemplate DataType="{x:Type EgtWPFLib5:FamilyToolTreeViewItem}" ItemsSource="{Binding Items}">

                  <Grid Height="20">
                     <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="1*"/>
                     </Grid.ColumnDefinitions>

                     <Image Grid.Column="0" Source="{Binding PictureString}" Height="20" Width="20" Margin="0,0,5,0" />
                     <TextBlock Grid.Column="1" Text="{Binding Name}" FontSize="15" Margin="0,-2,5,0" VerticalAlignment="Center" />

                  </Grid>

               </HierarchicalDataTemplate>

               <DataTemplate DataType="{x:Type EgtWPFLib5:ToolTreeViewItem}">
                  <Grid Height="20">
                     <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="1*"/>
                     </Grid.ColumnDefinitions>

                     <!--<Image Grid.Column="0" Source="{Binding PictureString}" Height="32" Margin="0,8,6,4" />-->
                     <CheckBox Name="ActiveTxBx" Grid.Column="0" Height="15" Width="15" Margin="-15,0,5,0" VerticalContentAlignment="Center"
                               IsChecked="{Binding Active}"
                               Visibility="{Binding Path=DataContext.Active_Visibility,
                                                    RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}"/>
                     <TextBlock Grid.Column="1" Text="{Binding NamePar}" FontSize="15" Margin="0,-2,5,0" VerticalAlignment="Center" />

                  </Grid>
               </DataTemplate>

            </TreeView.Resources>

         </TreeView>

         <UniformGrid Grid.Row="2" Columns="3">
            <Button Content="{Binding ImportMsg}"
                    Command="{Binding ImportCommand}" 
                    IsEnabled="{Binding IsEnabledImpExpBtn, Mode=OneWay}"
                    Height="30"
                    Style="{StaticResource OnlyRightPanel_HalfRound_Button}"/>
            <Button Content="{Binding ExportMsg}"
                    Command="{Binding ExportCommand}"
                    IsEnabled="{Binding IsEnabledImpExpBtn, Mode=OneWay}"
                    Height="30"
                    Style="{StaticResource OnlyRightPanel_HalfRound_Button}"/>
            <Button Content="{Binding ResetMsg}" 
                    Command="{Binding ReloadToolCommand}" 
                    CommandParameter="{Binding Path=SelectedItem,ElementName=ToolsTreeView}" 
                    Height="30"
                    Style="{StaticResource OnlyRightPanel_HalfRound_Button}"/>
         </UniformGrid>

      </Grid>

      <ContentControl Content="{Binding Path=ParamPageV}" Grid.Column="1"/>

      <!--ContentControl che ospita la scena restituita sotto forma di WindowsFormsHost-->
      <ContentControl Content="{Binding ToolSceneHost}" Grid.Column="2"/>

   </Grid>

</EgtWPFLib5:EgtCustomWindow>
