Skip to content

Commit

Permalink
update: support theme adjustable
Browse files Browse the repository at this point in the history
  • Loading branch information
emako committed Jul 24, 2024
1 parent f615112 commit c055f4e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NotifyIcon/NotifyIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace NotifyIconEx;

public class NotifyIcon
{
public static NotifyIconTheme Theme { get; set; } = NotifyIconTheme.System;

private readonly System.Windows.Forms.NotifyIcon notifyIcon = null!;
private readonly ToolStripRenderer toolStripRenderer = null!;
protected EventHandlerList Events = new();
Expand Down
13 changes: 9 additions & 4 deletions NotifyIcon/NotifyIconColors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ namespace NotifyIconEx;

internal static class NotifyIconColors
{
public static Color ForeColor => ThemeListener.IsDarkMode ? ForeColorDark : ForeColorLight;
public static Color BackColor => ThemeListener.IsDarkMode ? BackColorDark : BackColorLight;
public static Color HoverBackColor => ThemeListener.IsDarkMode ? HoverBackColorDark : HoverBackColorLight;
public static Color SeparatorColor => ThemeListener.IsDarkMode ? SeparatorColorDark : SeparatorColorLight;
private static bool IsDarkMode =>
NotifyIcon.Theme == NotifyIconTheme.System
? ThemeListener.IsDarkMode
: NotifyIcon.Theme == NotifyIconTheme.Dark;

public static Color ForeColor => IsDarkMode ? ForeColorDark : ForeColorLight;
public static Color BackColor => IsDarkMode ? BackColorDark : BackColorLight;
public static Color HoverBackColor => IsDarkMode ? HoverBackColorDark : HoverBackColorLight;
public static Color SeparatorColor => IsDarkMode ? SeparatorColorDark : SeparatorColorLight;

private static Color ForeColorLight => Color.FromArgb(0x99, 0x00, 0x00, 0x00);
private static Color ForeColorDark => Color.FromArgb(0x99, 0xFF, 0xFF, 0xFF);
Expand Down
8 changes: 8 additions & 0 deletions NotifyIcon/NotifyIconTheme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace NotifyIconEx;

public enum NotifyIconTheme
{
System,
Light,
Dark,
}

0 comments on commit c055f4e

Please sign in to comment.