当前位置: 首页>>代码示例>>C#>>正文


C# TextRange.Save方法代码示例

本文整理汇总了C#中System.Windows.Documents.TextRange.Save方法的典型用法代码示例。如果您正苦于以下问题:C# TextRange.Save方法的具体用法?C# TextRange.Save怎么用?C# TextRange.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Documents.TextRange的用法示例。


在下文中一共展示了TextRange.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertRtfToXaml

        public static string ConvertRtfToXaml(string rtfText)
        {
            var richTextBox = new System.Windows.Controls.RichTextBox();
            if (string.IsNullOrEmpty(rtfText))
                return String.Empty;
            var textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
            using (var rtfMemoryStream = new MemoryStream())
            {
                using (var rtfStreamWriter = new StreamWriter(rtfMemoryStream))
                {
                    rtfStreamWriter.Write(rtfText);
                    rtfStreamWriter.Flush();
                    rtfMemoryStream.Seek(0, SeekOrigin.Begin);
                    textRange.Load(rtfMemoryStream, DataFormats.Rtf);
                }
            }

            using (var rtfMemoryStream = new MemoryStream())
            {
                textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
                textRange.Save(rtfMemoryStream, System.Windows.DataFormats.Xaml);
                rtfMemoryStream.Seek(0, SeekOrigin.Begin);
                using (var rtfStreamReader = new StreamReader(rtfMemoryStream))
                {
                    return rtfStreamReader.ReadToEnd();
                }
            }
        }
开发者ID:uwcbc,项目名称:uwcbc-marimba,代码行数:28,代码来源:email.cs

示例2: UndoLevelStyle

        public UndoLevelStyle(OutlinerNote note)
        {
            __NoteId = note.Id;

            __Before = new MemoryStream[note.Columns.Count];
            __After = new MemoryStream[note.Columns.Count];

            __IsEmpty = true;

            for (int i = 0; i < note.Columns.Count; i++)
            {
                FlowDocument document = note.Columns[i].ColumnData as FlowDocument;
                if (document == null)
                    continue;

                __Before[i] = new MemoryStream();
                __After[i] = new MemoryStream();

                TextRange range = new TextRange(document.ContentStart, document.ContentEnd);
                range.Save(__Before[i], DataFormats.Xaml);

                if (!range.IsEmpty)
                    __IsEmpty = false;

            }
        }
开发者ID:fednep,项目名称:UV-Outliner,代码行数:26,代码来源:UndoLevelStyle.cs

示例3: SaveData

        public void SaveData()
        {
            TextRange sourceDocument = new TextRange(mainRTB.Document.ContentStart, mainRTB.Document.ContentEnd);
            string rtf = "";

            using (MemoryStream stream = new MemoryStream())
            {
                sourceDocument.Save(stream, DataFormats.Rtf);
                stream.Seek(0, SeekOrigin.Begin);

                using (StreamReader reader = new StreamReader(stream))
                {
                    rtf = reader.ReadToEnd();
                }
            }

            if (mIsSummaryNarrative)
            {
                mDataSet.Tables["i9Narrative"].Rows[0]["SummaryNarrative"] = sourceDocument.Text;
                mDataSet.Tables["i9Narrative"].Rows[0]["SummaryNarrativeFormat"] = rtf;
            }
            else
            {
                mDataSet.Tables["i9Narrative"].Rows[0]["Narrative"] = sourceDocument.Text;
                mDataSet.Tables["i9Narrative"].Rows[0]["NarrativeFormat"] = rtf;
            }
        }
开发者ID:Nsobi,项目名称:PoliceReports,代码行数:27,代码来源:Narrative.xaml.cs

示例4: AddBlock

        public static void AddBlock(Block from, FlowDocument to)
        {
            if (from != null)
              {
            //if (from is ItemsContent)
            //{
            //  ((ItemsContent)from).RunBeforeCopy();
            //}
            //else
            {
              TextRange range = new TextRange(from.ContentStart, from.ContentEnd);

              MemoryStream stream = new MemoryStream();

              System.Windows.Markup.XamlWriter.Save(range, stream);

              range.Save(stream, DataFormats.XamlPackage);

              TextRange textRange2 = new TextRange(to.ContentEnd, to.ContentEnd);

              textRange2.Load(stream, DataFormats.XamlPackage);
            }

              }
        }
开发者ID:adamnowak,项目名称:SmartWorking,代码行数:25,代码来源:XPSCreator.cs

示例5: open_button_Click

        private void open_button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();
            openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            openFileDialog1.Filter = @"Evennote File(*.note)|*.note";

            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == true)
            {
                Note temp = Evennote.OpenNoteFromFile(openFileDialog1.FileName);

                titleTextBox.Text = temp.Title;

                using (MemoryStream mem = new MemoryStream())
                {
                    TextRange range = new TextRange(temp.Text.ContentStart,
                        temp.Text.ContentEnd);
                    range.Save(mem, DataFormats.XamlPackage);
                    mem.Position = 0;

                    TextRange kange = new TextRange(richTextBox.Document.ContentStart,
                        richTextBox.Document.ContentEnd);
                    kange.Load(mem, DataFormats.XamlPackage);
                }
            }
        }
开发者ID:haletsky,项目名称:evennote,代码行数:28,代码来源:editnote_page.xaml.cs

示例6: GetPaginator

        /// <summary>
        /// 获取文档分页器
        /// </summary>
        /// <param name="pageWidth"></param>
        /// <param name="pageHeight"></param>
        /// <returns></returns>
        public DocumentPaginator GetPaginator(double pageWidth,double pageHeight)
        {
            //将RichTextBox的文档内容转为XAML
            TextRange originalRange = new TextRange(
            _textBox.Document.ContentStart,
            _textBox.Document.ContentEnd
            );
            MemoryStream memoryStream = new MemoryStream();
            originalRange.Save(memoryStream, System.Windows.DataFormats.XamlPackage);

            //根据XAML将流文档复制一份
            FlowDocument copy = new FlowDocument();

            TextRange copyRange = new TextRange(
            copy.ContentStart,
            copy.ContentEnd
            );
            copyRange.Load(memoryStream, System.Windows.DataFormats.XamlPackage);

            DocumentPaginator paginator =
            ((IDocumentPaginatorSource)copy).DocumentPaginator;

            //转换为新的分页器
            return new PrintingPaginator(
            paginator,new Size( pageWidth,pageHeight),
            new Size(DPI,DPI)
            );
        }
开发者ID:HETUAN,项目名称:PersonalInfoForWPF,代码行数:34,代码来源:PrintManager.cs

示例7: LoadRange

 private static void LoadRange(RichTextBox richTextBox, TextRange range)
 {
     MemoryStream buffer = new MemoryStream();
     range.Save(buffer, DataFormats.Rtf);
     var rtf = Encoding.UTF8.GetString(buffer.ToArray());
     SetContent(richTextBox, rtf);
 }
开发者ID:peterson1,项目名称:ErrH,代码行数:7,代码来源:RichTextBoxHelper.cs

示例8: SavePost

 public void SavePost(string postFile)
 {
     FileStream fileStream = new FileStream(postFile, FileMode.Create);
     TextRange range = new TextRange(_postEdit.Document.ContentStart, _postEdit.Document.ContentEnd);
     range.Save(fileStream, DataFormats.Rtf);
     fileStream.Close();
 }
开发者ID:flyingfish2000,项目名称:PostBoard,代码行数:7,代码来源:PostEditor.xaml.cs

示例9: ConvertRtfToXaml

        private static string ConvertRtfToXaml(string rtfText)
        {
            var richTextBox = new RichTextBox();
            if (string.IsNullOrEmpty(rtfText)) return "";

            var textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);

            //Create a MemoryStream of the Rtf content

            using (var rtfMemoryStream = new MemoryStream())
            {
                using (var rtfStreamWriter = new StreamWriter(rtfMemoryStream))
                {
                    rtfStreamWriter.Write(rtfText);
                    rtfStreamWriter.Flush();
                    rtfMemoryStream.Seek(0, SeekOrigin.Begin);

                    //Load the MemoryStream into TextRange ranging from start to end of RichTextBox.
                    textRange.Load(rtfMemoryStream, DataFormats.Rtf);
                }
            }

            using (var rtfMemoryStream = new MemoryStream())
            {

                textRange = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd);
                textRange.Save(rtfMemoryStream, DataFormats.Xaml);
                rtfMemoryStream.Seek(0, SeekOrigin.Begin);
                using (var rtfStreamReader = new StreamReader(rtfMemoryStream))
                {
                    return rtfStreamReader.ReadToEnd();
                }
            }
        }
开发者ID:mmanela,项目名称:MarkupConverter,代码行数:34,代码来源:RtfToHtmlConverter.cs

示例10: GetText

 protected override string GetText()
 {
     var rnge = new TextRange(_doc.ContentStart, _doc.ContentEnd);
     var stream = new MemoryStream();
     rnge.Save(stream, DataFormats.Rtf);
     return UTF8Encoding.UTF8.GetString(stream.ToArray());
 }
开发者ID:peterson1,项目名称:ErrH,代码行数:7,代码来源:FlowDocLogFormatter.cs

示例11: GetText

 public string GetText(FlowDocument document)
 {
     var tr = new TextRange(document.ContentStart, document.ContentEnd);
     using (var ms = new MemoryStream())
     {
         tr.Save(ms, DataFormats.Xaml);
         return Encoding.Default.GetString(ms.ToArray());
     }
 }
开发者ID:bhattvishal,项目名称:CalendarSyncplus,代码行数:9,代码来源:XamlFormatter.cs

示例12: GetText

 /// <summary>
 /// Gets the RTF Content of a flow document as UTF-8 Encoded string.
 /// </summary>
 /// <param name="document">The flow document for the RTF extracting.</param>
 /// <returns>The RTF content of the flow document as UTF-8 Encoded string.</returns>
 public string GetText(FlowDocument document)
 {
     TextRange tr = new TextRange(document.ContentStart, document.ContentEnd);
     using (MemoryStream ms = new MemoryStream())
     {
         tr.Save(ms, DataFormats.Rtf);
         return Encoding.UTF8.GetString(ms.ToArray());
     }
 }
开发者ID:jprofi,项目名称:MSProjects,代码行数:14,代码来源:RtfFormatter.cs

示例13: GetText

 public string GetText(System.Windows.Documents.FlowDocument document)
 {
     TextRange tr = new TextRange(document.ContentStart, document.ContentEnd);
     using (MemoryStream ms = new MemoryStream())
     {
         tr.Save(ms, DataFormats.Xaml);
         return ASCIIEncoding.Default.GetString(ms.ToArray());
     }
 }
开发者ID:JonHaywood,项目名称:Oberon,代码行数:9,代码来源:XamlFormatter.cs

示例14: SaveCore

 protected override void SaveCore(IDocument document, string fileName)
 {
     FlowDocument flowDocument = ((RichTextDocument)document).Content;
     TextRange range = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);
     using (FileStream stream = new FileStream(fileName, FileMode.Create))
     {
         range.Save(stream, DataFormats.Rtf);
     }
 }
开发者ID:hliang89,项目名称:WpfApplicationFramework,代码行数:9,代码来源:RichTextDocumentType.cs

示例15: Render

 public override void Render (IConsoleBufferSource buffer)
 {
     var document = new FlowDocument();
     RenderToFlowDocument(buffer, document);
     var content = new TextRange(document.ContentStart, document.ContentEnd);
     content.Save(_output, DataFormats.Rtf);
     if (_leaveOpen)
         _output.Flush();
     else
         _output.Dispose();
 }
开发者ID:jhorv,项目名称:CsConsoleFormat,代码行数:11,代码来源:RtfRenderTarget.cs


注:本文中的System.Windows.Documents.TextRange.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。