diff --git a/ntfysh_client/NotificationDialog.cs b/ntfysh_client/NotificationDialog.cs index ee225de..a824801 100644 --- a/ntfysh_client/NotificationDialog.cs +++ b/ntfysh_client/NotificationDialog.cs @@ -5,6 +5,7 @@ using System.Windows.Forms; using System.ComponentModel; using Microsoft.Win32; using System.Diagnostics; +using ntfysh_client.Themes; namespace ntfysh_client @@ -21,6 +22,10 @@ namespace ntfysh_client private System.Windows.Forms.Timer? _updateTimer = null; private Stopwatch? _shownStopwatch = null; + private BaseTheme _darkModeTheme = new DarkModeTheme(); + private BaseTheme _defaultTheme = new DefaultTheme(); + private BaseTheme? _theme = null; + public NotificationDialog() { ShowInTaskbar = false; @@ -38,6 +43,17 @@ namespace ntfysh_client HandleTimeout(null, null); } + if(showInDarkMode) + { + _theme = _darkModeTheme; + } + else + { + _theme = _defaultTheme; + } + + ApplyTheme(); + // setup data IconBox.Image = (icon is null) ? null : ConvertToolTipIconToImage(icon.Value); @@ -95,6 +111,31 @@ namespace ntfysh_client SetWindowPosition(); } + private void ApplyTheme() + { + if (_theme is null) _theme = _defaultTheme; + + // back colors + BackColor = _theme.BackgroundColor; + TxBTitle.BackColor = _theme.BackgroundColor; + TxBMessage.BackColor = _theme.BackgroundColor; + LblTimeout.BackColor = _theme.BackgroundColor; + ProgressBar1.BackColor = _theme.BackgroundColor; + + // this one is not "hiding" + ButtonClose.BackColor = _theme.ControlBackGroundColor; + // handle mouse over + ButtonClose.FlatAppearance.MouseOverBackColor = _theme.ControlMouseOverBackgroundColor; + + // fore colors + ForeColor = _theme.ForegroundColor; + TxBTitle.ForeColor = _theme.ForegroundColor; + TxBMessage.ForeColor = _theme.ForegroundColor; + LblTimeout.ForeColor = _theme.ForegroundColor; + ProgressBar1.ForeColor = _theme.ForegroundColor; + ButtonClose.ForeColor = _theme.ForegroundColor; + } + private void UpdateProgress(object? sender, EventArgs e) { if (_shownStopwatch is null) return; diff --git a/ntfysh_client/Themes/BaseTheme.cs b/ntfysh_client/Themes/BaseTheme.cs new file mode 100644 index 0000000..b139ab9 --- /dev/null +++ b/ntfysh_client/Themes/BaseTheme.cs @@ -0,0 +1,12 @@ +using System.Drawing; + +namespace ntfysh_client.Themes +{ + internal abstract class BaseTheme + { + public abstract Color BackgroundColor {get; } + public abstract Color ControlBackGroundColor {get; } + public abstract Color ControlMouseOverBackgroundColor { get; } + public abstract Color ForegroundColor { get; } + } +} diff --git a/ntfysh_client/Themes/DarkModeTheme.cs b/ntfysh_client/Themes/DarkModeTheme.cs new file mode 100644 index 0000000..51adc3c --- /dev/null +++ b/ntfysh_client/Themes/DarkModeTheme.cs @@ -0,0 +1,12 @@ +using System.Drawing; + +namespace ntfysh_client.Themes +{ + internal class DarkModeTheme: BaseTheme + { + public override Color BackgroundColor { get => SystemColors.ControlDark; } + public override Color ControlBackGroundColor { get => Color.Black; } + public override Color ControlMouseOverBackgroundColor { get => Color.Silver; } + public override Color ForegroundColor { get => SystemColors.ControlLight; } + } +} diff --git a/ntfysh_client/Themes/DefaultTheme.cs b/ntfysh_client/Themes/DefaultTheme.cs new file mode 100644 index 0000000..b435a16 --- /dev/null +++ b/ntfysh_client/Themes/DefaultTheme.cs @@ -0,0 +1,12 @@ +using System.Drawing; + +namespace ntfysh_client.Themes +{ + internal class DefaultTheme: BaseTheme + { + public override Color BackgroundColor { get => Color.White; } + public override Color ControlBackGroundColor { get => SystemColors.ControlDark; } + public override Color ControlMouseOverBackgroundColor { get => Color.LightSkyBlue; } + public override Color ForegroundColor { get => SystemColors.WindowText; } + } +}