<UserControl x:Class="VIZ.Package.Module.ProjectTreePanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
             xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
             xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
             xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
             xmlns:dxi="http://schemas.devexpress.com/winfx/2008/xaml/core/internal"
             xmlns:dxgt="http://schemas.devexpress.com/winfx/2008/xaml/grid/themekeys"
             xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
             xmlns:common="clr-namespace:VIZ.Package.Common;assembly=VIZ.Package.Common"
             xmlns:local="clr-namespace:VIZ.Package.Module"
             xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
             xmlns:resource="clr-namespace:VIZ.Package.Module.Resource;assembly=VIZ.Package.Module.Resource"
             mc:Ignorable="d"
             d:DataContext="{d:DesignInstance Type=local:ProjectTreePanelModel}" 
             d:DesignHeight="450" d:DesignWidth="800">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/VIZ.Package.Module.Resource;component/DevExpreess/GridControl/GridControl_Files.xaml"></ResourceDictionary>
                <ResourceDictionary Source="/VIZ.Framework.Common.Resource;component/Style/GridSplitter/GridSplitter_None.xaml"></ResourceDictionary>
                <ResourceDictionary Source="/VIZ.Package.Module.Resource;component/Style/CheckBox/CheckBox_Resource.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
            <fcore:Bitmap2ImageSourceConverter x:Key="Bitmap2ImageSourceConverter"></fcore:Bitmap2ImageSourceConverter>
        </ResourceDictionary>
    </UserControl.Resources>

    <dxmvvm:Interaction.Behaviors>
        <dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
    </dxmvvm:Interaction.Behaviors>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300" MinWidth="300" MaxWidth="500"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <!-- 文件夹 -->
        <dxg:TreeViewControl ItemsSource="{Binding Path=FolderModels}" Margin="0,0,5,0"
                             SelectedItem="{Binding Path=SelectedFolderModel,Mode=TwoWay}"
                             ContextMenu="{Binding Path=FolderContextMenu,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProjectTreePanel}}}"
                             SelectionMode="Row" ShowExpandButtons="True" x:Name="t1"
                             ShowNodeImages="True" ShowSearchPanel="False"
                             ExpandStateFieldName="IsExpand"
                             AllowEditing="False" TreeViewFieldName="Name" ChildNodesPath="Folders">
            <dxmvvm:Interaction.Behaviors>
                <dxmvvm:EventToCommand EventName="NodeExpanding" PassEventArgsToCommand="True" Command="{Binding Path=FolderExpandingCommand}"></dxmvvm:EventToCommand>
                <dxmvvm:EventToCommand EventName="NodeDoubleClick" PassEventArgsToCommand="True" Command="{Binding Path=FolderExpandCommand}"></dxmvvm:EventToCommand>
            </dxmvvm:Interaction.Behaviors>
            <dxg:TreeViewControl.NodeImageSelector>
                <common:DefaultTreeListNodeImageSelector Icon="/VIZ.Package.Module.Resource;component/Icons/folder_24x24.png"></common:DefaultTreeListNodeImageSelector>
            </dxg:TreeViewControl.NodeImageSelector>
            <dxg:TreeViewControl.NodeContentStyle>
                <Style TargetType="dxg:LightweightCellEditor">
                    <Setter Property="Height" Value="30"></Setter>
                </Style>
            </dxg:TreeViewControl.NodeContentStyle>
        </dxg:TreeViewControl>

        <!-- 文件夹等待 -->
        <dx:WaitIndicator DeferedVisibility="{Binding IsFolderLoading}" Content="Loading..." Margin="0,0,6,0" />
        <GridSplitter HorizontalAlignment="Right" Width="5" Style="{StaticResource  GridSplitter_None}"></GridSplitter>

        <!-- 文件列表 -->
        <dxg:GridControl ItemsSource="{Binding FileModels}" ShowBorder="False" 
                         IsEnabled="{Binding Path=IsFilePanelEnabled}"
                         IsFilterEnabled="False" Grid.Column="1" SelectionMode="Row"
                         SelectedItem="{Binding SelectedFileModel,Mode=TwoWay}"
                         SelectedItems="{Binding SelectedFileModels,Mode=OneWayToSource}"
                         ContextMenu="{Binding Path=FileContextMenu,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:ProjectTreePanel}}}">
            <dxg:GridControl.Columns>
                <dxg:GridColumn Header="名称" FieldName="Name" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"
                                Width="400">
                    <dxg:GridColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="40"></ColumnDefinition>
                                    <ColumnDefinition Width="*"></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <Image Width="20" Height="20"
                                       Source="/VIZ.Package.Module.Resource;component/Icons/file_32x32.png"></Image>
                                <TextBlock Text="{Binding Path=Row.Name}" VerticalAlignment="Center" Grid.Column="1"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </dxg:GridColumn.CellTemplate>
                </dxg:GridColumn>
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:TableView IsColumnMenuEnabled="False"
                               AllowEditing="True" ShowIndicator="False" RowMinHeight="30"
                               NavigationStyle="Row" ShowVerticalLines="False" ShowHorizontalLines="False"
                               ShowGroupPanel="False" EditorShowMode="MouseDown"
                               AllowDragDrop="True" ShowColumnHeaders="False"
                               ShowBandsPanel="False"
                               ShowTotalSummary="False"
                               ShowFixedTotalSummary="False"
                               ShowDragDropHint="False"
                               ShowTargetInfoInDragDropHint="false">
                    <dxmvvm:Interaction.Behaviors>
                        <dxmvvm:EventToCommand EventName="RowDoubleClick" Command="{Binding Path=FileDoubleClickCommand}"></dxmvvm:EventToCommand>
                    </dxmvvm:Interaction.Behaviors>
                </dxg:TableView>
            </dxg:GridControl.View>
        </dxg:GridControl>

        <!-- 文件等待 -->
        <dx:WaitIndicator DeferedVisibility="{Binding IsFileLoading}" Content="Loading..." Grid.Column="1" Grid.Row="1" />
    </Grid>
</UserControl>
