private void NewFileButton_Click(object sender, EventArgs e)
 {
     sapi5engine.SpeakAsyncCancelAll();
     sapi5engine.Resume();
     playButton.Enabled             = true;
     pauseButton.Enabled            = false;
     stopButton.Enabled             = false;
     playToolStripMenuItem.Enabled  = true;
     pauseToolStripMenuItem.Enabled = false;
     stopToolStripMenuItem.Enabled  = false;
     if (changesMade)
     {
         DialogResult r = MessageBox.Show("Changes were made. Do you wish to save your changes before starting a new file?", "OutLoud Text Reader", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (r != DialogResult.Cancel)
         {
             if (r == DialogResult.Yes)
             {
                 AttemptSave(false);
             }
         }
         else
         {
             return;
         }
     }
     MainTextBox.Clear();
     MainTextBox.ClearUndo();
     changesMade = false;
     fileName    = "";
 }
        private void OpenButton_Click(object sender, EventArgs e)
        {
            sapi5engine.SpeakAsyncCancelAll();
            sapi5engine.Resume();
            playButton.Enabled             = true;
            pauseButton.Enabled            = false;
            stopButton.Enabled             = false;
            playToolStripMenuItem.Enabled  = true;
            pauseToolStripMenuItem.Enabled = false;
            stopToolStripMenuItem.Enabled  = false;
            if (changesMade)
            {
                DialogResult r = MessageBox.Show("Changes were made. Do you wish to save your changes before opening another file?", "OutLoud Text Reader", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (r != DialogResult.Cancel)
                {
                    if (r == DialogResult.Yes)
                    {
                        AttemptSave(false);
                    }
                }
                else
                {
                    return;
                }
            }
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    MainTextBox.Clear();

                    fileName         = openFileDialog1.FileName;
                    MainTextBox.Text = File.ReadAllText(fileName);
                    MainTextBox.ClearUndo();
                    changesMade = false;
                }
                catch (FileLoadException x)
                {
                    MessageBox.Show($"There was an error loading the file: {x.Message}", "OutLoud Text Reader", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MainTextBox.Clear();
                    MainTextBox.ClearUndo();
                    changesMade = false;
                    return;
                }
                catch (Exception x)
                {
                    MessageBox.Show($"PLEASE REPORT THIS PROBLEM!\nException message: {x.Message}\nSource: {x.Source}\n--Stack Trace--\n{x.StackTrace}", "OutLoud Text Reader", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MainTextBox.Clear();
                    MainTextBox.ClearUndo();
                    changesMade = false;
                }
            }
        }
Exemplo n.º 3
0
        private void UpdateTextBoxFromData()
        {
            if (string.IsNullOrEmpty(textValue))
            {
                MainTextBox.Text = "";
                return;
            }

            Cursor = Cursors.WaitCursor;



            MainTextBox.Text = textValue;
            //MainTextBox.IsChanged = false;
            MainTextBox.ClearUndo();

            Cursor = Cursors.Default;
        }