Skip to content

Commit

Permalink
fix sequence of SolidFillLayerHandler.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aytackydln committed Jun 13, 2024
1 parent 61cb7f7 commit 410359b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 38 deletions.
30 changes: 20 additions & 10 deletions Project-Aurora/Project-Aurora/EffectsEngine/EffectCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,35 @@ public sealed class CanvasGridProperties(
public float GridHeight { get; } = gridHeight;
}

public sealed class EffectCanvas(
int width,
int height,
Dictionary<DeviceKeys, BitmapRectangle> bitmapMap)
: IEqualityComparer<EffectCanvas>, IEquatable<EffectCanvas>
public sealed class EffectCanvas : IEqualityComparer<EffectCanvas>, IEquatable<EffectCanvas>
{
public int Width { get; } = width;
public int Height { get; } = height;
public int BiggestSize { get; } = Math.Max(width, height);
public EffectCanvas(int width,
int height,
Dictionary<DeviceKeys, BitmapRectangle> bitmapMap)
{
Width = width;
Height = height;
BiggestSize = Math.Max(width, height);
BitmapMap = bitmapMap;
CanvasGridProperties = new(0, 0, width, height);

EntireSequence = new(WholeFreeForm);
}

public int Width { get; }
public int Height { get; }
public int BiggestSize { get; }

//TODO those 4 vars are about Control. Remove htem from here
public float GridBaselineX => CanvasGridProperties.GridBaselineX;
public float GridBaselineY => CanvasGridProperties.GridBaselineY;

public Dictionary<DeviceKeys, BitmapRectangle> BitmapMap { get; } = bitmapMap;
public Dictionary<DeviceKeys, BitmapRectangle> BitmapMap { get; }

public float WidthCenter { get; init; }
public float HeightCenter { get; init; }

public CanvasGridProperties CanvasGridProperties { get; set; } = new(0, 0, width, height);
public CanvasGridProperties CanvasGridProperties { get; set; }

public float EditorToCanvasWidth => Width / CanvasGridProperties.GridWidth;
public float EditorToCanvasHeight => Height / CanvasGridProperties.GridHeight;
Expand All @@ -46,6 +55,7 @@ public sealed class EffectCanvas(
/// Creates a new FreeFormObject that perfectly occupies the entire canvas.
/// </summary>
public FreeFormObject WholeFreeForm => new(-CanvasGridProperties.GridBaselineX, -CanvasGridProperties.GridBaselineY, CanvasGridProperties.GridWidth, CanvasGridProperties.GridHeight);
public KeySequence EntireSequence { get; }

public BitmapRectangle GetRectangle(DeviceKeys key)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing;
using System.Windows.Controls;
using AuroraRgb.EffectsEngine;
using AuroraRgb.Profiles;
Expand Down Expand Up @@ -30,12 +28,6 @@ public override void Default()
public sealed class SolidFillLayerHandler : LayerHandler<SolidFillLayerHandlerProperties>
{
private readonly SolidBrush _solidBrush = new(Color.Transparent);
private KeySequence _entireSequence = new(Effects.Canvas.WholeFreeForm);

public SolidFillLayerHandler() : base("Solid Fill Layer")
{
Effects.CanvasChanged += EffectsOnCanvasChanged;
}

protected override UserControl CreateControl()
{
Expand All @@ -44,25 +36,8 @@ protected override UserControl CreateControl()

public override EffectLayer Render(IGameState gameState)
{
EffectLayer.Set(_entireSequence, _solidBrush);
return EffectLayer;
}

private void EffectsOnCanvasChanged(object? sender, EventArgs e)
{
_entireSequence = new KeySequence(Effects.Canvas.WholeFreeForm);
}

protected override void PropertiesChanged(object? sender, PropertyChangedEventArgs args)
{
base.PropertiesChanged(sender, args);
_solidBrush.Color = Properties.PrimaryColor;
}

public override void Dispose()
{
base.Dispose();

Effects.CanvasChanged -= EffectsOnCanvasChanged;
EffectLayer.Set(Effects.Canvas.EntireSequence, _solidBrush);
return EffectLayer;
}
}

0 comments on commit 410359b

Please sign in to comment.