apply suggestions
This commit is contained in:
@@ -102,10 +102,8 @@ namespace ntfysh_client
|
|||||||
// ok, show the window
|
// ok, show the window
|
||||||
Show();
|
Show();
|
||||||
SetWindowPosition();
|
SetWindowPosition();
|
||||||
if(playNotificationSound)
|
|
||||||
{
|
if (playNotificationSound) PlayNotificationSound();
|
||||||
PlayNotificationSound();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyTheme()
|
private void ApplyTheme()
|
||||||
@@ -274,25 +272,22 @@ namespace ntfysh_client
|
|||||||
|
|
||||||
private void PlayNotificationSound()
|
private void PlayNotificationSound()
|
||||||
{
|
{
|
||||||
bool found = false;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using RegistryKey? key = Registry.CurrentUser.OpenSubKey(@"AppEvents\Schemes\Apps\.Default\Notification.Default\.Current");
|
using RegistryKey? defaultSoundPathKey = Registry.CurrentUser.OpenSubKey(@"AppEvents\Schemes\Apps\.Default\Notification.Default\.Current");
|
||||||
if (key != null)
|
|
||||||
{
|
if (defaultSoundPathKey is null) throw new Exception();
|
||||||
Object? o = key.GetValue(null); // pass null to get (Default)
|
|
||||||
if (o != null)
|
if (defaultSoundPathKey.GetValue(null) is not string defaultSoundPath) throw new Exception();
|
||||||
{
|
|
||||||
SoundPlayer theSound = new SoundPlayer((String)o);
|
SoundPlayer loadedSound = new(defaultSoundPath);
|
||||||
theSound.Play();
|
|
||||||
found = true;
|
loadedSound.Play();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{ }
|
{
|
||||||
if (!found)
|
|
||||||
SystemSounds.Beep.Play(); // consolation prize
|
SystemSounds.Beep.Play(); // consolation prize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user