private void btnSave_Click(object sender, RoutedEventArgs e) { StringBuilder sb = DocumentPersister.prepareDocumentXML(rta.Blocks); if (sb == null) { MessageBox.Show("Saving documents with images is not supported"); return; } SaveFileDialog sfd = new SaveFileDialog(); sfd.DefaultExt = ".sav"; sfd.Filter = "Saved Files|*.sav|All Files|*.*"; if (sfd.ShowDialog().Value) { using (FileStream fs = (FileStream)sfd.OpenFile()) { System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); byte[] buffer = enc.GetBytes(sb.ToString()); fs.Write(buffer, 0, buffer.Length); fs.Close(); IsDirty = false; } } }
void MainPage_Loaded(object sender, RoutedEventArgs e) { System.Xml.XmlReader r = System.Xml.XmlReader.Create("/RichNotepad;component/sample.sav"); DocumentPersister.parseSavedDocument(r, rta.Blocks); r.Close(); }
public void btnRO_Checked(object sender, RoutedEventArgs e) { rta.IsReadOnly = !rta.IsReadOnly; if (rta.IsReadOnly) { btnRO.Content = DocumentPersister.createImageFromUri(new Uri("/RichNotepad;component/images/view.png", UriKind.RelativeOrAbsolute), 29, 32); } else { btnRO.Content = DocumentPersister.createImageFromUri(new Uri("/RichNotepad;component/images/edit.png", UriKind.RelativeOrAbsolute), 29, 32); } ReturnFocus(); }
public void btnRTL_Checked(object sender, RoutedEventArgs e) { IsRTL = !IsRTL; if (IsRTL) { btnRTL.Content = DocumentPersister.createImageFromUri(new Uri("/RichNotepad;component/images/rtl.png", UriKind.RelativeOrAbsolute), 30, 32); } else { btnRTL.Content = DocumentPersister.createImageFromUri(new Uri("/RichNotepad;component/images/ltr.png", UriKind.RelativeOrAbsolute), 30, 32); } ReturnFocus(); }
private void btnOpen_Click(object sender, RoutedEventArgs e) { btnNew_Click(sender, e); OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = false; ofd.Filter = "Saved Files|*.sav|All Files|*.*"; if (ofd.ShowDialog().Value) { FileInfo fi = ofd.File; System.Xml.XmlReader r = System.Xml.XmlReader.Create(fi.OpenText()); DocumentPersister.parseSavedDocument(r, rta.Blocks); r.Close(); } }
private Image getImage() { return(DocumentPersister.createImageFromUri(new Uri("desert.jpg", UriKind.RelativeOrAbsolute), 200, 150)); }