示例#1
0
        private void chkCTRLSpeak_CheckedChanged(object sender, EventArgs e)
        {
            if (!_initialized)
            {
                return;
            }
            _uiInputModified = true;
            SpeakAloudInfo newInfo = new SpeakAloudInfo();

            LoadSpeakInfoFromUI(newInfo);
            newInfo.Save();
            _uiInputModified = false;

            if (!_speakAloudInfo.StartShortcut.Equals(newInfo.StartShortcut))
            {
                _speakAloudInfo.StartShortcut.UnregisterKey(this.Handle);
                newInfo.StartShortcut.RegisterKey(this.Handle);
            }
            if (!_speakAloudInfo.StopShortcut.Equals(newInfo.StopShortcut))
            {
                _speakAloudInfo.StopShortcut.UnregisterKey(this.Handle);
                newInfo.StopShortcut.RegisterKey(this.Handle);
            }
            if (!_speakAloudInfo.ReadClipboardShortcut.Equals(newInfo.ReadClipboardShortcut))
            {
                _speakAloudInfo.ReadClipboardShortcut.UnregisterKey(this.Handle);
                newInfo.ReadClipboardShortcut.RegisterKey(this.Handle);
            }
            if (!_speakAloudInfo.PauseShortcut.Equals(newInfo.PauseShortcut))
            {
                _speakAloudInfo.PauseShortcut.UnregisterKey(this.Handle);
                newInfo.PauseShortcut.RegisterKey(this.Handle);
            }
            if (!_speakAloudInfo.ResumeShortcut.Equals(newInfo.ResumeShortcut))
            {
                _speakAloudInfo.ResumeShortcut.UnregisterKey(this.Handle);
                newInfo.ResumeShortcut.RegisterKey(this.Handle);
            }

            _speakAloudInfo = newInfo;
        }
示例#2
0
        public override bool Equals(object obj)
        {
            SpeakAloudInfo sai = obj as SpeakAloudInfo;

            if (sai == null)
            {
                return(false);
            }

            if (string.Compare(this.Voice, sai.Voice, true) == 0 &&
                this.StartShortcut.Equals(sai.StartShortcut) &&
                this.StopShortcut.Equals(sai.StopShortcut) &&
                this.ReadClipboardShortcut.Equals(sai.ReadClipboardShortcut) &&
                this.PauseShortcut.Equals(sai.PauseShortcut) &&
                this.ResumeShortcut.Equals(sai.ResumeShortcut) &&
                this.Volume == sai.Volume &&
                this.Speed == sai.Speed)
            {
                return(true);
            }

            return(false);
        }
示例#3
0
        void LoadSpeakInfoFromUI(SpeakAloudInfo speakInfo)
        {
            try
            {
                speakInfo.Clear();
                speakInfo.Voice = cbVoice.SelectedItem as string;
                if (chkALTSpeak.Checked)
                {
                    speakInfo.StartShortcut._mod1 = Consts.MOD_ALT;
                }
                if (chkCTRLSpeak.Checked)
                {
                    speakInfo.StartShortcut._mod2 = Consts.MOD_CONTROL;
                }
                if (chkShiftSpeak.Checked)
                {
                    speakInfo.StartShortcut._mod1 = Consts.MOD_SHIFT;
                }
                speakInfo.StartShortcut._key = (Keys)cbSpeakKey.SelectedItem;

                if (chkALTStop.Checked)
                {
                    speakInfo.StopShortcut._mod1 = Consts.MOD_ALT;
                }
                if (chkCTRLStop.Checked)
                {
                    speakInfo.StopShortcut._mod2 = Consts.MOD_CONTROL;
                }
                if (chkSHIFTStop.Checked)
                {
                    speakInfo.StopShortcut._mod1 = Consts.MOD_SHIFT;
                }
                speakInfo.StopShortcut._key = (Keys)cbStopKey.SelectedItem;

                if (chkALTClipboard.Checked)
                {
                    speakInfo.ReadClipboardShortcut._mod1 = Consts.MOD_ALT;
                }
                if (chkCTRLClipboard.Checked)
                {
                    speakInfo.ReadClipboardShortcut._mod2 = Consts.MOD_CONTROL;
                }
                if (chkSHIFTClipboard.Checked)
                {
                    speakInfo.ReadClipboardShortcut._mod1 = Consts.MOD_SHIFT;
                }
                speakInfo.ReadClipboardShortcut._key = (Keys)cbKeyClipboard.SelectedItem;

                if (chkALTPause.Checked)
                {
                    speakInfo.PauseShortcut._mod1 = Consts.MOD_ALT;
                }
                if (chkCTRLPause.Checked)
                {
                    speakInfo.PauseShortcut._mod2 = Consts.MOD_CONTROL;
                }
                if (chkSHIFTPause.Checked)
                {
                    speakInfo.PauseShortcut._mod1 = Consts.MOD_SHIFT;
                }
                speakInfo.PauseShortcut._key = (Keys)cbPauseKey.SelectedItem;

                if (chkALTResume.Checked)
                {
                    speakInfo.ResumeShortcut._mod1 = Consts.MOD_ALT;
                }
                if (chkCTRLResume.Checked)
                {
                    speakInfo.ResumeShortcut._mod2 = Consts.MOD_CONTROL;
                }
                if (chkSHIFTResume.Checked)
                {
                    speakInfo.ResumeShortcut._mod1 = Consts.MOD_SHIFT;
                }
                speakInfo.ResumeShortcut._key = (Keys)cbResumeKey.SelectedItem;

                speakInfo.Volume = int.Parse(txtVolume.Text);
                speakInfo.Speed  = int.Parse(cbSpeed.SelectedItem.ToString());
            }
            catch
            {
            }
        }
示例#4
0
        void UpdateSpekaInfoUI(SpeakAloudInfo speakInfo)
        {
            // select the default voice
            for (int i = 0; i < cbVoice.Items.Count; i++)
            {
                string name = cbVoice.Items[i].ToString();
                if (string.Compare(name, speakInfo.Voice, true) == 0)
                {
                    cbVoice.SelectedIndex = i;
                }
            }

            if (cbVoice.SelectedItem == null)
            {
                cbVoice.SelectedIndex = 0;
                speakInfo.Voice       = cbVoice.Items[0].ToString();
                _uiInputModified      = true;
            }

            txtVolume.Text = speakInfo.Volume.ToString();
            for (int i = 0; i < cbSpeed.Items.Count; i++)
            {
                string strVal = cbSpeed.Items[i].ToString();
                if (string.Compare(strVal, speakInfo.Speed.ToString(), true) == 0)
                {
                    cbSpeed.SelectedIndex = i;
                }
            }

            if ((speakInfo.StartShortcut._mod1 & Consts.MOD_ALT) == Consts.MOD_ALT ||
                (speakInfo.StartShortcut._mod2 & Consts.MOD_ALT) == Consts.MOD_ALT ||
                (speakInfo.StartShortcut._mod3 & Consts.MOD_ALT) == Consts.MOD_ALT)
            {
                chkALTSpeak.Checked = true;
            }
            if ((speakInfo.StartShortcut._mod1 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL ||
                (speakInfo.StartShortcut._mod2 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL ||
                (speakInfo.StartShortcut._mod3 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL)
            {
                chkCTRLSpeak.Checked = true;
            }
            if ((speakInfo.StartShortcut._mod1 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT ||
                (speakInfo.StartShortcut._mod2 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT ||
                (speakInfo.StartShortcut._mod3 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT)
            {
                chkShiftSpeak.Checked = true;
            }
            if ((speakInfo.StartShortcut._mod1 & Consts.MOD_WIN) == Consts.MOD_WIN)
            {
            }
            cbSpeakKey.SelectedItem = speakInfo.StartShortcut._key;

            if ((speakInfo.StopShortcut._mod1 & Consts.MOD_ALT) == Consts.MOD_ALT ||
                (speakInfo.StopShortcut._mod2 & Consts.MOD_ALT) == Consts.MOD_ALT ||
                (speakInfo.StopShortcut._mod3 & Consts.MOD_ALT) == Consts.MOD_ALT)
            {
                chkALTStop.Checked = true;
            }
            if ((speakInfo.StopShortcut._mod1 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL ||
                (speakInfo.StopShortcut._mod2 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL ||
                (speakInfo.StopShortcut._mod3 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL)
            {
                chkCTRLStop.Checked = true;
            }
            if ((speakInfo.StopShortcut._mod1 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT ||
                (speakInfo.StopShortcut._mod2 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT ||
                (speakInfo.StopShortcut._mod3 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT)
            {
                chkSHIFTStop.Checked = true;
            }
            if ((speakInfo.StopShortcut._mod1 & Consts.MOD_WIN) == Consts.MOD_WIN)
            {
            }
            cbStopKey.SelectedItem = speakInfo.StopShortcut._key;

            if ((speakInfo.ReadClipboardShortcut._mod1 & Consts.MOD_ALT) == Consts.MOD_ALT ||
                (speakInfo.ReadClipboardShortcut._mod2 & Consts.MOD_ALT) == Consts.MOD_ALT ||
                (speakInfo.ReadClipboardShortcut._mod3 & Consts.MOD_ALT) == Consts.MOD_ALT)
            {
                chkALTClipboard.Checked = true;
            }
            if ((speakInfo.ReadClipboardShortcut._mod1 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL ||
                (speakInfo.ReadClipboardShortcut._mod2 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL ||
                (speakInfo.ReadClipboardShortcut._mod3 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL)
            {
                chkCTRLClipboard.Checked = true;
            }
            if ((speakInfo.ReadClipboardShortcut._mod1 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT ||
                (speakInfo.ReadClipboardShortcut._mod2 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT ||
                (speakInfo.ReadClipboardShortcut._mod3 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT)
            {
                chkSHIFTClipboard.Checked = true;
            }
            if ((speakInfo.ReadClipboardShortcut._mod1 & Consts.MOD_WIN) == Consts.MOD_WIN)
            {
            }
            cbKeyClipboard.SelectedItem = speakInfo.ReadClipboardShortcut._key;

            if ((speakInfo.PauseShortcut._mod1 & Consts.MOD_ALT) == Consts.MOD_ALT ||
                (speakInfo.PauseShortcut._mod2 & Consts.MOD_ALT) == Consts.MOD_ALT ||
                (speakInfo.PauseShortcut._mod3 & Consts.MOD_ALT) == Consts.MOD_ALT)
            {
                chkALTPause.Checked = true;
            }
            if ((speakInfo.PauseShortcut._mod1 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL ||
                (speakInfo.PauseShortcut._mod2 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL ||
                (speakInfo.PauseShortcut._mod3 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL)
            {
                chkCTRLPause.Checked = true;
            }
            if ((speakInfo.PauseShortcut._mod1 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT ||
                (speakInfo.PauseShortcut._mod2 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT ||
                (speakInfo.PauseShortcut._mod3 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT)
            {
                chkSHIFTPause.Checked = true;
            }
            if ((speakInfo.PauseShortcut._mod1 & Consts.MOD_WIN) == Consts.MOD_WIN)
            {
            }
            cbPauseKey.SelectedItem = speakInfo.PauseShortcut._key;

            if ((speakInfo.ResumeShortcut._mod1 & Consts.MOD_ALT) == Consts.MOD_ALT ||
                (speakInfo.ResumeShortcut._mod2 & Consts.MOD_ALT) == Consts.MOD_ALT ||
                (speakInfo.ResumeShortcut._mod3 & Consts.MOD_ALT) == Consts.MOD_ALT)
            {
                chkALTResume.Checked = true;
            }
            if ((speakInfo.ResumeShortcut._mod1 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL ||
                (speakInfo.ResumeShortcut._mod2 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL ||
                (speakInfo.ResumeShortcut._mod3 & Consts.MOD_CONTROL) == Consts.MOD_CONTROL)
            {
                chkCTRLResume.Checked = true;
            }
            if ((speakInfo.ResumeShortcut._mod1 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT ||
                (speakInfo.ResumeShortcut._mod2 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT ||
                (speakInfo.ResumeShortcut._mod3 & Consts.MOD_SHIFT) == Consts.MOD_SHIFT)
            {
                chkSHIFTResume.Checked = true;
            }
            if ((speakInfo.ResumeShortcut._mod1 & Consts.MOD_WIN) == Consts.MOD_WIN)
            {
            }
            cbResumeKey.SelectedItem = speakInfo.ResumeShortcut._key;

            if (_uiInputModified)
            {
                speakInfo.Save();
                _uiInputModified = false;
            }
        }