示例#1
0
        /// <summary>
        /// Saves settings
        /// </summary>
        /// <returns>true on success, false on failure</returns>
        public bool Save()
        {
            SAPISettings.Volume = Synthesizer.Volume;
            SAPISettings.Rate   = Synthesizer.Rate;

            SAPISettings.Save();

            return(true);
        }
示例#2
0
        /// <summary>
        /// User clicked OK. Confirm if settings needs to be saved,
        /// and then save them and close window
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>
        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (!confirm("Save settings?"))
            {
                return;
            }

            if (checkBoxSelectVoice.Checked &&
                comboBoxSelectVoice.Items.Count > 0 &&
                comboBoxSelectVoice.SelectedItem != null)
            {
                var voice = comboBoxSelectVoice.SelectedItem as String;
                if (!String.IsNullOrWhiteSpace(voice))
                {
                    _settings.Voice = voice;
                }
                else
                {
                    MessageBox.Show("Must select voice", Text);
                    return;
                }
            }
            else
            {
                var gender = comboBoxGender.SelectedItem as String;
                if (!String.IsNullOrEmpty(gender))
                {
                    var voiceGender = stringToVoiceGender(gender);
                    if (voiceGender != VoiceGender.NotSet)
                    {
                        _settings.Gender = voiceGender;
                        _settings.Voice  = String.Empty;
                    }
                }
            }

            _settings.Save();

            if (Windows.GetOSVersion() == Windows.WindowsVersion.Win7)
            {
                MessageBox.Show("You are running Windows 7. Text to speech voice selection may not work",
                                Text,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }

            Close();
        }