• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Documents.FlowDocument类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



FlowDocument类属于System.Windows.Documents命名空间,在下文中一共展示了FlowDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Write

        public void Write(string outputPath, FlowDocument doc)
        {
            Document pdfDoc = new Document(PageSize.A4, 50, 50, 50, 50);
            Font textFont = new Font(baseFont, DEFAULT_FONTSIZE, Font.NORMAL, BaseColor.BLACK);
            Font headingFont = new Font(baseFont, DEFAULT_HEADINGSIZE, Font.BOLD, BaseColor.BLACK);
            using (FileStream stream = new FileStream(outputPath, FileMode.Create))
            {
                PdfWriter writer = PdfWriter.GetInstance(pdfDoc, stream);
                pdfDoc.Open();
                foreach (Block i in doc.Blocks) {
                    if (i is System.Windows.Documents.Paragraph)
                    {
                        TextRange range = new TextRange(i.ContentStart, i.ContentEnd);
                        Console.WriteLine(i.Tag);
                        switch (i.Tag as string)
                        {
                            case "Paragraph": iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(range.Text, textFont);
                                par.Alignment = Element.ALIGN_JUSTIFIED;
                                              pdfDoc.Add(par);
                                              break;
                            case "Heading": iTextSharp.text.Paragraph head = new iTextSharp.text.Paragraph(range.Text, headingFont);
                                              head.Alignment = Element.ALIGN_CENTER;
                                              head.SpacingAfter = 10;
                                              pdfDoc.Add(head);
                                              break;
                            default:          iTextSharp.text.Paragraph def = new iTextSharp.text.Paragraph(range.Text, textFont);
                                              def.Alignment = Element.ALIGN_JUSTIFIED;
                                              pdfDoc.Add(def);
                                              break;

                        }
                    }
                    else if (i is System.Windows.Documents.List)
                    {
                        iTextSharp.text.List list = new iTextSharp.text.List(iTextSharp.text.List.UNORDERED, 10f);
                        list.SetListSymbol("\u2022");
                        list.IndentationLeft = 15f;
                        foreach (var li in (i as System.Windows.Documents.List).ListItems)
                        {
                            iTextSharp.text.ListItem listitem = new iTextSharp.text.ListItem();
                            TextRange range = new TextRange(li.Blocks.ElementAt(0).ContentStart, li.Blocks.ElementAt(0).ContentEnd);
                            string text = range.Text.Substring(1);
                            iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(text, textFont);
                            listitem.SpacingAfter = 10;
                            listitem.Add(par);
                            list.Add(listitem);
                        }
                        pdfDoc.Add(list);
                    }

               }
                if (pdfDoc.PageNumber == 0)
                {
                    iTextSharp.text.Paragraph par = new iTextSharp.text.Paragraph(" ");
                    par.Alignment = Element.ALIGN_JUSTIFIED;
                    pdfDoc.Add(par);
                }
               pdfDoc.Close();
            }
        }
开发者ID:drdaemos,项目名称:ODTCONVERTvs10,代码行数:60,代码来源:PDFWriter.cs


示例2: ZTextBufferWindow

        public ZTextBufferWindow(ZWindowManager manager, FontAndColorService fontAndColorService)
            : base(manager, fontAndColorService)
        {
            this.normalFontFamily = new FontFamily("Cambria");
            this.fixedFontFamily = new FontFamily("Consolas");

            var zero = new FormattedText(
                textToFormat: "0",
                culture: CultureInfo.InstalledUICulture,
                flowDirection: FlowDirection.LeftToRight,
                typeface: new Typeface(normalFontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal),
                emSize: this.FontSize,
                foreground: Brushes.Black);

            this.fontCharSize = new Size(zero.Width, zero.Height);

            this.document = new FlowDocument
            {
                FontFamily = normalFontFamily,
                FontSize = this.FontSize,
                PagePadding = new Thickness(8.0)
            };

            this.paragraph = new Paragraph();
            this.document.Blocks.Add(this.paragraph);

            this.scrollViewer = new FlowDocumentScrollViewer
            {
                FocusVisualStyle = null,
                Document = this.document
            };

            this.Children.Add(this.scrollViewer);
        }
开发者ID:modulexcite,项目名称:NZag,代码行数:34,代码来源:ZTextBufferWindow.cs


示例3: UndoMyEditAction

 public UndoMyEditAction(int columnId, bool isInlineNote, FlowDocument document, UVEditUndoAction undoAction)
 {
     __ColumnId = columnId;
     __IsInlineNote = isInlineNote;
     __DocumentGuid = (Guid)document.Tag;
     __UndoAction = undoAction;
 }
开发者ID:fednep,项目名称:UV-Outliner,代码行数:7,代码来源:UndoMyEditAction.cs


示例4: CreateDocument

		static FlowDocument CreateDocument(Project project, Lessee lessee, bool overview) {
			var doc = new FlowDocument();

			if ( lessee != null && !overview ) {// Print 1 page for a single lessee
				WritePage(doc, new Lessee[] { lessee }, project, false, true);
			} else if ( lessee == null && overview ) {// Partition lessees 8 at a time
				int i = 0;
				var list = new List<Lessee>();
				foreach ( Lessee l in project.Result.Lessees.Keys.OrderBy(l => l.Name) ) {
					list.Add(l);
					if ( ++i == 8 ) {
						WritePage(doc, list, project, true, false);
						i = 0;
						list = new List<Lessee>();
					}
				}
				if ( i > 6 ) {
					WritePage(doc, list.Take(6).ToList(), project, true, false);
					WritePage(doc, new Lessee[] { list[list.Count - 1] }, project, true, true);
				} else WritePage(doc, list, project, true, true);
			} else if ( lessee == null && !overview ) {// Print 1 page per lessee for all lessees
				foreach ( Lessee l in project.Result.Lessees.Keys ) {
					WritePage(doc, new Lessee[] { l }, project, false, false);
				}
			} else {
				throw new ArgumentException("Arguments invalid");
			}

			return doc;
		}
开发者ID:Wolfury,项目名称:nebenkosten,代码行数:30,代码来源:Print.cs


示例5: RotateContainers

 public FlowDocument RotateContainers(Object data)
 {
     var doc = new FlowDocument();
     if (data is ObservableCollection<Vehicle>)
     {
         vehicles = (ObservableCollection<Vehicle>)data;
         doc = ShowVehicles();
     }
     else if (data is List<VerticalBlock>)
     {
         vBlocks = (List<VerticalBlock>)data;
         doc = ShowVerticalBlocks();
     }
     else if (data is List<RowBlock>)
     {
         rBlocks = (List<RowBlock>)data;
         doc = ShowRowBlocks();
     }
     else if (data is List<Container>)
     {
         containers = (List<Container>)data;
         doc = ShowContainers();
     }
     else
     {
         MessageBox.Show("В форму отчета передан неверный тип данных:" + data.GetType());
         return null;
     }
     return doc;
 }
开发者ID:RadSt,项目名称:WPF-App-For-Ref,代码行数:30,代码来源:LoadSchemeCalculation.cs


示例6: OnBoundDocumentChanged

        private static void OnBoundDocumentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RichTextBox box = d as RichTextBox;

            if (box == null)
                return;

            RemoveEventHandler(box);

            string newXAML = GetBoundDocument(d);

            box.Document.Blocks.Clear();

            if (!string.IsNullOrEmpty(newXAML))
            {
                using (MemoryStream xamlMemoryStream = new MemoryStream(Encoding.ASCII.GetBytes(newXAML)))
                {
                    ParserContext parser = new ParserContext();
                    parser.XmlnsDictionary.Add("", "http://schemas.microsoft.com/winfx/2006/xaml/presentation");
                    parser.XmlnsDictionary.Add("x", "http://schemas.microsoft.com/winfx/2006/xaml");
                    FlowDocument doc = new FlowDocument();
                    Section section = XamlReader.Load(xamlMemoryStream, parser) as Section;

                    box.Document.Blocks.Add(section);

                }
            }

            AttachEventHandler(box);

        }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:31,代码来源:RichTextboxAssistant.cs


示例7: ReportPaginator

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="report">report document</param>
        /// <param name="data">report data</param>
        /// <exception cref="ArgumentException">Flow document must have a specified page height</exception>
        /// <exception cref="ArgumentException">Flow document must have a specified page width</exception>
        /// <exception cref="ArgumentException">Flow document can have only one report header section</exception>
        /// <exception cref="ArgumentException">Flow document can have only one report footer section</exception>
        public ReportPaginator(ReportDocument report, ReportData data)
        {
            _report = report;
            _data = data;

            _flowDocument = report.CreateFlowDocument();
            _pageSize = new Size(_flowDocument.PageWidth, _flowDocument.PageHeight);

            if (_flowDocument.PageHeight == double.NaN) throw new ArgumentException("Flow document must have a specified page height");
            if (_flowDocument.PageWidth == double.NaN) throw new ArgumentException("Flow document must have a specified page width");

            _dynamicCache = new ReportPaginatorDynamicCache(_flowDocument);
            ArrayList listPageHeaders = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportHeader));
            if (listPageHeaders.Count > 1) throw new ArgumentException("Flow document can have only one report header section");
            if (listPageHeaders.Count == 1) _blockPageHeader = (SectionReportHeader)listPageHeaders[0];
            ArrayList listPageFooters = _dynamicCache.GetFlowDocumentVisualListByType(typeof(SectionReportFooter));
            if (listPageFooters.Count > 1) throw new ArgumentException("Flow document can have only one report footer section");
            if (listPageFooters.Count == 1) _blockPageFooter = (SectionReportFooter)listPageFooters[0];

            _paginator = ((IDocumentPaginatorSource)_flowDocument).DocumentPaginator;

            // remove header and footer in our working copy
            Block block = _flowDocument.Blocks.FirstBlock;
            while (block != null)
            {
                Block thisBlock = block;
                block = block.NextBlock;
                if ((thisBlock == _blockPageHeader) || (thisBlock == _blockPageFooter)) _flowDocument.Blocks.Remove(thisBlock);
            }

            // get report context values
            _reportContextValues = _dynamicCache.GetFlowDocumentVisualListByInterface(typeof(IInlineContextValue));

            FillData();
        }
开发者ID:ivpusic,项目名称:Edward-company-cSharp-app,代码行数:44,代码来源:ReportPaginator.cs


示例8: AddTextToRTF

 private static void AddTextToRTF(FlowDocument myFlowDoc, string text)
 {
     var para = new Paragraph();
     var run = new Run(text);
     para.Inlines.Add(run);
     myFlowDoc.Blocks.Add(para);
 }
开发者ID:RobertHedgate,项目名称:TabInRichTextBox,代码行数:7,代码来源:MainWindow.xaml.cs


示例9: 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


示例10: FormatBlocks

 public void FormatBlocks(FlowDocument doc, BlockCollection blocks, StringBuilder buf, int indent)
 {
     foreach (Block block in blocks)
      {
     FormatBlock (doc, block, buf, indent);
      }
 }
开发者ID:jeremyrsellars,项目名称:recipe,代码行数:7,代码来源:ViewRecipe.xaml.cs


示例11: FormatDocument

        public string FormatDocument(FlowDocument doc)
        {
            StringBuilder buf = new StringBuilder ();
             FormatBlocks (doc, doc.Blocks, buf, 0);

             return buf.ToString ();
        }
开发者ID:jeremyrsellars,项目名称:recipe,代码行数:7,代码来源:ViewRecipe.xaml.cs


示例12: GetRunsAndParagraphs

        private static IEnumerable<TextElement> GetRunsAndParagraphs(FlowDocument doc)
        {
            for (TextPointer position = doc.ContentStart;
              position != null && position.CompareTo(doc.ContentEnd) <= 0;
              position = position.GetNextContextPosition(LogicalDirection.Forward))
            {
                if (position.GetPointerContext(LogicalDirection.Forward) == TextPointerContext.ElementEnd)
                {
                    Run run = position.Parent as Run;

                    if (run != null)
                    {
                        yield return run;
                    }
                    else
                    {
                        Paragraph para = position.Parent as Paragraph;

                        if (para != null)
                        {
                            yield return para;
                        }
                    }
                }
            }
        }
开发者ID:RagingBigFemaleBird,项目名称:sgs,代码行数:26,代码来源:FlowDocumentExtensions.cs


示例13: SubscribeToAllHyperlinks

 private void SubscribeToAllHyperlinks(FlowDocument flowDocument)
 {
     var hyperlinks = GetVisuals(flowDocument).OfType<Hyperlink>();
       foreach (var link in hyperlinks) {
     link.RequestNavigate += OnRequestNavigate;
       }
 }
开发者ID:vipwolf,项目名称:moni,代码行数:7,代码来源:MarkdownToFlowDocumentConverter.cs


示例14: Print

        public static void Print(FlowDocument printedPage)
        {
            PrintDialog dialog = new PrintDialog();

            dialog.PrintTicket = dialog.PrintQueue.DefaultPrintTicket;
            dialog.PrintTicket.PageOrientation = PageOrientation.Portrait;
            dialog.PrintTicket.OutputQuality = OutputQuality.High;
            dialog.PrintTicket.PageBorderless = PageBorderless.None;
            dialog.PrintTicket.PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4);

            if (dialog.ShowDialog() == true)
            {
                double pageHeight = printedPage.PageHeight;
                double pageWidth = printedPage.PageWidth;
                Thickness pagePadding = printedPage.PagePadding;
                double columnGap = printedPage.ColumnGap;
                double columnWidth = printedPage.ColumnWidth;

                printedPage.PageHeight = dialog.PrintableAreaHeight;
                printedPage.PageWidth = dialog.PrintableAreaWidth;
                printedPage.PagePadding = new Thickness(50);

                dialog.PrintDocument(((IDocumentPaginatorSource)printedPage).DocumentPaginator, "");

                printedPage.PagePadding = pagePadding;
                printedPage.PageHeight = pageHeight;
                printedPage.PageWidth = pageWidth;
                printedPage.ColumnWidth = columnWidth;
                printedPage.ColumnGap = columnGap;

            }
        }
开发者ID:Ashna,项目名称:ShayanDent,代码行数:32,代码来源:Common.cs


示例15: Convert

        public Object Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
        {
            var text = value as String;
            var flowDocument = new FlowDocument();

            if (String.IsNullOrEmpty(text))
                return flowDocument;

            var paragraph = new Paragraph();

            using (var reader = new StringReader(text))
            {
                String line;

                while ((line = reader.ReadLine()) != null)
                {
                    if (line.StartsWith("+++") || 
                        line.StartsWith("---") || 
                        line.StartsWith("diff ", StringComparison.OrdinalIgnoreCase))
                        continue;

                    paragraph.Inlines.Add(BuildLine(line));
                    paragraph.Inlines.Add(new LineBreak());
                }
            }

            return paragraph.Inlines;
        }
开发者ID:naighes,项目名称:Modern.Hg,代码行数:28,代码来源:FormattedDiffConverter.cs


示例16: create_torrent_hyperlinks

        // ReSharper disable once FunctionComplexityOverflow
        private void create_torrent_hyperlinks( bool download )
        {
            try
            {
                var doc = new FlowDocument();

                var para = new Paragraph();
                doc.Blocks.Add( para );

                foreach ( var torrent in Factory.Instance.Eztv.get_torrents().Where( torrent => String.Compare( torrent.Imbdid, this.TvdbSeries.ImdbId, StringComparison.Ordinal ) == 0 ) )
                {
                    if ( this.CheckBoxHdtv.IsChecked ?? false )
                    {
                        if ( torrent.Epname.ToLower().Contains( "hdtv" ) && !torrent.Epname.ToLower().Contains( "720" ) && !torrent.Epname.ToLower().Contains( "1080" ) )
                        {
                            continue;
                        }
                    }

                    if ( this.CheckBox720P.IsChecked ?? false )
                    {
                        if ( torrent.Epname.ToLower().Contains( "720" ) )
                        {
                            continue;
                        }
                    }

                    if ( this.CheckBox1080P.IsChecked ?? false )
                    {
                        if ( torrent.Epname.ToLower().Contains( "1080" ) )
                        {
                            continue;
                        }
                    }

                    var textblock = new TextBlock {Text = torrent.Epname, TextWrapping = TextWrapping.NoWrap};

                    var link = new Hyperlink {IsEnabled = true};
                    link.Inlines.Add( textblock );
                    link.NavigateUri = new Uri( torrent.Magnetlink );
                    link.Click += this.Link_Click;

                    para.Inlines.Add( link );
                    para.Inlines.Add( Environment.NewLine );

                    if ( download )
                    {
                        Factory.Instance.Utils.download_torrent( link.NavigateUri.ToString() );
                    }
                }

                this.RichTextTorrents.Document = doc;
                this.RichTextTorrents.IsReadOnly = true;
            }
            catch ( Exception ex )
            {
                Factory.Instance.LogLines.Enqueue( ex.Message );
                Factory.Instance.LogLines.Enqueue( ex.StackTrace );
            }
        }
开发者ID:dmzoneill,项目名称:filebotpp,代码行数:61,代码来源:UserControlSeriesViewer.cs


示例17: cmdCreateDynamicDocument_Click

        private void cmdCreateDynamicDocument_Click(object sender, RoutedEventArgs e)
        {
            // Create first part of sentence.
            Run runFirst = new Run();
            runFirst.Text = "Hello world of ";

            // Create bolded text.
            Bold bold = new Bold();
            Run runBold = new Run();
            runBold.Text = "dynamically generated";
            bold.Inlines.Add(runBold);

            // Create last part of sentence.
            Run runLast = new Run();
            runLast.Text = " documents";

            // Add three parts of sentence to a paragraph, in order.
            Paragraph paragraph = new Paragraph();
            paragraph.Inlines.Add(runFirst);
            paragraph.Inlines.Add(bold);
            paragraph.Inlines.Add(runLast);

            // Create a document and add this paragraph.
            FlowDocument document = new FlowDocument();
            document.Blocks.Add(paragraph);

            // Show the document.
            docViewer.Document = document;
        }
开发者ID:ittray,项目名称:LocalDemo,代码行数:29,代码来源:FlowContent.xaml.cs


示例18: GetFlowDocumentText

        // ---------------------------------------------------------------------
        //
        // Internal Methods
        //
        // ---------------------------------------------------------------------

        #region Internal Methods

        public static string GetFlowDocumentText(FlowDocument flowDoc)
        {
            TextPointer contentstart = flowDoc.ContentStart;
            TextPointer contentend = flowDoc.ContentEnd;
            TextRange textRange = new TextRange(contentstart, contentend);
            return textRange.Text;
        }
开发者ID:DVitinnik,项目名称:UniversityApps,代码行数:15,代码来源:HtmlFromXamlConverter.cs


示例19: 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


示例20: Convert

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var regEx = new Regex(@"\<a\s(href\=""|[^\>]+?\shref\="")(?<link>[^""]+)"".*?\>(?<text>.*?)(\<\/a\>|$)", RegexOptions.IgnoreCase | RegexOptions.Multiline);

            FlowDocument flowDocument = new FlowDocument();
            string html = AppSettings.HyperlinkifyAll((string)value, "");
            html = html.Replace("<br />", "");
            html = html.Replace("<br/>", "");
            flowDocument.FontFamily = new System.Windows.Media.FontFamily("Segoe UI");

            int nextOffset = 0;
            foreach (Match match in regEx.Matches(html))
            {
                if (match.Index > nextOffset)
                {
                    AppendText(flowDocument, html.Substring(nextOffset, match.Index - nextOffset));
                    nextOffset = match.Index + match.Length;
                    AppendLink(flowDocument, match.Groups["text"].Value, new Uri(match.Groups["link"].Value));
                }
            }

            if (nextOffset < html.Length)
                AppendText(flowDocument, html.Substring(nextOffset));

            return flowDocument;
        }
开发者ID:supudo,项目名称:BombaJob-WF,代码行数:26,代码来源:HTMLtoFDConverter.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Documents.Hyperlink类代码示例发布时间:2022-05-26
下一篇:
C# Documents.FixedPage类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap