toast notifications(+) #17

Merged
mshafer1 merged 41 commits from dev/toast_notifications_plus into master 2025-02-11 04:53:56 -05:00
10 changed files with 787 additions and 14 deletions
Showing only changes of commit 52f315e4e3 - Show all commits

View File

@@ -73,7 +73,7 @@ namespace ntfysh_client
string finalTitle = string.IsNullOrWhiteSpace(e.Title) ? $"{e.Sender.TopicId}@{e.Sender.ServerUrl}" : e.Title;
if (Program.Settings.UseNativeWindowsNotifications)
if (Program.Settings.NotificationsMethod == SettingsModel.NotificationsType.NativeWindows)
{
notifyIcon.ShowBalloonTip((int)TimeSpan.FromSeconds((double)Program.Settings.Timeout).TotalMilliseconds, finalTitle, e.Message, priorityIcon);
}
@@ -152,8 +152,8 @@ namespace ntfysh_client
//Load current settings into dialog
dialog.ReconnectAttempts = Program.Settings.ReconnectAttempts;
dialog.ReconnectAttemptDelay = Program.Settings.ReconnectAttemptDelay;
dialog.UseNativeWindowsNotifications = Program.Settings.UseNativeWindowsNotifications;
dialog.UseCustomTrayNotifications = Program.Settings.UseCustomTrayNotifications;
dialog.UseNativeWindowsNotifications = Program.Settings.NotificationsMethod == SettingsModel.NotificationsType.NativeWindows;
dialog.UseCustomTrayNotifications = Program.Settings.NotificationsMethod == SettingsModel.NotificationsType.CustomTray;
dialog.CustomTrayNotificationsShowTimeoutBar = Program.Settings.CustomTrayNotificationsShowTimeoutBar;
dialog.CustomTrayNotificationsShowInDarkMode = Program.Settings.CustomTrayNotificationsShowInDarkMode;
dialog.Timeout = Program.Settings.Timeout; // set timeout last so bounds are setup before setting value
@@ -168,8 +168,7 @@ namespace ntfysh_client
Program.Settings.Timeout = dialog.Timeout;
Program.Settings.ReconnectAttempts = dialog.ReconnectAttempts;
Program.Settings.ReconnectAttemptDelay = dialog.ReconnectAttemptDelay;
Program.Settings.UseNativeWindowsNotifications = dialog.UseNativeWindowsNotifications;
Program.Settings.UseCustomTrayNotifications = dialog.UseCustomTrayNotifications;
Program.Settings.NotificationsMethod = (dialog.UseNativeWindowsNotifications)? SettingsModel.NotificationsType.NativeWindows : SettingsModel.NotificationsType.CustomTray;
Program.Settings.CustomTrayNotificationsShowTimeoutBar = dialog.CustomTrayNotificationsShowTimeoutBar;
Program.Settings.CustomTrayNotificationsShowInDarkMode = dialog.CustomTrayNotificationsShowInDarkMode;
@@ -328,8 +327,7 @@ namespace ntfysh_client
Timeout = 5,
ReconnectAttempts = 10,
ReconnectAttemptDelay = 3,
UseNativeWindowsNotifications = true,
UseCustomTrayNotifications = false,
NotificationsMethod = SettingsModel.NotificationsType.NativeWindows,
CustomTrayNotificationsShowTimeoutBar = true,
CustomTrayNotificationsShowInDarkMode = false,
};
@@ -346,8 +344,7 @@ namespace ntfysh_client
//Apply settings introduced in Revision 2 (Native vs custom notifications)
if (older.Revision < 2)
{
older.UseNativeWindowsNotifications = newer.UseNativeWindowsNotifications;
older.UseCustomTrayNotifications = newer.UseCustomTrayNotifications;
older.NotificationsMethod = newer.NotificationsMethod;
older.CustomTrayNotificationsShowTimeoutBar = newer.CustomTrayNotificationsShowTimeoutBar;
older.CustomTrayNotificationsShowInDarkMode = newer.CustomTrayNotificationsShowInDarkMode;
}

View File

@@ -1,10 +1,13 @@
using System;
using System.Windows.Forms;
using static ntfysh_client.SettingsModel;
namespace ntfysh_client
{
public partial class SettingsDialog : Form
{
public NotificationsType NotificationsMethod { get; set; }
public decimal Timeout
{
get => timeout.Value;
@@ -31,6 +34,7 @@ namespace ntfysh_client
{
useNativeWindowsNotifications.Checked = value;
groupCustomNotificationSettings.Enabled = !value;
NotificationsMethod = (value) ? NotificationsType.NativeWindows : NotificationsType.CustomTray;
}
}
@@ -40,6 +44,7 @@ namespace ntfysh_client
set {
useCustomTrayNotifications.Checked = value;
groupCustomNotificationSettings.Enabled = value;
NotificationsMethod = (value) ? NotificationsType.NativeWindows : NotificationsType.CustomTray;
}
}
#endregion

View File

@@ -2,12 +2,17 @@
{
public class SettingsModel
{
public enum NotificationsType
{
NativeWindows,
CustomTray
}
public uint Revision { get; set; }
public decimal Timeout { get; set; }
public decimal ReconnectAttempts { get; set; }
public decimal ReconnectAttemptDelay { get; set; }
public bool UseNativeWindowsNotifications { get; set; }
public bool UseCustomTrayNotifications { get; set; }
public NotificationsType NotificationsMethod { get; set; }
public bool CustomTrayNotificationsShowTimeoutBar { get; set; }
public bool CustomTrayNotificationsShowInDarkMode { get; set; }
}