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