// 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); } }
// 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; }
/* 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."; } } }
/* 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; } }
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++; } }
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(); }
public ContentDialogAncnew(string content) { this.InitializeComponent(); RichTB.NavigateToString(content); }
// Paste() - Paste copied or cut text private void Paste() { RichTB.Paste(); }
// Copy() - Copy selected text private void Copy() { RichTB.Copy(); }
// Cut() - Cut selected text private void Cut() { RichTB.Cut(); }