Example #1
0
        // Save() - Save file as existing format
        private void Save()
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.DefaultExt = "*.rtf";
            saveFileDialog.Filter     = "RTF Files|*.rtf";

            if (saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.FileName.Length > 0)
            {
                RichTB.SaveFile(saveFileDialog.FileName);
            }
        }
Example #2
0
        // Allow Users to save the text file with new name.
        private void SaveAsFile()
        {
            SaveFileDialog saveFile = new SaveFileDialog();

            saveFile.Filter = "Rich Text File (*.rtf)| *.rtf";
            DialogResult dr = saveFile.ShowDialog();

            if (dr == DialogResult.OK)
            {
                RichTB.SaveFile(saveFile.FileName, RichTextBoxStreamType.RichText);
                currentFile = saveFile.FileName;
            }
            saved = true;
        }
Example #3
0
 /* Allow users to Save the Text file.
  * Ask user to type filename if it's first time to save.
  * once user save as new name, user can override to existing file.
  */
 private void SaveFile()
 {
     if (currentFile == "")
     {
         SaveAsFile();
     }
     else
     {
         if (File.Exists(currentFile))
         {
             File.Delete(currentFile);
             RichTB.SaveFile(currentFile, RichTextBoxStreamType.RichText);
             saved = true;
             MessageBox.Show("File is succeessfully saved in " + currentFile + "! ", "Save", MessageBoxButtons.OK);
         }
         else
         {
             Testlabel.Text = "Error occured while saving the file.";
         }
     }
 }
Example #4
0
        /* Allow users to open existing file.
         * File extension should be .rtf (rich text file format)
         */
        private void OpenFile()
        {
            OpenFileDialog openFile = new OpenFileDialog();
            string         filename = "";

            openFile.Title  = "Open a Text File";
            openFile.Filter = "Rich Text File (*.rtf)| *.rtf";
            DialogResult dr = openFile.ShowDialog();

            if (dr == DialogResult.OK)
            {
                filename = openFile.FileName;
                MessageBox.Show("The File Selected was:" + filename);
                currentFile = openFile.FileName;
            }
            try
            {
                RichTB.LoadFile(filename);
            }
            catch (Exception e)
            {
                Testlabel.Text = e.Message;
            }
        }
Example #5
0
        private void Checktext(string text)
        {
            if (text[cPos] == RichTB.Text[cPos])
            {
                RichTB.Select(cPos, cCountLimited);
                RichTB.SelectionColor = Config.SelectColor;
                cPos++;
                cCorrect++;
                ProgBar.Value++;

                if (cPos == GetCharacterCount())
                {
                    SpeedTimer.Stop();
                    InputTb.Enabled    = false;
                    ResetBtn.Enabled   = true;
                    StopBtn.Enabled    = false;
                    ResultSwitch.Value = true;
                    wCount++;
                    UpdateResults();
                    ResetBtn.Focus();
                }
                if (RichTB.Text[cPos].ToString() == " ")
                {
                    wCount++;

                    if (Config.SpeechEnabled)
                    {
                        SS.Speak(Words[wCount], 0);
                    }
                }
            }
            else
            {
                cIncorrect++;
            }
        }
Example #6
0
 private void ResetBtn_Click(object sender, EventArgs e)
 {
     cPos          = 0;
     cCorrect      = 0;
     cIncorrect    = 0;
     cSecound      = 0;
     ProgBar.Value = 0;
     wCount        = 0;
     RichTB.Clear();
     InputTb.Clear();
     SW.Reset();
     CSecLabel.Text       = "00:00:00";
     CCorrectLabel.Text   = "0";
     CIncorrectLabel.Text = "0";
     CCorrectLabel.Text   = "0";
     WCountLabel.Text     = "0 / 0";
     WPMLabel.Text        = "0";
     CPMLabel.Text        = "0";
     StopBtn.Text         = "Stop";
     StartBtn.Enabled     = true;
     StopBtn.Enabled      = false;
     InputTb.Enabled      = false;
     SetupGame();
 }
Example #7
0
 public ContentDialogAncnew(string content)
 {
     this.InitializeComponent();
     RichTB.NavigateToString(content);
 }
Example #8
0
 // Paste() - Paste copied or cut text
 private void Paste()
 {
     RichTB.Paste();
 }
Example #9
0
 // Copy() - Copy selected text
 private void Copy()
 {
     RichTB.Copy();
 }
Example #10
0
 // Cut() - Cut selected text
 private void Cut()
 {
     RichTB.Cut();
 }