<Window x:Class="ImportExportToolWD"
   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:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"
   FontFamily="{DynamicResource OmagCut_Font}"
   ResizeMode="NoResize" WindowStyle="None" AllowsTransparency="True" Background="Transparent"
   Title="SaveNameWD" Height="350" Width="426.5" ShowInTaskbar="False">
    <!--Definizione della pagina di scelta del nome con cui salvare il progetto-->
    <Border Style="{DynamicResource OmagCut_Border}">

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

            <ScrollViewer Grid.Row="0" Margin="20">
                <TreeView ItemsSource="{Binding FamilyList}" Background="{DynamicResource OmagCut_TreeViewBackGroundColor}">
                    <TreeView.Resources>
                        <HierarchicalDataTemplate DataType="{x:Type EgtWPFLib5:ImpExpToolFamily}" ItemsSource="{Binding ToolList}">

                            <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>
                            <!-- multibinding quando sono attivi.-->
                            <HierarchicalDataTemplate.ItemContainerStyle>
                                <Style TargetType="{x:Type TreeViewItem}" >
                                    <Setter Property="Foreground" Value="{DynamicResource OmagCut_TreeViewTextColor}" />
                                    <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                                    <Setter Property="IsExpanded" Value="{Binding IsExpanded}" />
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type TreeViewItem}">
                                                <Grid>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition MinWidth="19" Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="*"/>
                                                    </Grid.ColumnDefinitions>
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="Auto"/>
                                                        <RowDefinition/>
                                                    </Grid.RowDefinitions>
                                                    <ToggleButton x:Name="Expander" ClickMode="Press" IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ExpandCollapseToggleStyle}"/>
                                                    <Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.Column="1" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
                                                        <ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                                    </Border>
                                                    <ItemsPresenter x:Name="ItemsHost" Grid.ColumnSpan="2" Grid.Column="1" Grid.Row="1"/>
                                                    <Rectangle Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4" HorizontalAlignment="Stretch" VerticalAlignment="Top" Fill="{DynamicResource OmagCut_TreeViewDelimiterColor}" Height="1" />
                                                </Grid>
                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="IsExpanded" Value="false">
                                                        <Setter Property="Visibility" TargetName="ItemsHost" Value="Collapsed"/>
                                                    </Trigger>
                                                    <Trigger Property="HasItems" Value="false">
                                                        <Setter Property="Visibility" TargetName="Expander" Value="Hidden"/>
                                                    </Trigger>
                                                    <Trigger Property="IsSelected" Value="true">
                                                        <Setter Property="Background" TargetName="Bd" Value="{DynamicResource OmagCut_TreeViewSelectedItemBackground}" />
                                                        <Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource OmagCut_TreeViewSelectedItemBorder}"/>
                                                        <Setter Property="BorderThickness" TargetName="Bd" Value="1"/>
                                                        <!--<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>-->
                                                    </Trigger>
                                                    <!--<MultiTrigger>
                                       <MultiTrigger.Conditions>
                                          <Condition Property="IsSelected" Value="true"/>
                                          <Condition Property="IsSelectionActive" Value="false"/>
                                       </MultiTrigger.Conditions>
                                       <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                                       <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                                    </MultiTrigger>-->
                                                    <Trigger Property="IsEnabled" Value="false">
                                                        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                                                    </Trigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </HierarchicalDataTemplate.ItemContainerStyle>
                        </HierarchicalDataTemplate>

                        <DataTemplate DataType="{x:Type EgtWPFLib5:ImpExpToolItem}">
                            <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 Name}" 
                                           Style="{StaticResource OmagCut_ListBoxTextBlock}"  />

                            </Grid>
                        </DataTemplate>

                    </TreeView.Resources>
                </TreeView>
            </ScrollViewer>

            <Grid Grid.Column="1" Grid.Row="1">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="1*"/>
                </Grid.ColumnDefinitions>

                <Button Name="OkBtn" Grid.Row="0"  Grid.Column="1" Style="{DynamicResource OmagCut_GradientBlueIconButton}" 
                        Margin="5,-10,5,15"
                        Command="{Binding OkCommand}">
                <Image Source="{DynamicResource VImg}" Style="{StaticResource OmagCut_ButtonIcon}"/>
                </Button>
                <Button Name="ExitBtn" Grid.Row="0" Grid.Column="3" Style="{DynamicResource OmagCut_GradientBlueIconButton}" 
                        Margin="5,-10,5,15"
                        IsCancel="True">
                    <Image Source="{DynamicResource XImg}" Style="{StaticResource OmagCut_ButtonIcon}"/>
                </Button>
            </Grid>
                
        </Grid>

    </Border>

</Window>
