feat: add programmatic tray icon generation (green/yellow/red)

This commit is contained in:
2026-04-07 11:42:49 +01:00
parent 7568d3d288
commit 807b3ebb7f

View File

@@ -0,0 +1,28 @@
namespace SpamGuard.Tray;
using System.Drawing;
using System.Drawing.Drawing2D;
public static class IconGenerator
{
public static Icon CreateCircleIcon(Color color, int size = 16)
{
using var bitmap = new Bitmap(size, size);
using var graphics = Graphics.FromImage(bitmap);
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.Clear(Color.Transparent);
using var brush = new SolidBrush(color);
graphics.FillEllipse(brush, 1, 1, size - 2, size - 2);
// Add a subtle border
using var pen = new Pen(Color.FromArgb(100, 0, 0, 0), 1);
graphics.DrawEllipse(pen, 1, 1, size - 3, size - 3);
return Icon.FromHandle(bitmap.GetHicon());
}
public static Icon Green => CreateCircleIcon(Color.FromArgb(76, 175, 80));
public static Icon Yellow => CreateCircleIcon(Color.FromArgb(255, 193, 7));
public static Icon Red => CreateCircleIcon(Color.FromArgb(244, 67, 54));
}