Newer
Older
Correlator / Correlator / Dialog / ImageChildFolderDialog.xaml
<UserControl
    x:Class="Correlator.Dialog.ImageChildFolderDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
    xmlns:cvt="clr-namespace:Correlator.Converter"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:hc="https://handyorg.github.io/handycontrol"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="http://prismlibrary.com/"
    xmlns:vm="clr-namespace:Correlator.ViewModels"
    Width="1200"
    Height="635"
    d:DataContext="{d:DesignInstance Type=vm:ImageChildFolderViewModel}"
    Background="White"
    mc:Ignorable="d">

    <prism:Dialog.WindowStyle>
        <Style TargetType="Window">
            <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterOwner" />
            <Setter Property="ShowInTaskbar" Value="False" />
            <Setter Property="ResizeMode" Value="NoResize" />
            <Setter Property="SizeToContent" Value="WidthAndHeight" />
        </Style>
    </prism:Dialog.WindowStyle>

    <UserControl.Resources>
        <cvt:EmptyViewConverter x:Key="EmptyViewConverterKey" />
        <cvt:ContentViewConverter x:Key="ContentViewConverterKey" />
        <cvt:TaskStateConverter x:Key="TaskStateConverterKey" />
        <cvt:ChildFolderImageConverter x:Key="ChildFolderImageConverterKey" />
    </UserControl.Resources>

    <Grid>
        <Grid Visibility="{Binding ChildFolders.Count, Converter={StaticResource EmptyViewConverterKey}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="100" />
                <RowDefinition />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="100" />
            </Grid.RowDefinitions>

            <Image Grid.Row="1" Source="/Correlator;component/Image/empty_image.png" />

            <TextBlock
                Grid.Row="2"
                HorizontalAlignment="Center"
                FontSize="18"
                Text="这里什么都没有~" />
        </Grid>

        <Grid Visibility="{Binding ChildFolders.Count, Converter={StaticResource ContentViewConverterKey}}">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <ListBox
                x:Name="ImageFileListBox"
                Grid.Row="0"
                Padding="0,2"
                BorderThickness="0"
                ItemsSource="{Binding ChildFolders}">

                <b:Interaction.Triggers>
                    <b:EventTrigger EventName="SelectionChanged">
                        <b:InvokeCommandAction Command="{Binding ItemSelectedCommand}" CommandParameter="{Binding ElementName=ImageFileListBox, Path=SelectedItem}" />
                    </b:EventTrigger>

                    <b:EventTrigger EventName="MouseDoubleClick">
                        <b:InvokeCommandAction Command="{Binding MouseDoubleClickCommand}" CommandParameter="{Binding ElementName=ImageFileListBox, Path=SelectedItem}" />
                    </b:EventTrigger>
                </b:Interaction.Triggers>

                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Grid Width="101">
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <Image
                                Grid.Row="0"
                                Margin="10"
                                Source="{Binding FolderType, Converter={StaticResource ChildFolderImageConverterKey}}" />

                            <TextBlock
                                Grid.Row="1"
                                HorizontalAlignment="Center"
                                FontSize="16"
                                Text="{Binding FolderName}" />
                        </Grid>
                    </DataTemplate>
                </ListBox.ItemTemplate>

                <!--  ListBox横排  -->
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel HorizontalAlignment="Stretch" Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>

                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Margin" Value="3" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                    <Border
                                        x:Name="ItemContainerBorder"
                                        BorderBrush="{StaticResource BackgroundBrush}"
                                        BorderThickness="1">
                                        <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Center" />
                                    </Border>

                                    <ControlTemplate.Triggers>
                                        <Trigger Property="IsSelected" Value="True">
                                            <Setter TargetName="ItemContainerBorder" Property="Background" Value="{StaticResource BackgroundBrush}" />
                                        </Trigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>

            <Grid Grid.Row="1" Margin="10,8">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>

                <TextBlock
                    Grid.Column="1"
                    VerticalAlignment="Center"
                    FontSize="16"
                    Text="{Binding SelectedFolder.ChildFileCount, StringFormat={}包含 {0} 个项目}" />

                <hc:Pagination
                    Grid.Column="2"
                    IsJumpEnabled="True"
                    MaxPageCount="{Binding MaxPage}">
                    <hc:Interaction.Triggers>
                        <hc:EventTrigger EventName="PageUpdated">
                            <hc:EventToCommand Command="{Binding PageUpdatedCmd}" PassEventArgsToCommand="True" />
                        </hc:EventTrigger>
                    </hc:Interaction.Triggers>
                </hc:Pagination>
            </Grid>
        </Grid>

        <Grid VerticalAlignment="Center" Visibility="{Binding TaskHasCompleted, Converter={StaticResource TaskStateConverterKey}}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <ProgressBar
                Grid.Row="0"
                Width="400"
                IsIndeterminate="True" />

            <TextBlock
                Grid.Row="1"
                Margin="0,20"
                HorizontalAlignment="Center"
                FontSize="18"
                Text="文件加载中,请稍后..." />
        </Grid>
    </Grid>
</UserControl>