Ejemplo n.º 1
0
        private void AddSoundSetting(SoundSetting setting)
        {
            string key = setting.ToString().ToLower();

            if (soundSettings.ContainsKey(key))
            {
                soundSettings[key] = setting;
            }
            else
            {
                soundSettings.Add(key, setting);
                lbSoundAlerts.Items.Add(UppercaseFirst(setting.ToString()));
            }
        }
Ejemplo n.º 2
0
        private void lbSoundAlerts_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lbSoundAlerts.SelectedIndex != -1)
            {
                SoundSetting selected = soundSettings[lbSoundAlerts.SelectedItem.ToString().ToLower()];
                tbAlertType.Text = selected.special;
                switch (selected.soundType)
                {
                case SoundSettingTypeEnum.Asterisk:
                    rbAlertAsterisk.Checked = true;
                    break;

                case SoundSettingTypeEnum.Beep:
                    rbAlertBeep.Checked = true;
                    break;

                case SoundSettingTypeEnum.Error:
                    rbAlertError.Checked = true;
                    break;

                case SoundSettingTypeEnum.Exclamation:
                    rbAlertExclamation.Checked = true;
                    break;

                case SoundSettingTypeEnum.Question:
                    rbAlertQuestion.Checked = true;
                    break;

                case SoundSettingTypeEnum.TTS:
                    rbAlertTts.Checked = true;
                    break;

                case SoundSettingTypeEnum.Wav:
                    rbAlertWav.Checked = true;
                    break;
                }
                tbAlertTts.Text = rbAlertTts.Checked ? selected.soundData : String.Empty;
                tbAlertWav.Text = rbAlertWav.Checked ? selected.soundData : String.Empty;
            }
        }
Ejemplo n.º 3
0
        private void btnSoundAdd_Click(object sender, EventArgs e)
        {
            SoundSetting setting = new SoundSetting();

            setting.special = tbAlertType.Text;
            if (rbAlertAsterisk.Checked)
            {
                setting.soundType = SoundSettingTypeEnum.Asterisk;
            }
            else if (rbAlertBeep.Checked)
            {
                setting.soundType = SoundSettingTypeEnum.Beep;
            }
            else if (rbAlertError.Checked)
            {
                setting.soundType = SoundSettingTypeEnum.Error;
            }
            else if (rbAlertExclamation.Checked)
            {
                setting.soundType = SoundSettingTypeEnum.Exclamation;
            }
            else if (rbAlertQuestion.Checked)
            {
                setting.soundType = SoundSettingTypeEnum.Question;
            }
            else if (rbAlertTts.Checked)
            {
                setting.soundType = SoundSettingTypeEnum.TTS;
                setting.soundData = tbAlertTts.Text;
            }
            else if (rbAlertWav.Checked)
            {
                setting.soundType = SoundSettingTypeEnum.Wav;
                setting.soundData = tbAlertWav.Text;
            }

            AddSoundSetting(setting);
        }
Ejemplo n.º 4
0
        public override bool Equals(object obj)
        {
            SoundSetting other = (SoundSetting)obj;

            return(this.ToString().Equals(other.ToString()));
        }
Ejemplo n.º 5
0
        private void LoadXmlSettings()
        {
            FileInfo file = new FileInfo(xmlFileName);

            if (!file.Exists)
            {
                // Add default beep for "None" special type
                SoundSetting setting = new SoundSetting();
                setting.special   = "None";
                setting.soundType = SoundSettingTypeEnum.Beep;
                AddSoundSetting(setting);

                return;
            }
            XmlTextReader xml = new XmlTextReader(xmlFileName);

            try
            {
                while (xml.Read())
                {
                    if (xml.NodeType == XmlNodeType.Element)
                    {
                        try
                        {
                            if (xml.LocalName == "SoundSettings")
                            {
                                while (xml.Read())
                                {
                                    if (xml.NodeType == XmlNodeType.Element)
                                    {
                                        if (xml.LocalName == "SoundSetting")
                                        {
                                            SoundSetting setting = new SoundSetting();
                                            setting.special = xml.GetAttribute("Special");
                                            int type = 0;
                                            try { type = Int32.Parse(xml.GetAttribute("SoundType")); }
                                            catch { }
                                            setting.soundType = (SoundSettingTypeEnum)type;
                                            setting.soundData = xml.GetAttribute("SoundData");

                                            AddSoundSetting(setting);
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        catch (System.Exception ex)
                        {
                            string error = String.Format("Error while parsing XML settings: Line #{0} ({1})\n{2}",
                                                         xml.LineNumber, xml.LocalName, ex.Message);
                            MessageBox.Show(error + "\n\n Attempting default setting", "XML Preferences Error",
                                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            ActGlobals.oFormActMain.WriteExceptionLog(ex, error);
                            continue;
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                string error = "The XML settings file may be corrupt or unusable.  Loading defaults where applicable.";
                MessageBox.Show(error, "XML Preferences Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ActGlobals.oFormActMain.WriteExceptionLog(ex, error);
            }
            xml.Close();
        }