<UserControl
    x:Class="MECF.Framework.UI.Client.CenterViews.Editors.Recipe.RecipeSelectDialogView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:editors="clr-namespace:MECF.Framework.UI.Client.CenterViews.Editors"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:lex="http://wpflocalizeextension.codeplex.com"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:micro="clr-namespace:Caliburn.Micro"
    Width="350"
    Height="500"
    lex:LocalizeDictionary.DesignCulture="en"
    lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
    lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
    mc:Ignorable="d">
    <UserControl.Resources>
        <HierarchicalDataTemplate x:Key="FolderTemplate" ItemsSource="{Binding Files}">
            <StackPanel Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext}">
                <Image
                    x:Name="ExpandImage"
                    Width="14"
                    Height="12"
                    Margin="2,0,0,0"
                    VerticalAlignment="Center"
                    Source="/MECF.Framework.UI.Client;component/Resources/Images/Folder_Close.png" />
                <TextBlock
                    Margin="5,0,0,0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    Text="{Binding Name}" />
            </StackPanel>
            <HierarchicalDataTemplate.Triggers>
                <Trigger Property="IsEnabled" Value="false">
                    <Setter TargetName="ExpandImage" Property="Image.Source" Value="/MECF.Framework.UI.Client;component/Resources/Images/Folder_Unable.png" />
                </Trigger>
            </HierarchicalDataTemplate.Triggers>
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate x:Key="FileTemplate" ItemsSource="{Binding Files}">
            <StackPanel Orientation="Horizontal" Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext}">
                <Path
                    Width="13"
                    Height="16"
                    HorizontalAlignment="Left"
                    Data="M0.5,5.125 L5.125,5.125 5.125,0.5 M5.1,0.5 L15.5,0.5 15.5,19.5 0.5,19.5 C0.5,14.7 0.5,10 0.5,5.1 2,3.6 3.6,2 5.1,0.5 z M8.1,8.5 L8.2,8.5 z M8.1,11.5 L8.2,11.5 z M8.1,14.5 L8.2,14.5 z"
                    Fill="#FFF3F3F3"
                    Stretch="Fill"
                    Stroke="#FF454545" />
                <TextBlock
                    Margin="5,0,0,0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    Text="{Binding Name}" />
            </StackPanel>
        </HierarchicalDataTemplate>
        <editors:FolderOrFileTemplateSelector
            x:Key="FolderFileTemplateSelector"
            FileTemplate="{StaticResource FileTemplate}"
            FolderTemplate="{StaticResource FolderTemplate}" />

    </UserControl.Resources>

    <Border
        Background="{DynamicResource Tab_BG}"
        BorderBrush="Gray"
        BorderThickness="0,1,0,0">
        <Grid Margin="10">
            <Grid.RowDefinitions>
                <RowDefinition Height="40" />
                <RowDefinition />
                <RowDefinition Height="auto" />
            </Grid.RowDefinitions>

            <StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0 0 0 3">
                <Label
                    Margin="5,0,0,0"
                    VerticalAlignment="Center"
                    Content="{lex:Loc ID_TXT_Filter}"
                    FontSize="16" />
                <TextBox
                    Width="226"
                    Height="26"
                    Margin="0,0,5,0"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Center"
                    Text="{Binding CurrentCriteria, UpdateSourceTrigger=PropertyChanged}" />
                <Button
                    Width="30"
                    Height="30"
                    Margin="0,0,5,0"
                    Padding="0"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Center">
                    <Button.Content>
                        <Path
                            Width="15"
                            Height="15"
                            Margin="0,3"
                            Data="M5.5,0 L8.5,0 8.5,5.5 14,5.5 14,8.5 8.5,8.5 8.5,14 5.5,14 5.5,8.5 0,8.5 0,5.5 5.5,5.5 z"
                            Fill="Black"
                            RenderTransformOrigin="0.5,0.5"
                            Stretch="Fill"
                            StrokeThickness="3">
                            <Path.RenderTransform>
                                <TransformGroup>
                                    <ScaleTransform />
                                    <SkewTransform />
                                    <RotateTransform Angle="45" />
                                    <TranslateTransform />
                                </TransformGroup>
                            </Path.RenderTransform>
                        </Path>
                    </Button.Content>
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <micro:ActionMessage MethodName="ClearFilter" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
            </StackPanel>

            <Border
                Grid.Row="1"
                Background="Transparent"
                BorderBrush="{DynamicResource Table_BD}"
                BorderThickness="0">
                <TabControl
                    Padding="0"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    HorizontalContentAlignment="Stretch"
                    VerticalContentAlignment="Stretch"
                    ItemsSource="{Binding ProcessTypeFileList}"
                    SelectedIndex="{Binding ProcessTypeIndexSelection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                    <TabControl.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding ProcessType}" />
                        </DataTemplate>
                    </TabControl.ItemTemplate>
                    <TabControl.ContentTemplate>
                        <DataTemplate>
                            <TreeView
                                x:Name="RecipeTree1"
                                Height="{Binding Path=ActualHeight, ElementName=PART_BORDER, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
                                Margin="0"
                                VerticalAlignment="Stretch"
                                ItemTemplateSelector="{StaticResource FolderFileTemplateSelector}"
                                ItemsSource="{Binding FileListByProcessType}"
                                Tag="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext}"
                                VirtualizingPanel.IsVirtualizing="True"
                                VirtualizingPanel.VirtualizationMode="Recycling">
                                <TreeView.ItemContainerStyle>
                                    <Style BasedOn="{StaticResource TreeViewItemExtend}" TargetType="{x:Type TreeViewItem}">
                                        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                                        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                                        <Setter Property="Visibility" Value="{Binding IsMatch, Mode=TwoWay}" />
                                    </Style>
                                </TreeView.ItemContainerStyle>
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="SelectedItemChanged">
                                        <micro:ActionMessage MethodName="TreeSelectChanged">
                                            <micro:Parameter Value="{Binding SelectedItem, ElementName=RecipeTree1}" />
                                        </micro:ActionMessage>
                                    </i:EventTrigger>
                                    <i:EventTrigger EventName="MouseDoubleClick">
                                        <micro:ActionMessage MethodName="TreeMouseDoubleClick">
                                            <micro:Parameter Value="{Binding SelectedItem, ElementName=RecipeTree1}" />
                                        </micro:ActionMessage>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>

                            </TreeView>
                        </DataTemplate>
                    </TabControl.ContentTemplate>

                </TabControl>

            </Border>
            <StackPanel
                Grid.Row="2"
                Margin="0,10,0,0"
                HorizontalAlignment="Center"
                Orientation="Horizontal">
                <Button
                    Width="90"
                    Height="30"
                    Content="OK">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <micro:ActionMessage MethodName="OK" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
                <Button
                    Width="90"
                    Height="30"
                    Margin="10,0,0,0"
                    Content="Cancel">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <micro:ActionMessage MethodName="Cancel" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
