Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
 private void SelectAllClick(object sender, RoutedEventArgs e)
 {
     UserRichTextBox.SelectAll();
 }
Exemple #4
0
 private void DateAndTimeClick(object sender, RoutedEventArgs e)
 {
     UserRichTextBox.SelectAll();
     UserRichTextBox.Document.Blocks.Add(new Paragraph(new Run(DateTime.Now.ToShortTimeString() + " " + DateTime.Now.ToShortDateString())));
 }