Esempio n. 1
0
        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(' ',"&emsp;")}<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, "");
        }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
 public void Save(Stream stream, TextViewerTextType textType)
 {
     innerTextBox.SaveFile(stream, (RichTextBoxStreamType)textType);
 }
Esempio n. 6
0
 public void Save(Stream stream, TextViewerTextType textType)
 {
 }
Esempio n. 7
0
 public void Load(System.IO.Stream stream, TextViewerTextType textType)
 {
 }
Esempio n. 8
0
 public void Save(Stream stream, TextViewerTextType textType)
 {
     TextBox.Selection.Save(stream, textType.ToWpf());
 }
 public void Load(Stream stream, TextViewerTextType textType)
 {
     Widget.Load(stream, textType);
 }
Esempio n. 10
0
 public void Save(Stream stream, TextViewerTextType textType)
 {
     Widget.Save(stream, textType);
 }
Esempio n. 11
0
 public void Load(Stream stream, TextViewerTextType textType)
 {
     Backend.Load(stream, textType);
 }
Esempio n. 12
0
 public void Save(Stream stream, TextViewerTextType textType)
 {
     Backend.Save(stream, textType);
 }