Newer
Older
Correlator / Correlator / Views / AudioFileView.xaml
<UserControl
    x:Class="Correlator.Views.AudioFileView"
    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: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"
    d:DataContext="{d:DesignInstance Type=vm:AudioFileViewModel}"
    d:DesignHeight="1080"
    d:DesignWidth="1920"
    mc:Ignorable="d">

    <prism:Dialog.WindowStyle>
        <Style TargetType="Window">
            <Setter Property="prism:Dialog.WindowStartupLocation" Value="CenterOwner" />
            <Setter Property="ShowInTaskbar" Value="False" />
            <Setter Property="WindowStyle" Value="None" />
            <Setter Property="WindowState" Value="Maximized" />
            <Setter Property="AllowsTransparency" Value="True" />
            <Setter Property="ResizeMode" Value="NoResize" />
        </Style>
    </prism:Dialog.WindowStyle>

    <Grid Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="80" />
            <RowDefinition Height="*" />
            <RowDefinition Height="80" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <StackPanel Margin="20,0,0,0" Orientation="Horizontal">
                <Button
                    Height="40"
                    Margin="10,0"
                    Command="{Binding GoBackCommand}">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock
                            Margin="0,0,5,0"
                            VerticalAlignment="Center"
                            FontFamily="/Correlator;component/Fonts/#iconfont"
                            FontSize="20"
                            Text="&#xe60f;" />
                        <TextBlock FontSize="18" Text="返回" />
                    </StackPanel>
                </Button>

                <StackPanel VerticalAlignment="Center" Orientation="Vertical">
                    <TextBlock FontSize="18" Text="文件列表" />
                    <TextBlock
                        FontSize="14"
                        Foreground="#cecece"
                        Text="File List" />
                </StackPanel>
            </StackPanel>
        </Grid>

        <DataGrid
            Grid.Row="1"
            Margin="30,0"
            hc:DataGridAttach.CanUnselectAllWithBlankArea="True"
            AutoGenerateColumns="False"
            ColumnHeaderHeight="60"
            FontSize="18"
            HeadersVisibility="All"
            ItemsSource="{Binding AudioFiles}"
            RowHeight="60">

            <b:Interaction.Triggers>
                <b:EventTrigger EventName="SelectionChanged">
                    <b:InvokeCommandAction Command="{Binding ItemSelectedCommand}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}" />
                </b:EventTrigger>
            </b:Interaction.Triggers>

            <DataGrid.Columns>
                <DataGridTextColumn
                    Width="100"
                    Binding="{Binding Order}"
                    CanUserResize="False"
                    FontSize="18"
                    Header="序号"
                    IsReadOnly="True" />
                <DataGridTextColumn
                    Width="*"
                    Binding="{Binding FileName}"
                    CanUserResize="False"
                    FontSize="18"
                    Header="名称"
                    IsReadOnly="True" />
                <DataGridTextColumn
                    Width="200"
                    Binding="{Binding FileSource}"
                    CanUserResize="False"
                    FontSize="18"
                    Header="文件来源"
                    IsReadOnly="True" />
                <DataGridTextColumn
                    Width="300"
                    Binding="{Binding CreationTime}"
                    CanUserResize="False"
                    FontSize="18"
                    Header="生成时间"
                    IsReadOnly="True" />
                <DataGridTextColumn
                    Width="200"
                    Binding="{Binding FileSize}"
                    CanUserResize="False"
                    FontSize="18"
                    Header="文件大小"
                    IsReadOnly="True" />
                <DataGridTemplateColumn
                    Width="170"
                    CanUserResize="False"
                    Header="操作">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Button
                                    Margin="0,0,7,0"
                                    hc:IconElement.Geometry="{StaticResource AudioGeometry}"
                                    Command="{Binding DataContext.PlayAudioCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                                    Content="播放"
                                    Style="{StaticResource ButtonInfo}" />

                                <Button
                                    Margin="7,0,0,0"
                                    hc:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}"
                                    Command="{Binding DataContext.DeleteAudioCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                                    Content="删除"
                                    Style="{StaticResource ButtonDanger}" />
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>

        <hc:Pagination
            Grid.Row="2"
            Margin="30,0"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            DataCountPerPage="5"
            IsJumpEnabled="True"
            MaxPageCount="{Binding MaxPage}"
            PageIndex="{Binding PageIndex}">
            <hc:Interaction.Triggers>
                <hc:EventTrigger EventName="PageUpdated">
                    <hc:EventToCommand Command="{Binding PageUpdatedCmd}" PassEventArgsToCommand="True" />
                </hc:EventTrigger>
            </hc:Interaction.Triggers>
        </hc:Pagination>
    </Grid>
</UserControl>