diff --git a/ntfysh_client/NotificationDialog.cs b/ntfysh_client/NotificationDialog.cs index d456faa..c27f3db 100644 --- a/ntfysh_client/NotificationDialog.cs +++ b/ntfysh_client/NotificationDialog.cs @@ -20,8 +20,8 @@ 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 readonly BaseTheme _darkModeTheme = new DarkModeTheme(); + private readonly BaseTheme _defaultTheme = new DefaultTheme(); private BaseTheme? _theme = null; public NotificationDialog() @@ -41,14 +41,7 @@ namespace ntfysh_client HandleTimeout(null, null); } - if(showInDarkMode) - { - _theme = _darkModeTheme; - } - else - { - _theme = _defaultTheme; - } + _theme = showInDarkMode ? _darkModeTheme : _defaultTheme; ApplyTheme(); @@ -111,7 +104,7 @@ namespace ntfysh_client private void ApplyTheme() { - if (_theme is null) _theme = _defaultTheme; + _theme ??= _defaultTheme; // back colors BackColor = _theme.BackgroundColor; @@ -139,7 +132,7 @@ namespace ntfysh_client if (_shownStopwatch is null) return; ProgressBar1.Value = (_timeoutSeconds - _shownStopwatch.Elapsed.Seconds) * 100 / _timeoutSeconds; - LblTimeout.Text = $"{_timeoutSeconds - _shownStopwatch.Elapsed.Seconds}"; + LblTimeout.Text = $@"{_timeoutSeconds - _shownStopwatch.Elapsed.Seconds}"; } protected override void SetVisibleCore(bool value) @@ -153,7 +146,7 @@ namespace ntfysh_client AnimateWindow( Handle, time: 250, - flags: NFWinUserAnimateWindowConstnats.AW_SLIDE | NFWinUserAnimateWindowConstnats.AW_VER_NEGATIVE + flags: NFWinUserAnimateWindowConstants.AW_SLIDE | NFWinUserAnimateWindowConstants.AW_VER_NEGATIVE ); } @@ -162,11 +155,11 @@ namespace ntfysh_client private void SetWindowPosition() { - int workingtop = Screen.PrimaryScreen.WorkingArea.Height - Height; - Top = workingtop - NotificationDialog.ScreenMargin; + var workingTop = Screen.PrimaryScreen.WorkingArea.Height - Height; + Top = workingTop - NotificationDialog.ScreenMargin; - int workingleft = Screen.PrimaryScreen.WorkingArea.Width - Width; - Left = workingleft - NotificationDialog.ScreenMargin; + var workingLeft = Screen.PrimaryScreen.WorkingArea.Width - Width; + Left = workingLeft - NotificationDialog.ScreenMargin; } private void UIThreadAnimatedHideWindow(object? sender, EventArgs? e) @@ -175,7 +168,7 @@ namespace ntfysh_client AnimateWindow( Handle, time: 250, - flags: NFWinUserAnimateWindowConstnats.AW_SLIDE | NFWinUserAnimateWindowConstnats.AW_VER_POSITIVE | NFWinUserAnimateWindowConstnats.AW_HIDE + flags: NFWinUserAnimateWindowConstants.AW_SLIDE | NFWinUserAnimateWindowConstants.AW_VER_POSITIVE | NFWinUserAnimateWindowConstants.AW_HIDE ); Visible = false; @@ -219,7 +212,7 @@ namespace ntfysh_client Visible = false; } - private class NFWinUserAnimateWindowConstnats + private class NFWinUserAnimateWindowConstants { public const int AW_HOR_POSITIVE = 0x00000001; public const int AW_HOR_NEGATIVE = 0x00000002; diff --git a/ntfysh_client/SettingsDialog.cs b/ntfysh_client/SettingsDialog.cs index 754c551..20cbfa2 100644 --- a/ntfysh_client/SettingsDialog.cs +++ b/ntfysh_client/SettingsDialog.cs @@ -66,7 +66,7 @@ namespace ntfysh_client public SettingsDialog() { InitializeComponent(); - SetNotificationsUIElements(); + SetNotificationsUiElements(); } private void saveButton_Click(object sender, EventArgs e) @@ -79,7 +79,7 @@ namespace ntfysh_client DialogResult = DialogResult.Cancel; } - private void SetNotificationsUIElements() + private void SetNotificationsUiElements() { groupCustomNotificationSettings.Enabled = useCustomTrayNotifications.Checked; timeoutLabel.Text = useCustomTrayNotifications.Checked ? _customNotificationsTimeout : _windowsNotificationsTimeout; @@ -87,7 +87,7 @@ namespace ntfysh_client private void UseCustomTrayNotifications_CheckedChanged(object sender, EventArgs e) { - SetNotificationsUIElements(); + SetNotificationsUiElements(); } private const string _windowsNotificationsTimeout = "Notification Toast Timeout (seconds, may be ignored by OS based on accessibility settings):";