private void cmdTestErrorSound_Click(object sender, EventArgs e) { try { AudioSetting audioSetting = new AudioSetting() { Enabled = true, AudioFilePath = txtErrorAudioFilePath.Text, UseSystemSounds = chkErrorUseSystemSounds.Checked, SoundRepeatCount = (int)errorRepeatCountNumericUpDown.Value, SoundVolumePerc = errorVolumePercTrackBar.Value }; if (chkErrorUseSystemSounds.Checked) { audioSetting.SystemSound = (SystemSounds)cboErrorSystemSound.SelectedIndex; } else { audioSetting.AudioFilePath = txtErrorAudioFilePath.Text; } backgroundWorker1.RunWorkerAsync(audioSetting); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void PlaySoundForState(AudioSetting audioSetting) { if (audioSetting.UseSystemSounds) { PlaySystemSound(audioSetting.SystemSound, audioSetting.SoundVolumePerc, audioSetting.SoundRepeatCount); } else { PlayCustomSound(audioSetting.AudioFilePath, audioSetting.SoundVolumePerc, audioSetting.SoundRepeatCount); } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { AudioSetting audioSetting = (AudioSetting)e.Argument; if (audioSetting.UseSystemSounds) { AudioNotifier.PlaySystemSound(audioSetting.SystemSound, audioSetting.SoundVolumePerc, audioSetting.SoundRepeatCount); } else { AudioNotifier.PlayCustomSound(audioSetting.AudioFilePath, audioSetting.SoundVolumePerc, audioSetting.SoundRepeatCount); } }
public AudioNotifierConfig() { GoodSoundSettings = new AudioSetting() { Enabled = false, UseSystemSounds = true }; WarningSoundSettings = new AudioSetting() { Enabled = true, UseSystemSounds = true, SystemSound = SystemSounds.Exclamation }; ErrorSoundSettings = new AudioSetting() { Enabled = true, UseSystemSounds = true, SystemSound = SystemSounds.Hand }; }