private void OpenFile(string path = null) { if (path == null) { path = GetPathOfFile(); } try { UserRichTextBox.SelectAll(); UserRichTextBox.Document.Blocks.Add(new Paragraph(new Run(System.IO.File.ReadAllText(path)))); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SaveFile(object pathObj = null) { var path = pathObj as string; if (path == null) { path = GetPathOfFile(); } try { UserRichTextBox.SelectAll(); using (var ws = new StreamWriter(path)) { ws.WriteLine(UserRichTextBox.Selection.Text); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SelectAllClick(object sender, RoutedEventArgs e) { UserRichTextBox.SelectAll(); }
private void DateAndTimeClick(object sender, RoutedEventArgs e) { UserRichTextBox.SelectAll(); UserRichTextBox.Document.Blocks.Add(new Paragraph(new Run(DateTime.Now.ToShortTimeString() + " " + DateTime.Now.ToShortDateString()))); }