public void Load(Stream stream, TextViewerTextType textType) { string html = null; if (textType == TextViewerTextType.PlainText || textType == TextViewerTextType.UnicodePlainText) { var reader = new StreamReader(stream, textType == TextViewerTextType.UnicodePlainText ? Encoding.Unicode : Encoding.ASCII); var text = new StringBuilder(); var line = reader.ReadLine(); while (line != null) { text.Append($"{System.Net.WebUtility.HtmlEncode (line).ReplaceLeading(' '," ")}<br>"); line = reader.ReadLine(); } html = text.ToString(); } if (textType == TextViewerTextType.RichText) { var converterPool = Registry.Pooled <ConverterPool <Stream> > (); var converter = converterPool.Find(ContentTypes.RTF, ContentTypes.HTML) as IHtmlConverter; if (converter != null) { html = converter.WithHmtlHeaderTags(stream); } } stream.Position = 0; Widget.LoadHtml(html, ""); }
public static string ToWpf(this TextViewerTextType value) { // Rtf, Text, Xaml, and XamlPackage if (value == TextViewerTextType.PlainText) { return(DataFormats.OemText); } if (value == TextViewerTextType.UnicodePlainText) { return(DataFormats.UnicodeText); } if (value == TextViewerTextType.RichText) { return(DataFormats.Rtf); } return(null); }
public void Load(Stream stream, TextViewerTextType textType) { var format = textType.ToWpf(); if (format == SW.DataFormats.UnicodeText) { var reader = new StreamReader(stream, textType == TextViewerTextType.UnicodePlainText ? Encoding.Unicode : Encoding.ASCII); var text = reader.ReadToEnd(); TextBox.Document.Blocks.Clear(); TextBox.Document.Blocks.Add(new Paragraph(new Run(text))); } else { new TextRange(TextBox.Document.ContentStart, TextBox.Document.ContentEnd) .Load(stream, format); } Modified = false; TextBox.Selection.Select(TextBox.Document.ContentStart, TextBox.Document.ContentStart); }
public void Load(Stream stream, TextViewerTextType textType) { //innerTextBox.Clear (); var color = innerTextBox.BackColor; if (textType == TextViewerTextType.RichText) { innerTextBox.LoadFile(stream, RichTextBoxStreamType.RichText); } else if (textType == TextViewerTextType.UnicodePlainText) { if (TextHelper.IsUnicode(stream.GetBuffer(30))) { using (var reader = new StreamReader(stream, Encoding.Unicode)) innerTextBox.Text = reader.ReadToEnd(); } else { innerTextBox.LoadFile(stream, RichTextBoxStreamType.PlainText); } } innerTextBox.BackColor = color; AfterLoadRTF(); }
public void Save(Stream stream, TextViewerTextType textType) { innerTextBox.SaveFile(stream, (RichTextBoxStreamType)textType); }
public void Save(Stream stream, TextViewerTextType textType) { }
public void Load(System.IO.Stream stream, TextViewerTextType textType) { }
public void Save(Stream stream, TextViewerTextType textType) { TextBox.Selection.Save(stream, textType.ToWpf()); }
public void Load(Stream stream, TextViewerTextType textType) { Widget.Load(stream, textType); }
public void Save(Stream stream, TextViewerTextType textType) { Widget.Save(stream, textType); }
public void Load(Stream stream, TextViewerTextType textType) { Backend.Load(stream, textType); }
public void Save(Stream stream, TextViewerTextType textType) { Backend.Save(stream, textType); }