<UserControl x:Class="PDF_Office.Views.PropertyPanel.AnnotPanel.StampAnnotProperty"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
             xmlns:customcontrol="clr-namespace:PDF_Office.CustomControl"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.AnnotPanel" 
             xmlns:annotpanel="clr-namespace:PDF_Office.ViewModels.PropertyPanel.AnnotPanel"
             xmlns:model="clr-namespace:PDF_Office.Model.AnnotPanel"
             xmlns:dd="clr-namespace:PDFSettings;assembly=PDFSettings"
             xmlns:dataconvert="clr-namespace:PDF_Office.DataConvert" 
             d:DataContext="{d:DesignInstance Type=annotpanel:StampAnnotPropertyViewModel}"
             mc:Ignorable="d" 
             Background="#FCFDFF"
             >
    <UserControl.Resources>
        <PathGeometry x:Key="Ic_SettingButtonPath"  Figures="M8.24998 1.87558L13.1782 4.72088C13.3329 4.8102 13.4282 4.97526 13.4282 5.15389V10.8445C13.4282 11.0231 13.3329 11.1882 13.1782 11.2775L8.24998 14.1228C8.09528 14.2121 7.90468 14.2121 7.74998 14.1228L2.82178 11.2775C2.66708 11.1882 2.57178 11.0231 2.57178 10.8445V5.15389C2.57178 4.97526 2.66708 4.8102 2.82178 4.72088L7.74998 1.87558C7.90468 1.78626 8.09528 1.78626 8.24998 1.87558ZM6.99998 0.576543C7.61878 0.219277 8.38118 0.219277 8.99998 0.576543L13.9282 3.42184C14.547 3.77911 14.9282 4.43936 14.9282 5.15389V10.8445C14.9282 11.559 14.547 12.2193 13.9282 12.5765L8.99998 15.4218C8.38118 15.7791 7.61878 15.7791 6.99998 15.4218L2.07178 12.5765C1.45298 12.2193 1.07178 11.559 1.07178 10.8445V5.15389C1.07178 4.43936 1.45298 3.77911 2.07178 3.42184L6.99998 0.576543ZM9.99998 7.99919C9.99998 9.10376 9.10455 9.99919 7.99998 9.99919C6.89541 9.99919 5.99998 9.10376 5.99998 7.99919C5.99998 6.89462 6.89541 5.99919 7.99998 5.99919C9.10455 5.99919 9.99998 6.89462 9.99998 7.99919ZM11.5 7.99919C11.5 9.93219 9.93298 11.4992 7.99998 11.4992C6.06698 11.4992 4.49998 9.93219 4.49998 7.99919C4.49998 6.0662 6.06698 4.49919 7.99998 4.49919C9.93298 4.49919 11.5 6.0662 11.5 7.99919Z"/>
        <dataconvert:BoolToVisible x:Key="BoolToVisible"/>
        <dataconvert:ListCountToVisible x:Key="ListCountToVisible"/>
        <dataconvert:UnVisivleConvert x:Key="UnVisivleConvert"/>
        <Style TargetType="{x:Type TabItem}">
            <Setter Property="Width" Value="74.67 " />
            <Setter Property="Height" Value="28" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="Template" Value="{StaticResource Segmented}" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="50"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="16"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="16"/>
        </Grid.ColumnDefinitions>
        <Grid Grid.Column="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <TextBlock x:Name="AnnoteTypeTitle" Text="Stamp" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="0 8 0 0" FontFamily="Segoe UI Semibold" FontWeight="SemiBold" FontSize="18"/>
            <customcontrol:PathButton Grid.Column="1"
            Visibility="{Binding UnStandard,Converter={StaticResource BoolToVisible}}"
            Command="{Binding ShowDialogCommand}"
            Height="24" Width="24"  IconHeight="16"  IconWidth="16" 
            Icon="{StaticResource Ic_SettingButtonPath}"  IconFill="#616469"
            IconPress="{StaticResource Ic_SettingButtonPath}" IconPressFill="#C04CF8"
            IconMouseOver="{StaticResource Ic_SettingButtonPath}" IconMouseOverFill="#C04CF8" />
        </Grid>
        <TabControl Padding="0" Grid.Column="1" BorderThickness="0" Grid.Row="1" Name="StampTabControl" SelectedIndex="{Binding TabControlSelectedIndex,Mode=TwoWay}"  HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"  Style="{StaticResource FormTabControl}">
            <TabItem x:Name="TabStandard"
                        Header="Standard"
                        FontFamily="Segoe UI"
                        HorizontalContentAlignment="Center"
                        FontSize="12"
                        IsSelected="True">
                <ListBox ItemsSource="{Binding StandardStampList}" SelectionMode="Single"  Height="auto" VerticalAlignment="Top"  BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" >
                    <ListBox.ItemTemplate>
                        <DataTemplate >
                            <Grid >
                                <Grid.ContextMenu>
                                        <ContextMenu>
                                            <MenuItem Header="导出图章">
                                                <MenuItem x:Name="SavePNG" Header="PNG" Tag="PNG" Click="Save_Click"/>
                                                <MenuItem x:Name="SavePDF" Header="PDF" Tag="PDF" Click="Save_Click"/>
                                            </MenuItem>
                                        </ContextMenu>
                                    </Grid.ContextMenu>
                                <Image Source="{Binding SourcePath}" Stretch="Uniform" Height="48"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="Height" Value="64"/>
                            <!--<Setter Property="Padding" Value="12 5 12 5"/>-->
                            <Setter Property="HorizontalContentAlignment" Value="Center"/>
                            <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListBoxItem_PreviewMouseLeftButtonDown"/>
                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>

            </TabItem>
            <TabItem  x:Name="TabDydamic"
                        Header="Dynamic"
                        FontFamily="Segoe UI" Foreground="#FF666666"
                        HorizontalContentAlignment="Center"
                        FontSize="12"
                        >
                <ListBox ItemsSource="{Binding DynamicStampList}" Loaded="DydamicListBox_Loaded" SelectionMode="Single" Height="auto" VerticalAlignment="Top"  BorderThickness="0" ScrollViewer.HorizontalScrollBarVisibility="Disabled" >
                    <ListBox.ItemTemplate>
                        <DataTemplate >
                            <Grid>
                                <Image Source="{Binding ImageSource}" Stretch="Uniform" Height="48"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="Height" Value="64"/>
                            <Setter Property="Padding" Value="12 5 12 5"/>
                            <Setter Property="HorizontalContentAlignment" Value="Center"/>
                            <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListBoxItem_PreviewMouseLeftButtonDown"/>
                        </Style>
                    </ListBox.ItemContainerStyle>
                </ListBox>
            </TabItem>
            <TabItem  x:Name="TabCustom"
                        Header="Custom"
                        FontFamily="Segoe UI" Foreground="#FF666666"
                        FontSize="12" 
                        HorizontalContentAlignment="Center"
                        >
                <Grid>
                    <StackPanel VerticalAlignment="Center" x:Name="NoStampStackPanel" Visibility="{Binding CustomStampList.Count, Converter={StaticResource ListCountToVisible}}">
                        <Image Source="pack://application:,,,/PDF Office;component/Resources/PropertyPanel/nostamp.png" />
                        <TextBlock Text="No custom stamp created" FontSize="14" FontFamily="Segoe UI" Height="22" HorizontalAlignment="Center"/>
                        <TextBlock Width="168" FontSize="12" FontFamily="Segoe UI" TextWrapping="Wrap" Foreground="#94989C" HorizontalAlignment="Center">
                         <Run Text="Click the"  />
                         <Run Text="Add button" FontWeight="Bold"/>
                         <Run Text="in the upper right corner to create a new stamp." />

                        </TextBlock>
                    </StackPanel>
                <ListBox Name="CusListbox" Margin="0 0 0 56"  Visibility="{Binding ElementName=NoStampStackPanel,Path=Visibility,Converter={StaticResource UnVisivleConvert}}"
                             VerticalAlignment="Top"
                             Height="auto"
                             BorderThickness="0"
                             ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                             ItemsSource="{Binding CustomStampList}"
                             SelectedIndex="{Binding CusListboxIndex,Mode=TwoWay}"
                             >
                    <ListBox.ItemTemplate>
                        <HierarchicalDataTemplate  DataType="{x:Type model:Stamp}" >
                            <Grid>
                                <Grid.ContextMenu>
                                    <ContextMenu>
                                        <MenuItem x:Name="Delete" Header="删除图章" Click="Delete_Click"/>
                                        <MenuItem x:Name="DeleteAll" Header="删除全部图章" Click="DeleteAll_Click"/>
                                        <MenuItem Header="导出图章">
                                            <MenuItem x:Name="SavePNG" Header="PNG" Tag="PNG" Click="Save_Click"/>
                                            <MenuItem x:Name="SavePDF" Header="PDF" Tag="PDF" Click="Save_Click"/>
                                        </MenuItem>
                                        <MenuItem Header="编辑文字图章" Click="Editor_Click"/>
                                    </ContextMenu>
                                </Grid.ContextMenu>
                                <Image Source="{Binding SourcePath}"/>
                            </Grid>
                        </HierarchicalDataTemplate>
                    </ListBox.ItemTemplate>

                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="Height" Value="64"/>
                            <!--<Setter Property="Padding" Value="12 5 12 5"/>-->
                            <Setter Property="HorizontalContentAlignment" Value="Center"/>
                            <EventSetter Event="PreviewMouseLeftButtonDown" Handler="ListBoxItem_PreviewMouseLeftButtonDown"/>
                        </Style>
                    </ListBox.ItemContainerStyle>
                    </ListBox>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</UserControl>
