Browse Source

Fixed syntax errors

flabbet 3 years ago
parent
commit
1f2488dc8d

+ 1 - 3
PixiEditor/Helpers/Converters/IndexOfConverter.cs

@@ -17,9 +17,7 @@ namespace PixiEditor.Helpers.Converters
                 return index;
             }
 
-            return value is Layer layer && bitmapManager.ActiveDocument != null
-                   ? bitmapManager.ActiveDocument.Layers.IndexOf(layer)
-                   : Binding.DoNothing;
+            return Binding.DoNothing;
         }
     }
 }

+ 4 - 4
PixiEditor/Models/Layers/Layer.cs

@@ -302,14 +302,14 @@ namespace PixiEditor.Models.Layers
             return LayerBitmap.GetSRGBPixel(x, y);
         }
 
-        public void SetPixelWithOffset(Coordinates coordinates, Color color)
+        public void SetPixelWithOffset(Coordinates coordinates, SKColor color)
         {
-            LayerBitmap.SetPixel(coordinates.X - OffsetX, coordinates.Y - OffsetY, color);
+            LayerBitmap.SetSRGBPixel(coordinates.X - OffsetX, coordinates.Y - OffsetY, color);
         }
 
-        public void SetPixelWithOffset(int x, int y, Color color)
+        public void SetPixelWithOffset(int x, int y, SKColor color)
         {
-            LayerBitmap.SetPixel(x - OffsetX, y - OffsetY, color);
+            LayerBitmap.SetSRGBPixel(x - OffsetX, y - OffsetY, color);
         }
 
         /// <summary>

+ 4 - 2
PixiEditor/Models/Position/CoordinatesCalculator.cs

@@ -1,4 +1,6 @@
 using PixiEditor.Models.DataHolders;
+using PixiEditor.Models.Layers;
+using SkiaSharp;
 using System;
 using System.Collections.Generic;
 
@@ -62,9 +64,9 @@ namespace PixiEditor.Models.Position
             return coordinates;
         }
 
-        public static void DrawRectangle(Layer layer, Color color, int x1, int y1, int x2, int y2)
+        public static void DrawRectangle(Layer layer, SKColor color, int x1, int y1, int x2, int y2)
         {
-            using var ctx = layer.LayerBitmap.GetBitmapContext();
+            //TODO: use some kind of context
             x2++;
             y2++;
             for (int y = y1; y < y1 + (y2 - y1); y++)

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

@@ -5,6 +5,7 @@ using System.Windows.Media;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
+using SkiaSharp;
 
 namespace PixiEditor.Models.Tools
 {
@@ -17,6 +18,6 @@ namespace PixiEditor.Models.Tools
         public bool UseDefaultUndoMethod { get; set; } = true;
         public virtual bool UsesShift => true;
 
-        public abstract void Use(Layer layer, List<Coordinates> mouseMove, Color color);
+        public abstract void Use(Layer layer, List<Coordinates> mouseMove, SKColor color);
     }
 }

+ 3 - 3
PixiEditor/Models/Tools/ShapeTool.cs

@@ -56,9 +56,9 @@ namespace PixiEditor.Models.Tools
         }
 
         // TODO: Add cache for lines 31, 32 (hopefully it would speed up calculation)
-        public abstract override LayerChange[] Use(Layer layer, List<Coordinates> coordinates, SKColor color);
+        public abstract override void Use(Layer layer, List<Coordinates> coordinates, SKColor color);
 
-        protected static void ThickenShape(Layer layer, Color color, IEnumerable<Coordinates> shape, int thickness)
+        protected static void ThickenShape(Layer layer, SKColor color, IEnumerable<Coordinates> shape, int thickness)
         {
             foreach (Coordinates item in shape)
             {
@@ -66,7 +66,7 @@ namespace PixiEditor.Models.Tools
             }
         }
 
-        protected static void ThickenShape(Layer layer, Color color, Coordinates coords, int thickness)
+        protected static void ThickenShape(Layer layer, SKColor color, Coordinates coords, int thickness)
         {
             var dcords = CoordinatesCalculator.CalculateThicknessCenter(coords, thickness);
             CoordinatesCalculator.DrawRectangle(layer, color, dcords.Coords1.X, dcords.Coords1.Y, dcords.Coords2.X, dcords.Coords2.Y);

+ 51 - 36
PixiEditor/Models/Tools/Tool.cs

@@ -13,72 +13,87 @@ using PixiEditor.Models.Tools.ToolSettings.Toolbars;
 using PixiEditor.Models.Undo;
 
 namespace PixiEditor.Models.Tools
-{
-    public abstract class Tool : NotifyableObject
-    {
-        private bool isActive;
+{
+    public abstract class Tool : NotifyableObject
+    {
+        private bool isActive;
         private string actionDisplay = string.Empty;
 
         public virtual string ToolName => GetType().Name.Replace("Tool", string.Empty);
 
+        public virtual string DisplayName => ToolName.AddSpacesBeforeUppercaseLetters();
+
+        public virtual string ImagePath => $"/Images/Tools/{ToolName}Image.png";
+
+        public virtual bool HideHighlight { get; }
+
+        public abstract string Tooltip { get; }
+
+        public string ActionDisplay
+        {
+            get => actionDisplay;
+            set
+            {
+                actionDisplay = value;
+                RaisePropertyChanged("ActionDisplay");
+            }
+        }
+
         public bool IsActive
         {
             get => isActive;
             set
             {
-                actionDisplay = value;
-                RaisePropertyChanged(nameof(ActionDisplay));
+                isActive = value;
+                RaisePropertyChanged("IsActive");
             }
         }
-
-        public bool IsActive
-        {
-            get => isActive;
-            set
-            {
-                isActive = value;
-                RaisePropertyChanged(nameof(IsActive));
-            }
-        }
-
-        public Cursor Cursor { get; set; } = Cursors.Arrow;
-
-        public Toolbar Toolbar { get; set; } = new EmptyToolbar();
-
-        public bool CanStartOutsideCanvas { get; set; } = false;
-
+
+        public Cursor Cursor { get; set; } = Cursors.Arrow;
+
+        public Toolbar Toolbar { get; set; } = new EmptyToolbar();
+
+        public bool CanStartOutsideCanvas { get; set; } = false;
+
         public virtual void OnMouseDown(MouseEventArgs e)
         {
         }
 
-        public virtual void OnKeyUp(KeyEventArgs e)

-        {

+        public virtual void AddUndoProcess(Document document)
+        {
+            //StorageBasedChange change = new StorageBasedChange(document, affectedLayers, false);
+
+            //manager.AddUndoChange(change.ToChange(), )
         }
 
-        public virtual void OnStart(Coordinates clickPosition)

-        {

+        public virtual void OnMouseUp(MouseEventArgs e)
+        {
         }
-
-        public virtual void OnStoppedRecordingMouseUp(MouseEventArgs e)
+
+        public virtual void OnKeyDown(KeyEventArgs e)
         {
         }
-
-        public virtual void OnMouseMove(MouseEventArgs e)
+
+        public virtual void OnKeyUp(KeyEventArgs e)
         {
         }
 
-        public virtual void AddUndoProcess(Document document)
+        public virtual void OnStart(Coordinates clickPosition)
         {
-            //StorageBasedChange change = new StorageBasedChange(document, affectedLayers, false);
+        }
 
-            //manager.AddUndoChange(change.ToChange(), )
+        public virtual void OnRecordingLeftMouseDown(MouseEventArgs e)
+        {
         }
 
-        public virtual void RedoProcess(UndoManager manager)
+        public virtual void OnStoppedRecordingMouseUp(MouseEventArgs e)
         {
+        }
 
+        public virtual void OnMouseMove(MouseEventArgs e)
+        {
         }
-
+
         public virtual void AfterAddedUndo(UndoManager undoManager)
         {
         }

+ 2 - 3
PixiEditor/Models/Tools/Tools/BrightnessTool.cs

@@ -55,7 +55,7 @@ namespace PixiEditor.Models.Tools.Tools
             }
         }
 
-        public override LayerChange[] Use(Layer layer, List<Coordinates> coordinates, SKColor color)
+        public override void Use(Layer layer, List<Coordinates> coordinates, SKColor color)
         {
             int toolSize = Toolbar.GetSetting<SizeSetting>("ToolSize").Value;
             float correctionFactor = Toolbar.GetSetting<FloatSetting>("CorrectionFactor").Value;
@@ -79,9 +79,8 @@ namespace PixiEditor.Models.Tools.Tools
                 centeredCoords.Coords1.Y,
                 centeredCoords.Coords2.X,
                 centeredCoords.Coords2.Y);
-            BitmapPixelChanges changes = new BitmapPixelChanges(new Dictionary<Coordinates, SKColor>());
 
-            using var ctx = layer.LayerBitmap.GetBitmapContext();
+            //using var ctx = layer.LayerBitmap.GetBitmapContext();
 
             foreach (Coordinates coordinate in rectangleCoordinates)
             {

+ 11 - 19
PixiEditor/Models/Tools/Tools/CircleTool.cs

@@ -1,6 +1,4 @@
-using PixiEditor.Helpers.Extensions;
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Layers;
+using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Tools.ToolSettings.Settings;
 using SkiaSharp;
@@ -9,12 +7,6 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Windows.Input;
 using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using PixiEditor.Helpers.Extensions;
-using PixiEditor.Models.DataHolders;
-using PixiEditor.Models.Layers;
-using PixiEditor.Models.Position;
-using PixiEditor.Models.Tools.ToolSettings.Settings;
 
 namespace PixiEditor.Models.Tools.Tools
 {
@@ -43,7 +35,7 @@ namespace PixiEditor.Models.Tools.Tools
             }
         }
 
-        public override LayerChange[] Use(Layer layer, List<Coordinates> coordinates, SKColor color)
+        public override void Use(Layer layer, List<Coordinates> coordinates, SKColor color)
         {
             int thickness = Toolbar.GetSetting<SizeSetting>("ToolSize").Value;
             DoubleCords fixedCoordinates = CalculateCoordinatesForShapeRotation(coordinates[^1], coordinates[0]);
@@ -64,7 +56,7 @@ namespace PixiEditor.Models.Tools.Tools
         /// <param name="endCoordinates">Bottom right coordinate of ellipse.</param>
         /// <param name="thickness">Thickness of ellipse.</param>
         /// <param name="filled">Should ellipse be filled.</param>
-        public void CreateEllipse(Layer layer, Color color, Coordinates startCoordinates, Coordinates endCoordinates, int thickness, bool filled)
+        public void CreateEllipse(Layer layer, SKColor color, Coordinates startCoordinates, Coordinates endCoordinates, int thickness, bool filled)
         {
             IEnumerable<Coordinates> outline = CreateEllipse(layer, color, startCoordinates, endCoordinates, thickness);
             if (filled)
@@ -79,7 +71,7 @@ namespace PixiEditor.Models.Tools.Tools
         /// <param name="startCoordinates">Top left coordinate of ellipse.</param>
         /// <param name="endCoordinates">Bottom right coordinate of ellipse.</param>
         /// <param name="thickness">Thickness of ellipse.</param>
-        public IEnumerable<Coordinates> CreateEllipse(Layer layer, Color color, Coordinates startCoordinates, Coordinates endCoordinates, int thickness)
+        public IEnumerable<Coordinates> CreateEllipse(Layer layer, SKColor color, Coordinates startCoordinates, Coordinates endCoordinates, int thickness)
         {
             double radiusX = (endCoordinates.X - startCoordinates.X) / 2.0;
             double radiusY = (endCoordinates.Y - startCoordinates.Y) / 2.0;
@@ -95,9 +87,9 @@ namespace PixiEditor.Models.Tools.Tools
             return ellipse;
         }
 
-        public List<Coordinates> GenerateMidpointEllipse(Layer layer, Color color, double halfWidth, double halfHeight, double centerX, double centerY)
+        public List<Coordinates> GenerateMidpointEllipse(Layer layer, SKColor color, double halfWidth, double halfHeight, double centerX, double centerY)
         {
-            using var ctx = layer.LayerBitmap.GetBitmapContext();
+            //using var ctx = layer.LayerBitmap.GetBitmapContext();
 
             if (halfWidth < 1 || halfHeight < 1)
             {
@@ -153,9 +145,9 @@ namespace PixiEditor.Models.Tools.Tools
             return outputCoordinates;
         }
 
-        public void DrawEllipseFill(Layer layer, Color color, IEnumerable<Coordinates> outlineCoordinates)
+        public void DrawEllipseFill(Layer layer, SKColor color, IEnumerable<Coordinates> outlineCoordinates)
         {
-            using var ctx = layer.LayerBitmap.GetBitmapContext();
+            //using var ctx = layer.LayerBitmap.GetBitmapContext();
 
             if (!outlineCoordinates.Any())
             {
@@ -176,9 +168,9 @@ namespace PixiEditor.Models.Tools.Tools
             }
         }
 
-        private List<Coordinates> DrawFallbackRectangle(Layer layer, Color color, double halfWidth, double halfHeight, double centerX, double centerY)
+        private List<Coordinates> DrawFallbackRectangle(Layer layer, SKColor color, double halfWidth, double halfHeight, double centerX, double centerY)
         {
-            using var ctx = layer.LayerBitmap.GetBitmapContext();
+            //using var ctx = layer.LayerBitmap.GetBitmapContext();
 
             List<Coordinates> coordinates = new List<Coordinates>();
 
@@ -207,7 +199,7 @@ namespace PixiEditor.Models.Tools.Tools
             return coordinates;
         }
 
-        private Coordinates[] DrawRegionPoints(Layer layer, Color color, double x, double xc, double y, double yc)
+        private Coordinates[] DrawRegionPoints(Layer layer, SKColor color, double x, double xc, double y, double yc)
         {
             Coordinates[] outputCoordinates = new Coordinates[4];
             outputCoordinates[0] = new Coordinates((int)Math.Floor(x), (int)Math.Floor(y));

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

@@ -24,7 +24,7 @@ namespace PixiEditor.Models.Tools.Tools
 

         public override string Tooltip => "Erasers color from pixel. (E)";
 
-        public override LayerChange[] Use(Layer layer, List<Coordinates> coordinates, SKColor color)
+        public override void Use(Layer layer, List<Coordinates> coordinates, SKColor color)
         {
             Erase(layer, coordinates, Toolbar.GetSetting<SizeSetting>("ToolSize").Value);
         }

+ 89 - 90
PixiEditor/Models/Tools/Tools/FloodFill.cs

@@ -1,18 +1,18 @@
-using PixiEditor.Models.Controllers;
+using PixiEditor.Models.Controllers;
 using PixiEditor.Models.DataHolders;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
-using SkiaSharp;
+using SkiaSharp;
 using System.Collections.Generic;
-using System.Diagnostics;
-
+using System.Diagnostics;
+
 namespace PixiEditor.Models.Tools.Tools
 {
     public class FloodFill : BitmapOperationTool
-    {
+    {
         private BitmapManager BitmapManager { get; }
-
-
+
+
         public FloodFill(BitmapManager bitmapManager)
         {
             ActionDisplay = "Press on an area to fill it.";
@@ -21,109 +21,108 @@ namespace PixiEditor.Models.Tools.Tools
 
         public override string Tooltip => "Fills area with color. (G)";
 
-        public override LayerChange[] Use(Layer layer, List<Coordinates> coordinates, SKColor color)
+        public override void Use(Layer layer, List<Coordinates> coordinates, SKColor color)
         {
             Stopwatch sw = new Stopwatch();
             sw.Start();
-            var res = Only(LinearFill(layer, coordinates[0], color), layer);
+            LinearFill(layer, coordinates[0], color);
             sw.Stop();
             Trace.WriteLine(sw.ElapsedMilliseconds);
-            return res;
         }
 
         public BitmapPixelChanges LinearFill(Layer layer, Coordinates startingCoords, SKColor newColor)
         {
             List<Coordinates> changedCoords = new List<Coordinates>();
             Queue<FloodFillRange> floodFillQueue = new Queue<FloodFillRange>();
-            SKColor colorToReplace = layer.GetPixelWithOffset(startingCoords.X, startingCoords.Y);
-            if ((colorToReplace.Alpha == 0 && newColor.Alpha == 0) ||
-                colorToReplace == newColor)
-                return BitmapPixelChanges.Empty;
-
+            SKColor colorToReplace = layer.GetPixelWithOffset(startingCoords.X, startingCoords.Y);
+            if ((colorToReplace.Alpha == 0 && newColor.Alpha == 0) ||
+                colorToReplace == newColor)
+                return BitmapPixelChanges.Empty;
+
             int width = BitmapManager.ActiveDocument.Width;
-            int height = BitmapManager.ActiveDocument.Height;
-            if (startingCoords.X < 0 || startingCoords.Y < 0 || startingCoords.X >= width || startingCoords.Y >= height)
-                return BitmapPixelChanges.Empty;
-            var visited = new bool[width * height];
-
-            PerformLinearFill(layer, changedCoords, floodFillQueue, startingCoords, width, colorToReplace, visited);
-            PerformFloodFIll(layer, changedCoords, floodFillQueue, colorToReplace, width, height, visited);
-
+            int height = BitmapManager.ActiveDocument.Height;
+            if (startingCoords.X < 0 || startingCoords.Y < 0 || startingCoords.X >= width || startingCoords.Y >= height)
+                return BitmapPixelChanges.Empty;
+            var visited = new bool[width * height];
+
+            PerformLinearFill(layer, changedCoords, floodFillQueue, startingCoords, width, colorToReplace, visited);
+            PerformFloodFIll(layer, changedCoords, floodFillQueue, colorToReplace, width, height, visited);
+
             return BitmapPixelChanges.FromSingleColoredArray(changedCoords, newColor);
         }
 
-        private void PerformLinearFill(
-            Layer layer,
-            List<Coordinates> changedCoords, Queue<FloodFillRange> floodFillQueue,
-        public override LayderChange[] Use(Layer layer, List<Coordinates> coordinates, SKColor color)
-        {
-            // Find the Left Edge of the Color Area
-            int fillXLeft = coords.X;
-            while (true)
-            {
-                // Fill with the color
-                changedCoords.Add(new Coordinates(fillXLeft, coords.Y));
-
-                // Indicate that this pixel has already been checked and filled
-                int pixelIndex = (coords.Y * width) + fillXLeft;
-                visited[pixelIndex] = true;
-
-                // Move one pixel to the left
-                fillXLeft--;
-                // Exit the loop if we're at edge of the bitmap or the color area
-                if (fillXLeft < 0 || visited[pixelIndex - 1] || layer.GetPixelWithOffset(fillXLeft, coords.Y) != colorToReplace)
-                    break;
-            }
-            int lastFilledPixelLeft = fillXLeft + 1;
-
-
-            // Find the Right Edge of the Color Area
-            int fillXRight = coords.X;
-            while (true)
-            {
-                changedCoords.Add(new Coordinates(fillXRight, coords.Y));
-
-                int pixelIndex = (coords.Y * width) + fillXRight;
-                visited[pixelIndex] = true;
-
-                fillXRight++;
-                if (fillXRight >= width || visited[pixelIndex + 1] || layer.GetPixelWithOffset(fillXRight, coords.Y) != colorToReplace)
-                    break;
+        private void PerformLinearFill(
+            Layer layer,
+            List<Coordinates> changedCoords, Queue<FloodFillRange> floodFillQueue,
+            Coordinates coords, int width, SKColor colorToReplace, bool[] visited)
+        {
+            // Find the Left Edge of the Color Area
+            int fillXLeft = coords.X;
+            while (true)
+            {
+                // Fill with the color
+                changedCoords.Add(new Coordinates(fillXLeft, coords.Y));
+
+                // Indicate that this pixel has already been checked and filled
+                int pixelIndex = (coords.Y * width) + fillXLeft;
+                visited[pixelIndex] = true;
+
+                // Move one pixel to the left
+                fillXLeft--;
+                // Exit the loop if we're at edge of the bitmap or the color area
+                if (fillXLeft < 0 || visited[pixelIndex - 1] || layer.GetPixelWithOffset(fillXLeft, coords.Y) != colorToReplace)
+                    break;
             }
-            int lastFilledPixelRight = fillXRight - 1;
+            int lastFilledPixelLeft = fillXLeft + 1;
 
 
-            FloodFillRange range = new FloodFillRange(lastFilledPixelLeft, lastFilledPixelRight, coords.Y);
-            floodFillQueue.Enqueue(range);
+            // Find the Right Edge of the Color Area
+            int fillXRight = coords.X;
+            while (true)
+            {
+                changedCoords.Add(new Coordinates(fillXRight, coords.Y));
+
+                int pixelIndex = (coords.Y * width) + fillXRight;
+                visited[pixelIndex] = true;
+
+                fillXRight++;
+                if (fillXRight >= width || visited[pixelIndex + 1] || layer.GetPixelWithOffset(fillXRight, coords.Y) != colorToReplace)
+                    break;
+            }
+            int lastFilledPixelRight = fillXRight - 1;
+
+
+            FloodFillRange range = new FloodFillRange(lastFilledPixelLeft, lastFilledPixelRight, coords.Y);
+            floodFillQueue.Enqueue(range);
         }
 
-        private void PerformFloodFIll(
-            Layer layer,
-            List<Coordinates> changedCords, Queue<FloodFillRange> floodFillQueue,
-            SKColor colorToReplace, int width, int height, bool[] pixelsVisited)
-        {
-            while (floodFillQueue.Count > 0)
-            {
-                FloodFillRange range = floodFillQueue.Dequeue();
-
-                //START THE LOOP UPWARDS AND DOWNWARDS
-                int upY = range.Y - 1; //so we can pass the y coord by ref
-                int downY = range.Y + 1;
-                int downPixelxIndex = (width * (range.Y + 1)) + range.StartX;
-                int upPixelIndex = (width * (range.Y - 1)) + range.StartX;
-                for (int i = range.StartX; i <= range.EndX; i++)
-                {
-                    //START LOOP UPWARDS
-                    //if we're not above the top of the bitmap and the pixel above this one is within the color tolerance
-                    if (range.Y > 0 && (!pixelsVisited[upPixelIndex]) && layer.GetPixelWithOffset(i, upY) == colorToReplace)
-                        PerformLinearFill(layer, changedCords, floodFillQueue, new Coordinates(i, upY), width, colorToReplace, pixelsVisited);
-                    //START LOOP DOWNWARDS
-                    if (range.Y < (height - 1) && (!pixelsVisited[downPixelxIndex]) && layer.GetPixel(i, downY) == colorToReplace)
-                        PerformLinearFill(layer, changedCords, floodFillQueue, new Coordinates(i, downY), width, colorToReplace, pixelsVisited);
-                    downPixelxIndex++;
-                    upPixelIndex++;
-                }
-            }
+        private void PerformFloodFIll(
+            Layer layer,
+            List<Coordinates> changedCords, Queue<FloodFillRange> floodFillQueue,
+            SKColor colorToReplace, int width, int height, bool[] pixelsVisited)
+        {
+            while (floodFillQueue.Count > 0)
+            {
+                FloodFillRange range = floodFillQueue.Dequeue();
+
+                //START THE LOOP UPWARDS AND DOWNWARDS
+                int upY = range.Y - 1; //so we can pass the y coord by ref
+                int downY = range.Y + 1;
+                int downPixelxIndex = (width * (range.Y + 1)) + range.StartX;
+                int upPixelIndex = (width * (range.Y - 1)) + range.StartX;
+                for (int i = range.StartX; i <= range.EndX; i++)
+                {
+                    //START LOOP UPWARDS
+                    //if we're not above the top of the bitmap and the pixel above this one is within the color tolerance
+                    if (range.Y > 0 && (!pixelsVisited[upPixelIndex]) && layer.GetPixelWithOffset(i, upY) == colorToReplace)
+                        PerformLinearFill(layer, changedCords, floodFillQueue, new Coordinates(i, upY), width, colorToReplace, pixelsVisited);
+                    //START LOOP DOWNWARDS
+                    if (range.Y < (height - 1) && (!pixelsVisited[downPixelxIndex]) && layer.GetPixel(i, downY) == colorToReplace)
+                        PerformLinearFill(layer, changedCords, floodFillQueue, new Coordinates(i, downY), width, colorToReplace, pixelsVisited);
+                    downPixelxIndex++;
+                    upPixelIndex++;
+                }
+            }
         }
     }
 }

+ 10 - 10
PixiEditor/Models/Tools/Tools/LineTool.cs

@@ -46,7 +46,7 @@ namespace PixiEditor.Models.Tools.Tools
             }
         }
 
-        public override LayerChange[] Use(Layer layer, List<Coordinates> coordinates, SKColor color)
+        public override void Use(Layer layer, List<Coordinates> coordinates, SKColor color)
         {
             layer.DynamicResize(coordinates.Max(x => x.X), coordinates.Max(x => x.Y), coordinates.Min(x => x.X), coordinates.Min(x => x.Y));
 
@@ -58,12 +58,12 @@ namespace PixiEditor.Models.Tools.Tools
                 CapType.Square);
         }
 
-        public List<Coordinates> CreateLine(Layer layer, Color color, Coordinates start, Coordinates end, int thickness)
+        public List<Coordinates> CreateLine(Layer layer, SKColor color, Coordinates start, Coordinates end, int thickness)
         {
             return CreateLineFastest(layer, color, start, end, thickness);
         }
 
-        private List<Coordinates> CreateLine(Layer layer, Color color, IEnumerable<Coordinates> coordinates, int thickness, CapType startCap, CapType endCap)
+        private List<Coordinates> CreateLine(Layer layer, SKColor color, IEnumerable<Coordinates> coordinates, int thickness, CapType startCap, CapType endCap)
         {
             Coordinates startingCoordinates = coordinates.Last();
             Coordinates latestCoordinates = coordinates.First();
@@ -71,7 +71,7 @@ namespace PixiEditor.Models.Tools.Tools
             return CreateLine(layer, color, startingCoordinates, latestCoordinates, thickness, startCap, endCap);
         }
 
-        private List<Coordinates> CreateLine(Layer layer, Color color, Coordinates start, Coordinates end, int thickness, CapType startCap, CapType endCap)
+        private List<Coordinates> CreateLine(Layer layer, SKColor color, Coordinates start, Coordinates end, int thickness, CapType startCap, CapType endCap)
         {
             if (thickness == 1)
             {
@@ -81,7 +81,7 @@ namespace PixiEditor.Models.Tools.Tools
             return GenerateLine(layer, color, start, end, thickness, startCap, endCap);
         }
 
-        private List<Coordinates> CreateLineFastest(Layer layer, Color color, Coordinates start, Coordinates end, int thickness)
+        private List<Coordinates> CreateLineFastest(Layer layer, SKColor color, Coordinates start, Coordinates end, int thickness)
         {
             var line = BresenhamLine(layer, color, start.X, start.Y, end.X, end.Y);
             if (thickness == 1)
@@ -93,7 +93,7 @@ namespace PixiEditor.Models.Tools.Tools
             return line;
         }
 
-        private List<Coordinates> GenerateLine(Layer layer, Color color, Coordinates start, Coordinates end, int thickness, CapType startCap, CapType endCap)
+        private List<Coordinates> GenerateLine(Layer layer, SKColor color, Coordinates start, Coordinates end, int thickness, CapType startCap, CapType endCap)
         {
             ApplyCap(layer, color, startCap, start, thickness);
             if (start == end)
@@ -112,7 +112,7 @@ namespace PixiEditor.Models.Tools.Tools
             return line;
         }
 
-        private void ApplyCap(Layer layer, Color color, CapType cap, Coordinates position, int thickness)
+        private void ApplyCap(Layer layer, SKColor color, CapType cap, Coordinates position, int thickness)
         {
             switch (cap)
             {
@@ -131,16 +131,16 @@ namespace PixiEditor.Models.Tools.Tools
         /// </summary>
         /// <param name="position">Starting position of cap.</param>
         /// <param name="thickness">Thickness of cap.</param>
-        private void ApplyRoundCap(Layer layer, Color color, Coordinates position, int thickness)
+        private void ApplyRoundCap(Layer layer, SKColor color, Coordinates position, int thickness)
         {
             IEnumerable<Coordinates> rectangleCords = CoordinatesCalculator.RectangleToCoordinates(
                 CoordinatesCalculator.CalculateThicknessCenter(position, thickness));
             circleTool.CreateEllipse(layer, color, rectangleCords.First(), rectangleCords.Last(), 1, true);
         }
 
-        private List<Coordinates> BresenhamLine(Layer layer, Color color, int x1, int y1, int x2, int y2)
+        private List<Coordinates> BresenhamLine(Layer layer, SKColor color, int x1, int y1, int x2, int y2)
         {
-            using BitmapContext context = layer.LayerBitmap.GetBitmapContext();
+            //using BitmapContext context = layer.LayerBitmap.GetBitmapContext();
             linePoints.Clear();
             Coordinates cords;
             if (x1 == x2 && y1 == y2)

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

@@ -128,7 +128,7 @@ namespace PixiEditor.Models.Tools.Tools
             }
         }
 
-        private BitmapPixelChanges ApplyPixelPerfectToPixels(Coordinates p1, Coordinates p2, Coordinates p3, SKColor color, int toolSize)
+        private BitmapPixelChanges ApplyPixelPerfectToPixels(Layer layer, Coordinates p1, Coordinates p2, Coordinates p3, SKColor color, int toolSize)
         {
             if (Math.Abs(p3.X - p1.X) == 1 && Math.Abs(p3.Y - p1.Y) == 1 && !confirmedPixels.Contains(p2))
             {

+ 5 - 5
PixiEditor/Models/Tools/Tools/RectangleTool.cs

@@ -55,11 +55,11 @@ namespace PixiEditor.Models.Tools.Tools
             }
         }
 
-        public void CreateRectangle(Layer layer, Color color, List<Coordinates> coordinates, int thickness)
+        public void CreateRectangle(Layer layer, SKColor color, List<Coordinates> coordinates, int thickness)
         {
             DoubleCords fixedCoordinates = CalculateCoordinatesForShapeRotation(coordinates[^1], coordinates[0]);
 
-            using var ctx = layer.LayerBitmap.GetBitmapContext();
+            //using var ctx = layer.LayerBitmap.GetBitmapContext();
 
             DrawRectangle(layer, color, fixedCoordinates);
 
@@ -78,12 +78,12 @@ namespace PixiEditor.Models.Tools.Tools
             }
         }
 
-        public void CreateRectangle(Layer layer, Color color, Coordinates start, Coordinates end, int thickness)
+        public void CreateRectangle(Layer layer, SKColor color, Coordinates start, Coordinates end, int thickness)
         {
             CreateRectangle(layer, color, new() { end, start }, thickness);
         }
 
-        public void DrawRectangleFill(Layer layer, Color color, Coordinates start, Coordinates end, int thickness)
+        public void DrawRectangleFill(Layer layer, SKColor color, Coordinates start, Coordinates end, int thickness)
         {
             int offset = (int)Math.Ceiling(thickness / 2f);
             DoubleCords fixedCords = CalculateCoordinatesForShapeRotation(start, end);
@@ -113,7 +113,7 @@ namespace PixiEditor.Models.Tools.Tools
             }
         }
 
-        private void DrawRectangle(Layer layer, Color color, DoubleCords coordinates)
+        private void DrawRectangle(Layer layer, SKColor color, DoubleCords coordinates)
         {
             for (int i = coordinates.Coords1.X; i < coordinates.Coords2.X + 1; i++)
             {