Beispiel #1
0
        public override void RecordMessage(AlertRaised alertRaised)
        {
            if (AgentConfig != null)
            {
                AudioNotifierConfig config = (AudioNotifierConfig)AgentConfig;

                if (alertRaised.Level == AlertLevel.Info || alertRaised.Level == AlertLevel.Debug)
                {
                    if (config.GoodSoundSettings.Enabled)
                    {
                        PlaySoundForState(config.GoodSoundSettings);
                    }
                }
                else if (alertRaised.Level == AlertLevel.Warning)
                {
                    if (config.WarningSoundSettings.Enabled)
                    {
                        PlaySoundForState(config.WarningSoundSettings);
                    }
                }
                else if (alertRaised.Level == AlertLevel.Error || alertRaised.Level == AlertLevel.Crisis)
                {
                    if (config.ErrorSoundSettings.Enabled)
                    {
                        PlaySoundForState(config.ErrorSoundSettings);
                    }
                }
            }
        }
Beispiel #2
0
        public override void RecordMessage(AlertRaised alertRaised)
        {
            if (AgentConfig != null)
            {
                AudioNotifierConfig config = (AudioNotifierConfig)AgentConfig;

                if (alertRaised.Level == AlertLevel.Info || alertRaised.Level == AlertLevel.Debug)
                {
                    if (config.GoodSoundSettings.Enabled)
                    {
                        PlaySoundForState(config.GoodSoundSettings);
                    }
                }
                else if (alertRaised.Level == AlertLevel.Warning)
                {
                    if (config.WarningSoundSettings.Enabled)
                    {
                        PlaySoundForState(config.WarningSoundSettings);
                    }
                }
                else if (alertRaised.Level == AlertLevel.Error || alertRaised.Level == AlertLevel.Crisis)
                {
                    if (config.ErrorSoundSettings.Enabled)
                    {
                        PlaySoundForState(config.ErrorSoundSettings);
                    }
                }

                //if (config.UseSystemSounds)
                //{
                //    if (alertRaised.Level == AlertLevel.Warning)
                //    {
                //        PlaySystemSound(config.WarningSystemSound, config.WarningSoundVolumePerc, config.WarningSoundRepeatCount);
                //    }
                //    else if (alertRaised.Level == AlertLevel.Error)
                //    {
                //        PlaySystemSound(config.ErrorSystemSound, config.ErrorSoundVolumePerc, config.ErrorSoundRepeatCount);
                //    }
                //}
                //else
                //{
                //    if (alertRaised.Level == AlertLevel.Warning)
                //    {
                //        PlaySound(config.WarningSoundPath, config.WarningSoundVolumePerc, config.WarningSoundRepeatCount);
                //    }
                //    else if (alertRaised.Level == AlertLevel.Error)
                //    {
                //        PlaySound(config.ErrorSoundPath, config.ErrorSoundVolumePerc, config.ErrorSoundRepeatCount);
                //    }
                //}
            }
        }
        public override void OkClicked()
        {
            try
            {
                AudioNotifierConfig currentConfig;
                if (SelectedConfig == null)
                {
                    SelectedConfig = new AudioNotifierConfig();
                }
                currentConfig = (AudioNotifierConfig)SelectedConfig;

                if (chkGoodEnabled.Checked)
                {
                    if (chkGoodUseSystemSounds.Checked && cboGoodSystemSound.SelectedIndex < 0)
                    {
                        MessageBox.Show("You must specify a good system sound!");
                        cboGoodSystemSound.Focus();
                        return;
                    }
                    else if (!chkGoodUseSystemSounds.Checked && txtGoodAudioFilePath.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("You must specify a good sound!");
                        txtGoodAudioFilePath.Focus();
                        return;
                    }
                }
                if (chkWarningEnabled.Checked)
                {
                    if (chkWarningUseSystemSounds.Checked && cboWarningSystemSound.SelectedIndex < 0)
                    {
                        MessageBox.Show("You must specify a warning system sound!");
                        cboWarningSystemSound.Focus();
                        return;
                    }
                    else if (!chkWarningUseSystemSounds.Checked && txtWarningAudioFilePath.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("You must specify a warning sound!");
                        txtWarningAudioFilePath.Focus();
                        return;
                    }
                }
                if (chkErrorEnabled.Checked)
                {
                    if (chkErrorUseSystemSounds.Checked && cboErrorSystemSound.SelectedIndex < 0)
                    {
                        MessageBox.Show("You must specify an error system sound!");
                        cboErrorSystemSound.Focus();
                        return;
                    }
                    else if (!chkErrorUseSystemSounds.Checked && txtErrorAudioFilePath.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("You must specify an error sound!");
                        txtErrorAudioFilePath.Focus();
                        return;
                    }
                }

                currentConfig.GoodSoundSettings.Enabled          = chkGoodEnabled.Checked;
                currentConfig.GoodSoundSettings.UseSystemSounds  = chkGoodUseSystemSounds.Checked;
                currentConfig.GoodSoundSettings.AudioFilePath    = txtGoodAudioFilePath.Text;
                currentConfig.GoodSoundSettings.SystemSound      = (SystemSounds)cboGoodSystemSound.SelectedIndex;
                currentConfig.GoodSoundSettings.SoundRepeatCount = (int)goodRepeatCountNumericUpDown.Value;
                currentConfig.GoodSoundSettings.SoundVolumePerc  = goodVolumePercTrackBar.Value;

                currentConfig.WarningSoundSettings.Enabled          = chkWarningEnabled.Checked;
                currentConfig.WarningSoundSettings.UseSystemSounds  = chkWarningUseSystemSounds.Checked;
                currentConfig.WarningSoundSettings.AudioFilePath    = txtWarningAudioFilePath.Text;
                currentConfig.WarningSoundSettings.SystemSound      = (SystemSounds)cboWarningSystemSound.SelectedIndex;
                currentConfig.WarningSoundSettings.SoundRepeatCount = (int)warningRepeatCountNumericUpDown.Value;
                currentConfig.WarningSoundSettings.SoundVolumePerc  = warningVolumePercTrackBar.Value;

                currentConfig.ErrorSoundSettings.Enabled          = chkErrorEnabled.Checked;
                currentConfig.ErrorSoundSettings.UseSystemSounds  = chkErrorUseSystemSounds.Checked;
                currentConfig.ErrorSoundSettings.AudioFilePath    = txtErrorAudioFilePath.Text;
                currentConfig.ErrorSoundSettings.SystemSound      = (SystemSounds)cboErrorSystemSound.SelectedIndex;
                currentConfig.ErrorSoundSettings.SoundRepeatCount = (int)errorRepeatCountNumericUpDown.Value;
                currentConfig.ErrorSoundSettings.SoundVolumePerc  = errorVolumePercTrackBar.Value;

                DialogResult = System.Windows.Forms.DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
 public AudioNotifier()
 {
     AgentConfig = new AudioNotifierConfig();
 }