<UserControl x:Class="ComPDFKit.Controls.PDFControl.FeaturesListControl"
             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:local="clr-namespace:ComPDFKit.Controls.PDFControl"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800"
             Loaded="UserControl_Loaded"
             Unloaded="UserControl_Unloaded">
    <UserControl.Resources>
        <Style TargetType="Button" x:Key="PageButtonStyle">
            <Setter Property="Padding" Value="0"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Margin" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border x:Name="border"
                                Background="Transparent"
                                BorderThickness="0"
                                SnapsToDevicePixels="True"
                                Height="{TemplateBinding Height}"
                                Width="{TemplateBinding Width}">
                            <ContentPresenter HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              Content="{TemplateBinding Content}"></ContentPresenter>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="border" Property="Background" Value="#1A000000"></Setter>
                            </Trigger>
                            <Trigger Property="IsPressed" Value="True">
                                <Setter TargetName="border" Property="Background" Value="#2A000000"></Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        
        <Style TargetType="ListBox" x:Key="WrapListBoxStyle">
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="Padding" Value="0" />
        </Style>

        <Style x:Key="ItemBorderStyle" TargetType="Border">
            <Setter Property="CornerRadius" Value="5" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="BorderBrush" Value="Transparent"></Setter>
            <Setter Property="Background" Value="#ffffff"></Setter>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="BorderBrush" Value="#6495ed"></Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>
    <Grid Margin="0, 0, 0,0">
        <Grid.RowDefinitions>
            <RowDefinition Height="40"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <TextBlock x:Name="FeaturesListTxb" Foreground="#001A4E" FontFamily="Microsoft YaHei" FontSize="24" LineHeight="32" FontWeight="Medium"></TextBlock>
        <Grid x:Name="ListGd" Grid.Row="1" SizeChanged="ListGd_SizeChanged">
            <Grid.RowDefinitions>
                <RowDefinition></RowDefinition>
                <RowDefinition  Height="auto"></RowDefinition>
            </Grid.RowDefinitions>
            <ListBox  x:Name="FeaturesListBox" Style="{StaticResource WrapListBoxStyle}" ItemsSource="{Binding PageItems}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"  SelectionMode="Single" >
                <ListBox.Resources>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="HorizontalContentAlignment" Value="Center" />
                        <Setter Property="VerticalContentAlignment" Value="Center" />
                    </Style>
                </ListBox.Resources>
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Margin" Value="{Binding ItemMargin}" />
                        <Setter Property="HorizontalContentAlignment" Value="Center" />
                        <Setter Property="VerticalContentAlignment" Value="Center" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <ContentPresenter />
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Width="{Binding ElementName=FeaturesListBox, Path=ActualWidth}"></WrapPanel>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Border  Width="{Binding ItemWidth}" Height="{Binding ItemHeight}" Style="{StaticResource ItemBorderStyle}">
                            <Grid Margin="16,20,16,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="33"></ColumnDefinition>
                                    <ColumnDefinition></ColumnDefinition>
                                </Grid.ColumnDefinitions>
                                <ContentControl Grid.Column="0" Content="{Binding IconCanvas}" />
                                <Grid Grid.Column="1">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="auto"></RowDefinition>
                                        <RowDefinition></RowDefinition>
                                    </Grid.RowDefinitions>
                                    <TextBlock FontSize="14" Margin="0,0,0,5"  Foreground="#1a1a1a" FontWeight="Bold" Text="{Binding TitleText}"/>
                                    <TextBlock Grid.Row="1"  FontSize="12" Foreground="#666666" Text="{Binding DescriptionText}" TextWrapping="Wrap" TextTrimming="CharacterEllipsis"/>
                                </Grid>
                            </Grid>
                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <Grid Grid.Row="1">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                    <Button Name="PrePageBtn" Style="{StaticResource PageButtonStyle}" Height="40" Width="40" Click="PrePageBtn_Click">
                        <Path Data="M5.79777 12L6.5 11.2733L1.40446 6L6.5 0.726727L5.79777 0L0 6L5.79777 12Z" Fill="#001A4E"></Path>
                    </Button>
                    <TextBlock Text="{Binding CurrentIndex}" FontFamily="Microsoft YaHei" VerticalAlignment="Center" FontWeight="DemiBold" FontSize="18"  Margin="5,0,5,0"></TextBlock>
                    <TextBlock Text="/" FontFamily="Microsoft YaHei" VerticalAlignment="Center" FontWeight="DemiBold" FontSize="18" ></TextBlock>
                    <TextBlock Text="{Binding TotalIndex}" FontFamily="Microsoft YaHei" VerticalAlignment="Center" FontWeight="DemiBold" FontSize="18"   Margin="5,0,5,0"></TextBlock>
                    <Button x:Name="NextPageBtn"  Style="{StaticResource PageButtonStyle}" Height="40" Width="40" Click="NextPageBtn_Click">
                        <Path Data="M0.702232 12L0 11.2733L5.09554 6L0 0.726727L0.702232 0L6.5 6L0.702232 12Z" Fill="#001A4E"></Path>
                    </Button>
                </StackPanel>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
