Browse Source

Finished resize canvas popup, logic wip

flabbet 5 years ago
parent
commit
2b22ea2747

+ 1 - 0
PixiEditor/App.xaml

@@ -12,6 +12,7 @@
                 <ResourceDictionary Source="Styles/ComboBoxDarkStyle.xaml"/>
                 <ResourceDictionary Source="Styles/ComboBoxDarkStyle.xaml"/>
                 <ResourceDictionary Source="Styles/ColorSliderStyle.xaml"/>
                 <ResourceDictionary Source="Styles/ColorSliderStyle.xaml"/>
                 <ResourceDictionary Source="Styles/ColorToggleButton.xaml"/>
                 <ResourceDictionary Source="Styles/ColorToggleButton.xaml"/>
+                <ResourceDictionary Source="Styles/AnchorPointToggleButtonStyle.xaml"/>
             </ResourceDictionary.MergedDictionaries>
             </ResourceDictionary.MergedDictionaries>
         </ResourceDictionary>
         </ResourceDictionary>
     </Application.Resources>
     </Application.Resources>

BIN
PixiEditor/Images/AnchorDot.png


+ 62 - 21
PixiEditor/Models/DataHolders/Document.cs

@@ -1,9 +1,12 @@
 using PixiEditor.Helpers;
 using PixiEditor.Helpers;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.Controllers;
+using PixiEditor.Models.Enums;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using System;
 using System;
 using System.Collections.ObjectModel;
 using System.Collections.ObjectModel;
+using System.DirectoryServices;
+using System.Drawing.Text;
 using System.Linq;
 using System.Linq;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
 
 
@@ -71,6 +74,39 @@ namespace PixiEditor.Models.DataHolders
             DocumentSizeChanged?.Invoke(this, new DocumentSizeChangedEventArgs(Width, Height, width, height));
             DocumentSizeChanged?.Invoke(this, new DocumentSizeChangedEventArgs(Width, Height, width, height));
         }
         }
 
 
+        public void ResizeCanvas(int width, int height, AnchorPoint anchor)
+        {
+            int offsetX = GetOffsetXForAnchor(Width, width, anchor);
+            int offsetY = GetOffsetYForAnchor(Height, height, anchor);
+            ResizeCanvas(offsetX, offsetY, Width, width, height);
+        }
+
+        private int GetOffsetXForAnchor(int srcWidth, int destWidth, AnchorPoint anchor)
+        {
+            if (anchor.HasFlag(AnchorPoint.Center))
+            {
+                return destWidth / 2 - srcWidth / 2;
+            }
+            else if (anchor.HasFlag(AnchorPoint.Right))
+            {
+                return destWidth - srcWidth;
+            }
+            return 0;
+        }
+
+        private int GetOffsetYForAnchor(int srcHeight, int destHeight,AnchorPoint anchor)
+        {
+            if (anchor.HasFlag(AnchorPoint.Middle))
+            {
+                return destHeight / 2 - srcHeight / 2;
+            }
+            else if (anchor.HasFlag(AnchorPoint.Bottom))
+            {
+                return destHeight - srcHeight;
+            }
+            return 0;
+        }
+
         public void Resize(int newWidth, int newHeight)
         public void Resize(int newWidth, int newHeight)
         {
         {
             int oldWidth = Width;
             int oldWidth = Width;
@@ -98,41 +134,46 @@ namespace PixiEditor.Models.DataHolders
             Width = width;
             Width = width;
         }
         }
 
 
-        private void ReverseCrop(object[] arguments) //Reverses process of cropping
+        private void ResizeCanvas(int offsetX, int offsetY, int oldWidth, int newWidth, int newHeight)
         {
         {
-            int offsetX = (int)arguments[0];
-            int offsetY = (int)arguments[1];
-            int oldWidth = (int)arguments[2]; //oldWidth is the width before first crop
-            int oldHeight = (int)arguments[3];
-            int newWidth = (int)arguments[4]; //newWidth is the width after first crop
-            int newHeight = (int)arguments[5];
             int sizeOfArgb = 4;
             int sizeOfArgb = 4;
-            if (offsetX < 0) offsetX = 0;
-            if (offsetX + newWidth > oldWidth) newWidth = oldWidth - offsetX;
-            if (offsetY < 0) offsetY = 0;
-            if (offsetY + newHeight > oldHeight) newHeight = oldHeight - offsetY;
-
             for (int i = 0; i < Layers.Count; i++)
             for (int i = 0; i < Layers.Count; i++)
             {
             {
                 using (var srcContext = Layers[i].LayerBitmap.GetBitmapContext(ReadWriteMode.ReadOnly))
                 using (var srcContext = Layers[i].LayerBitmap.GetBitmapContext(ReadWriteMode.ReadOnly))
                 {
                 {
-                    var result = BitmapFactory.New(oldWidth, oldHeight);
+                    var result = BitmapFactory.New(newWidth, newHeight);
                     using (var destContext = result.GetBitmapContext())
                     using (var destContext = result.GetBitmapContext())
                     {
                     {
-                        for (int line = 0; line < newHeight; line++)
+                        for (int line = 0; line < oldWidth; line++)
                         {
                         {
-                            var srcOff = line * newWidth * sizeOfArgb;
-                            var dstOff = ((offsetY + line) * oldWidth + offsetX) * sizeOfArgb;
-                            BitmapContext.BlockCopy(srcContext, srcOff, destContext, dstOff, newWidth * sizeOfArgb);
+                            var srcOff = line * Width * sizeOfArgb;
+                            var dstOff = ((offsetY + line) * newWidth + offsetX) * sizeOfArgb;
+                            BitmapContext.BlockCopy(srcContext, srcOff, destContext, dstOff, oldWidth * sizeOfArgb);
                         }
                         }
                         Layers[i].LayerBitmap = result;
                         Layers[i].LayerBitmap = result;
-                        Layers[i].Width = oldWidth;
-                        Layers[i].Height = oldHeight;
+                        Layers[i].Width = newWidth;
+                        Layers[i].Height = newHeight;
                     }
                     }
                 }
                 }
             }
             }
-            Width = oldWidth;
-            Height = oldHeight;
+            Width = newWidth;
+            Height = newHeight;
+        }
+
+        private void ReverseCrop(object[] arguments) //Reverses process of cropping
+        {
+            int offsetX = (int)arguments[0];
+            int offsetY = (int)arguments[1];
+            int oldWidth = (int)arguments[2]; //oldWidth is the width before first crop
+            int oldHeight = (int)arguments[3];
+            int newWidth = (int)arguments[4]; //newWidth is the width after first crop
+            int newHeight = (int)arguments[5];
+            if (offsetX < 0) offsetX = 0;
+            if (offsetX + newWidth > oldWidth) newWidth = oldWidth - offsetX;
+            if (offsetY < 0) offsetY = 0;
+            if (offsetY + newHeight > oldHeight) newHeight = oldHeight - offsetY;
+
+            ResizeCanvas(offsetX, offsetY, newWidth, oldWidth, oldHeight);
         }
         }
 
 
         public void ClipCanvas()
         public void ClipCanvas()

+ 36 - 9
PixiEditor/Models/Dialogs/ResizeDocumentDialog.cs

@@ -1,4 +1,5 @@
-using PixiEditor.Views;
+using PixiEditor.Models.Enums;
+using PixiEditor.Views;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
@@ -7,7 +8,8 @@ namespace PixiEditor.Models.Dialogs
 {
 {
     public class ResizeDocumentDialog : CustomDialog
     public class ResizeDocumentDialog : CustomDialog
     {
     {
-
+        public bool OpenResizeCanvas { get; set; } = false;
+        public AnchorPoint ResizeAnchor { get; set; }
         private int _width;
         private int _width;
 
 
         public int Width
         public int Width
@@ -25,24 +27,49 @@ namespace PixiEditor.Models.Dialogs
             set { if (_height != value) { _height = value; RaisePropertyChanged("Height"); } }
             set { if (_height != value) { _height = value; RaisePropertyChanged("Height"); } }
         }
         }
 
 
-        public ResizeDocumentDialog(int currentWidth, int currentHeight)
+        public ResizeDocumentDialog(int currentWidth, int currentHeight, bool openResizeCanvas = false)
         {
         {
             Width = currentWidth;
             Width = currentWidth;
             Height = currentHeight;
             Height = currentHeight;
+            OpenResizeCanvas = openResizeCanvas;
         }
         }
 
 
         public override bool ShowDialog()
         public override bool ShowDialog()
         {
         {
-            ResizeDocumentPopup popup = new ResizeDocumentPopup(); 
-            ResizeDocumentPopup result = popup.DataContext as ResizeDocumentPopup;
-            result.NewHeight = Height;
-            result.NewWidth = Width;
+            return OpenResizeCanvas ? ShowResizeCanvasDialog() : ShowResizeDocumentCanvas();
+        }
+
+        private bool ShowResizeDocumentCanvas()
+        {
+            ResizeDocumentPopup popup = new ResizeDocumentPopup
+            {
+                NewHeight = Height,
+                NewWidth = Width
+            };
+
+            popup.ShowDialog();
+            if (popup.DialogResult == true)
+            { 
+                Width = popup.NewWidth;
+                Height = popup.NewHeight;
+            }
+            return (bool)popup.DialogResult;
+        }
+
+        private bool ShowResizeCanvasDialog()
+        {
+            ResizeCanvasPopup popup = new ResizeCanvasPopup
+            {
+                NewHeight = Height,
+                NewWidth = Width
+            };
 
 
             popup.ShowDialog();
             popup.ShowDialog();
             if (popup.DialogResult == true)
             if (popup.DialogResult == true)
             {
             {
-                Width = result.NewWidth;
-                Height = result.NewHeight;
+                Width = popup.NewWidth;
+                Height = popup.NewHeight;
+                ResizeAnchor = popup.SelectedAnchorPoint;
             }
             }
             return (bool)popup.DialogResult;
             return (bool)popup.DialogResult;
         }
         }

+ 17 - 0
PixiEditor/Models/Enums/AnchorPoint.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace PixiEditor.Models.Enums
+{
+    [Flags]
+    public enum AnchorPoint
+    {
+        Left = 1, 
+        Center = 2, 
+        Right = 4, 
+        Top = 8, 
+        Middle = 16, 
+        Bottom = 32
+    }
+}

+ 2 - 0
PixiEditor/PixiEditor.csproj

@@ -16,6 +16,7 @@
   </PropertyGroup>
   </PropertyGroup>
 
 
   <ItemGroup>
   <ItemGroup>
+    <None Remove="Images\AnchorDot.png" />
     <None Remove="Images\ColorCircle.png" />
     <None Remove="Images\ColorCircle.png" />
     <None Remove="Images\ColorPalette.png" />
     <None Remove="Images\ColorPalette.png" />
     <None Remove="Images\MoveImage.png" />
     <None Remove="Images\MoveImage.png" />
@@ -46,6 +47,7 @@
     </PackageReference>
     </PackageReference>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <Resource Include="Images\AnchorDot.png" />
     <Resource Include="Images\BucketImage.png" />
     <Resource Include="Images\BucketImage.png" />
     <Resource Include="Images\CircleImage.png" />
     <Resource Include="Images\CircleImage.png" />
     <Resource Include="Images\ColorCircle.png" />
     <Resource Include="Images\ColorCircle.png" />

+ 53 - 0
PixiEditor/Styles/AnchorPointToggleButtonStyle.xaml

@@ -0,0 +1,53 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+                    xmlns:local="clr-namespace:PixiEditor">
+    
+    <Style x:Key="FocusVisual">
+        <Setter Property="Control.Template">
+            <Setter.Value>
+                <ControlTemplate>
+                    <Rectangle Margin="2" StrokeDashArray="1 2" SnapsToDevicePixels="true" StrokeThickness="1" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+    <SolidColorBrush x:Key="Button.Static.Background" Color="#FFDDDDDD"/>
+    <SolidColorBrush x:Key="Button.Static.Border" Color="#FF707070"/>
+    <SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD"/>
+    <SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1"/>
+    <SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6"/>
+    <SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B"/>
+    <SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/>
+    <SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/>
+    <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/>
+    <Style x:Key="AnchorPointToggleButtonStyle" TargetType="{x:Type ToggleButton}">
+        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
+        <Setter Property="Background" Value="{StaticResource Button.Static.Background}"/>
+        <Setter Property="BorderBrush" Value="{StaticResource Button.Static.Border}"/>
+        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
+        <Setter Property="BorderThickness" Value="1"/>
+        <Setter Property="HorizontalContentAlignment" Value="Center"/>
+        <Setter Property="VerticalContentAlignment" Value="Center"/>
+        <Setter Property="Padding" Value="1"/>
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="{x:Type ToggleButton}">
+                    <Border x:Name="border" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" SnapsToDevicePixels="true">
+                        <ContentPresenter x:Name="contentPresenter" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="Button.IsDefaulted" Value="true">
+                            <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
+                        </Trigger>
+                        <Trigger Property="IsMouseOver" Value="true">
+                            <Setter Property="BorderBrush" TargetName="border" Value="DimGray"/>
+                        </Trigger>
+                        <Trigger Property="ToggleButton.IsChecked" Value="True">
+                            <Setter Property="BorderBrush" TargetName="border" Value="White"/>
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
+</ResourceDictionary>

+ 4 - 3
PixiEditor/ViewModels/ViewModelMain.cs

@@ -239,12 +239,13 @@ namespace PixiEditor.ViewModels
 
 
         private void OpenResizePopup(object parameter)
         private void OpenResizePopup(object parameter)
         {
         {
-            ResizeDocumentDialog dialog = new ResizeDocumentDialog(BitmapManager.ActiveDocument.Width, BitmapManager.ActiveDocument.Height);
+            bool isCanvasDialog = (string)parameter == "canvas";
+            ResizeDocumentDialog dialog = new ResizeDocumentDialog(BitmapManager.ActiveDocument.Width, BitmapManager.ActiveDocument.Height, isCanvasDialog);
             if (dialog.ShowDialog())
             if (dialog.ShowDialog())
             {
             {
-                if ((string)parameter == "canvas")
+                if (isCanvasDialog)
                 {
                 {
-                    //Todo resize canvas
+                    BitmapManager.ActiveDocument.ResizeCanvas(dialog.Width, dialog.Height, dialog.ResizeAnchor);
                 }
                 }
                 else
                 else
                 {
                 {

+ 65 - 0
PixiEditor/Views/AnchorPointPicker.xaml

@@ -0,0 +1,65 @@
+<UserControl x:Class="PixiEditor.Views.AnchorPointPicker"
+             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"
+             mc:Ignorable="d" 
+             d:DesignHeight="78" d:DesignWidth="78">
+    <Grid Name="container">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="26"/>
+            <RowDefinition Height="26"/>
+            <RowDefinition Height="26"/>
+        </Grid.RowDefinitions>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="26"/>
+            <ColumnDefinition Width="26"/>
+            <ColumnDefinition Width="26"/>
+        </Grid.ColumnDefinitions>
+        <ToggleButton IsChecked="True" Checked="ToggleButton_Checked" Click="ToggleButton_Click"  Margin="0.25" Style="{DynamicResource AnchorPointToggleButtonStyle}" ToolTip="Top left" Grid.Row="0" Grid.Column="0" BorderBrush="Black">
+            <ToggleButton.Background>
+                <ImageBrush ImageSource="../Images/AnchorDot.png"/>
+            </ToggleButton.Background>
+        </ToggleButton>
+        <ToggleButton Checked="ToggleButton_Checked" Click="ToggleButton_Click" Margin="0.25" Style="{DynamicResource AnchorPointToggleButtonStyle}" Grid.Row="0" ToolTip="Top center" Grid.Column="1" BorderBrush="Black">
+            <ToggleButton.Background>
+                <ImageBrush ImageSource="../Images/AnchorDot.png"/>
+            </ToggleButton.Background>
+        </ToggleButton>
+        <ToggleButton Checked="ToggleButton_Checked" Click="ToggleButton_Click" Margin="0.25" Style="{DynamicResource AnchorPointToggleButtonStyle}" ToolTip="Top right" Grid.Row="0" Grid.Column="2" BorderBrush="Black">
+            <ToggleButton.Background>
+                <ImageBrush ImageSource="../Images/AnchorDot.png"/>
+            </ToggleButton.Background>
+        </ToggleButton>
+        <ToggleButton Checked="ToggleButton_Checked" Click="ToggleButton_Click" Margin="0.25" Style="{DynamicResource AnchorPointToggleButtonStyle}" Grid.Row="1" ToolTip="Middle left" Grid.Column="0" BorderBrush="Black">
+            <ToggleButton.Background>
+                <ImageBrush ImageSource="../Images/AnchorDot.png"/>
+            </ToggleButton.Background>
+        </ToggleButton>
+        <ToggleButton Checked="ToggleButton_Checked" Click="ToggleButton_Click" Margin="0.25" Style="{DynamicResource AnchorPointToggleButtonStyle}" Grid.Row="1" Grid.Column="1" ToolTip="Middle center" BorderBrush="Black">
+            <ToggleButton.Background>
+                <ImageBrush ImageSource="../Images/AnchorDot.png"/>
+            </ToggleButton.Background>
+        </ToggleButton>
+        <ToggleButton Checked="ToggleButton_Checked" Click="ToggleButton_Click" Margin="0.25" Style="{DynamicResource AnchorPointToggleButtonStyle}" Grid.Row="1" Grid.Column="2" ToolTip="Middle right" BorderBrush="Black">
+            <ToggleButton.Background>
+                <ImageBrush ImageSource="../Images/AnchorDot.png"/>
+            </ToggleButton.Background>
+        </ToggleButton>
+        <ToggleButton Checked="ToggleButton_Checked" Click="ToggleButton_Click" Margin="0.25" Style="{DynamicResource AnchorPointToggleButtonStyle}" Grid.Row="2" Grid.Column="0" ToolTip="Bottom left" BorderBrush="Black">
+            <ToggleButton.Background>
+                <ImageBrush ImageSource="../Images/AnchorDot.png"/>
+            </ToggleButton.Background>
+        </ToggleButton>
+        <ToggleButton Checked="ToggleButton_Checked" Click="ToggleButton_Click" Margin="0.25" Style="{DynamicResource AnchorPointToggleButtonStyle}" Grid.Row="2" Grid.Column="1" ToolTip="Bottom center" BorderBrush="Black">
+            <ToggleButton.Background>
+                <ImageBrush ImageSource="../Images/AnchorDot.png"/>
+            </ToggleButton.Background>
+        </ToggleButton>
+        <ToggleButton Checked="ToggleButton_Checked" Click="ToggleButton_Click" Margin="0.25" Style="{DynamicResource AnchorPointToggleButtonStyle}" Grid.Row="2" Grid.Column="2" ToolTip="Bottom right" BorderBrush="Black">
+            <ToggleButton.Background>
+                <ImageBrush ImageSource="../Images/AnchorDot.png"/>
+            </ToggleButton.Background>
+        </ToggleButton>
+    </Grid>
+</UserControl>

+ 59 - 0
PixiEditor/Views/AnchorPointPicker.xaml.cs

@@ -0,0 +1,59 @@
+using PixiEditor.Models.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
+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 AnchorPointPicker.xaml
+    /// </summary>
+    public partial class AnchorPointPicker : UserControl
+    {
+
+        public AnchorPoint AnchorPoint
+        {
+            get { return (AnchorPoint)GetValue(AnchorPointProperty); }
+            set { SetValue(AnchorPointProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for AnchorPoint.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty AnchorPointProperty =
+            DependencyProperty.Register("AnchorPoint", typeof(AnchorPoint), typeof(AnchorPointPicker), new PropertyMetadata());
+
+
+        private ToggleButton _selectedToggleButton;
+        public AnchorPointPicker()
+        {
+            InitializeComponent();
+        }
+
+        private void ToggleButton_Checked(object sender, RoutedEventArgs e)
+        {
+            ToggleButton btn = (ToggleButton)sender;
+            AnchorPoint = (AnchorPoint)(1 << Grid.GetRow(btn) + 3) | (AnchorPoint)(1 << Grid.GetColumn(btn));
+            if(_selectedToggleButton != null)
+            {
+                _selectedToggleButton.IsChecked = false;
+            }
+            _selectedToggleButton = btn;
+        }
+
+        private void ToggleButton_Click(object sender, RoutedEventArgs e)
+        {
+            if ((sender as ToggleButton).IsChecked.Value)
+                e.Handled = true;
+        }
+    }
+}

+ 6 - 0
PixiEditor/Views/ColorPicker.xaml.cs

@@ -36,6 +36,12 @@ namespace PixiEditor.Views
             _dispatcher = Application.Current.Dispatcher;
             _dispatcher = Application.Current.Dispatcher;
             NotifyableColor = new NotifyableColor(SelectedColor);
             NotifyableColor = new NotifyableColor(SelectedColor);
             NotifyableColor.ColorChanged += SelectedColor_ColorChanged;
             NotifyableColor.ColorChanged += SelectedColor_ColorChanged;
+            _colorPalette.IsVisibleChanged += _colorPalette_IsVisibleChanged;
+        }
+
+        private void _colorPalette_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
+        {
+            _timer.Stop();
         }
         }
 
 
         private void SelectedColor_ColorChanged(object sender, EventArgs e)
         private void SelectedColor_ColorChanged(object sender, EventArgs e)

+ 0 - 3
PixiEditor/Views/PortableColorPicker.xaml.cs

@@ -47,8 +47,5 @@ namespace PixiEditor.Views
         // Using a DependencyProperty as the backing store for SecondaryColor.  This enables animation, styling, binding, etc...
         // Using a DependencyProperty as the backing store for SecondaryColor.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty SecondaryColorProperty =
         public static readonly DependencyProperty SecondaryColorProperty =
             DependencyProperty.Register("SecondaryColor", typeof(Color), typeof(PortableColorPicker), new PropertyMetadata(Colors.White));
             DependencyProperty.Register("SecondaryColor", typeof(Color), typeof(PortableColorPicker), new PropertyMetadata(Colors.White));
-
-
-
     }
     }
 }
 }

+ 62 - 0
PixiEditor/Views/ResizeCanvasPopup.xaml

@@ -0,0 +1,62 @@
+<Window x:Class="PixiEditor.Views.ResizeCanvasPopup"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:PixiEditor.Views"
+        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
+        xmlns:behaviors="clr-namespace:PixiEditor.Helpers.Behaviours" 
+        xmlns:converters="clr-namespace:PixiEditor.Helpers"
+        mc:Ignorable="d" Name="window"
+        Title="ResizeCanvasPopup" Topmost="True" ShowInTaskbar="False" WindowStartupLocation="CenterScreen" Height="370" Width="400" WindowStyle="None">
+
+    <Window.Resources>
+        <converters:ToolSizeToIntConverter x:Key="ToolSizeToIntConverter"/>
+    </Window.Resources>
+
+    <WindowChrome.WindowChrome>
+        <WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
+    </WindowChrome.WindowChrome>
+
+    <Window.CommandBindings>
+        <CommandBinding Command="{x:Static SystemCommands.CloseWindowCommand}" CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed_Close" />
+    </Window.CommandBindings>
+
+    <Grid Background="{StaticResource AccentColor}">
+        <Grid.RowDefinitions>
+            <RowDefinition Height="35"/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+
+        <DockPanel Grid.Row="0" Background="{StaticResource MainColor}">
+            <Button DockPanel.Dock="Right" HorizontalAlignment="Right" Style="{StaticResource CloseButtonStyle}" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="Close"
+                            Command="{x:Static SystemCommands.CloseWindowCommand}"/>
+        </DockPanel>
+        <Label Grid.Row="1" VerticalAlignment="Top" Foreground="White" FontSize="24" HorizontalAlignment="Center" Content="Resize Canvas"/>
+        <StackPanel HorizontalAlignment="Center" Margin="0,50,0,0" Background="{StaticResource MainColor}" VerticalAlignment="Top" Grid.Row="1" Width="300" Height="230">
+            <DockPanel Margin="50,35,0,0">
+                <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=window, Converter={StaticResource ToolSizeToIntConverter}, Path=NewHeight, Mode=TwoWay}" MaxLength="4">
+                    <i:Interaction.Behaviors>
+                        <behaviors:TextBoxFocusBehavior FillSize="True"/>
+                    </i:Interaction.Behaviors>
+                </TextBox>
+            </DockPanel>
+            <DockPanel Margin="50,10,0,0">
+                <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=window, Converter={StaticResource ToolSizeToIntConverter}, Path=NewWidth, Mode=TwoWay}" MaxLength="4">
+                    <i:Interaction.Behaviors>
+                        <behaviors:TextBoxFocusBehavior FillSize="True"/>
+                    </i:Interaction.Behaviors>
+                </TextBox>
+            </DockPanel>
+            <Separator Margin="10,20,10,0" Background="{StaticResource AccentColor}" Height="1"/>
+            <Label Content="Anchor point:" Foreground="White" Margin="10,5,0,0" HorizontalAlignment="Left" FontSize="16"/>
+            <local:AnchorPointPicker AnchorPoint="{Binding Path=SelectedAnchorPoint, Mode=TwoWay, ElementName=window}" Width="78" Margin="45,-25,0,0" Height="78"/>
+        </StackPanel>
+        <Button Grid.Row="1" Height="30" Width="60" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="10" Style="{StaticResource DarkRoundButton}" Content="OK" Click="Button_Click"/>
+    </Grid>
+</Window>

+ 84 - 0
PixiEditor/Views/ResizeCanvasPopup.xaml.cs

@@ -0,0 +1,84 @@
+using PixiEditor.Models.Enums;
+using System;
+using System.Collections.Generic;
+using System.Text;
+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.Shapes;
+
+namespace PixiEditor.Views
+{
+    /// <summary>
+    /// Interaction logic for ResizeCanvasPopup.xaml
+    /// </summary>
+    public partial class ResizeCanvasPopup : Window
+    {
+        public ResizeCanvasPopup()
+        {
+            InitializeComponent();
+        }
+
+
+
+
+
+        public AnchorPoint SelectedAnchorPoint
+        {
+            get { return (AnchorPoint)GetValue(SelectedAnchorPointProperty); }
+            set { SetValue(SelectedAnchorPointProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for SelectedAnchorPoint.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty SelectedAnchorPointProperty =
+            DependencyProperty.Register("SelectedAnchorPoint", typeof(AnchorPoint), typeof(ResizeCanvasPopup), new PropertyMetadata(AnchorPoint.Top | AnchorPoint.Left));
+
+
+
+
+
+        public int NewHeight
+        {
+            get { return (int)GetValue(NewHeightProperty); }
+            set { SetValue(NewHeightProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for NewHeight.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty NewHeightProperty =
+            DependencyProperty.Register("NewHeight", typeof(int), typeof(ResizeCanvasPopup), new PropertyMetadata(0));
+
+
+
+        public int NewWidth
+        {
+            get { return (int)GetValue(NewWidthProperty); }
+            set { SetValue(NewWidthProperty, value); }
+        }
+
+        // Using a DependencyProperty as the backing store for NewWidth.  This enables animation, styling, binding, etc...
+        public static readonly DependencyProperty NewWidthProperty =
+            DependencyProperty.Register("NewWidth", typeof(int), typeof(ResizeCanvasPopup), new PropertyMetadata(0));
+
+
+
+        private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
+        {
+            e.CanExecute = true;
+        }
+
+        private void CommandBinding_Executed_Close(object sender, ExecutedRoutedEventArgs e)
+        {
+            SystemCommands.CloseWindow(this);
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            DialogResult = true;
+            Close();
+        }
+    }
+}