<UserControl x:Class="ComPDFKit.Controls.Annotation.PDFAnnotationPanel.PDFAnnotationUI.CPDFSignatureUI"
             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.Annotation.PDFAnnotationPanel.PDFAnnotationUI"
             xmlns:common="clr-namespace:ComPDFKit.Controls.Common"
             mc:Ignorable="d" 
             Loaded="UserControl_Loaded"
             Unloaded="UserControl_Unloaded"
              d:DesignHeight="800" d:DesignWidth="300">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../../Asset/Styles/ButtonStyle.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
            <common:PropertyPanelResourceConverter x:Key="PropertyPanelResourceConverter"></common:PropertyPanelResourceConverter>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid  Background="#FAFCFF">
        <Grid.RowDefinitions>
            <RowDefinition Height="36" />
            <RowDefinition Height="2" />
            <RowDefinition Height="72" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Border BorderThickness="1" BorderBrush="#1A000000">
            <Grid  Height="40" Background="White" >
                <TextBlock Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Title_Sig}" FontFamily="Microsoft YaHei" FontSize="16" FontWeight="Bold" VerticalAlignment="Center" HorizontalAlignment="Center"/>
            </Grid>
        </Border>
        <Button Grid.Row="2" Height="32" Width="236"  Click="CreateSignature_Click" Style="{StaticResource ButtonStyle}">
            <Button.Content>
                <StackPanel Orientation="Horizontal">
                    <Grid Width="17" Height="16">
                        <Path Data="M9 7.5V3H8V7.5H3.5V8.5H8V13H9V8.5H13.5V7.5H9Z" Fill="White"/>
                    </Grid>
                    <TextBlock Margin="4,0,0,0" Text="{Binding Converter={StaticResource PropertyPanelResourceConverter},ConverterParameter=Button_NewSig}" FontFamily="Microsoft YaHei" FontSize="14" FontWeight="Regular" Foreground="White"/>
                </StackPanel>
            </Button.Content>
        </Button>
        <ListBox Grid.Row="3"
                x:Name="SignatureListBox"
                VerticalAlignment="Top"
                BorderThickness="0"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
            >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Image   Height="48"
                                Source="{Binding SourcePath}"
                                Stretch="Uniform" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>

            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Height" Value="65" />
                    <Setter Property="Padding" Value="8" />
                    <Setter Property="HorizontalContentAlignment" Value="Center" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                <Border
                                        x:Name="Bd"
                                        Padding="{TemplateBinding Padding}"
                                        Background="{TemplateBinding Background}"
                                        BorderBrush="{TemplateBinding BorderBrush}"
                                        BorderThickness="{TemplateBinding BorderThickness}"
                                        SnapsToDevicePixels="true">
                                    <Grid>
                                        <ContentPresenter
                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                        <Button HorizontalAlignment="Right" VerticalAlignment="Top" x:Name="DeleteIcon" Width="20" Height="20" Background="Transparent" BorderThickness="0" Click="Delete_Click" Visibility="Hidden" >
                                            <Path Width="16" Height="16" Fill="#43474D" Data="M11.8572 12.5643C12.0525 12.7596 12.3691 12.7596 12.5643 12.5643C12.7596 12.3691 12.7596 12.0525 12.5643 11.8572L8.95809 8.25099L12.5643 4.64475C12.7596 4.44949 12.7596 4.1329 12.5643 3.93764C12.3691 3.74238 12.0525 3.74238 11.8572 3.93764L8.25099 7.54389L4.64473 3.93763C4.44946 3.74236 4.13288 3.74236 3.93762 3.93763C3.74236 4.13289 3.74236 4.44947 3.93762 4.64473L7.54388 8.25099L3.93763 11.8572C3.74237 12.0525 3.74237 12.3691 3.93763 12.5643C4.1329 12.7596 4.44948 12.7596 4.64474 12.5643L8.25099 8.9581L11.8572 12.5643Z"/>
                                        </Button>
                                    </Grid>
                                </Border>
                                <ControlTemplate.Triggers>
                                    <MultiTrigger>
                                        <MultiTrigger.Conditions>
                                            <Condition Property="IsMouseOver" Value="True" />
                                        </MultiTrigger.Conditions>
                                        <Setter TargetName="Bd" Property="Background" Value="#DDE9FF" />
                                        <Setter TargetName="Bd" Property="BorderBrush" Value="#DDE9FF" />
                                        <Setter TargetName="DeleteIcon" Property="Visibility" Value="Visible" />
                                    </MultiTrigger>
                                    <MultiTrigger>
                                        <MultiTrigger.Conditions>
                                            <Condition Property="Selector.IsSelectionActive" Value="False" />
                                            <Condition Property="IsSelected" Value="True" />
                                        </MultiTrigger.Conditions>
                                        <Setter TargetName="Bd" Property="Background" Value="#DDE9FF" />
                                        <Setter TargetName="Bd" Property="BorderBrush" Value="#DDE9FF" />
                                    </MultiTrigger>
                                    <MultiTrigger>
                                        <MultiTrigger.Conditions>
                                            <Condition Property="Selector.IsSelectionActive" Value="True" />
                                            <Condition Property="IsSelected" Value="True" />
                                        </MultiTrigger.Conditions>
                                        <Setter TargetName="Bd" Property="Background" Value="#DDE9FF" />
                                        <Setter TargetName="Bd" Property="BorderBrush" Value="#DDE9FF" />
                                    </MultiTrigger>
                                    <Trigger Property="IsEnabled" Value="False">
                                        <Setter TargetName="Bd" Property="TextElement.Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <EventSetter Event="PreviewMouseLeftButtonDown" Handler="Signature_PreviewMouseLeftButtonDown" />
                </Style>
            </ListBox.ItemContainerStyle>
        </ListBox>
    </Grid>
</UserControl>
