Dashboard/Dashboard.Drawing/Brush.cs

53 lines
1.5 KiB
C#
Raw Normal View History

2024-12-14 17:43:50 +01:00
using System;
using System.Drawing;
2024-12-13 19:57:07 +01:00
namespace Dashboard.Drawing
{
public class BrushExtension : DrawExtension
{
private BrushExtension() : base("DB_Brush") { }
public static readonly BrushExtension Instance = new BrushExtension();
}
public interface IBrush : IDrawResource
{
}
2025-01-15 18:42:09 +01:00
public readonly struct SolidBrush(Color color) : IBrush
2024-12-13 19:57:07 +01:00
{
public IDrawExtension Kind { get; } = SolidBrushExtension.Instance;
2025-01-15 18:42:09 +01:00
public Color Color { get; } = color;
2024-12-24 20:10:31 +01:00
public override int GetHashCode()
2024-12-13 19:57:07 +01:00
{
2024-12-24 20:10:31 +01:00
return HashCode.Combine(Kind, Color);
2024-12-13 19:57:07 +01:00
}
2024-12-24 20:10:31 +01:00
}
2025-01-15 18:42:09 +01:00
public readonly struct GradientBrush(Gradient gradient) : IBrush
2024-12-24 20:10:31 +01:00
{
public IDrawExtension Kind { get; } = GradientBrushExtension.Instance;
2025-01-15 18:42:09 +01:00
public Gradient Gradient { get; } = gradient;
2024-12-14 17:43:50 +01:00
public override int GetHashCode()
{
2024-12-24 20:10:31 +01:00
return HashCode.Combine(Kind, Gradient);
2024-12-14 17:43:50 +01:00
}
2024-12-13 19:57:07 +01:00
}
public class SolidBrushExtension : DrawExtension
{
private SolidBrushExtension() : base("DB_Brush_solid", new[] { BrushExtension.Instance }) { }
public static readonly SolidBrushExtension Instance = new SolidBrushExtension();
}
2024-12-24 20:10:31 +01:00
public class GradientBrushExtension : DrawExtension
{
private GradientBrushExtension() : base("DB_Brush_gradient", new[] { BrushExtension.Instance }) { }
public static readonly GradientBrushExtension Instance = new GradientBrushExtension();
}
2024-12-13 19:57:07 +01:00
}