Esempio n. 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);
            }
        }
Esempio n. 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);
            }
        }
Esempio n. 3
0
 private void SelectAllClick(object sender, RoutedEventArgs e)
 {
     UserRichTextBox.SelectAll();
 }
Esempio n. 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())));
 }