<UserControl
    x:Class="PDF_Office.Views.PropertyPanel.ViewModular.ReadModeContent"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ViewModular="clr-namespace:PDF_Office.ViewModels.PropertyPanel.ViewModular"
    xmlns:convert="clr-namespace:PDF_Office.DataConvert"
    xmlns:converter="clr-namespace:PDF_Office.DataConvert"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:helper="clr-namespace:PDF_Office.Helper"
    xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
    xmlns:local="clr-namespace:PDF_Office.Views.PropertyPanel.ViewModular"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:prism="http://prismlibrary.com/"
    x:Name="ReadMode"
    Width="auto"
    d:DataContext="{d:DesignInstance Type=ViewModular:ReadModeContentViewModel}"
    d:DesignHeight="44"
    d:DesignWidth="230"
    Background="#CC000000"
    mc:Ignorable="d">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="pack://application:,,,/Styles/ButtonStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <convert:ObjectConvert x:Key="ObjectConvert" />
        </ResourceDictionary>
    </UserControl.Resources>
    <StackPanel Name="ParentPanel" Orientation="Horizontal">

        <RepeatButton
            x:Name="BtnZoomOut"
            Width="32"
            Height="32"
            Margin="1,0,2,0"
            Background="Transparent"
            BorderThickness="0"
            Command="{Binding ZoomOutCommand}"
            Interval="200"
            Template="{StaticResource zoomout}" />
        <RepeatButton
            Name="BtnZoomIn"
            Width="32"
            Height="32"
            Margin="0,0,1,0"
            Background="Transparent"
            BorderThickness="0"
            Command="{Binding ZoomInCommand}"
            Interval="200"
            Template="{StaticResource zoomin}" />

        <Border
            Width="100"
            Height="32"
            BorderBrush="White"
            BorderThickness="0">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid>
                    <TextBox
                        x:Name="TxtCurrentPageNum"
                        Width="45"
                        Height="32"
                        Padding="0,5.5,0,0"
                        Background="Transparent"
                        BorderThickness="0"
                        CaretBrush="Black"
                        FontFamily="Segoe UI"
                        FontSize="14"
                        Foreground="Black"
                        InputMethod.IsInputMethodEnabled="False"
                        LostFocus="TxtCurrentPageNum_LostFocus"
                        LostKeyboardFocus="TxtCurrentPageNum_LostKeyboardFocus"
                        Text="{Binding CurrentPage}"
                        TextAlignment="Center">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="KeyDown">
                                <helper:AdvancedInvokeCommandAction
                                    Command="{Binding KeyDownCommand}"
                                    CommandParameter="{Binding ElementName=TxbCurrentPageNum}"
                                    PassEventArgsToCommand="True" />
                            </i:EventTrigger>
                            <i:EventTrigger EventName="PreviewKeyDown">
                                <i:InvokeCommandAction Command="{Binding PreviewKeyDownCommand}" PassEventArgsToCommand="True" />
                            </i:EventTrigger>
                            <!--<i:EventTrigger EventName="LostKeyboardFocus">
                            <helper:AdvancedInvokeCommandAction
                            Command="{Binding LostKeyboardFocusCommand}"
                            CommandParameter="{Binding ElementName=TxbCurrentPageNum}"
                            PassEventArgsToCommand="True" />
                            </i:EventTrigger>-->
                        </i:Interaction.Triggers>
                    </TextBox>

                    <TextBlock
                        Name="TxbCurrentPageNum"
                        Width="45"
                        Height="32"
                        Padding="0,5.5,0,0"
                        Background="Transparent"
                        FontFamily="Segoe UI"
                        FontSize="14"
                        Foreground="White"
                        PreviewMouseLeftButtonDown="TxbCurrentPageNum_PreviewMouseLeftButtonDown"
                        Text="{Binding CurrentPage}"
                        TextAlignment="Center"
                        Visibility="Visible" />
                </Grid>

                <TextBlock
                    x:Name="TxtPageCount"
                    Grid.Column="1"
                    Height="32"
                    MinWidth="50"
                    Padding="0,5.5,0,0"
                    FontFamily="Segoe UI"
                    FontSize="14"
                    Foreground="#999999"
                    Text="{Binding PageCount, StringFormat=/    {0}}"
                    TextAlignment="Left" />
            </Grid>
        </Border>
        <Button
            Name="BtnPrePage"
            Margin="25,0,2,0"
            Background="Transparent"
            Command="{Binding PrePageCommand}"
            CommandParameter="{Binding ElementName=BtnPrePage}"
            Template="{StaticResource prepage}" />
        <Button
            x:Name="BtnNextPage"
            Margin="2,0,1,0"
            Background="Transparent"
            Command="{Binding NextPageCommand}"
            CommandParameter="{Binding ElementName=BtnNextPage}"
            Template="{StaticResource nextpage}" />
    </StackPanel>

    <i:Interaction.Triggers>
        <i:EventTrigger EventName="Loaded">
            <helper:AdvancedInvokeCommandAction Command="{Binding LoadedCommand}" PassEventArgsToCommand="True">
                <helper:AdvancedInvokeCommandAction.CommandParameter>
                    <MultiBinding Converter="{StaticResource ResourceKey=ObjectConvert}" Mode="TwoWay">
                        <MultiBinding.Bindings>
                            <Binding ElementName="BtnPrePage" />
                            <Binding ElementName="BtnNextPage" />
                            <Binding ElementName="BtnZoomOut" />
                            <Binding ElementName="BtnZoomIn" />
                        </MultiBinding.Bindings>
                    </MultiBinding>
                </helper:AdvancedInvokeCommandAction.CommandParameter>
            </helper:AdvancedInvokeCommandAction>
        </i:EventTrigger>
    </i:Interaction.Triggers>
</UserControl>