// these processors were created to centralize functionality that is invoked from both a button
        // and a keypress

        // OPEN FILE PROCESSOR

        private void ProcessOpenFile()
        {
            //string initialDir = @"C:\Program Files\Words+, Inc\EZ KeysXP\Eq";
            string initialDir = Common.AppPreferences.LectureManagerHomeDirectory;

            removeWatchdogs();

            AgentManager.Instance.RemoveAgent(this.Handle);

            this.Hide();

            LectureManagerOpenFileForm dlgOpenFile = new LectureManagerOpenFileForm(initialDir);

            DialogResult result = dlgOpenFile.ShowDialog();

            AgentManager.Instance.AddAgent(this.Handle, new LectureManagerAgent(this));

            this.Show();

            enableWatchdogs();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                lblChosenFile.Text = dlgOpenFile.FileName;

                string fileExtension = Path.GetExtension(lblChosenFile.Text).ToLower();

                try
                {
                    if (fileExtension.Equals(".txt"))
                    {
                        strSpeechBuffer = File.ReadAllText(dlgOpenFile.FileName);
                    }
                    else if ((fileExtension.Equals(".doc")) || (fileExtension.Equals(".docx")))
                    {
                        strSpeechBuffer = GetTextFromWordFile(dlgOpenFile.FileName);
                    }
                    FileLoaded = true;
                }
                catch (Exception ex)
                {
                    Log.Debug("Error reading from file " + dlgOpenFile.FileName + ", ex: " + ex.ToString());
                }

                txtLectureBox.Text = strSpeechBuffer;
                btnNavTop.PerformClick();
            }
        }
		// these processors were created to centralize functionality that is invoked from both a button
		// and a keypress

		// OPEN FILE PROCESSOR

		private void ProcessOpenFile()
		{
            
            //string initialDir = @"C:\Program Files\Words+, Inc\EZ KeysXP\Eq";
            string initialDir = Common.AppPreferences.LectureManagerHomeDirectory;
            
            removeWatchdogs();

            AgentManager.Instance.RemoveAgent(this.Handle);

            this.Hide();

            LectureManagerOpenFileForm dlgOpenFile = new LectureManagerOpenFileForm(initialDir);

            DialogResult result = dlgOpenFile.ShowDialog();

            AgentManager.Instance.AddAgent(this.Handle, new LectureManagerAgent(this));

            this.Show();

            enableWatchdogs();

            if (result == System.Windows.Forms.DialogResult.OK)
			{
                lblChosenFile.Text = dlgOpenFile.FileName;

                string fileExtension = Path.GetExtension(lblChosenFile.Text).ToLower();

                try
                {
                    if (fileExtension.Equals(".txt"))
                    {
                        strSpeechBuffer = File.ReadAllText(dlgOpenFile.FileName);
                    }
                    else if ((fileExtension.Equals(".doc")) || (fileExtension.Equals(".docx")))
                    {
                        strSpeechBuffer = GetTextFromWordFile(dlgOpenFile.FileName);
                    }
                    FileLoaded = true;
                }
                catch (Exception ex)
                {
                    Log.Debug("Error reading from file " + dlgOpenFile.FileName + ", ex: " + ex.ToString());
                }

				txtLectureBox.Text = strSpeechBuffer;
				btnNavTop.PerformClick();
			}
		}