<UserControl x:Class="VIZ.Package.Module.MediaResourcePanel"
             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:local="clr-namespace:VIZ.Package.Module"
             xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
             mc:Ignorable="d"
             d:DataContext="{d:DesignInstance Type=local:MediaResourcePanelViewModel}" 
             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.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="*" MinWidth="240" MaxWidth="400"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
  
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <!--<RowDefinition Height="30"></RowDefinition>-->
            <RowDefinition Height="*"></RowDefinition>
            <!--<RowDefinition Height="*"></RowDefinition>-->
        </Grid.RowDefinitions>
        <!-- 资源文件夹 -->
        <Border Grid.Row="0">

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

                <dxg:TreeViewControl ItemsSource="{Binding Path=FolderModels}" Margin="0,0,6,0" Grid.RowSpan="2"
                             SelectedItem="{Binding Path=SelectedFolderModel,Mode=TwoWay}"
                             SelectionMode="Row" ShowNodeImages="True" ShowSearchPanel="False"
                             ContextMenu="{Binding Path=FolderContextMenu,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:MediaResourcePanel}}}"
                             ExpandStateFieldName="IsExpand"
                             AllowEditing="False" TreeViewFieldName="Name" ChildNodesPath="Children">

                    <dxmvvm:Interaction.Behaviors>
                        <dxmvvm:EventToCommand EventName="NodeDoubleClick" PassEventArgsToCommand="True" Command="{Binding Path=FolderExpandCommand}"></dxmvvm:EventToCommand>
                    </dxmvvm:Interaction.Behaviors>
                    <dxg:TreeViewControl.NodeImageSelector>
                        <local:GHResourceFolderNodeImageSelector Folder="/VIZ.Package.Module.Resource;component/Icons/folder_24x24.png"
                                                       Project="/VIZ.Package.Module.Resource;component/Icons/project_24x24.png"></local:GHResourceFolderNodeImageSelector>
                    </dxg:TreeViewControl.NodeImageSelector>
                </dxg:TreeViewControl>


                <GroupBox Header="回收站" Grid.Row="1" Grid.Column="0" Visibility="{Binding VisibilityReCycle}">


                    <dxg:GridControl x:Name="ReCycleFileList" ShowBorder="False" ItemsSource="{Binding Path= FileRecycleModels,Mode=TwoWay}"  
                                     SelectedItem="{Binding Path=SelectedfileRecycleFileModel,Mode=TwoWay}"
                         ContextMenu="{Binding Path=RecycleContextMenu,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:MediaResourcePanel}}}" >

                        <dxg:GridColumn FieldName="Name"  Header="文件名" Width="100" />
                        <dxg:GridColumn FieldName="FileFolder"  Header="类型" Width="120"/>
                        <dxg:GridColumn FieldName="Date"  Header="日期" Width="150"/>
                        <!--<dxg:GridColumn FieldName="FileSize"  Header="大小" Width="130"/>-->
                        <!--#endregion-->
                        <dxg:GridControl.View>
                            <dxg:TableView AutoWidth="True"  ShowGroupPanel="False"  ShowVerticalLines="False" ShowHorizontalLines="False"
                               BorderThickness="0"  
                               ShowFilterPanelMode="Never" 
                               AllowColumnFiltering="False"
                               AllowSorting="False"
                               AllowEditing="False"  >
                            </dxg:TableView>
                        </dxg:GridControl.View>
                    </dxg:GridControl>

                </GroupBox>
            </Grid>

        </Border>

       
        

        <!-- 文件夹等待 -->
        <dx:WaitIndicator DeferedVisibility="{Binding IsFolderLoading}" Content="Loading..." Grid.Row="1" Margin="0,0,6,0" />
        
        <GridSplitter HorizontalAlignment="Right" Width="4" Grid.Row="0"></GridSplitter>

        <dxg:GridControl x:Name="fileGrid" Grid.Column="1" Grid.RowSpan="2" ShowBorder="False" Grid.Row="0" Visibility="{Binding VisibilityImage,Mode=TwoWay}"
                         CustomRowFilterCommand="{Binding Path=FileRowFilterCommand}"
                         ItemsSource="{Binding Path=FileModels}"
                         SelectedItem="{Binding Path=SelectedFileModel,Mode=TwoWay}"
                         ContextMenu="{Binding Path=FileContextMenu,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:MediaResourcePanel}}}">
            
            <dxmvvm:Interaction.Behaviors>
                <dxmvvm:EventToCommand EventName="MouseDoubleClick" Command="{Binding Path=FileDoubleClickCommand}"></dxmvvm:EventToCommand>
            </dxmvvm:Interaction.Behaviors>
            <dxg:GridControl.Resources>
                <!-- 定义Card模板 -->
                <DataTemplate x:Key="CardTemplate">
                    <Grid Width="160" ClipToBounds="False" UseLayoutRounding="True" >
                        <Grid.RowDefinitions>
                            <RowDefinition Height="90" />
                            <RowDefinition Height="30" />
                        </Grid.RowDefinitions>
                        <Image Source="{Binding Path=Row.ThumbnailBitmap,Converter={StaticResource Bitmap2ImageSourceConverter}}"></Image>
                        <TextBlock Grid.Row="1" TextAlignment="Center" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Center"
                                   Text="{Binding Path=Row.Name}" ToolTip="{Binding Path=Row.Name}" Margin="0,5,0,0"/>
                    </Grid>
                </DataTemplate>
            </dxg:GridControl.Resources>
            
            <dxg:GridControl.Columns>
                <dxg:GridColumn FieldName="Name" AllowColumnFiltering="False" AllowEditing="False" ReadOnly="True"></dxg:GridColumn>
            </dxg:GridControl.Columns>
            <dxg:GridControl.View>
                <dxg:CardView IsColumnChooserVisible="False"
                              SeparatorThickness="0"
                              CardLayout="Rows"
                              ShowCardExpandButton="False"
                              ShowColumnHeaders="False"
                              ShowFilterPanelMode="Never"
                              ShowGroupedColumns="False"
                              ShowGroupPanel="False"
                              SearchPanelHighlightResults="False"
                              SearchPanelAllowFilter="True"
                              ShowSearchPanelMode="Never"
                              SearchColumns="Name"
                              NavigationStyle="Row"
                              CardTemplate="{StaticResource CardTemplate}"/>
            </dxg:GridControl.View>
        </dxg:GridControl>

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


        <dxg:GridControl x:Name="FileList" ShowBorder="False" ItemsSource="{Binding Path= FileModels,Mode=TwoWay}" Visibility="{Binding VisibilityList, Mode=TwoWay}" Grid.Column="1" 
                         ContextMenu="{Binding Path=FileListContextMenu,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:MediaResourcePanel}}}" >
            
            <dxg:GridColumn FieldName="Name"  Header="文件名" Width="100" />
                        <dxg:GridColumn FieldName="FileFolder"  Header="类型" Width="100"/>
                        <dxg:GridColumn FieldName="Date"  Header="日期" Width="130"/>
            <dxg:GridColumn FieldName="FileSize"  Header="大小" Width="130"/>
            <!--#endregion-->
            <dxg:GridControl.View>
                <dxg:TableView AutoWidth="True"  ShowGroupPanel="False"  ShowVerticalLines="False" ShowHorizontalLines="False"
                               BorderThickness="0"  
                               ShowFilterPanelMode="Never" 
                               AllowColumnFiltering="False"
                               AllowSorting="False"
                               AllowEditing="False"  >
                </dxg:TableView>
            </dxg:GridControl.View>
        </dxg:GridControl>
      
    </Grid>
</UserControl>
