From 807b3ebb7f88729a8af02bfeaa4e096480259e06 Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 7 Apr 2026 11:42:49 +0100 Subject: [PATCH] feat: add programmatic tray icon generation (green/yellow/red) --- src/SpamGuard/Tray/IconGenerator.cs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/SpamGuard/Tray/IconGenerator.cs diff --git a/src/SpamGuard/Tray/IconGenerator.cs b/src/SpamGuard/Tray/IconGenerator.cs new file mode 100644 index 0000000..08a9423 --- /dev/null +++ b/src/SpamGuard/Tray/IconGenerator.cs @@ -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)); +}