<UserControl x:Class="ComPDFKit.Controls.PDFControlUI.CPDFSearchInputUI"
             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.PDFControlUI"
             xmlns:common="clr-namespace:ComPDFKit.Controls.Common"
             d:DesignWidth="300" d:DesignHeight="100"
             mc:Ignorable="d">
    <UserControl.Resources>
        <ResourceDictionary>
            <common:TextLengthToVisibilityConverter x:Key="TextLengthToVisibilityConverter"/>
            <common:InvertTextLengthToVisibilityConverter x:Key="InvertTextLengthToVisibilityConverter"/>
            <common:TextLengthToBoolConverter x:Key="TextLengthToBoolConverter"/>
            <common:BotaResourceConverter x:Key="BotaResourceConverter"></common:BotaResourceConverter>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../../Asset/Styles/ButtonStyle.xaml"></ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid x:Name="InputGrid">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="auto"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
            
        <Grid Margin="0,0,8,0">
            <TextBox Name="SearchTextBox" VerticalContentAlignment="Center" Height="30" KeyDown="SearchTextBox_KeyDown" Padding="5,0,30,0"></TextBox>
            <TextBlock VerticalAlignment="Center" IsHitTestVisible="False" Margin="10,0,0,0" Foreground="#999999" 
                       Visibility="{Binding ElementName=SearchTextBox,Path=Text,Converter={StaticResource TextLengthToVisibilityConverter}}"
                       Text="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Holder_Search}"></TextBlock>
            
            <Border Visibility="{Binding ElementName=SearchTextBox,Path=Text,Converter={StaticResource InvertTextLengthToVisibilityConverter}}"
                    HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0"
                    Background="#01000000" MouseLeftButtonDown="TextClear_MouseLeftButtonDown">
                <Path Fill="Black" IsHitTestVisible="False">
                    <Path.Data>
                        M12.5762 3.95117L8.5332 8L12.5762 12.0488L12.0488 12.5762L8 8.5332L3.95117 12.5762L3.42383 12.0488L7.4668 8L3.42383 3.95117L3.95117 3.42383L8 7.4668L12.0488 3.42383L12.5762 3.95117Z
                    </Path.Data>
                </Path>
            </Border>
        </Grid>
        
        <Grid Grid.Column="1">
            <Button Name="SearchBtn" Style="{StaticResource ButtonStyle}"  Width="56" Height="30" FontSize="14" Click="SearchBtn_Click"
                    IsEnabled="{Binding ElementName=SearchTextBox,Path=Text,Converter={StaticResource TextLengthToBoolConverter}}"
                    Content="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Button_Done}">
            </Button>
        </Grid>

        <Grid Grid.Row="1" Margin="0,0,8,0">
            <TextBox Name="ReplaceTextBox" VerticalContentAlignment="Center" Height="30" KeyDown="SearchTextBox_KeyDown" Padding="5,0,30,0"></TextBox>
            <TextBlock VerticalAlignment="Center" IsHitTestVisible="False" Margin="10,0,0,0" Foreground="#999999" 
                       Visibility="{Binding ElementName=ReplaceTextBox,Path=Text,Converter={StaticResource TextLengthToVisibilityConverter}}"
                       Text="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Holder_Replace}"></TextBlock>
            
            <Border Visibility="{Binding ElementName=ReplaceTextBox,Path=Text,Converter={StaticResource InvertTextLengthToVisibilityConverter}}"
                    HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0"
                    Background="#01000000" MouseLeftButtonDown="ReplaceTextClear_MouseLeftButtonDown">
                <Path Fill="Black" IsHitTestVisible="False">
                    <Path.Data>
                        M12.5762 3.95117L8.5332 8L12.5762 12.0488L12.0488 12.5762L8 8.5332L3.95117 12.5762L3.42383 12.0488L7.4668 8L3.42383 3.95117L3.95117 3.42383L8 7.4668L12.0488 3.42383L12.5762 3.95117Z
                    </Path.Data>
                </Path>
            </Border>
        </Grid>
        
        <Grid Grid.Row="1" Grid.Column="1">
            <DockPanel>
                <Button Background="Transparent" BorderThickness="0" Width="20" Height="20" FontSize="14" HorizontalAlignment="Left" Click="Previous_Click" 
                        ToolTip="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Button_Prev}">
                    <Viewbox>
                        <Path StrokeThickness="1.5" Stroke="#999999">
                            <Path.Data>
                                M8 1.07129L2 7.07111L8 13.0709
                            </Path.Data>
                        </Path>
                    </Viewbox>
                </Button>
                
                <Button Background="Transparent" BorderThickness="0" Width="20" Height="20" FontSize="14" HorizontalAlignment="Right" Click="Next_Click"
                        ToolTip="{Binding Converter={StaticResource BotaResourceConverter},ConverterParameter=Button_Next}">
                    <Viewbox>
                        <Path StrokeThickness="1.5" Stroke="#999999">
                            <Path.Data>
                                M2 1.07129L8 7.07111L2 13.0709
                            </Path.Data>
                        </Path>
                    </Viewbox>
                </Button>
            </DockPanel>
        </Grid>
    </Grid>
</UserControl>
