Browse Source

Created float setting

flabbet 5 years ago
parent
commit
1a5de74e8d

+ 43 - 5
PixiEditor/Helpers/Behaviours/TextBoxNumericFinisherBehavior.cs → PixiEditor/Helpers/Behaviours/TextBoxFocusBehavior.cs

@@ -4,13 +4,47 @@ using System.Linq;
 using System.Text;
 using System.Text;
 using System.Text.RegularExpressions;
 using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
+using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
+using System.Windows.Input;
 using System.Windows.Interactivity;
 using System.Windows.Interactivity;
 
 
 namespace PixiEditor.Helpers.Behaviours
 namespace PixiEditor.Helpers.Behaviours
 {
 {
-    class TextBoxNumericFinisherBehavior : Behavior<TextBox>
+    class TextBoxFocusBehavior : Behavior<TextBox>
     {
     {
+
+        public bool FillSize
+        {
+            get { return (bool)GetValue(FillSizeProperty); }
+            set { SetValue(FillSizeProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for FillSize.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty FillSizeProperty =
+            DependencyProperty.Register("FillSize", typeof(bool), typeof(TextBoxFocusBehavior), new PropertyMetadata(false));
+
+
+
+
+
+        public FocusNavigationDirection NextFocusDirection
+        {
+            get { return (FocusNavigationDirection)GetValue(NextFocusDirectionProperty); }
+            set { SetValue(NextFocusDirectionProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for NextFocusDirection.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty NextFocusDirectionProperty =
+            DependencyProperty.Register("NextFocusDirection", typeof(FocusNavigationDirection), typeof(TextBoxFocusBehavior), 
+                new PropertyMetadata(FocusNavigationDirection.Up));
+
+
+
+
+
+
+
         private string _oldText; //Value of textbox before editing
         private string _oldText; //Value of textbox before editing
         private bool _valueConverted = false; //This bool is used to avoid double convertion if enter is hitted
         private bool _valueConverted = false; //This bool is used to avoid double convertion if enter is hitted
 
 
@@ -34,13 +68,17 @@ namespace PixiEditor.Helpers.Behaviours
             if (e.Key != System.Windows.Input.Key.Enter) return;
             if (e.Key != System.Windows.Input.Key.Enter) return;
 
 
             ConvertValue();
             ConvertValue();
-            AssociatedObject.MoveFocus(new System.Windows.Input.TraversalRequest(System.Windows.Input.FocusNavigationDirection.Previous));
+            AssociatedObject.MoveFocus(new TraversalRequest(NextFocusDirection));
         }
         }
 
 
         private void AssociatedObject_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e)
         private void AssociatedObject_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e)
         {
         {
-            _valueConverted = false;
-            _oldText = AssociatedObject.Text; //Sets old value when keyboard is focused on object
+            AssociatedObject.SelectAll();
+            if (FillSize)
+            {
+                _valueConverted = false;
+                _oldText = AssociatedObject.Text; //Sets old value when keyboard is focused on object
+            }
         }
         }
 
 
         private void AssociatedObject_LostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e)
         private void AssociatedObject_LostKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e)
@@ -53,7 +91,7 @@ namespace PixiEditor.Helpers.Behaviours
         /// </summary>
         /// </summary>
         private void ConvertValue()
         private void ConvertValue()
         {
         {
-            if (_valueConverted == true) return;
+            if (_valueConverted == true || FillSize == false) return;
             if (int.TryParse(Regex.Replace(AssociatedObject.Text, "\\p{L}", ""), out _) == true)
             if (int.TryParse(Regex.Replace(AssociatedObject.Text, "\\p{L}", ""), out _) == true)
             {
             {
                 AssociatedObject.Text = string.Format("{0} {1}", AssociatedObject.Text, "px");
                 AssociatedObject.Text = string.Format("{0} {1}", AssociatedObject.Text, "px");

+ 46 - 0
PixiEditor/Models/Tools/ToolSettings/Settings/FloatSetting.cs

@@ -0,0 +1,46 @@
+using PixiEditor.Views;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+
+namespace PixiEditor.Models.Tools.ToolSettings.Settings
+{
+    public class FloatSetting : Setting
+    {
+
+        public float Min { get; set; }
+        public float Max { get; set; }
+
+        public FloatSetting(string name, float initialValue, string label = "", 
+            float min = float.NegativeInfinity, float max = float.PositiveInfinity) : base(name)
+        {
+            Label = label;
+            Value = initialValue;
+            Min = min;
+            Max = max;
+            SettingControl = GenerateNumberInput();
+        }
+
+        private NumberInput GenerateNumberInput()
+        {
+            NumberInput numbrInput = new NumberInput()
+            {
+                Width = 40,
+                Height = 20,
+                Min = Min,
+                Max = Max
+
+            };
+            Binding binding = new Binding("Value")
+            {
+                Mode = BindingMode.TwoWay,
+            };
+            numbrInput.SetBinding(NumberInput.ValueProperty, binding);
+            return numbrInput;
+        }
+    }
+}

+ 4 - 1
PixiEditor/Models/Tools/ToolSettings/Settings/SizeSetting.cs

@@ -35,7 +35,10 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
                 Mode = BindingMode.TwoWay,
                 Mode = BindingMode.TwoWay,
             };
             };
             tb.SetBinding(TextBox.TextProperty, binding);
             tb.SetBinding(TextBox.TextProperty, binding);
-            TextBoxNumericFinisherBehavior behavor = new TextBoxNumericFinisherBehavior();
+            TextBoxFocusBehavior behavor = new TextBoxFocusBehavior
+            {
+                FillSize = true
+            };
             Interaction.GetBehaviors(tb).Add(behavor);
             Interaction.GetBehaviors(tb).Add(behavor);
             return tb;
             return tb;
         }
         }

+ 15 - 0
PixiEditor/Models/Tools/ToolSettings/Toolbars/BrightnessToolToolbar.cs

@@ -0,0 +1,15 @@
+using PixiEditor.Models.Tools.ToolSettings.Settings;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace PixiEditor.Models.Tools.ToolSettings.Toolbars
+{
+    public class BrightnessToolToolbar : BasicToolbar
+    {
+        public BrightnessToolToolbar(float initialValue)
+        {
+            Settings.Add(new FloatSetting("CorrectionFactor", initialValue, "Strength:", 0f, 100f));
+        }
+    }
+}

+ 6 - 4
PixiEditor/Models/Tools/Tools/BrightnessTool.cs

@@ -2,6 +2,7 @@
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.ToolSettings;
 using PixiEditor.Models.Tools.ToolSettings;
+using PixiEditor.Models.Tools.ToolSettings.Toolbars;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Windows.Input;
 using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media;
@@ -12,22 +13,23 @@ namespace PixiEditor.Models.Tools.Tools
     public class BrightnessTool : Tool
     public class BrightnessTool : Tool
     {
     {
         public override ToolType ToolType => ToolType.Brightness;
         public override ToolType ToolType => ToolType.Brightness;
-        public const float CorrectionFactor = 5f;
+        private const float CorrectionFactor = 5f; //Initial correction factor
         
         
         public BrightnessTool()
         public BrightnessTool()
         {
         {
             Tooltip = "Makes pixel brighter or darker pixel (U)";
             Tooltip = "Makes pixel brighter or darker pixel (U)";
-            Toolbar = new BasicToolbar();
+            Toolbar = new BrightnessToolToolbar(CorrectionFactor);
         }
         }
 
 
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color)
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
             int toolSize = (int)Toolbar.GetSetting("ToolSize").Value;
             int toolSize = (int)Toolbar.GetSetting("ToolSize").Value;
+            float correctionFactor = (float)Toolbar.GetSetting("CorrectionFactor").Value;
             if(Keyboard.IsKeyDown(Key.LeftCtrl))
             if(Keyboard.IsKeyDown(Key.LeftCtrl))
             {
             {
-                return ChangeBrightness(layer, coordinates[0], toolSize, -CorrectionFactor);
+                return ChangeBrightness(layer, coordinates[0], toolSize, -correctionFactor);
             }
             }
-                return ChangeBrightness(layer, coordinates[0], toolSize, CorrectionFactor);
+                return ChangeBrightness(layer, coordinates[0], toolSize, correctionFactor);
         }       
         }       
 
 
         private BitmapPixelChanges ChangeBrightness(Layer layer, Coordinates coordinates, int toolSize, float correctionFactor)
         private BitmapPixelChanges ChangeBrightness(Layer layer, Coordinates coordinates, int toolSize, float correctionFactor)

+ 2 - 0
PixiEditor/Styles/ThemeStyle.xaml

@@ -38,6 +38,8 @@
     </Style>
     </Style>
 
 
     <Style TargetType="Button"  x:Key="DarkRoundButton" BasedOn="{StaticResource BaseDarkButton}">
     <Style TargetType="Button"  x:Key="DarkRoundButton" BasedOn="{StaticResource BaseDarkButton}">
+        <Setter Property="OverridesDefaultStyle" Value="True"/>
+        <Setter Property="Background" Value="#303030"/>
         <Setter Property="Template">
         <Setter Property="Template">
             <Setter.Value>
             <Setter.Value>
                 <ControlTemplate TargetType="Button">
                 <ControlTemplate TargetType="Button">

+ 16 - 8
PixiEditor/Views/NewFilePopup.xaml

@@ -6,11 +6,13 @@
              xmlns:local="clr-namespace:PixiEditor.Views"
              xmlns:local="clr-namespace:PixiEditor.Views"
              xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
              xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
              xmlns:vm="clr-namespace:PixiEditor.ViewModels"
              xmlns:vm="clr-namespace:PixiEditor.ViewModels"
-             xmlns:helpers="clr-namespace:PixiEditor.Helpers.Behaviours"
-             mc:Ignorable="d" 
+             xmlns:helpers="clr-namespace:PixiEditor.Helpers.Behaviours" 
+             xmlns:converters="clr-namespace:PixiEditor.Helpers"
+        mc:Ignorable="d" 
              d:DesignHeight="600" d:DesignWidth="450" DataContext="{DynamicResource NewFileMenuViewModel}" WindowStyle="None" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Height="600" Width="450" Name="newFilePopup">
              d:DesignHeight="600" d:DesignWidth="450" DataContext="{DynamicResource NewFileMenuViewModel}" WindowStyle="None" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" Height="600" Width="450" Name="newFilePopup">
     <Window.Resources>
     <Window.Resources>
         <vm:NewFileMenuViewModel x:Key="NewFileMenuViewModel"/>
         <vm:NewFileMenuViewModel x:Key="NewFileMenuViewModel"/>
+        <converters:ToolSizeToIntConverter x:Key="ToolSizeToIntConverter"/>
     </Window.Resources>
     </Window.Resources>
     <Border BorderBrush="Black" BorderThickness="1">
     <Border BorderBrush="Black" BorderThickness="1">
         <Grid Background="#404040">
         <Grid Background="#404040">
@@ -24,7 +26,8 @@
                         <i:InvokeCommandAction Command="{Binding DragMoveCommand}"/>
                         <i:InvokeCommandAction Command="{Binding DragMoveCommand}"/>
                     </i:EventTrigger>
                     </i:EventTrigger>
                 </i:Interaction.Triggers>
                 </i:Interaction.Triggers>
-                <Button Width="20" Height="20" VerticalAlignment="Top" HorizontalAlignment="Right" BorderThickness="0" Command="{Binding CloseCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}">
+                <Button Width="20" Height="20" VerticalAlignment="Top" Style="{StaticResource ImageButtonStyle}" Cursor="Hand" HorizontalAlignment="Right" BorderThickness="0" Command="{Binding CloseCommand}" 
+                        CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}">
                     <Button.Background>
                     <Button.Background>
                         <ImageBrush ImageSource="/Images/Cross.png" Stretch="Uniform"/>
                         <ImageBrush ImageSource="/Images/Cross.png" Stretch="Uniform"/>
                     </Button.Background>
                     </Button.Background>
@@ -33,22 +36,27 @@
             <StackPanel HorizontalAlignment="Center" Margin="0,50,0,0" Background="#303030" VerticalAlignment="Top" Grid.Row="1" Width="350" Height="150">
             <StackPanel HorizontalAlignment="Center" Margin="0,50,0,0" Background="#303030" VerticalAlignment="Top" Grid.Row="1" Width="350" Height="150">
                 <DockPanel Margin="50,35,0,0">
                 <DockPanel Margin="50,35,0,0">
                     <TextBlock Height="30" Foreground="Snow" Text="Height:" TextAlignment="Center" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                     <TextBlock Height="30" Foreground="Snow" Text="Height:" TextAlignment="Center" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                    <TextBox Height="30" Width="150" Style="{StaticResource DarkTextBoxStyle}" FontSize="16" HorizontalAlignment="Left" TextAlignment="Center" Margin="5,0,0,0" Text="{Binding ElementName=newFilePopup, Path=FileHeight, Mode=TwoWay}" MaxLength="4">
+                    <TextBox Height="30" Width="150" Style="{StaticResource DarkTextBoxStyle}" FontSize="16"
+                             HorizontalAlignment="Left" TextAlignment="Center" 
+                             Margin="5,0,0,0" Text="{Binding ElementName=newFilePopup, Converter={StaticResource ToolSizeToIntConverter}, Path=FileHeight, Mode=TwoWay}" MaxLength="4">
                         <i:Interaction.Behaviors>
                         <i:Interaction.Behaviors>
-                            <helpers:AllowableCharactersTextBoxBehavior RegularExpression="^[0-9./-]+$" MaxLength="4"/>
+                            <helpers:TextBoxFocusBehavior FillSize="True" NextFocusDirection="Next"/>
                         </i:Interaction.Behaviors>
                         </i:Interaction.Behaviors>
                     </TextBox>
                     </TextBox>
                 </DockPanel>
                 </DockPanel>
                 <DockPanel Margin="50,10,0,0">
                 <DockPanel Margin="50,10,0,0">
                     <TextBlock Height="30" Foreground="Snow" Text="Width:" TextAlignment="Center" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                     <TextBlock Height="30" Foreground="Snow" Text="Width:" TextAlignment="Center" FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                    <TextBox Height="30" Width="150" Style="{StaticResource DarkTextBoxStyle}" FontSize="16" HorizontalAlignment="Left" Margin="10,0,0,0" TextAlignment="Center" Text="{Binding ElementName=newFilePopup, Path=FileWidth, Mode=TwoWay}" MaxLength="4">
+                    <TextBox Height="30" Width="150" Style="{StaticResource DarkTextBoxStyle}" FontSize="16" HorizontalAlignment="Left" Margin="10,0,0,0" TextAlignment="Center"
+                             Text="{Binding ElementName=newFilePopup, Converter={StaticResource ToolSizeToIntConverter}, Path=FileWidth, Mode=TwoWay}" MaxLength="4">
                         <i:Interaction.Behaviors>
                         <i:Interaction.Behaviors>
-                            <helpers:AllowableCharactersTextBoxBehavior RegularExpression="^[0-9./-]+$" MaxLength="4"/>
+                            <helpers:TextBoxFocusBehavior FillSize="True" NextFocusDirection="Next"/>
                         </i:Interaction.Behaviors>
                         </i:Interaction.Behaviors>
                     </TextBox>
                     </TextBox>
                 </DockPanel>
                 </DockPanel>
             </StackPanel>
             </StackPanel>
-            <Button VerticalAlignment="Bottom" HorizontalAlignment="Right" FontSize="20" Height="30" Width="60" Style="{StaticResource DarkRoundButton}" Content="OK" Margin="0,0,10,10" Grid.Row="1" Command="{Binding OkCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
+            <Button VerticalAlignment="Bottom" HorizontalAlignment="Right" FontSize="20" Height="30" Width="60" 
+                    Style="{StaticResource DarkRoundButton}" Content="OK" Margin="0,0,10,10" Grid.Row="1" 
+                    Command="{Binding OkCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
         </Grid>
         </Grid>
     </Border>
     </Border>
 </Window>
 </Window>

+ 16 - 0
PixiEditor/Views/NumerInput.xaml

@@ -0,0 +1,16 @@
+<UserControl x:Class="PixiEditor.Views.NumberInput"
+             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:PixiEditor.Views" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:behaviours="clr-namespace:PixiEditor.Helpers.Behaviours"
+             mc:Ignorable="d" 
+             d:DesignHeight="20" d:DesignWidth="40" x:Name="numberInput">
+    <Grid>
+        <TextBox TextAlignment="Center" Style="{StaticResource DarkTextBoxStyle}" PreviewTextInput="TextBox_PreviewTextInput" Text="{Binding ElementName=numberInput, Path=Value}">
+            <i:Interaction.Behaviors>
+                <behaviours:TextBoxFocusBehavior/>
+            </i:Interaction.Behaviors>
+        </TextBox>
+    </Grid>
+</UserControl>

+ 74 - 0
PixiEditor/Views/NumerInput.xaml.cs

@@ -0,0 +1,74 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PixiEditor.Views
+{
+    /// <summary>
+    /// Interaction logic for NumerInput.xaml
+    /// </summary>
+    public partial class NumberInput : UserControl
+    {
+
+        public float Value
+        {
+            get { return (float)GetValue(ValueProperty); }
+            set { SetValue(ValueProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for Value.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty ValueProperty =
+            DependencyProperty.Register("Value", typeof(float), typeof(NumberInput), 
+                new PropertyMetadata(0f, new PropertyChangedCallback(OnValueChanged)));
+
+        private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            NumberInput input = (NumberInput)d;
+            input.Value = Math.Clamp((float)e.NewValue, input.Min, input.Max);
+        }
+
+        public float Min
+        {
+            get { return (float)GetValue(MinProperty); }
+            set { SetValue(MinProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for Min.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty MinProperty =
+            DependencyProperty.Register("Min", typeof(float), typeof(NumberInput), new PropertyMetadata(float.NegativeInfinity));
+
+
+
+        public float Max
+        {
+            get { return (float)GetValue(MaxProperty); }
+            set { SetValue(MaxProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for Max.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty MaxProperty =
+            DependencyProperty.Register("Max", typeof(float), typeof(NumberInput), new PropertyMetadata(float.PositiveInfinity));
+
+
+        public NumberInput()
+        {
+            InitializeComponent();
+        }
+
+        private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
+        {
+            Regex regex = new Regex("^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");
+            e.Handled = !regex.IsMatch((sender as TextBox).Text.Insert((sender as TextBox).SelectionStart, e.Text));
+        }
+    }
+}

+ 17 - 11
PixiEditor/Views/SaveFilePopup.xaml

@@ -6,11 +6,14 @@
         xmlns:local="clr-namespace:PixiEditor.Views"
         xmlns:local="clr-namespace:PixiEditor.Views"
         xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
         xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
         xmlns:vm="clr-namespace:PixiEditor.ViewModels"
         xmlns:vm="clr-namespace:PixiEditor.ViewModels"
-        xmlns:helpers="clr-namespace:PixiEditor.Helpers.Behaviours"
+        xmlns:helpers="clr-namespace:PixiEditor.Helpers.Behaviours" xmlns:helpers1="clr-namespace:PixiEditor.Helpers"
         mc:Ignorable="d"
         mc:Ignorable="d"
-        Title="SaveFilePopup" Height="250" Width="400" WindowStyle="None" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Name="saveFilePopup">
+        Title="SaveFilePopup" Height="300" Width="400" WindowStyle="None" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" Name="saveFilePopup">
+    <Window.Resources>
+        <helpers1:ToolSizeToIntConverter x:Key="ToolSizeToIntConverter"/>
+    </Window.Resources>
     <Border BorderBrush="Black" BorderThickness="1">
     <Border BorderBrush="Black" BorderThickness="1">
-    <Grid Background="#303030">
+        <Grid Background="#404040">
         <Grid.RowDefinitions>
         <Grid.RowDefinitions>
             <RowDefinition Height="20*"/>
             <RowDefinition Height="20*"/>
             <RowDefinition Height="229*"/>
             <RowDefinition Height="229*"/>
@@ -21,25 +24,28 @@
                     <i:InvokeCommandAction Command="{Binding DragMoveCommand}"/>
                     <i:InvokeCommandAction Command="{Binding DragMoveCommand}"/>
                 </i:EventTrigger>
                 </i:EventTrigger>
             </i:Interaction.Triggers>
             </i:Interaction.Triggers>
-            <Button Width="20" Height="20" VerticalAlignment="Top" HorizontalAlignment="Right" BorderThickness="0" Command="{Binding CloseButtonCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}">
+            <Button Width="20" Height="20" Style="{StaticResource ImageButtonStyle}" Cursor="Hand" VerticalAlignment="Top" HorizontalAlignment="Right" BorderThickness="0" 
+                    Command="{Binding CloseButtonCommand}" CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}">
                 <Button.Background>
                 <Button.Background>
                     <ImageBrush ImageSource="/Images/Cross.png" Stretch="Uniform"/>
                     <ImageBrush ImageSource="/Images/Cross.png" Stretch="Uniform"/>
                 </Button.Background>
                 </Button.Background>
             </Button>
             </Button>
         </Grid>
         </Grid>
         <TextBlock Grid.Row="1" Height="30" Width="120" Foreground="Snow" VerticalAlignment="Top" HorizontalAlignment="Center" Text="File settings" TextAlignment="Center" FontSize="20"/>
         <TextBlock Grid.Row="1" Height="30" Width="120" Foreground="Snow" VerticalAlignment="Top" HorizontalAlignment="Center" Text="File settings" TextAlignment="Center" FontSize="20"/>
-        <DockPanel Grid.Row="1" Height="70" Width="320" Margin="0,0,0,100" Background="#2D2D2D">
+        <DockPanel Grid.Row="1" Height="70" Width="320" Margin="0,10,0,100" Background="#303030">
             <TextBlock Foreground="Snow" Width="40" Height="40" HorizontalAlignment="Left" Margin="50,0,0,0" Text="Width:" TextAlignment="Center" Padding="0,11.5,0,0"/>
             <TextBlock Foreground="Snow" Width="40" Height="40" HorizontalAlignment="Left" Margin="50,0,0,0" Text="Width:" TextAlignment="Center" Padding="0,11.5,0,0"/>
-            <TextBox Style="{StaticResource DarkTextBoxStyle}" Width="70" Height="20" HorizontalAlignment="Left" Margin="5,0,0,0" Text="{Binding ElementName=saveFilePopup, Path=SaveWidth, Mode=TwoWay}">
+            <TextBox Style="{StaticResource DarkTextBoxStyle}" Width="70" Height="20" HorizontalAlignment="Left" Margin="5,0,0,0" 
+                     Text="{Binding ElementName=saveFilePopup, Converter={StaticResource ToolSizeToIntConverter}, Path=SaveWidth, Mode=TwoWay}">
                 <i:Interaction.Behaviors>
                 <i:Interaction.Behaviors>
-                    <helpers:AllowableCharactersTextBoxBehavior RegularExpression="^[0-9./-]+$" MaxLength="4"/>
-                </i:Interaction.Behaviors>
+                        <helpers:TextBoxFocusBehavior FillSize="True" NextFocusDirection="Next"/>
+                    </i:Interaction.Behaviors>
             </TextBox>
             </TextBox>
             <TextBlock Foreground="Snow" Width="40" Height="40"  HorizontalAlignment="Left" Margin="5,0,0,0" Text="Height:" TextAlignment="Center" Padding="0,11.5,0,0"/>
             <TextBlock Foreground="Snow" Width="40" Height="40"  HorizontalAlignment="Left" Margin="5,0,0,0" Text="Height:" TextAlignment="Center" Padding="0,11.5,0,0"/>
-            <TextBox Style="{StaticResource DarkTextBoxStyle}" Width="70" Height="20" HorizontalAlignment="Left" Margin="5,0,0,0" Text="{Binding ElementName=saveFilePopup, Path=SaveHeight,Mode=TwoWay}">
+            <TextBox Style="{StaticResource DarkTextBoxStyle}" Width="70" Height="20" HorizontalAlignment="Left" 
+                     Margin="5,0,0,0" Text="{Binding ElementName=saveFilePopup, Converter={StaticResource ToolSizeToIntConverter}, Path=SaveHeight,Mode=TwoWay}">
                 <i:Interaction.Behaviors>
                 <i:Interaction.Behaviors>
-                    <helpers:AllowableCharactersTextBoxBehavior RegularExpression="^[0-9./-]+$" MaxLength="4"/>
-                </i:Interaction.Behaviors>
+                        <helpers:TextBoxFocusBehavior FillSize="True" NextFocusDirection="Next"/>
+                    </i:Interaction.Behaviors>
             </TextBox>
             </TextBox>
         </DockPanel>
         </DockPanel>
         <Button Grid.Row="1" Foreground="Snow" Height="40" Width="160" Margin="0,50,0,0" Content="Path" Background="#303030" BorderBrush="{Binding PathButtonBorder}" Command="{Binding ChoosePathCommand}"/>
         <Button Grid.Row="1" Foreground="Snow" Height="40" Width="160" Margin="0,50,0,0" Content="Path" Background="#303030" BorderBrush="{Binding PathButtonBorder}" Command="{Binding ChoosePathCommand}"/>