<UserControl x:Class="PixiEditor.Views.UserControls.SizeInput"
             x:ClassModifier="internal"
             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:i="http://schemas.microsoft.com/xaml/behaviors"
             xmlns:behaviors="clr-namespace:PixiEditor.Helpers.Behaviours"
             xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
             xmlns:views="clr-namespace:PixiEditor.Views"
             xmlns:ui="clr-namespace:PixiEditor.Extensions.UI;assembly=PixiEditor.Extensions"
             mc:Ignorable="d" Foreground="White" Focusable="True"
             d:DesignHeight="30" Name="uc"
             FlowDirection="LeftToRight">
    <Border BorderThickness="1" CornerRadius="3.5"
            x:Name="border"
            Cursor="IBeam" MouseLeftButtonDown="Border_MouseLeftButtonDown"
            MouseWheel="Border_MouseWheel">
        <Border.Style>
            <Style TargetType="Border">
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="False">
                        <Setter Property="Background" Value="{StaticResource AccentColor}"/>
                        <Setter Property="BorderBrush" Value="{StaticResource BrighterAccentColor}"/>
                    </Trigger>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background" Value="{StaticResource DarkerAccentColor}"/>
                        <Setter Property="BorderBrush" Value="{StaticResource AlmostLightModeAccentColor}"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Border.Style>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="2"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <TextBox IsEnabled="{Binding IsEnabled, ElementName=uc}" HorizontalContentAlignment="Right"
                     InputScope="Number" BorderThickness="0" Background="Transparent"
                     SelectionBrush="{StaticResource SelectionColor}"
                     Foreground="{Binding Foreground, ElementName=uc}" Focusable="True" CaretBrush="{Binding Foreground, ElementName=uc}"
                     Margin="0,0,5,0" VerticalAlignment="Center"
                     x:Name="textBox"
                     Text="{Binding Size, ElementName=uc, Converter={converters:ToolSizeToIntConverter}}"
                     d:Text="22"
                     MaxLength="6"
                     MinWidth="43">
                <i:Interaction.Behaviors>
                    <behaviors:GlobalShortcutFocusBehavior/>
                    <behaviors:TextBoxFocusBehavior 
                        SelectOnMouseClick="{Binding BehaveLikeSmallEmbeddedField, ElementName=uc}" 
                        ConfirmOnEnter="{Binding BehaveLikeSmallEmbeddedField, ElementName=uc}"
                        DeselectOnFocusLoss="True"/>
                </i:Interaction.Behaviors>
            </TextBox>
            <Grid Grid.Column="1" Background="{Binding BorderBrush, ElementName=border}"
                  d:Background="{StaticResource BrighterAccentColor}"/>
            <TextBlock ui:Translator.Key="{Binding Unit, ElementName=uc, Converter={converters:EnumToStringConverter}}" TextAlignment="Right"
                       Grid.Column="2" Margin="5,0" VerticalAlignment="Center"
            />
        </Grid>
    </Border>
</UserControl>
