Browse Source

Fixed merge artifacts

flabbet 4 years ago
parent
commit
e32e405f87

+ 0 - 20
PixiEditor/Models/Controllers/ClipboardController.cs

@@ -127,25 +127,5 @@ namespace PixiEditor.Models.Controllers
         {
             ViewModelMain.Current.BitmapManager.ActiveDocument.AddNewLayer("Image", image);
         }
-
-        private static void RemoveLayerProcess(object[] parameters)
-        {
-            if (parameters.Length == 0 || !(parameters[0] is int))
-            {
-                return;
-            }
-
-            ViewModelMain.Current.BitmapManager.ActiveDocument.RemoveLayer((int)parameters[0]);
-        }
-
-        private static void AddLayerProcess(object[] parameters)
-        {
-            if (parameters.Length == 0 || !(parameters[0] is WriteableBitmap))
-            {
-                return;
-            }
-
-            AddImageToLayers((WriteableBitmap)parameters[0]);
-        }
     }
 }

+ 1 - 0
PixiEditor/Models/DataHolders/Document/Document.Layers.cs

@@ -505,6 +505,7 @@ namespace PixiEditor.Models.DataHolders
             LayerStructure.PostMoveReassignBounds(new GroupData(newGroup?.GroupGuid), layerGuid);
 
             RaisePropertyChanged(nameof(LayerStructure));
+        }
 
         public Color GetColorAtPoint(int x, int y)
         {

+ 0 - 16
PixiEditor/Models/IO/Importer.cs

@@ -71,22 +71,6 @@ namespace PixiEditor.Models.IO
             }
         }
 
-        public static Document ImportOldDocument(string path)
-        {
-            try
-            {
-                using FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read);
-
-                Document doc = PixiEditor.Parser.PixiParser.DeserializeOld(stream).ToDocument();
-                doc.DocumentFilePath = path;
-                return doc;
-            }
-            catch (SerializationException)
-            {
-                throw new CorruptedFileException();
-            }
-        }
-
         public static bool IsSupportedFile(string path)
         {
             path = path.ToLower();

+ 14 - 0
PixiEditor/Models/ImageManipulation/BitmapUtils.cs

@@ -110,6 +110,20 @@ namespace PixiEditor.Models.ImageManipulation
                 maxPreviewHeight);
         }
 
+        public static WriteableBitmap GeneratePreviewBitmap(IEnumerable<Layer> layers, int width, int height, int maxPreviewWidth, int maxPreviewHeight)
+        {
+            var opacityLayers = layers.Where(x => x.IsVisible && x.Opacity > 0.8f);
+
+            return GeneratePreviewBitmap(
+                opacityLayers.Select(x => x.LayerBitmap),
+                opacityLayers.Select(x => x.OffsetX),
+                opacityLayers.Select(x => x.OffsetY),
+                width,
+                height,
+                maxPreviewWidth,
+                maxPreviewHeight);
+        }
+
         public static WriteableBitmap GeneratePreviewBitmap(IEnumerable<SerializableLayer> layers, int width, int height, int maxPreviewWidth, int maxPreviewHeight)
         {
             var opacityLayers = layers.Where(x => x.IsVisible && x.Opacity > 0.8f);

+ 1 - 17
PixiEditor/Models/Tools/ShapeTool.cs

@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Linq;
 using System.Windows.Input;
 using System.Windows.Media;
@@ -70,21 +70,5 @@ namespace PixiEditor.Models.Tools
 
             return new DoubleCords(startingCords, secondCoordinates);
         }
-
-        // TODO: Add cache for lines 31, 32 (hopefully it would speed up calculation)
-        public abstract override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color);
-
-        protected IEnumerable<Coordinates> GetThickShape(IEnumerable<Coordinates> shape, int thickness)
-        {
-            List<Coordinates> output = new List<Coordinates>();
-            foreach (Coordinates item in shape)
-            {
-                output.AddRange(
-                    CoordinatesCalculator.RectangleToCoordinates(
-                        CoordinatesCalculator.CalculateThicknessCenter(item, thickness)));
-            }
-
-            return output.Distinct();
-        }
     }
 }

+ 1 - 1
PixiEditor/Models/Tools/Tools/ColorPickerTool.cs

@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Drawing;
 using System.Windows.Input;
 using PixiEditor.Models.Position;

+ 1 - 1
PixiEditor/Models/Tools/Tools/SelectTool.cs

@@ -90,7 +90,7 @@ namespace PixiEditor.Models.Tools.Tools
             return GetRectangleSelectionForPoints(new Coordinates(0, 0), new Coordinates(document.Width - 1, document.Height - 1));
         }
 
-        private void Select(Coordinates[] pixels, SelectionShape shape)
+        private void Select(List<Coordinates> pixels, SelectionShape shape)
         {
             IEnumerable<Coordinates> selection;
 

+ 1 - 0
PixiEditor/ViewModels/SubViewModels/Main/FileViewModel.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.IO;
 using System.Linq;

+ 1 - 1
PixiEditor/Views/MainWindow.xaml

@@ -12,7 +12,7 @@
         xmlns:cmd="http://www.galasoft.ch/mvvmlight" 
         xmlns:avalondock="https://github.com/Dirkster99/AvalonDock"
         xmlns:colorpicker="clr-namespace:ColorPicker;assembly=ColorPicker" xmlns:usercontrols="clr-namespace:PixiEditor.Views.UserControls" xmlns:behaviours="clr-namespace:PixiEditor.Helpers.Behaviours" 
-        xmlns:avalonDockTheme="clr-namespace:PixiEditor.Styles.AvalonDock" d:DataContext="{d:DesignInstance Type=vm:ViewModelMain}" xmlns:dataHolders="clr-namespace:PixiEditor.Models.DataHolders"
+        xmlns:avalonDockTheme="clr-namespace:PixiEditor.Styles.AvalonDock" d:DataContext="{d:DesignInstance Type=vm:ViewModelMain}"
         mc:Ignorable="d" WindowStyle="None" Initialized="MainWindow_Initialized"
         Title="PixiEditor" Name="mainWindow" Height="1000" Width="1600" Background="{StaticResource MainColor}"
         WindowStartupLocation="CenterScreen" WindowState="Maximized"

+ 1 - 1
PixiEditor/Views/MainWindow.xaml.cs

@@ -45,7 +45,7 @@ namespace PixiEditor
             Activated += MainWindow_Activated;
 
             MaxHeight = SystemParameters.MaximizedPrimaryScreenHeight;
-            rawLayerAnchorable.IsVisible = viewModel.IsDebug;
+            rawLayerAnchorable.IsVisible = DataContext.IsDebug;
             DataContext.CloseAction = Close;
             Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
 

+ 1 - 1
PixiEditor/Views/UserControls/LayersManager.xaml.cs

@@ -35,7 +35,7 @@ namespace PixiEditor.Views.UserControls
         {
             var items = (ObservableCollection<object>)e.NewValue;
             LayersManager manager = (LayersManager)d;
-            if (items != null && items.Count > 0 && ((ObservableCollection<object>)e.OldValue).Count == 0)
+            if (items != null && items.Count > 0 && (e.OldValue == null || ((ObservableCollection<object>)e.OldValue).Count == 0))
             {
                 var item = items[0];
                 manager.cachedItem = item;