<UserControl x:Class="HistoryView.Controls.Input.NumberKeyboard"
             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:HistoryView.Controls.Input"
             mc:Ignorable="d" 
             x:Name="This"
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <ContentPresenter x:Name="presenter" TouchEnter="presenter_TouchEnter"
                          TouchLeave="presenter_TouchLeave" Content="{Binding ElementName=This, Path=DisplayContent}"/>
        <Popup x:Name="PopKeyboard" AllowsTransparency="True" PopupAnimation="Slide" PlacementTarget="{Binding ElementName=presenter}" HorizontalOffset="-56" VerticalOffset="5">
            <Border BorderBrush="{StaticResource DarkBorderColor}" BorderThickness="2" CornerRadius="8" Background="{StaticResource BackgroundColor}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto"/>
                        <RowDefinition Height="8"/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>

                    <Border Background="{StaticResource LightThemeColor}" CornerRadius="8,8,0,0" >
                        <StackPanel Margin="8" Orientation="Horizontal" HorizontalAlignment="Center">
                            <TextBlock Foreground="Red" FontSize="16" FontWeight="Bold" VerticalAlignment="Center">|</TextBlock>
                            <TextBlock  FontSize="14" VerticalAlignment="Center" Text="{Binding ElementName=This, Path=Display}"/>
                            <TextBlock Foreground="Red" FontSize="16" FontWeight="Bold" VerticalAlignment="Center">|</TextBlock>
                        </StackPanel>
                    </Border>

                    <Grid Grid.Row="2" Margin="8" TextElement.FontSize="16" TextElement.FontWeight="Bold">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="42"/>
                            <ColumnDefinition Width="8"/>
                            <ColumnDefinition Width="42"/>
                            <ColumnDefinition Width="8"/>
                            <ColumnDefinition Width="42"/>
                            <ColumnDefinition Width="8"/>
                            <ColumnDefinition Width="42"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="42"/>
                            <RowDefinition Height="8"/>
                            <RowDefinition Height="42"/>
                            <RowDefinition Height="8"/>
                            <RowDefinition Height="42"/>
                            <RowDefinition Height="8"/>
                            <RowDefinition Height="42"/>
                            <RowDefinition Height="8"/>
                            <RowDefinition Height="42"/>
                        </Grid.RowDefinitions>

                        <Button Grid.Column="0" Grid.Row="0" Style="{StaticResource FunctionButton}" Background="{StaticResource NormalColor}" Click="Operate" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="+1">+1</Button>
                        <Button Grid.Column="2" Grid.Row="0" Style="{StaticResource FunctionButton}" Background="{StaticResource NormalColor}" Click="Operate" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="+.1" FontSize="12">+.1</Button>
                        <Button Grid.Column="4" Grid.Row="0" Style="{StaticResource FunctionButton}" Background="{StaticResource NormalColor}" Click="Operate" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="-.1" FontSize="12">-.1</Button>
                        <Button Grid.Column="6" Grid.Row="0" Style="{StaticResource FunctionButton}" Background="{StaticResource NormalColor}" Click="Operate" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="-1">-1</Button>

                        <Button Grid.Column="0" Grid.Row="2" Style="{StaticResource FunctionButton}" Background="{StaticResource ThemeColor}" Click="SendKey" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="1">1</Button>
                        <Button Grid.Column="2" Grid.Row="2" Style="{StaticResource FunctionButton}" Background="{StaticResource ThemeColor}" Click="SendKey" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="2">2</Button>
                        <Button Grid.Column="4" Grid.Row="2" Style="{StaticResource FunctionButton}" Background="{StaticResource ThemeColor}" Click="SendKey" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="3">3</Button>

                        <Button Grid.Column="0" Grid.Row="4" Style="{StaticResource FunctionButton}" Background="{StaticResource ThemeColor}" Click="SendKey" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="4">4</Button>
                        <Button Grid.Column="2" Grid.Row="4" Style="{StaticResource FunctionButton}" Background="{StaticResource ThemeColor}" Click="SendKey" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="5">5</Button>
                        <Button Grid.Column="4" Grid.Row="4" Style="{StaticResource FunctionButton}" Background="{StaticResource ThemeColor}" Click="SendKey" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="6">6</Button>

                        <Button Grid.Column="0" Grid.Row="6" Style="{StaticResource FunctionButton}" Background="{StaticResource ThemeColor}" Click="SendKey" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="7">7</Button>
                        <Button Grid.Column="2" Grid.Row="6" Style="{StaticResource FunctionButton}" Background="{StaticResource ThemeColor}" Click="SendKey" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="8">8</Button>
                        <Button Grid.Column="4" Grid.Row="6" Style="{StaticResource FunctionButton}" Background="{StaticResource ThemeColor}" Click="SendKey" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter="9">9</Button>

                        <Button Grid.Column="0" Grid.Row="8" Grid.ColumnSpan="3" Style="{StaticResource FunctionButton}" Background="{StaticResource ThemeColor}" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" Click="SendKey" CommandParameter="0">0</Button>
                        <Button Grid.Column="4" Grid.Row="8" Style="{StaticResource FunctionButton}" Click="SendKey" TouchDown="Button_TouchDown" TouchLeave="Button_TouchLeave" CommandParameter=".">.</Button>

                        <Button Grid.Column="6" Grid.Row="2" Style="{StaticResource FunctionButton}" Background="{StaticResource WarningColor}" Click="Delete" FontSize="11">Del</Button>
                        <Button Grid.Column="6" Grid.Row="4" Style="{StaticResource FunctionButton}" Background="{StaticResource WarningColor}" Click="Clear">C</Button>

                        <Button Grid.Column="6" Grid.Row="6" Style="{StaticResource FunctionButton}" Click="CancelConfirm" CommandParameter="Cancel" Background="{StaticResource EmergencyColor}">×</Button>
                        <Button Grid.Column="6" Grid.Row="8" Style="{StaticResource FunctionButton}" Click="CancelConfirm" CommandParameter="Confirm" Background="{StaticResource NiceGreen}">√</Button>


                    </Grid>
                </Grid>
            </Border>
        </Popup>

        <Popup x:Name="Hint" Placement="Top" VerticalOffset="-16" AllowsTransparency="True">
            <Border Background="White" Width="50" Height="50" CornerRadius="8">
                <TextBlock x:Name="HintText" FontSize="24" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold" Foreground="Black"/>
            </Border>
        </Popup>
    </Grid>
</UserControl>
