add support for still playing the Windows alert sound
This commit is contained in:
@@ -86,7 +86,8 @@ namespace ntfysh_client
|
|||||||
timeoutSeconds: (int)Program.Settings.Timeout,
|
timeoutSeconds: (int)Program.Settings.Timeout,
|
||||||
icon: priorityIcon,
|
icon: priorityIcon,
|
||||||
showTimeOutBar: Program.Settings.CustomTrayNotificationsShowTimeoutBar,
|
showTimeOutBar: Program.Settings.CustomTrayNotificationsShowTimeoutBar,
|
||||||
showInDarkMode: Program.Settings.CustomTrayNotificationsShowInDarkMode
|
showInDarkMode: Program.Settings.CustomTrayNotificationsShowInDarkMode,
|
||||||
|
playNotificationSound: Program.Settings.CustomTrayNotificationsPlayDefaultWindowsSound
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,6 +157,7 @@ namespace ntfysh_client
|
|||||||
dialog.UseCustomTrayNotifications = Program.Settings.NotificationsMethod == SettingsModel.NotificationsType.CustomTray;
|
dialog.UseCustomTrayNotifications = Program.Settings.NotificationsMethod == SettingsModel.NotificationsType.CustomTray;
|
||||||
dialog.CustomTrayNotificationsShowTimeoutBar = Program.Settings.CustomTrayNotificationsShowTimeoutBar;
|
dialog.CustomTrayNotificationsShowTimeoutBar = Program.Settings.CustomTrayNotificationsShowTimeoutBar;
|
||||||
dialog.CustomTrayNotificationsShowInDarkMode = Program.Settings.CustomTrayNotificationsShowInDarkMode;
|
dialog.CustomTrayNotificationsShowInDarkMode = Program.Settings.CustomTrayNotificationsShowInDarkMode;
|
||||||
|
dialog.CustomTrayNotificationsPlayDefaultWindowsSound = Program.Settings.CustomTrayNotificationsPlayDefaultWindowsSound;
|
||||||
dialog.Timeout = Program.Settings.Timeout; // set timeout last so bounds are setup before setting value
|
dialog.Timeout = Program.Settings.Timeout; // set timeout last so bounds are setup before setting value
|
||||||
|
|
||||||
//Show dialog
|
//Show dialog
|
||||||
@@ -171,6 +173,7 @@ namespace ntfysh_client
|
|||||||
Program.Settings.NotificationsMethod = (dialog.UseNativeWindowsNotifications)? SettingsModel.NotificationsType.NativeWindows : SettingsModel.NotificationsType.CustomTray;
|
Program.Settings.NotificationsMethod = (dialog.UseNativeWindowsNotifications)? SettingsModel.NotificationsType.NativeWindows : SettingsModel.NotificationsType.CustomTray;
|
||||||
Program.Settings.CustomTrayNotificationsShowTimeoutBar = dialog.CustomTrayNotificationsShowTimeoutBar;
|
Program.Settings.CustomTrayNotificationsShowTimeoutBar = dialog.CustomTrayNotificationsShowTimeoutBar;
|
||||||
Program.Settings.CustomTrayNotificationsShowInDarkMode = dialog.CustomTrayNotificationsShowInDarkMode;
|
Program.Settings.CustomTrayNotificationsShowInDarkMode = dialog.CustomTrayNotificationsShowInDarkMode;
|
||||||
|
Program.Settings.CustomTrayNotificationsPlayDefaultWindowsSound = dialog.CustomTrayNotificationsPlayDefaultWindowsSound;
|
||||||
|
|
||||||
//Save new settings persistently
|
//Save new settings persistently
|
||||||
SaveSettingsToFile();
|
SaveSettingsToFile();
|
||||||
@@ -330,6 +333,7 @@ namespace ntfysh_client
|
|||||||
NotificationsMethod = SettingsModel.NotificationsType.NativeWindows,
|
NotificationsMethod = SettingsModel.NotificationsType.NativeWindows,
|
||||||
CustomTrayNotificationsShowTimeoutBar = true,
|
CustomTrayNotificationsShowTimeoutBar = true,
|
||||||
CustomTrayNotificationsShowInDarkMode = false,
|
CustomTrayNotificationsShowInDarkMode = false,
|
||||||
|
CustomTrayNotificationsPlayDefaultWindowsSound = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
private void MergeSettingsRevisions(SettingsModel older, SettingsModel newer)
|
private void MergeSettingsRevisions(SettingsModel older, SettingsModel newer)
|
||||||
@@ -347,6 +351,7 @@ namespace ntfysh_client
|
|||||||
older.NotificationsMethod = newer.NotificationsMethod;
|
older.NotificationsMethod = newer.NotificationsMethod;
|
||||||
older.CustomTrayNotificationsShowTimeoutBar = newer.CustomTrayNotificationsShowTimeoutBar;
|
older.CustomTrayNotificationsShowTimeoutBar = newer.CustomTrayNotificationsShowTimeoutBar;
|
||||||
older.CustomTrayNotificationsShowInDarkMode = newer.CustomTrayNotificationsShowInDarkMode;
|
older.CustomTrayNotificationsShowInDarkMode = newer.CustomTrayNotificationsShowInDarkMode;
|
||||||
|
older.CustomTrayNotificationsPlayDefaultWindowsSound = newer.CustomTrayNotificationsPlayDefaultWindowsSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Update the revision
|
//Update the revision
|
||||||
|
@@ -4,6 +4,8 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using ntfysh_client.Themes;
|
using ntfysh_client.Themes;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using System.Media;
|
||||||
|
|
||||||
|
|
||||||
namespace ntfysh_client
|
namespace ntfysh_client
|
||||||
@@ -33,7 +35,7 @@ namespace ntfysh_client
|
|||||||
InitializeWindowHidden();
|
InitializeWindowHidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowNotification(string title, string message, int timeoutSeconds = 0, ToolTipIcon? icon = null, bool showTimeOutBar = true, bool showInDarkMode = true)
|
public void ShowNotification(string title, string message, int timeoutSeconds = 0, ToolTipIcon? icon = null, bool showTimeOutBar = true, bool showInDarkMode = true, bool playNotificationSound = false)
|
||||||
{
|
{
|
||||||
if (Visible)
|
if (Visible)
|
||||||
{
|
{
|
||||||
@@ -100,6 +102,10 @@ namespace ntfysh_client
|
|||||||
// ok, show the window
|
// ok, show the window
|
||||||
Show();
|
Show();
|
||||||
SetWindowPosition();
|
SetWindowPosition();
|
||||||
|
if(playNotificationSound)
|
||||||
|
{
|
||||||
|
PlayNotificationSound();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyTheme()
|
private void ApplyTheme()
|
||||||
@@ -265,5 +271,28 @@ namespace ntfysh_client
|
|||||||
_shownStopwatch = null;
|
_shownStopwatch = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PlayNotificationSound()
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using RegistryKey? key = Registry.CurrentUser.OpenSubKey(@"AppEvents\Schemes\Apps\.Default\Notification.Default\.Current");
|
||||||
|
if (key != null)
|
||||||
|
{
|
||||||
|
Object? o = key.GetValue(null); // pass null to get (Default)
|
||||||
|
if (o != null)
|
||||||
|
{
|
||||||
|
SoundPlayer theSound = new SoundPlayer((String)o);
|
||||||
|
theSound.Play();
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{ }
|
||||||
|
if (!found)
|
||||||
|
SystemSounds.Beep.Play(); // consolation prize
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
ntfysh_client/SettingsDialog.Designer.cs
generated
19
ntfysh_client/SettingsDialog.Designer.cs
generated
@@ -42,6 +42,7 @@ namespace ntfysh_client
|
|||||||
useCustomTrayNotifications = new System.Windows.Forms.RadioButton();
|
useCustomTrayNotifications = new System.Windows.Forms.RadioButton();
|
||||||
useNativeWindowsNotifications = new System.Windows.Forms.RadioButton();
|
useNativeWindowsNotifications = new System.Windows.Forms.RadioButton();
|
||||||
groupCustomNotificationSettings = new System.Windows.Forms.GroupBox();
|
groupCustomNotificationSettings = new System.Windows.Forms.GroupBox();
|
||||||
|
customNotificationsPlayWindowsNotificationAudio = new System.Windows.Forms.CheckBox();
|
||||||
customNotificationsShowInDarkMode = new System.Windows.Forms.CheckBox();
|
customNotificationsShowInDarkMode = new System.Windows.Forms.CheckBox();
|
||||||
customNotificationsShowTimeoutBar = new System.Windows.Forms.CheckBox();
|
customNotificationsShowTimeoutBar = new System.Windows.Forms.CheckBox();
|
||||||
label1 = new System.Windows.Forms.Label();
|
label1 = new System.Windows.Forms.Label();
|
||||||
@@ -59,7 +60,7 @@ namespace ntfysh_client
|
|||||||
buttonPanel.Controls.Add(cancelButton);
|
buttonPanel.Controls.Add(cancelButton);
|
||||||
buttonPanel.Controls.Add(saveButton);
|
buttonPanel.Controls.Add(saveButton);
|
||||||
buttonPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
|
buttonPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
buttonPanel.Location = new System.Drawing.Point(0, 316);
|
buttonPanel.Location = new System.Drawing.Point(0, 336);
|
||||||
buttonPanel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
buttonPanel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||||
buttonPanel.Name = "buttonPanel";
|
buttonPanel.Name = "buttonPanel";
|
||||||
buttonPanel.Size = new System.Drawing.Size(531, 51);
|
buttonPanel.Size = new System.Drawing.Size(531, 51);
|
||||||
@@ -174,14 +175,25 @@ namespace ntfysh_client
|
|||||||
//
|
//
|
||||||
// groupCustomNotificationSettings
|
// groupCustomNotificationSettings
|
||||||
//
|
//
|
||||||
|
groupCustomNotificationSettings.Controls.Add(customNotificationsPlayWindowsNotificationAudio);
|
||||||
groupCustomNotificationSettings.Controls.Add(customNotificationsShowInDarkMode);
|
groupCustomNotificationSettings.Controls.Add(customNotificationsShowInDarkMode);
|
||||||
groupCustomNotificationSettings.Controls.Add(customNotificationsShowTimeoutBar);
|
groupCustomNotificationSettings.Controls.Add(customNotificationsShowTimeoutBar);
|
||||||
groupCustomNotificationSettings.Location = new System.Drawing.Point(12, 243);
|
groupCustomNotificationSettings.Location = new System.Drawing.Point(12, 243);
|
||||||
groupCustomNotificationSettings.Name = "groupCustomNotificationSettings";
|
groupCustomNotificationSettings.Name = "groupCustomNotificationSettings";
|
||||||
groupCustomNotificationSettings.Size = new System.Drawing.Size(504, 67);
|
groupCustomNotificationSettings.Size = new System.Drawing.Size(504, 87);
|
||||||
groupCustomNotificationSettings.TabIndex = 10;
|
groupCustomNotificationSettings.TabIndex = 10;
|
||||||
groupCustomNotificationSettings.TabStop = false;
|
groupCustomNotificationSettings.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// customNotificationsPlayWindowsNotificationAudio
|
||||||
|
//
|
||||||
|
customNotificationsPlayWindowsNotificationAudio.AutoSize = true;
|
||||||
|
customNotificationsPlayWindowsNotificationAudio.Location = new System.Drawing.Point(4, 59);
|
||||||
|
customNotificationsPlayWindowsNotificationAudio.Name = "customNotificationsPlayWindowsNotificationAudio";
|
||||||
|
customNotificationsPlayWindowsNotificationAudio.Size = new System.Drawing.Size(200, 19);
|
||||||
|
customNotificationsPlayWindowsNotificationAudio.TabIndex = 2;
|
||||||
|
customNotificationsPlayWindowsNotificationAudio.Text = "Play Windows notification sound";
|
||||||
|
customNotificationsPlayWindowsNotificationAudio.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
// customNotificationsShowInDarkMode
|
// customNotificationsShowInDarkMode
|
||||||
//
|
//
|
||||||
customNotificationsShowInDarkMode.AutoSize = true;
|
customNotificationsShowInDarkMode.AutoSize = true;
|
||||||
@@ -216,7 +228,7 @@ namespace ntfysh_client
|
|||||||
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
BackColor = System.Drawing.Color.White;
|
BackColor = System.Drawing.Color.White;
|
||||||
ClientSize = new System.Drawing.Size(531, 367);
|
ClientSize = new System.Drawing.Size(531, 387);
|
||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Controls.Add(groupCustomNotificationSettings);
|
Controls.Add(groupCustomNotificationSettings);
|
||||||
Controls.Add(nativeVersusCustomNotificationsGroupBox);
|
Controls.Add(nativeVersusCustomNotificationsGroupBox);
|
||||||
@@ -266,5 +278,6 @@ namespace ntfysh_client
|
|||||||
private System.Windows.Forms.CheckBox customNotificationsShowTimeoutBar;
|
private System.Windows.Forms.CheckBox customNotificationsShowTimeoutBar;
|
||||||
private System.Windows.Forms.CheckBox customNotificationsShowInDarkMode;
|
private System.Windows.Forms.CheckBox customNotificationsShowInDarkMode;
|
||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
|
private System.Windows.Forms.CheckBox customNotificationsPlayWindowsNotificationAudio;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -61,6 +61,12 @@ namespace ntfysh_client
|
|||||||
get => customNotificationsShowInDarkMode.Checked;
|
get => customNotificationsShowInDarkMode.Checked;
|
||||||
set => customNotificationsShowInDarkMode.Checked = value;
|
set => customNotificationsShowInDarkMode.Checked = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CustomTrayNotificationsPlayDefaultWindowsSound
|
||||||
|
{
|
||||||
|
get => customNotificationsPlayWindowsNotificationAudio.Checked;
|
||||||
|
set => customNotificationsPlayWindowsNotificationAudio.Checked = value;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public SettingsDialog()
|
public SettingsDialog()
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root>
|
<root>
|
||||||
<!--
|
<!--
|
||||||
Microsoft ResX Schema
|
Microsoft ResX Schema
|
||||||
|
|
||||||
Version 2.0
|
Version 2.0
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
@@ -15,5 +15,6 @@
|
|||||||
public NotificationsType NotificationsMethod { get; set; }
|
public NotificationsType NotificationsMethod { get; set; }
|
||||||
public bool CustomTrayNotificationsShowTimeoutBar { get; set; }
|
public bool CustomTrayNotificationsShowTimeoutBar { get; set; }
|
||||||
public bool CustomTrayNotificationsShowInDarkMode { get; set; }
|
public bool CustomTrayNotificationsShowInDarkMode { get; set; }
|
||||||
|
public bool CustomTrayNotificationsPlayDefaultWindowsSound { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user