Newer
Older
Correlator / Correlator / Dialog / AudioFileDialog.xaml
<UserControl
    x:Class="Correlator.Dialog.AudioFileDialog"
    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"
    MinWidth="1200"
    MinHeight="635"
    MaxWidth="1200"
    MaxHeight="635"
    d:DataContext="{d:DesignInstance Type=vm:AudioFileDialogViewModel}"
    Loaded="AudioFileView_OnLoaded"
    Unloaded="AudioFileView_OnUnloaded"
    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>

    <Grid Background="White">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <DataGrid
            x:Name="TargetDataGrid"
            Grid.Row="0"
            hc:DataGridAttach.CanUnselectAllWithBlankArea="True"
            AutoGenerateColumns="False"
            CanUserSortColumns="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 ElementName=TargetDataGrid, Path=SelectedItem}" />
                </b:EventTrigger>
            </b:Interaction.Triggers>

            <DataGrid.Columns>
                <DataGridTextColumn
                    Width="1.5*"
                    Binding="{Binding FileName}"
                    CanUserResize="False"
                    Header="名称"
                    IsReadOnly="True" />
                <DataGridTextColumn
                    Width="*"
                    Binding="{Binding FileSource}"
                    CanUserResize="False"
                    Header="文件来源"
                    IsReadOnly="True" />
                <DataGridTextColumn
                    Width="300"
                    Binding="{Binding CreationTime}"
                    CanUserResize="False"
                    Header="生成时间"
                    IsReadOnly="True" />
                <DataGridTextColumn
                    Width="200"
                    Binding="{Binding FileSize}"
                    CanUserResize="False"
                    Header="文件大小"
                    IsReadOnly="True" />
                <DataGridTemplateColumn
                    Width="180"
                    CanUserResize="False"
                    Header="操作">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Button
                                    Margin="0,0,7,0"
                                    hc:IconElement.Geometry="{StaticResource AudioGeometry}"
                                    BorderThickness="0"
                                    Command="{Binding DataContext.PlayAudioCommand, ElementName=TargetDataGrid}"
                                    Content="播放" />

                                <Button
                                    Margin="7,0,0,0"
                                    hc:IconElement.Geometry="{StaticResource DeleteFillCircleGeometry}"
                                    BorderThickness="0"
                                    Command="{Binding DataContext.DeleteAudioCommand, ElementName=TargetDataGrid}"
                                    Content="删除" />
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>

        <Grid Grid.Row="1" Margin="30,5">
            <Path x:Name="StripsPath" />
        </Grid>

        <hc:Pagination
            Grid.Row="1"
            Margin="10"
            HorizontalAlignment="Right"
            VerticalAlignment="Center"
            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>