<UserControl x:Class="ComPDFKit.Controls.PDFControl.PreviewControl"
             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"
              xmlns:common="clr-namespace:ComPDFKit.Controls.Common"
             mc:Ignorable="d" 
             d:DesignHeight="449" d:DesignWidth="248" Loaded="UserControl_Loaded">
    <UserControl.Resources>
        <ResourceDictionary>
            <Style x:Key="TransparentButtonStyle" TargetType="{x:Type Button}">
                <Setter Property="BorderThickness" Value="0" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Border Name="border">
                                <ContentPresenter />
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="border" Property="Background" Value="#1a000000" />
                                </Trigger>
                                <Trigger Property="IsPressed" Value="True">
                                    <Setter TargetName="border" Property="Background" Value="#5a000000" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="PageButtonStyle" TargetType="{x:Type Button}">
                <Setter Property="BorderThickness" Value="0"></Setter>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Border Name="border" Background="#E1E1E1">
                                <ContentPresenter />
                            </Border>
                            <ControlTemplate.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Setter TargetName="border" Property="Background" Value="#C1C1C1" />
                                </Trigger> 
                                <Trigger Property="IsPressed" Value="True">
                                    <Setter TargetName="border"  Property="Background" Value="#A1A1A1" />
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
            <common:CommonResourceConverter x:Key="CommonResourceConverter" />
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid Margin="0,0,0,10">
            <TextBlock Text="{Binding Converter={StaticResource CommonResourceConverter},ConverterParameter=Title_Preview}" FontWeight="DemiBold" FontFamily="Microsoft YaHei" FontSize="14"></TextBlock>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
                <Button x:Name="ZoomInBtn" Height="20" Width="20" Style="{StaticResource TransparentButtonStyle}" Margin="0,0,10,0" Click="ScaleBtn_Click">
                    <Path HorizontalAlignment="Center" VerticalAlignment="Center" Data="M0,6.5 C0,2.91015 2.91015,0 6.5,0 C10.0899,0 13,2.91015 13,6.5 C13,8.12212 12.4058,9.60545 11.4232,10.7442 L15.5,14.821 L14.821,15.5 L10.7442,11.4232 C9.60545,12.4058 8.12212,13 6.5,13 C2.91015,13 0,10.0899 0,6.5 Z M12,6.5 C12,3.46243 9.53757,1 6.5,1 C3.46243,1 1,3.46243 1,6.5 C1,9.53757 3.46243,12 6.5,12 C9.53757,12 12,9.53757 12,6.5 Z M10,6 V7 H3 V6 H10 Z" 
              Fill="Black" />
                </Button>
                <Button x:Name="ZoomOutBtn" Height="20" Width="20"  Style="{StaticResource TransparentButtonStyle}"  Click="ScaleBtn_Click">
                    <Path HorizontalAlignment="Center" VerticalAlignment="Center" Data="M6.5 0C2.91015 0 0 2.91015 0 6.5C0 10.0899 2.91015 13 6.5 13C8.12212 13 9.60545 12.4058 10.7442 11.4232L14.821 15.5L15.5 14.821L11.4232 10.7442C12.4058 9.60545 13 8.12212 13 6.5C13 2.91015 10.0899 0 6.5 0ZM6.5 1C9.53757 1 12 3.46243 12 6.5C12 9.53757 9.53757 12 6.5 12C3.46243 12 1 9.53757 1 6.5C1 3.46243 3.46243 1 6.5 1ZM10 6H7V3H6V6H3V7H6V10H7V7H10V6Z" 
              Fill="Black" />
                </Button>
            </StackPanel>
        </Grid>
        <Border Grid.Row="1" x:Name="ImageGd" Background="#1A000000" ClipToBounds="True" BorderThickness="1" BorderBrush="#000000">
            <ScrollViewer x:Name="ImageSv" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
                <Image x:Name="Image" Source="{Binding ImageSource}" Stretch="None" MouseLeftButtonDown="Image_MouseLeftButtonDown" MouseLeftButtonUp="Image_MouseLeftButtonUp" MouseMove="Image_MouseMove">
                    <Image.LayoutTransform>
                        <ScaleTransform ScaleX="{Binding Scale}" ScaleY="{Binding Scale}"></ScaleTransform>
                    </Image.LayoutTransform>
                </Image>
            </ScrollViewer>
        </Border>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="2" Margin="0,8,0,0">
            <Button x:Name="PrePageBtn" Height="28" Width="28" Margin="0,0,16,0" Style="{StaticResource PageButtonStyle}" Click="PageBtn_Click">
                <Path Height="16" Width="16" Data="M11.2978 14L12 13.2733L6.90446 8L12 2.72673L11.2978 2L5.5 8L11.2978 14Z" 
              Fill="Black" />
            </Button>
            <TextBox x:Name="CurrentIndexTxt" Text="{Binding CurrentIndex, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Height="32" Width="48" Margin="0,0,8,0" PreviewTextInput="CurrentIndexTxt_PreviewTextInput" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"  InputMethod.IsInputMethodEnabled="False" CommandManager.CanExecute="CurrentIndexTxt_CanExecute"></TextBox>
            <TextBlock Text="/" FontSize="14" VerticalAlignment="Center" FontFamily="Microsoft YaHei"></TextBlock>
            <TextBlock Text="{Binding PageCount}" Margin="5,0,0,0" FontSize="14" VerticalAlignment="Center" FontFamily="Microsoft YaHei"></TextBlock>
            <Button x:Name="NextPageBtn" Height="28" Width="28"  Margin="16,0,0,0" Style="{StaticResource PageButtonStyle}"  Click="PageBtn_Click">
                <Path Height="16" Width="16" Data="M6.20223 14L5.5 13.2733L10.5955 8L5.5 2.72673L6.20223 2L12 8L6.20223 14Z" 
              Fill="Black" />
            </Button>
        </StackPanel>
    </Grid>
</UserControl>