<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="using:Bili.Workspace.Controls"
    xmlns:loc="using:Bili.Workspace.Resources.Extension"
    xmlns:local="using:Bili.Workspace.Controls.App">

    <Style x:Key="HorizontalEpisodeItemStyle" TargetType="local:EpisodeItem">
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:EpisodeItem">
                    <Grid>
                        <Grid.Resources>
                            <Style BasedOn="{StaticResource DefaultIconTextBlockStyle}" TargetType="local:IconTextBlock">
                                <Setter Property="Spacing" Value="4" />
                                <Setter Property="IconFontSize" Value="12" />
                                <Setter Property="FontSize" Value="12" />
                            </Style>
                        </Grid.Resources>
                        <controls:CardPanel
                            x:Name="RootCard"
                            AutomationProperties.Name="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Title}"
                            MaxHeight="140"
                            Command="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.PlayCommand}"
                            IsChecked="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.IsSelected}"
                            IsEnableCheck="False">

                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Grid
                                    x:Name="CoverContainer"
                                    Margin="8"
                                    VerticalAlignment="Stretch"
                                    CornerRadius="{StaticResource ControlCornerRadius}">
                                    <local:CommonImageEx
                                        x:Name="CoverImage"
                                        Width="180"
                                        VerticalAlignment="Center"
                                        ImageUrl="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Cover.Uri}"
                                        Stretch="UniformToFill" />

                                    <Grid
                                        x:Name="BadgeContainer"
                                        Margin="8,8,0,0"
                                        Padding="8,4"
                                        HorizontalAlignment="Left"
                                        VerticalAlignment="Top"
                                        Background="{ThemeResource AccentMaskBrush}"
                                        CornerRadius="{StaticResource ControlCornerRadius}"
                                        Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Highlight, Converter={StaticResource ObjectToVisibilityConverter}}">
                                        <TextBlock
                                            Style="{StaticResource CaptionTextBlockStyle}"
                                            Foreground="{ThemeResource TextOnAccentFillColorPrimaryBrush}"
                                            Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Highlight}" />
                                    </Grid>
                                </Grid>
                                <Grid
                                    x:Name="ContentContainer"
                                    Grid.Column="1"
                                    Padding="8"
                                    RowSpacing="8">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
                                    <TextBlock
                                        x:Name="SubtitleBlock"
                                        Style="{StaticResource CaptionTextBlockStyle}"
                                        VerticalAlignment="Center"
                                        Opacity="0.6"
                                        Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Subtitle}" />

                                    <TextBlock
                                        x:Name="TitleBlock"
                                        Grid.Row="1"
                                        VerticalAlignment="Top"
                                        MaxLines="1"
                                        Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Title}"
                                        TextTrimming="CharacterEllipsis"
                                        TextWrapping="Wrap">
                                        <ToolTipService.ToolTip>
                                            <ToolTip Content="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Title}" IsEnabled="{Binding ElementName=TitleBlock, Path=IsTextTrimmed}" />
                                        </ToolTipService.ToolTip>
                                    </TextBlock>

                                    <StackPanel Grid.Row="3" Orientation="Horizontal">
                                        <local:IconTextBlock
                                            Margin="0,0,12,0"
                                            Opacity="0.6"
                                            Symbol="PlayCircle"
                                            Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.PlayCountText}"
                                            ToolTipService.ToolTip="{loc:Locale Name=PlayCount}"
                                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.PlayCountText, Converter={StaticResource ObjectToVisibilityConverter}}" />
                                        <local:IconTextBlock
                                            Margin="0,0,12,0"
                                            Opacity="0.6"
                                            Symbol="SlideText"
                                            Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.DanmakuCountText}"
                                            ToolTipService.ToolTip="{loc:Locale Name=DanmakuCount}"
                                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.DanmakuCountText, Converter={StaticResource ObjectToVisibilityConverter}}" />
                                        <local:IconTextBlock
                                            Margin="0,0,12,0"
                                            Opacity="0.6"
                                            Symbol="RibbonStar"
                                            Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.TrackCountText}"
                                            ToolTipService.ToolTip="{loc:Locale Name=TrackCount}"
                                            Visibility="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.TrackCountText, Converter={StaticResource ObjectToVisibilityConverter}}" />
                                    </StackPanel>
                                </Grid>
                            </Grid>
                        </controls:CardPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="HorizontalDynamicEpisodeItemStyle" TargetType="local:EpisodeItem">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:EpisodeItem">
                    <Grid RowSpacing="8">
                        <Grid.Resources>
                            <Style BasedOn="{StaticResource DefaultIconTextBlockStyle}" TargetType="local:IconTextBlock">
                                <Setter Property="Spacing" Value="4" />
                                <Setter Property="IconFontSize" Value="12" />
                                <Setter Property="FontSize" Value="12" />
                            </Style>
                        </Grid.Resources>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid
                            x:Name="CoverContainer"
                            Width="120"
                            Height="76"
                            VerticalAlignment="Stretch"
                            CornerRadius="{StaticResource ControlCornerRadius}">
                            <local:CommonImageEx x:Name="CoverImage" ImageUrl="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Cover.Uri}" />

                            <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                                <Ellipse
                                    Width="40"
                                    Height="40"
                                    Fill="{ThemeResource AppMaskBrush}"
                                    Opacity="0.8" />
                                <controls:FluentIcon
                                    HorizontalAlignment="Center"
                                    VerticalAlignment="Center"
                                    FontSize="16"
                                    Foreground="{ThemeResource AccentTextFillColorPrimaryBrush}"
                                    Symbol="Play" />
                            </Grid>
                        </Grid>

                        <Grid
                            x:Name="ContentContainer"
                            Grid.Column="1"
                            Padding="8"
                            RowSpacing="4">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <TextBlock
                                x:Name="TitleBlock"
                                VerticalAlignment="Top"
                                FontSize="12"
                                MaxLines="2"
                                Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Title}"
                                TextTrimming="CharacterEllipsis"
                                TextWrapping="Wrap">
                                <ToolTipService.ToolTip>
                                    <ToolTip Content="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.Data.Identifier.Title}" IsEnabled="{Binding ElementName=TitleBlock, Path=IsTextTrimmed}" />
                                </ToolTipService.ToolTip>
                            </TextBlock>

                            <local:IconTextBlock
                                x:Name="InlineDurationBlock"
                                Grid.Row="1"
                                FontSize="12"
                                Foreground="{ThemeResource TextFillColorSecondaryBrush}"
                                IconFontSize="12"
                                Symbol="Timer"
                                Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}, Path=ViewModel.DurationText, Mode=OneWay}"
                                Visibility="Collapsed" />
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style BasedOn="{StaticResource VerticalEpisodeItemStyle}" TargetType="local:EpisodeItem" />

</ResourceDictionary>
