Browse Source

Preview image on tabs work in progress

flabbet 4 years ago
parent
commit
98031e18af

+ 3 - 1
PixiEditor/Models/Controllers/BitmapManager.cs

@@ -77,8 +77,9 @@ namespace PixiEditor.Models.Controllers
             get => activeDocument;
             get => activeDocument;
             set
             set
             {
             {
+                activeDocument?.UpdatePreviewImage();
                 activeDocument = value;
                 activeDocument = value;
-                RaisePropertyChanged("ActiveDocument");
+                RaisePropertyChanged(nameof(ActiveDocument));
                 DocumentChanged?.Invoke(this, new DocumentChangedEventArgs(value));
                 DocumentChanged?.Invoke(this, new DocumentChangedEventArgs(value));
             }
             }
         }
         }
@@ -140,6 +141,7 @@ namespace PixiEditor.Models.Controllers
             {
             {
                 ActiveDocument.PreviewLayer = null;
                 ActiveDocument.PreviewLayer = null;
             }
             }
+
             SelectedTool?.Toolbar.SaveToolbarSettings();
             SelectedTool?.Toolbar.SaveToolbarSettings();
             SelectedTool = tool;
             SelectedTool = tool;
             SelectedTool.Toolbar.LoadSharedSettings();
             SelectedTool.Toolbar.LoadSharedSettings();

+ 24 - 5
PixiEditor/Models/DataHolders/Document.cs

@@ -3,12 +3,15 @@ using System.Buffers;
 using System.Collections.ObjectModel;
 using System.Collections.ObjectModel;
 using System.IO;
 using System.IO;
 using System.Linq;
 using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
 using System.Windows;
 using System.Windows;
 using System.Windows.Media;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
 using PixiEditor.Helpers;
 using PixiEditor.Helpers;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.Enums;
 using PixiEditor.Models.Enums;
+using PixiEditor.Models.ImageManipulation;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.IO;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
@@ -54,6 +57,13 @@ namespace PixiEditor.Models.DataHolders
             }
             }
         }
         }
 
 
+        private WriteableBitmap _previewImage;
+
+        public WriteableBitmap PreviewImage
+        {
+            get => _previewImage;
+        }
+
         private string documentFilePath = string.Empty;
         private string documentFilePath = string.Empty;
 
 
         public string DocumentFilePath
         public string DocumentFilePath
@@ -114,7 +124,7 @@ namespace PixiEditor.Models.DataHolders
             set
             set
             {
             {
                 selection = value;
                 selection = value;
-                RaisePropertyChanged("ActiveSelection");
+                RaisePropertyChanged(nameof(ActiveSelection));
             }
             }
         }
         }
 
 
@@ -126,7 +136,7 @@ namespace PixiEditor.Models.DataHolders
             set
             set
             {
             {
                 previewLayer = value;
                 previewLayer = value;
-                RaisePropertyChanged("PreviewLayer");
+                RaisePropertyChanged(nameof(PreviewLayer));
             }
             }
         }
         }
 
 
@@ -202,11 +212,17 @@ namespace PixiEditor.Models.DataHolders
             set
             set
             {
             {
                 activeLayerIndex = value;
                 activeLayerIndex = value;
-                RaisePropertyChanged("ActiveLayerIndex");
-                RaisePropertyChanged("ActiveLayer");
+                RaisePropertyChanged(nameof(ActiveLayerIndex));
+                RaisePropertyChanged(nameof(ActiveLayer));
             }
             }
         }
         }
 
 
+        public void UpdatePreviewImage()
+        {
+            _previewImage = BitmapUtils.GeneratePreviewBitmap(this, 30, 20);
+            RaisePropertyChanged(nameof(PreviewImage));
+        }
+
         public void GeneratePreviewLayer()
         public void GeneratePreviewLayer()
         {
         {
             PreviewLayer = new Layer("_previewLayer")
             PreviewLayer = new Layer("_previewLayer")
@@ -429,7 +445,10 @@ namespace PixiEditor.Models.DataHolders
         {
         {
             XamlAccesibleViewModel.BitmapManager.MouseController.StopRecordingMouseMovementChanges();
             XamlAccesibleViewModel.BitmapManager.MouseController.StopRecordingMouseMovementChanges();
             XamlAccesibleViewModel.BitmapManager.MouseController.StartRecordingMouseMovementChanges(true);
             XamlAccesibleViewModel.BitmapManager.MouseController.StartRecordingMouseMovementChanges(true);
-            XamlAccesibleViewModel.BitmapManager.ActiveDocument = this;
+            if (XamlAccesibleViewModel.BitmapManager.ActiveDocument != this)
+            {
+                XamlAccesibleViewModel.BitmapManager.ActiveDocument = this;
+            }
         }
         }
 
 
         private void RequestCloseDocument(object parameter)
         private void RequestCloseDocument(object parameter)

+ 30 - 4
PixiEditor/Models/ImageManipulation/BitmapUtils.cs

@@ -1,5 +1,9 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
 using System.Windows.Media.Imaging;
 using System.Windows.Media.Imaging;
+using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using Color = System.Windows.Media.Color;
 using Color = System.Windows.Media.Color;
@@ -22,6 +26,7 @@ namespace PixiEditor.Models.ImageManipulation
             {
             {
                 bitmap.FromByteArray(byteArray);
                 bitmap.FromByteArray(byteArray);
             }
             }
+
             return bitmap;
             return bitmap;
         }
         }
 
 
@@ -31,8 +36,12 @@ namespace PixiEditor.Models.ImageManipulation
         /// <param name="layers">Layers to combine.</param>
         /// <param name="layers">Layers to combine.</param>
         /// <param name="width">Width of final bitmap.</param>
         /// <param name="width">Width of final bitmap.</param>
         /// <param name="height">Height of final bitmap.</param>
         /// <param name="height">Height of final bitmap.</param>
+        /// <param name="stepX">Width precision, determinates how much pixels per row to calculate.
+        /// Ex. layer width = 500, stepX = 5, output image would be 50px wide. So to fill all space, width would need to be 50.</param>
+        /// /// <param name="stepY">Height precision, determinates how much pixels per column to calculate.
+        /// Ex. layer height = 500, stepY = 5, output image would be 50px high. So to fill all space, height would need to be 50.</param>
         /// <returns>WriteableBitmap of layered bitmaps.</returns>
         /// <returns>WriteableBitmap of layered bitmaps.</returns>
-        public static WriteableBitmap CombineLayers(Layer[] layers, int width, int height)
+        public static WriteableBitmap CombineLayers(Layer[] layers, int width, int height, int stepX = 1, int stepY = 1)
         {
         {
             WriteableBitmap finalBitmap = BitmapFactory.New(width, height);
             WriteableBitmap finalBitmap = BitmapFactory.New(width, height);
 
 
@@ -41,9 +50,9 @@ namespace PixiEditor.Models.ImageManipulation
                 for (int i = 0; i < layers.Length; i++)
                 for (int i = 0; i < layers.Length; i++)
                 {
                 {
                     float layerOpacity = layers[i].Opacity;
                     float layerOpacity = layers[i].Opacity;
-                    for (int y = 0; y < finalBitmap.Height; y++)
+                    for (int y = 0; y < finalBitmap.Height; y += stepY)
                     {
                     {
-                        for (int x = 0; x < finalBitmap.Width; x++)
+                        for (int x = 0; x < finalBitmap.Width; x += stepX)
                         {
                         {
                             Color color = layers[i].GetPixelWithOffset(x, y);
                             Color color = layers[i].GetPixelWithOffset(x, y);
                             if (i > 0 && ((color.A < 255 && color.A > 0) || (layerOpacity < 1f && layerOpacity > 0 && color.A > 0)))
                             if (i > 0 && ((color.A < 255 && color.A > 0) || (layerOpacity < 1f && layerOpacity > 0 && color.A > 0)))
@@ -73,6 +82,23 @@ namespace PixiEditor.Models.ImageManipulation
             return finalBitmap;
             return finalBitmap;
         }
         }
 
 
+        public static WriteableBitmap GeneratePreviewBitmap(Document document, int maxPreviewWidth, int maxPreviewHeight)
+        {
+            int stepX = 1;
+            int stepY = 1;
+            int targetWidth = document.Width;
+            int targetHeight = document.Height;
+            if (document.Width > maxPreviewWidth || document.Height > maxPreviewHeight)
+            {
+                stepX = (int)Math.Floor((float)document.Width / maxPreviewWidth);
+                stepY = (int)Math.Floor((float)document.Height / maxPreviewHeight);
+                targetWidth = maxPreviewWidth;
+                targetHeight = maxPreviewHeight;
+            }
+
+            return CombineLayers(document.Layers.ToArray(), document.Width, document.Height, stepX, stepY);
+        }
+
         public static Dictionary<Layer, Color[]> GetPixelsForSelection(Layer[] layers, Coordinates[] selection)
         public static Dictionary<Layer, Color[]> GetPixelsForSelection(Layer[] layers, Coordinates[] selection)
         {
         {
             Dictionary<Layer, Color[]> result = new Dictionary<Layer, Color[]>();
             Dictionary<Layer, Color[]> result = new Dictionary<Layer, Color[]>();

+ 25 - 25
PixiEditor/Styles/AvalonDock/DarkBrushs.xaml

@@ -8,7 +8,7 @@
 	</ResourceDictionary.MergedDictionaries>
 	</ResourceDictionary.MergedDictionaries>
 
 
 	<!--  Accent Keys  -->
 	<!--  Accent Keys  -->
-    <Color x:Key="{x:Static reskeys:ResourceKeys.ControlAccentColorKey}">#234099</Color>
+    <Color x:Key="{x:Static reskeys:ResourceKeys.ControlAccentColorKey}">#B00022</Color>
 
 
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ControlAccentBrushKey}"
 		x:Key="{x:Static reskeys:ResourceKeys.ControlAccentBrushKey}"
@@ -27,7 +27,7 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.TabBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.TabBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#252526" />
+		Color="#252525" />
 
 
 	<!--  Auto Hide : Tab  -->
 	<!--  Auto Hide : Tab  -->
 	<SolidColorBrush
 	<SolidColorBrush
@@ -74,16 +74,16 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellOverflowButtonHoveredGlyph}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellOverflowButtonHoveredGlyph}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#234099" />
+		Color="#FFFFFF" />
 	<!--  AccentColor  -->
 	<!--  AccentColor  -->
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellOverflowButtonPressedBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellOverflowButtonPressedBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#234099" />
+		Color="#B00022" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellOverflowButtonPressedBorder}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellOverflowButtonPressedBorder}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#234099" />
+		Color="#B00022" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellOverflowButtonPressedGlyph}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellOverflowButtonPressedGlyph}"
 		options:Freeze="true"
 		options:Freeze="true"
@@ -94,7 +94,7 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabSelectedActiveBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabSelectedActiveBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#234099" />
+		Color="#505056" />
 
 
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabSelectedActiveText}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabSelectedActiveText}"
@@ -103,7 +103,7 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabSelectedInactiveBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabSelectedInactiveBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#3F3F46" />
+		Color="#505056" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabSelectedInactiveText}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabSelectedInactiveText}"
 		options:Freeze="true"
 		options:Freeze="true"
@@ -120,7 +120,7 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabUnselectedHoveredBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabUnselectedHoveredBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#4A6996" />
+		Color="#4B4B4B" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabUnselectedHoveredText}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabUnselectedHoveredText}"
 		options:Freeze="true"
 		options:Freeze="true"
@@ -136,12 +136,12 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabButtonSelectedActiveHoveredBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabButtonSelectedActiveHoveredBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#234099" />
+		Color="Black" />
 	<!--  AccentColor  -->
 	<!--  AccentColor  -->
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabButtonSelectedActiveHoveredBorder}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabButtonSelectedActiveHoveredBorder}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#234099" />
+		Color="Black" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabButtonSelectedActiveHoveredGlyph}"
 		x:Key="{x:Static reskeys:ResourceKeys.DocumentWellTabButtonSelectedActiveHoveredGlyph}"
 		options:Freeze="true"
 		options:Freeze="true"
@@ -226,7 +226,7 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionActiveBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionActiveBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#234099" />
+		Color="#B00022" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionActiveGrip}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionActiveGrip}"
 		options:Freeze="true"
 		options:Freeze="true"
@@ -238,7 +238,7 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionInactiveBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionInactiveBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#2D2D30" />
+		Color="#252525" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionInactiveGrip}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionInactiveGrip}"
 		options:Freeze="true"
 		options:Freeze="true"
@@ -257,12 +257,12 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActiveHoveredBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActiveHoveredBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#52B0EF" />
+		Color="#D60029" />
 	<!--  AccentColor  -->
 	<!--  AccentColor  -->
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActiveHoveredBorder}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActiveHoveredBorder}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#52B0EF" />
+		Color="#D60029" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActiveHoveredGlyph}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActiveHoveredGlyph}"
 		options:Freeze="true"
 		options:Freeze="true"
@@ -271,12 +271,12 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActivePressedBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActivePressedBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#0E6198" />
+		Color="#D60029" />
 	<!--  (AccentColor)  -->
 	<!--  (AccentColor)  -->
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActivePressedBorder}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActivePressedBorder}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#0E6198" />
+		Color="#D60029" />
 
 
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActivePressedGlyph}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonActivePressedGlyph}"
@@ -304,11 +304,11 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonInactivePressedBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonInactivePressedBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#0E6198" />
+		Color="#D60029" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonInactivePressedBorder}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonInactivePressedBorder}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#0E6198" />
+		Color="#D60029" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonInactivePressedGlyph}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowCaptionButtonInactivePressedGlyph}"
 		options:Freeze="true"
 		options:Freeze="true"
@@ -318,21 +318,21 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabSelectedActiveBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabSelectedActiveBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#252526" />
+		Color="#252525" />
 	<!--  (AccentColor)  -->
 	<!--  (AccentColor)  -->
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabSelectedActiveText}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabSelectedActiveText}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#234099" />
+		Color="#B00022" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabSelectedInactiveBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabSelectedInactiveBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#252526" />
+		Color="#252525" />
 	<!--  (AccentColor)  -->
 	<!--  (AccentColor)  -->
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabSelectedInactiveText}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabSelectedInactiveText}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#234099" />
+		Color="#B00022" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabUnselectedBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabUnselectedBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
@@ -349,7 +349,7 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabUnselectedHoveredText}"
 		x:Key="{x:Static reskeys:ResourceKeys.ToolWindowTabUnselectedHoveredText}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#55AAFF" />
+		Color="#D60029" />
 
 
 	<!--  Floating Document Window  -->
 	<!--  Floating Document Window  -->
 	<SolidColorBrush
 	<SolidColorBrush
@@ -375,7 +375,7 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.NavigatorWindowBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.NavigatorWindowBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#2D2D30" />
+		Color="#252525" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.NavigatorWindowForeground}"
 		x:Key="{x:Static reskeys:ResourceKeys.NavigatorWindowForeground}"
 		options:Freeze="true"
 		options:Freeze="true"
@@ -385,7 +385,7 @@
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.NavigatorWindowSelectedBackground}"
 		x:Key="{x:Static reskeys:ResourceKeys.NavigatorWindowSelectedBackground}"
 		options:Freeze="true"
 		options:Freeze="true"
-		Color="#234099" />
+		Color="#B00022" />
 	<SolidColorBrush
 	<SolidColorBrush
 		x:Key="{x:Static reskeys:ResourceKeys.NavigatorWindowSelectedText}"
 		x:Key="{x:Static reskeys:ResourceKeys.NavigatorWindowSelectedText}"
 		options:Freeze="true"
 		options:Freeze="true"

+ 16 - 23
PixiEditor/Styles/AvalonDock/Themes/Generic.xaml

@@ -1,14 +1,3 @@
-<!--
-	************************************************************************
-	AvalonDock
-	
-	Copyright (C) 2007-2013 Xceed Software Inc.
-	
-	This program is provided to you under the terms of the Microsoft Public
-	License (Ms-PL) as published at https://opensource.org/licenses/MS-PL
-	************************************************************************
--->
-
 <ResourceDictionary
 <ResourceDictionary
 	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -17,7 +6,8 @@
 	xmlns:avalonDockConverters="clr-namespace:AvalonDock.Converters;assembly=AvalonDock"
 	xmlns:avalonDockConverters="clr-namespace:AvalonDock.Converters;assembly=AvalonDock"
 	xmlns:avalonDockProperties="clr-namespace:AvalonDock.Properties;assembly=AvalonDock"
 	xmlns:avalonDockProperties="clr-namespace:AvalonDock.Properties;assembly=AvalonDock"
 	xmlns:reskeys="clr-namespace:PixiEditor.Styles.AvalonDock.Themes"
 	xmlns:reskeys="clr-namespace:PixiEditor.Styles.AvalonDock.Themes"
-	xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=AvalonDock">
+    xmlns:ex="clr-namespace:PixiEditor.Helpers.Extensions"
+	xmlns:shell="clr-namespace:Microsoft.Windows.Shell;assembly=AvalonDock" xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters">
 	<ResourceDictionary.MergedDictionaries>
 	<ResourceDictionary.MergedDictionaries>
 		<ResourceDictionary Source="/Styles/AvalonDock/OverlayButtons.xaml" />
 		<ResourceDictionary Source="/Styles/AvalonDock/OverlayButtons.xaml" />
         <ResourceDictionary Source="/Styles/AvalonDock/Themes/Menu/MenuItem.xaml" />
         <ResourceDictionary Source="/Styles/AvalonDock/Themes/Menu/MenuItem.xaml" />
@@ -315,9 +305,8 @@
 										x:Name="Bd"
 										x:Name="Bd"
 										Background="{TemplateBinding Background}"
 										Background="{TemplateBinding Background}"
 										BorderBrush="{Binding Background, RelativeSource={RelativeSource Self}}"
 										BorderBrush="{Binding Background, RelativeSource={RelativeSource Self}}"
+                                        CornerRadius="2.5 2.5 0 0"
 										BorderThickness="0,0,0,2" />
 										BorderThickness="0,0,0,2" />
-                                    <StackPanel Orientation="Horizontal">
-                                        <Image Margin="5" Width="50" Stretch="UniformToFill" Height="40" Source="{Binding }"/>
                                     <ContentPresenter
                                     <ContentPresenter
 										x:Name="Content"
 										x:Name="Content"
 										HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
 										HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
@@ -325,7 +314,6 @@
 										ContentSource="Header"
 										ContentSource="Header"
 										RecognizesAccessKey="True"
 										RecognizesAccessKey="True"
 										SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
 										SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
-                                    </StackPanel>
                                 </Grid>
                                 </Grid>
 								<ControlTemplate.Triggers>
 								<ControlTemplate.Triggers>
 									<Trigger Property="Selector.IsSelected" Value="true">
 									<Trigger Property="Selector.IsSelected" Value="true">
@@ -1230,9 +1218,9 @@
 		</Setter>
 		</Setter>
 	</Style>
 	</Style>
 
 
-	<DataTemplate x:Key="PixiEditorDockThemeDocumentHeaderTemplate">
-		<TextBlock Text="{Binding Title}" TextTrimming="CharacterEllipsis" />
-	</DataTemplate>
+    <DataTemplate x:Key="PixiEditorDockThemeDocumentHeaderTemplate">
+		<TextBlock VerticalAlignment="Center" Text="{Binding Title}" TextTrimming="CharacterEllipsis" />
+    </DataTemplate>
 
 
 	<DataTemplate x:Key="PixiEditorDockThemeAnchorableHeaderTemplate">
 	<DataTemplate x:Key="PixiEditorDockThemeAnchorableHeaderTemplate">
 		<TextBlock
 		<TextBlock
@@ -1244,7 +1232,7 @@
 	<DataTemplate x:Key="PixiEditorDockThemeDocumentTitleTemplate">
 	<DataTemplate x:Key="PixiEditorDockThemeDocumentTitleTemplate">
 		<TextBlock
 		<TextBlock
 			VerticalAlignment="Center"
 			VerticalAlignment="Center"
-			Text="{Binding Title}"
+			Text="Canvas"
 			TextTrimming="CharacterEllipsis" />
 			TextTrimming="CharacterEllipsis" />
 	</DataTemplate>
 	</DataTemplate>
 
 
@@ -1350,8 +1338,8 @@
 		</Setter>
 		</Setter>
 	</Style>
 	</Style>
 
 
-	<Style TargetType="{x:Type avalonDockControls:LayoutDocumentControl}">
-		<Setter Property="Template">
+    <Style TargetType="{x:Type avalonDockControls:LayoutDocumentControl}">
+        <Setter Property="Template">
 			<Setter.Value>
 			<Setter.Value>
 				<ControlTemplate TargetType="{x:Type avalonDockControls:LayoutDocumentControl}">
 				<ControlTemplate TargetType="{x:Type avalonDockControls:LayoutDocumentControl}">
 					<Border
 					<Border
@@ -1384,13 +1372,18 @@
 									<ColumnDefinition Width="Auto" />
 									<ColumnDefinition Width="Auto" />
 								</Grid.ColumnDefinitions>
 								</Grid.ColumnDefinitions>
 								<Border Grid.ColumnSpan="2" Background="Transparent" />
 								<Border Grid.ColumnSpan="2" Background="Transparent" />
-								<ContentPresenter
+                                <StackPanel Orientation="Horizontal">
+                                    <Image Stretch="Uniform" Name="previewImage" Margin="1" Width="30" Height="20"
+                                           RenderOptions.BitmapScalingMode="NearestNeighbor"
+                                           Source="{Binding LayoutItem.Model.PreviewImage, RelativeSource={RelativeSource TemplatedParent}}"/>
+                                    <ContentPresenter
 									Margin="4,0"
 									Margin="4,0"
 									Content="{Binding Model, RelativeSource={RelativeSource TemplatedParent}}"
 									Content="{Binding Model, RelativeSource={RelativeSource TemplatedParent}}"
 									ContentTemplate="{Binding DocumentHeaderTemplate, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type avalonDock:DockingManager}, Mode=FindAncestor}}"
 									ContentTemplate="{Binding DocumentHeaderTemplate, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type avalonDock:DockingManager}, Mode=FindAncestor}}"
 									ContentTemplateSelector="{Binding DocumentHeaderTemplateSelector, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type avalonDock:DockingManager}, Mode=FindAncestor}}"
 									ContentTemplateSelector="{Binding DocumentHeaderTemplateSelector, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type avalonDock:DockingManager}, Mode=FindAncestor}}"
 									TextBlock.Foreground="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TabItem}}" />
 									TextBlock.Foreground="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=TabItem}}" />
-								<!--  Close button should be moved out to the container style  -->
+                                </StackPanel>
+                                <!--  Close button should be moved out to the container style  -->
 								<Button
 								<Button
 									x:Name="DocumentCloseButton"
 									x:Name="DocumentCloseButton"
 									Grid.Column="1"
 									Grid.Column="1"

+ 1 - 1
PixiEditor/Styles/ImageCheckBoxStyle.xaml

@@ -6,7 +6,7 @@
             <Setter.Value>
             <Setter.Value>
                 <ControlTemplate TargetType="{x:Type CheckBox}">
                 <ControlTemplate TargetType="{x:Type CheckBox}">
                     <StackPanel Orientation="Horizontal">
                     <StackPanel Orientation="Horizontal">
-                        <Image Cursor="Hand" x:Name="checkboxImage" Source="../Images/Eye-off.png" Width="36"/>
+                        <Image Cursor="Hand" x:Name="checkboxImage" Source="../Images/Eye-off.png"/>
                         <ContentPresenter/>
                         <ContentPresenter/>
                     </StackPanel>
                     </StackPanel>
                     <ControlTemplate.Triggers>
                     <ControlTemplate.Triggers>

+ 1 - 1
PixiEditor/ViewModels/SubViewModels/Main/IoViewModel.cs

@@ -38,7 +38,7 @@ namespace PixiEditor.ViewModels.SubViewModels.Main
 
 
             Owner.BitmapManager.MouseController.MouseUp(new MouseEventArgs(
             Owner.BitmapManager.MouseController.MouseUp(new MouseEventArgs(
                 Mouse.PrimaryDevice,
                 Mouse.PrimaryDevice,
-                (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()));
+                (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds()));         
         }
         }
 
 
         public void KeyDown(object parameter)
         public void KeyDown(object parameter)

+ 1 - 0
PixiEditor/Views/MainWindow.xaml

@@ -5,6 +5,7 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:vm="clr-namespace:PixiEditor.ViewModels"
         xmlns:vm="clr-namespace:PixiEditor.ViewModels"
         xmlns:vws="clr-namespace:PixiEditor.Views"
         xmlns:vws="clr-namespace:PixiEditor.Views"
+        xmlns:ex="clr-namespace:PixiEditor.Helpers.Extensions"
         xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
         xmlns:converters="clr-namespace:PixiEditor.Helpers.Converters"
         xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
         xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
         xmlns:ui="clr-namespace:PixiEditor.Helpers.UI"
         xmlns:ui="clr-namespace:PixiEditor.Helpers.UI"

+ 4 - 3
PixiEditor/Views/UserControls/EditableTextBlock.xaml

@@ -10,13 +10,14 @@
         <converters:OppositeVisibilityConverter x:Key="OppositeVisibilityConverter" />
         <converters:OppositeVisibilityConverter x:Key="OppositeVisibilityConverter" />
     </UserControl.Resources>
     </UserControl.Resources>
     <Grid>
     <Grid>
-        <TextBlock Foreground="Snow" MouseDown="TextBlock_MouseDown"
+        <TextBlock Foreground="Snow" MouseLeftButtonDown="TextBlock_MouseDown"
+                   TextTrimming="CharacterEllipsis"
                    Visibility="{Binding Path=TextBlockVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
                    Visibility="{Binding Path=TextBlockVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
                    Text="{Binding Path=Text, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" />
                    Text="{Binding Path=Text, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" />
         <TextBox Style="{StaticResource DarkTextBoxStyle}"
         <TextBox Style="{StaticResource DarkTextBoxStyle}"
-                 LostFocus="TextBox_LostFocus"
+                 LostFocus="TextBox_LostFocus" 
                  Text="{Binding Path=Text, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
                  Text="{Binding Path=Text, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
-                 KeyDown="TextBox_KeyDown"
+                 KeyDown="TextBox_KeyDown"                 
                  LostKeyboardFocus="textBox_LostKeyboardFocus"
                  LostKeyboardFocus="textBox_LostKeyboardFocus"
                  Visibility="{Binding Path=TextBlockVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, 
                  Visibility="{Binding Path=TextBlockVisibility, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}, 
             Converter={StaticResource OppositeVisibilityConverter}}"
             Converter={StaticResource OppositeVisibilityConverter}}"

+ 22 - 19
PixiEditor/Views/UserControls/EditableTextBlock.xaml.cs

@@ -7,7 +7,7 @@ using PixiEditor.Models.Controllers.Shortcuts;
 namespace PixiEditor.Views
 namespace PixiEditor.Views
 {
 {
     /// <summary>
     /// <summary>
-    ///     Interaction logic for EditableTextBlock.xaml
+    ///     Interaction logic for EditableTextBlock.xaml.
     /// </summary>
     /// </summary>
     public partial class EditableTextBlock : UserControl
     public partial class EditableTextBlock : UserControl
     {
     {
@@ -16,7 +16,6 @@ namespace PixiEditor.Views
             DependencyProperty.Register("TextBlockVisibility", typeof(Visibility), typeof(EditableTextBlock),
             DependencyProperty.Register("TextBlockVisibility", typeof(Visibility), typeof(EditableTextBlock),
                 new PropertyMetadata(Visibility.Visible));
                 new PropertyMetadata(Visibility.Visible));
 
 
-
         // Using a DependencyProperty as the backing store for Text.  This enables animation, styling, binding, etc...
         // Using a DependencyProperty as the backing store for Text.  This enables animation, styling, binding, etc...
         public static readonly DependencyProperty TextProperty =
         public static readonly DependencyProperty TextProperty =
             DependencyProperty.Register("Text", typeof(string), typeof(EditableTextBlock),
             DependencyProperty.Register("Text", typeof(string), typeof(EditableTextBlock),
@@ -27,6 +26,7 @@ namespace PixiEditor.Views
             DependencyProperty.Register("IsEditing", typeof(bool), typeof(EditableTextBlock),
             DependencyProperty.Register("IsEditing", typeof(bool), typeof(EditableTextBlock),
                 new PropertyMetadata(OnIsEditingChanged));
                 new PropertyMetadata(OnIsEditingChanged));
 
 
+
         public EditableTextBlock()
         public EditableTextBlock()
         {
         {
             InitializeComponent();
             InitializeComponent();
@@ -34,33 +34,22 @@ namespace PixiEditor.Views
 
 
         public Visibility TextBlockVisibility
         public Visibility TextBlockVisibility
         {
         {
-            get => (Visibility) GetValue(TextBlockVisibilityProperty);
+            get => (Visibility)GetValue(TextBlockVisibilityProperty);
             set => SetValue(TextBlockVisibilityProperty, value);
             set => SetValue(TextBlockVisibilityProperty, value);
         }
         }
 
 
-
         public bool IsEditing
         public bool IsEditing
         {
         {
-            get => (bool) GetValue(EnableEditingProperty);
+            get => (bool)GetValue(EnableEditingProperty);
             set => SetValue(EnableEditingProperty, value);
             set => SetValue(EnableEditingProperty, value);
         }
         }
 
 
-
         public string Text
         public string Text
         {
         {
-            get => (string) GetValue(TextProperty);
+            get => (string)GetValue(TextProperty);
             set => SetValue(TextProperty, value);
             set => SetValue(TextProperty, value);
         }
         }
 
 
-        private static void OnIsEditingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
-        {
-            if ((bool) e.NewValue)
-            {
-                EditableTextBlock tb = (EditableTextBlock) d;
-                tb.EnableEditing();
-            }
-        }
-
         public void EnableEditing()
         public void EnableEditing()
         {
         {
             ShortcutController.BlockShortcutExecution = true;
             ShortcutController.BlockShortcutExecution = true;
@@ -70,22 +59,36 @@ namespace PixiEditor.Views
             textBox.SelectAll();
             textBox.SelectAll();
         }
         }
 
 
-        private void DisableEditing()
+        public void DisableEditing()
         {
         {
             TextBlockVisibility = Visibility.Visible;
             TextBlockVisibility = Visibility.Visible;
             ShortcutController.BlockShortcutExecution = false;
             ShortcutController.BlockShortcutExecution = false;
             IsEditing = false;
             IsEditing = false;
         }
         }
 
 
+        private static void OnIsEditingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+        {
+            if ((bool)e.NewValue)
+            {
+                EditableTextBlock tb = (EditableTextBlock)d;
+                tb.EnableEditing();
+            }
+        }
 
 
         private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
         private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
         {
         {
-            if (e.ChangedButton == MouseButton.Left && e.ClickCount == 2) EnableEditing();
+            if (e.ClickCount == 2)
+            {
+                EnableEditing();
+            }
         }
         }
 
 
         private void TextBox_KeyDown(object sender, KeyEventArgs e)
         private void TextBox_KeyDown(object sender, KeyEventArgs e)
         {
         {
-            if (e.Key == Key.Enter) DisableEditing();
+            if (e.Key == Key.Enter)
+            {
+                DisableEditing();
+            }
         }
         }
 
 
         private void TextBox_LostFocus(object sender, RoutedEventArgs e)
         private void TextBox_LostFocus(object sender, RoutedEventArgs e)

+ 4 - 4
PixiEditor/Views/UserControls/LayerItem.xaml

@@ -23,12 +23,12 @@
         </i:Interaction.Triggers>
         </i:Interaction.Triggers>
         <Grid>
         <Grid>
             <Grid.ColumnDefinitions>
             <Grid.ColumnDefinitions>
-                <ColumnDefinition Width="35"/>
+                <ColumnDefinition Width="30"/>
                 <ColumnDefinition Width="199*"/>
                 <ColumnDefinition Width="199*"/>
-                <ColumnDefinition Width="35"/>
+                <ColumnDefinition Width="20"/>
             </Grid.ColumnDefinitions>
             </Grid.ColumnDefinitions>
             <CheckBox Style="{StaticResource ImageCheckBox}" VerticalAlignment="Center"
             <CheckBox Style="{StaticResource ImageCheckBox}" VerticalAlignment="Center"
-                      IsThreeState="False" HorizontalAlignment="Center"
+                      IsThreeState="False" HorizontalAlignment="Center" 
                       IsChecked="{Binding Path=IsVisible, Mode=TwoWay}" Grid.Column="0" Height="16" />
                       IsChecked="{Binding Path=IsVisible, Mode=TwoWay}" Grid.Column="0" Height="16" />
             <StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Left" Margin="5,0,0,0">
             <StackPanel Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Left" Margin="5,0,0,0">
                 <Image Source="{Binding PreviewImage,ElementName=uc}" Stretch="Uniform" Width="50" Height="20" Margin="0,0,20,0"
                 <Image Source="{Binding PreviewImage,ElementName=uc}" Stretch="Uniform" Width="50" Height="20" Margin="0,0,20,0"
@@ -39,7 +39,7 @@
                     Text="{Binding LayerName, ElementName=uc, Mode=TwoWay}" />
                     Text="{Binding LayerName, ElementName=uc, Mode=TwoWay}" />
             </StackPanel>
             </StackPanel>
             <StackPanel Visibility="{Binding Path=ControlButtonsVisible, ElementName=uc}" 
             <StackPanel Visibility="{Binding Path=ControlButtonsVisible, ElementName=uc}" 
-                        Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" Width="15" 
+                        Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center" Width="11" 
                         Grid.Column="2">
                         Grid.Column="2">
                 <Button CommandParameter="{Binding LayerIndex, ElementName=uc}" Command="{Binding Path=MoveToFrontCommand, ElementName=uc}" Background="Transparent" Style="{StaticResource OpacityButtonStyle}" Foreground="White" HorizontalAlignment="Center" BorderThickness="0">
                 <Button CommandParameter="{Binding LayerIndex, ElementName=uc}" Command="{Binding Path=MoveToFrontCommand, ElementName=uc}" Background="Transparent" Style="{StaticResource OpacityButtonStyle}" Foreground="White" HorizontalAlignment="Center" BorderThickness="0">
                     <TextBlock Text="&#9650;"/>
                     <TextBlock Text="&#9650;"/>