Browse Source

Added basic shape settings and some setting(s)

flabbet 5 years ago
parent
commit
b15266c73c

+ 3 - 2
PixiEditor/Helpers/Behaviours/TextBoxNumericFinisherBehavior.cs

@@ -2,6 +2,7 @@
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using System.Windows.Controls;
 using System.Windows.Controls;
 using System.Windows.Interactivity;
 using System.Windows.Interactivity;
@@ -33,7 +34,7 @@ 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.Next));
+            AssociatedObject.MoveFocus(new System.Windows.Input.TraversalRequest(System.Windows.Input.FocusNavigationDirection.Previous));
         }
         }
 
 
         private void AssociatedObject_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e)
         private void AssociatedObject_GotKeyboardFocus(object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e)
@@ -53,7 +54,7 @@ namespace PixiEditor.Helpers.Behaviours
         private void ConvertValue()
         private void ConvertValue()
         {
         {
             if (_valueConverted == true) return;
             if (_valueConverted == true) return;
-            if (int.TryParse(AssociatedObject.Text, 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");
             }
             }

+ 1 - 1
PixiEditor/Helpers/Converters/ToolSizeToIntConverter.cs

@@ -21,7 +21,7 @@ namespace PixiEditor.Helpers
         {
         {
             if (string.IsNullOrWhiteSpace(value as string)) return null;
             if (string.IsNullOrWhiteSpace(value as string)) return null;
             string slicedString = value.ToString().Split(' ').First();
             string slicedString = value.ToString().Split(' ').First();
-            slicedString = Regex.Replace(slicedString, "[^0-9.]", "");
+            slicedString = Regex.Replace(slicedString, "\\p{L}", "");
             if (slicedString == "") return null;
             if (slicedString == "") return null;
             return int.Parse(slicedString);
             return int.Parse(slicedString);
         }
         }

+ 15 - 0
PixiEditor/Helpers/Extensions/DictionaryHelper.cs

@@ -0,0 +1,15 @@
+using System.Collections.Generic;
+
+namespace PixiEditor.Helpers.Extensions
+{
+    public static class DictionaryHelper
+    {
+        public static void AddRangeOverride<TKey, TValue>(this IDictionary<TKey, TValue> dic, IDictionary<TKey, TValue> dictToAdd)
+        {
+            foreach (var item in dictToAdd)
+            {
+                dic[item.Key] = item.Value;
+            }
+        }
+    }
+}

+ 13 - 4
PixiEditor/Models/Controllers/BitmapOperationsUtility.cs

@@ -18,7 +18,16 @@ namespace PixiEditor.Models.Controllers
     public class BitmapOperationsUtility : NotifyableObject
     public class BitmapOperationsUtility : NotifyableObject
     {
     {
         public MouseMovementController MouseController { get; set; }
         public MouseMovementController MouseController { get; set; }
-        public Tool SelectedTool { get; set; }
+        private Tool _selectedTool;
+        public Tool SelectedTool
+        {
+            get => _selectedTool;
+            set
+            {
+                _selectedTool = value;
+                RaisePropertyChanged("SelectedTool");
+            }
+        }
 
 
         private ObservableCollection<Layer> _layers = new ObservableCollection<Layer>();
         private ObservableCollection<Layer> _layers = new ObservableCollection<Layer>();
 
 
@@ -55,8 +64,8 @@ namespace PixiEditor.Models.Controllers
         public Layer ActiveLayer => Layers.Count > 0 ? Layers[ActiveLayerIndex] : null;
         public Layer ActiveLayer => Layers.Count > 0 ? Layers[ActiveLayerIndex] : null;
 
 
         public Color PrimaryColor { get; set; }
         public Color PrimaryColor { get; set; }
-        
-        public int ToolSize { get; set; }
+
+        public int ToolSize => SelectedTool.Toolbar.GetSetting("ToolSize") != null ? (int)SelectedTool.Toolbar.GetSetting("ToolSize").Value : 1;
 
 
         public event EventHandler<BitmapChangedEventArgs> BitmapChanged;
         public event EventHandler<BitmapChangedEventArgs> BitmapChanged;
         public event EventHandler<LayersChangedEventArgs> LayersChanged;
         public event EventHandler<LayersChangedEventArgs> LayersChanged;
@@ -179,7 +188,7 @@ namespace PixiEditor.Models.Controllers
         private void UseToolOnPreviewLayer(List<Coordinates> mouseMove)
         private void UseToolOnPreviewLayer(List<Coordinates> mouseMove)
         {
         {
             BitmapPixelChanges changedPixels;
             BitmapPixelChanges changedPixels;
-            if (mouseMove[0] != _lastMousePos)
+            if (mouseMove.Count > 0 && mouseMove[0] != _lastMousePos)
             {
             {
                 GeneratePreviewLayer();
                 GeneratePreviewLayer();
                 PreviewLayer.Clear();
                 PreviewLayer.Clear();

+ 2 - 0
PixiEditor/Models/Tools/ShapeTool.cs

@@ -1,6 +1,7 @@
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.Tools;
 using PixiEditor.Models.Tools.Tools;
+using PixiEditor.Models.Tools.ToolSettings;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
@@ -19,6 +20,7 @@ namespace PixiEditor.Models.Tools
         {
         {
             RequiresPreviewLayer = true;
             RequiresPreviewLayer = true;
             Cursor = Cursors.Cross;
             Cursor = Cursors.Cross;
+            Toolbar = new BasicShapeToolbar();
         }
         }
 
 
         protected Coordinates[] GetThickShape(Coordinates[] shape, int thickness)
         protected Coordinates[] GetThickShape(Coordinates[] shape, int thickness)

+ 16 - 0
PixiEditor/Models/Tools/ToolSettings/BasicShapeToolbar.cs

@@ -0,0 +1,16 @@
+using PixiEditor.Models.Tools.ToolSettings.Settings;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace PixiEditor.Models.Tools.ToolSettings
+{
+    public class BasicShapeToolbar : BasicToolbar
+    {
+        public BasicShapeToolbar()
+        {
+            Settings.Add(new BoolSetting("Fill", "Fill shape: "));
+            Settings.Add(new ColorSetting("FillColor", "Fill color"));            
+        }
+    }
+}

+ 1 - 1
PixiEditor/Models/Tools/ToolSettings/BasicToolbar.cs

@@ -11,7 +11,7 @@ namespace PixiEditor.Models.Tools.ToolSettings
     {
     {
         public BasicToolbar()
         public BasicToolbar()
         {
         {
-            Settings.Add(new SizeSetting("ToolSize"));
+            Settings.Add(new SizeSetting("ToolSize", "Tool size:"));
         }
         }
     }
     }
 }
 }

+ 40 - 0
PixiEditor/Models/Tools/ToolSettings/Settings/BoolSetting.cs

@@ -0,0 +1,40 @@
+using System.Windows.Controls;
+using System.Windows.Data;
+
+namespace PixiEditor.Models.Tools.ToolSettings.Settings
+{
+    public class BoolSetting : Setting
+    {
+        public BoolSetting(string name, string label = "") : base(name)
+        {
+            Label = label;
+            Value = false;
+            SettingControl = GenerateCheckBox();
+        }
+
+        public BoolSetting(string name, bool isChecked, string label = "") : base(name)
+        {
+            Label = label;
+            Value = isChecked;
+            SettingControl = GenerateCheckBox();
+        }
+
+        private Control GenerateCheckBox()
+        {
+            CheckBox checkBox = new CheckBox()
+            {
+                IsChecked = (bool)Value,
+                VerticalAlignment = System.Windows.VerticalAlignment.Center
+            };
+
+            Binding binding = new Binding("Value")
+            {
+                Mode = BindingMode.TwoWay
+            };
+
+            checkBox.SetBinding(CheckBox.IsCheckedProperty, binding);
+
+            return checkBox;
+        }
+    }
+}

+ 32 - 0
PixiEditor/Models/Tools/ToolSettings/Settings/ColorSetting.cs

@@ -0,0 +1,32 @@
+using System.Windows.Data;
+using System.Windows.Media;
+using Xceed.Wpf.Toolkit;
+
+namespace PixiEditor.Models.Tools.ToolSettings.Settings
+{
+    public class ColorSetting : Setting
+    {
+        public ColorSetting(string name, string label = "") : base(name)
+        {
+            Label = label;
+            SettingControl = GenerateColorPicker();
+            Value = Color.FromArgb(0, 0, 0, 0);
+        }
+
+        private ColorPicker GenerateColorPicker()
+        {
+            ColorPicker picker = new ColorPicker()
+            {
+                UsingAlphaChannel = true,
+                AvailableColorsSortingMode = ColorSortingMode.Alphabetical,
+                Width = 70
+            };
+            Binding binding = new Binding("Value")
+            {
+                Mode = BindingMode.TwoWay,
+            };
+            picker.SetBinding(ColorPicker.SelectedColorProperty, binding);
+            return picker;
+        }
+    }
+}

+ 2 - 0
PixiEditor/Models/Tools/ToolSettings/Settings/Setting.cs

@@ -9,6 +9,8 @@ namespace PixiEditor.Models.Tools.ToolSettings
     public abstract class Setting : NotifyableObject
     public abstract class Setting : NotifyableObject
     {
     {
         public string Name { get; protected set; }
         public string Name { get; protected set; }
+        public string Label { get; set; }
+        public bool HasLabel => !string.IsNullOrEmpty(Label);
         private object value;
         private object value;
         public object Value { get => value;
         public object Value { get => value;
             set
             set

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

@@ -12,10 +12,11 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
 {
 {
     public class SizeSetting : Setting
     public class SizeSetting : Setting
     {
     {
-        public SizeSetting(string name) : base(name)
+        public SizeSetting(string name, string label = null) : base(name)
         {
         {
             Value = 1;
             Value = 1;
             SettingControl = GenerateTextBox();
             SettingControl = GenerateTextBox();
+            Label = label;
         }
         }
 
 
         private TextBox GenerateTextBox()
         private TextBox GenerateTextBox()
@@ -26,16 +27,16 @@ namespace PixiEditor.Models.Tools.ToolSettings.Settings
                 TextAlignment = TextAlignment.Center,
                 TextAlignment = TextAlignment.Center,
                 MaxLength = 4,
                 MaxLength = 4,
                 Width = 40,
                 Width = 40,
+                Height = 20
             };
             };
-            //TextBoxNumericFinisherBehavior behavor = new TextBoxNumericFinisherBehavior();
-            //Interaction.GetBehaviors(tb).Add(behavor);
             Binding binding = new Binding("Value")
             Binding binding = new Binding("Value")
             {
             {
                 Converter = new ToolSizeToIntConverter(),
                 Converter = new ToolSizeToIntConverter(),
                 Mode = BindingMode.TwoWay,
                 Mode = BindingMode.TwoWay,
-                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
             };
             };
             tb.SetBinding(TextBox.TextProperty, binding);
             tb.SetBinding(TextBox.TextProperty, binding);
+            TextBoxNumericFinisherBehavior behavor = new TextBoxNumericFinisherBehavior();
+            Interaction.GetBehaviors(tb).Add(behavor);
             return tb;
             return tb;
         }
         }
     }
     }

+ 1 - 1
PixiEditor/Models/Tools/ToolSettings/Toolbar.cs

@@ -10,7 +10,7 @@ namespace PixiEditor.Models.Tools.ToolSettings
 
 
         public virtual Setting GetSetting(string name)
         public virtual Setting GetSetting(string name)
         {
         {
-            return Settings.First(x => x.Name == name);
+            return Settings.FirstOrDefault(x => x.Name == name);
         }
         }
     }
     }
 }
 }

+ 2 - 1
PixiEditor/Models/Tools/Tools/CircleTool.cs

@@ -21,7 +21,8 @@ namespace PixiEditor.Models.Tools.Tools
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color)
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
             DoubleCords fixedCoordinates = CalculateCoordinatesForShapeRotation(coordinates[^1], coordinates[0]);
             DoubleCords fixedCoordinates = CalculateCoordinatesForShapeRotation(coordinates[^1], coordinates[0]);
-            return BitmapPixelChanges.FromSingleColoredArray(CreateEllipse(fixedCoordinates.Coords1, fixedCoordinates.Coords2, false, 1), color);
+            return BitmapPixelChanges.FromSingleColoredArray(
+                CreateEllipse(fixedCoordinates.Coords1, fixedCoordinates.Coords2, false, (int)Toolbar.GetSetting("ToolSize").Value), color);
         }
         }
 
 
         public Coordinates[] CreateEllipse(Coordinates startCoordinates, Coordinates endCoordinates, bool filled, int thickness)
         public Coordinates[] CreateEllipse(Coordinates startCoordinates, Coordinates endCoordinates, bool filled, int thickness)

+ 3 - 1
PixiEditor/Models/Tools/Tools/LineTool.cs

@@ -1,6 +1,7 @@
 using PixiEditor.Models.ImageManipulation;
 using PixiEditor.Models.ImageManipulation;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
+using PixiEditor.Models.Tools.ToolSettings;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Linq;
 using System.Linq;
@@ -16,11 +17,12 @@ namespace PixiEditor.Models.Tools.Tools
         public LineTool()
         public LineTool()
         {
         {
             Tooltip = "Draws line on canvas (L)";
             Tooltip = "Draws line on canvas (L)";
+            Toolbar = new BasicToolbar();
         }
         }
 
 
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color)
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
-            return BitmapPixelChanges.FromSingleColoredArray(CreateLine(coordinates, 1), color);
+            return BitmapPixelChanges.FromSingleColoredArray(CreateLine(coordinates, (int)Toolbar.GetSetting("ToolSize").Value), color);
         }
         }
 
 
         public Coordinates[] CreateLine(Coordinates[] coordinates, int thickness)
         public Coordinates[] CreateLine(Coordinates[] coordinates, int thickness)

+ 3 - 1
PixiEditor/Models/Tools/Tools/PenTool.cs

@@ -9,17 +9,19 @@ namespace PixiEditor.Models.Tools.Tools
     public class PenTool : Tool
     public class PenTool : Tool
     {
     {
         public override ToolType ToolType => ToolType.Pen;
         public override ToolType ToolType => ToolType.Pen;
+        private int _toolSizeIndex;
 
 
         public PenTool()
         public PenTool()
         {
         {
             Cursor = Cursors.Pen;
             Cursor = Cursors.Pen;
             Tooltip = "Standard brush (B)";
             Tooltip = "Standard brush (B)";
             Toolbar = new BasicToolbar();
             Toolbar = new BasicToolbar();
+            _toolSizeIndex = Toolbar.Settings.IndexOf(Toolbar.GetSetting("ToolSize"));
         }
         }
 
 
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color)
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
-            return Draw(coordinates[0], color, (int)Toolbar.GetSetting("ToolSize").Value);
+            return Draw(coordinates[0], color, (int)Toolbar.Settings[_toolSizeIndex].Value);
         }
         }
 
 
         public BitmapPixelChanges Draw(Coordinates startingCoords, Color color, int toolSize)
         public BitmapPixelChanges Draw(Coordinates startingCoords, Color color, int toolSize)

+ 32 - 16
PixiEditor/Models/Tools/Tools/RectangleTool.cs

@@ -1,4 +1,5 @@
-using PixiEditor.Models.Layers;
+using PixiEditor.Helpers.Extensions;
+using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
@@ -19,33 +20,42 @@ namespace PixiEditor.Models.Tools.Tools
 
 
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color)
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color)
         {
         {
-            return BitmapPixelChanges.FromSingleColoredArray(CreateRectangle(coordinates, 1), color);
+            int thickness = (int)Toolbar.GetSetting("ToolSize").Value;
+            BitmapPixelChanges pixels = BitmapPixelChanges.FromSingleColoredArray(CreateRectangle(coordinates, thickness), color);
+            if ((bool)Toolbar.GetSetting("Fill").Value)
+            {
+                Color fillColor = (Color)Toolbar.GetSetting("FillColor").Value;
+                pixels.ChangedPixels.AddRangeOverride(
+                    BitmapPixelChanges.FromSingleColoredArray
+                    (CalculateFillForRectangle(coordinates[^1], coordinates[0], thickness), fillColor).ChangedPixels);
+            }
+            return pixels;
         }
         }
 
 
         public Coordinates[] CreateRectangle(Coordinates[] coordinates, int thickness)
         public Coordinates[] CreateRectangle(Coordinates[] coordinates, int thickness)
         {
         {
             DoubleCords fixedCoordinates = CalculateCoordinatesForShapeRotation(coordinates[^1], coordinates[0]);
             DoubleCords fixedCoordinates = CalculateCoordinatesForShapeRotation(coordinates[^1], coordinates[0]);
             List<Coordinates> output = new List<Coordinates>();
             List<Coordinates> output = new List<Coordinates>();
-            Coordinates[] rectangle =  CalculateRectanglePoints(fixedCoordinates, Filled);
+            Coordinates[] rectangle =  CalculateRectanglePoints(fixedCoordinates);
             output.AddRange(rectangle);
             output.AddRange(rectangle);
 
 
             for (int i = 1; i < (int)Math.Floor(thickness / 2f) + 1; i++)
             for (int i = 1; i < (int)Math.Floor(thickness / 2f) + 1; i++)
             {
             {
                 output.AddRange(CalculateRectanglePoints(new DoubleCords(
                 output.AddRange(CalculateRectanglePoints(new DoubleCords(
                     new Coordinates(fixedCoordinates.Coords1.X - i, fixedCoordinates.Coords1.Y - i),
                     new Coordinates(fixedCoordinates.Coords1.X - i, fixedCoordinates.Coords1.Y - i),
-                    new Coordinates(fixedCoordinates.Coords2.X + i, fixedCoordinates.Coords2.Y + i)), false));
+                    new Coordinates(fixedCoordinates.Coords2.X + i, fixedCoordinates.Coords2.Y + i))));
             }
             }
             for (int i = 1; i < (int)Math.Ceiling(thickness / 2f); i++)
             for (int i = 1; i < (int)Math.Ceiling(thickness / 2f); i++)
             {
             {
                 output.AddRange(CalculateRectanglePoints(new DoubleCords(
                 output.AddRange(CalculateRectanglePoints(new DoubleCords(
                     new Coordinates(fixedCoordinates.Coords1.X + i, fixedCoordinates.Coords1.Y + i),
                     new Coordinates(fixedCoordinates.Coords1.X + i, fixedCoordinates.Coords1.Y + i),
-                    new Coordinates(fixedCoordinates.Coords2.X - i, fixedCoordinates.Coords2.Y - i)), false));
+                    new Coordinates(fixedCoordinates.Coords2.X - i, fixedCoordinates.Coords2.Y - i))));
             }
             }
 
 
             return output.Distinct().ToArray();
             return output.Distinct().ToArray();
         }
         }
 
 
-        private Coordinates[] CalculateRectanglePoints(DoubleCords coordinates, bool filled)
+        private Coordinates[] CalculateRectanglePoints(DoubleCords coordinates)
         {
         {
             List<Coordinates> finalCoordinates = new List<Coordinates>();
             List<Coordinates> finalCoordinates = new List<Coordinates>();
 
 
@@ -59,29 +69,35 @@ namespace PixiEditor.Models.Tools.Tools
                 finalCoordinates.Add(new Coordinates(coordinates.Coords1.X, i));
                 finalCoordinates.Add(new Coordinates(coordinates.Coords1.X, i));
                 finalCoordinates.Add(new Coordinates(coordinates.Coords2.X, i));
                 finalCoordinates.Add(new Coordinates(coordinates.Coords2.X, i));
             }            
             }            
-
-            if (filled)
-            {
-                finalCoordinates.AddRange(CalculatedFillForRectangle(coordinates));
-            }
             return finalCoordinates.ToArray();
             return finalCoordinates.ToArray();
         }
         }
 
 
-        private Coordinates[] CalculatedFillForRectangle(DoubleCords cords)
+        private Coordinates[] CalculateFillForRectangle(Coordinates start, Coordinates end, int thickness)
         {
         {
-            int height = cords.Coords2.Y - cords.Coords1.Y;
-            int width = cords.Coords2.X - cords.Coords1.X;
+            int offset = (int)Math.Ceiling(thickness / 2f);
+            DoubleCords fixedCords = CalculateCoordinatesForShapeRotation(start, end);
+
+            DoubleCords innerCords = new DoubleCords
+            {
+                Coords1 = new Coordinates(fixedCords.Coords1.X + offset, fixedCords.Coords1.Y + offset),
+                Coords2 = new Coordinates(fixedCords.Coords2.X - (offset - 1), fixedCords.Coords2.Y - (offset - 1))
+            };
+
+            int height = innerCords.Coords2.Y - innerCords.Coords1.Y;
+            int width = innerCords.Coords2.X - innerCords.Coords1.X;
+
+            if (height < 1 || width < 1) return Array.Empty<Coordinates>();
             Coordinates[] filledCoordinates = new Coordinates[width * height];
             Coordinates[] filledCoordinates = new Coordinates[width * height];
             int i = 0;
             int i = 0;
             for (int y = 0; y < height; y++)
             for (int y = 0; y < height; y++)
             {
             {
                 for (int x = 0; x < width; x++)
                 for (int x = 0; x < width; x++)
                 {
                 {
-                    filledCoordinates[i] = new Coordinates(cords.Coords1.X + x, cords.Coords1.Y + y);
+                    filledCoordinates[i] = new Coordinates(innerCords.Coords1.X + x, innerCords.Coords1.Y + y);
                     i++;
                     i++;
                 }
                 }
             }
             }
-            return filledCoordinates;
+            return filledCoordinates.Distinct().ToArray();
         }
         }
     }
     }
 }
 }

+ 0 - 18
PixiEditor/ViewModels/ViewModelMain.cs

@@ -97,23 +97,6 @@ namespace PixiEditor.ViewModels
                     RaisePropertyChanged("SelectedTool"); } }
                     RaisePropertyChanged("SelectedTool"); } }
         }        
         }        
 
 
-
-        private int _toolSize;
-
-        public int ToolSize
-        {
-            get { return _toolSize; }
-            set 
-            { 
-                if (_toolSize != value) 
-                { 
-                    _toolSize = value;
-                    BitmapUtility.ToolSize = value;
-                    RaisePropertyChanged("ToolSize"); 
-                } 
-            }
-        }
-
         public ObservableCollection<Tool> ToolSet { get; set; }
         public ObservableCollection<Tool> ToolSet { get; set; }
 
 
         private LayerChanges _undoChanges;
         private LayerChanges _undoChanges;
@@ -195,7 +178,6 @@ namespace PixiEditor.ViewModels
             UndoManager.SetMainRoot(this);
             UndoManager.SetMainRoot(this);
             SetActiveTool(ToolType.Pen);
             SetActiveTool(ToolType.Pen);
             BitmapUtility.PrimaryColor = PrimaryColor;
             BitmapUtility.PrimaryColor = PrimaryColor;
-            ToolSize = 1;
         }
         }
 
 
         public void SetTool(object parameter)
         public void SetTool(object parameter)

+ 10 - 6
PixiEditor/Views/MainWindow.xaml

@@ -72,9 +72,17 @@
         </WrapPanel>
         </WrapPanel>
         <StackPanel Background="#404040" Orientation="Horizontal" Grid.ColumnSpan="2" Margin="0,30,0,0" Grid.RowSpan="2">
         <StackPanel Background="#404040" Orientation="Horizontal" Grid.ColumnSpan="2" Margin="0,30,0,0" Grid.RowSpan="2">
             <ItemsControl ItemsSource="{Binding BitmapUtility.SelectedTool.Toolbar.Settings}">
             <ItemsControl ItemsSource="{Binding BitmapUtility.SelectedTool.Toolbar.Settings}">
+                <ItemsControl.ItemsPanel>
+                    <ItemsPanelTemplate>
+                        <StackPanel Orientation="Horizontal" Margin="10, 0, 0, 0"/>
+                    </ItemsPanelTemplate>
+                </ItemsControl.ItemsPanel>
                 <ItemsControl.ItemTemplate>
                 <ItemsControl.ItemTemplate>
                     <DataTemplate>
                     <DataTemplate>
-                        <ContentPresenter Content="{Binding SettingControl}"/>
+                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="10,0,10,0">
+                            <Label Visibility="{Binding HasLabel, Converter={StaticResource BoolToVisibilityConverter}}" Foreground="White" Content="{Binding Label}"/>
+                            <ContentPresenter Content="{Binding SettingControl}"/>
+                        </StackPanel>
                     </DataTemplate>
                     </DataTemplate>
                 </ItemsControl.ItemTemplate>
                 </ItemsControl.ItemTemplate>
             </ItemsControl>
             </ItemsControl>
@@ -121,11 +129,7 @@
         </Grid>
         </Grid>
 
 
         <StackPanel Orientation="Vertical" Cursor="Arrow" Grid.Row="2" Grid.Column="0" Margin="0,7,5,0" Background="#404040" Grid.RowSpan="2">
         <StackPanel Orientation="Vertical" Cursor="Arrow" Grid.Row="2" Grid.Column="0" Margin="0,7,5,0" Background="#404040" Grid.RowSpan="2">
-            <TextBox Style="{StaticResource DarkTextBoxStyle}" Margin="0,10,0,0" Text="{Binding ToolSize, Mode=TwoWay,Converter={StaticResource ToolSizeToIntConverter}}" TextAlignment="Center" MaxLength="4">
-                <i:Interaction.Behaviors>
-                    <behaviors:TextBoxNumericFinisherBehavior/>
-                </i:Interaction.Behaviors>
-            </TextBox>
+            
             <ItemsControl ItemsSource="{Binding ToolSet}">
             <ItemsControl ItemsSource="{Binding ToolSet}">
                 <ItemsControl.ItemTemplate>
                 <ItemsControl.ItemTemplate>
                     <DataTemplate>
                     <DataTemplate>