|
@@ -1,9 +1,12 @@
|
|
|
-using System.Collections.Generic;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Windows.Controls;
|
|
|
using System.Windows.Input;
|
|
|
using System.Windows.Media;
|
|
|
using System.Windows.Media.Imaging;
|
|
|
using PixiEditor.Models.Colors;
|
|
|
using PixiEditor.Models.DataHolders;
|
|
|
+using PixiEditor.Models.Enums;
|
|
|
using PixiEditor.Models.Layers;
|
|
|
using PixiEditor.Models.Position;
|
|
|
using PixiEditor.Models.Tools.ToolSettings.Toolbars;
|
|
@@ -15,6 +18,9 @@ namespace PixiEditor.Models.Tools.Tools
|
|
|
private const float CorrectionFactor = 5f; //Initial correction factor
|
|
|
|
|
|
public override ToolType ToolType => ToolType.Brightness;
|
|
|
+ public BrightnessMode Mode { get; set; } = BrightnessMode.Default;
|
|
|
+
|
|
|
+ private List<Coordinates> _pixelsVisited = new List<Coordinates>();
|
|
|
|
|
|
public BrightnessTool()
|
|
|
{
|
|
@@ -22,10 +28,19 @@ namespace PixiEditor.Models.Tools.Tools
|
|
|
Toolbar = new BrightnessToolToolbar(CorrectionFactor);
|
|
|
}
|
|
|
|
|
|
+ public override void OnMouseDown()
|
|
|
+ {
|
|
|
+ base.OnMouseDown();
|
|
|
+ _pixelsVisited.Clear();
|
|
|
+ }
|
|
|
+
|
|
|
public override LayerChange[] Use(Layer layer, Coordinates[] coordinates, Color color)
|
|
|
{
|
|
|
int toolSize = (int) Toolbar.GetSetting("ToolSize").Value;
|
|
|
float correctionFactor = (float) Toolbar.GetSetting("CorrectionFactor").Value;
|
|
|
+ Enum.TryParse<BrightnessMode>((Toolbar.GetSetting("Mode").Value as ComboBoxItem)?.Content as string, out var mode);
|
|
|
+ Mode = mode;
|
|
|
+
|
|
|
LayerChange[] layersChanges = new LayerChange[1];
|
|
|
if (Keyboard.IsKeyDown(Key.LeftCtrl))
|
|
|
layersChanges[0] = new LayerChange(ChangeBrightness(layer, coordinates[0], toolSize, -correctionFactor),
|
|
@@ -47,6 +62,13 @@ namespace PixiEditor.Models.Tools.Tools
|
|
|
|
|
|
for (int i = 0; i < rectangleCoordinates.Length; i++)
|
|
|
{
|
|
|
+ if (Mode == BrightnessMode.Default)
|
|
|
+ {
|
|
|
+ if(_pixelsVisited.Contains(rectangleCoordinates[i]))
|
|
|
+ continue;
|
|
|
+ _pixelsVisited.Add(rectangleCoordinates[i]);
|
|
|
+ }
|
|
|
+
|
|
|
Color pixel = layer.LayerBitmap.GetPixel(rectangleCoordinates[i].X, rectangleCoordinates[i].Y);
|
|
|
Color newColor = ExColor.ChangeColorBrightness(Color.FromArgb(pixel.A, pixel.R, pixel.G, pixel.B),
|
|
|
correctionFactor);
|