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

C# Documents.Paragraph类代码示例

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

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



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

示例1: ColorizeXAML

    public static FlowDocument ColorizeXAML( string xamlText, FlowDocument targetDoc )
    {
      XmlTokenizer tokenizer = new XmlTokenizer();
      XmlTokenizerMode mode = XmlTokenizerMode.OutsideElement;

      List<XmlToken> tokens = tokenizer.Tokenize( xamlText, ref mode );
      List<string> tokenTexts = new List<string>( tokens.Count );
      List<Color> colors = new List<Color>( tokens.Count );
      int position = 0;
      foreach( XmlToken token in tokens )
      {
        string tokenText = xamlText.Substring( position, token.Length );
        tokenTexts.Add( tokenText );
        Color color = ColorForToken( token, tokenText );
        colors.Add( color );
        position += token.Length;
      }

      Paragraph p = new Paragraph();

      // Loop through tokens
      for( int i = 0; i < tokenTexts.Count; i++ )
      {
        Run r = new Run( tokenTexts[ i ] );
        r.Foreground = new SolidColorBrush( colors[ i ] );
        p.Inlines.Add( r );
      }

      targetDoc.Blocks.Add( p );

      return targetDoc;
    }
开发者ID:ChaitG,项目名称:arcgis-pro-sdk-community-samples,代码行数:32,代码来源:XamlFormatter.cs


示例2: BindFeatures

        private void BindFeatures(List<HalanVersionInfo> products)
        {
            foreach( HalanVersionInfo inf in products ) {

            string title = string.Format("{0} {1}.{2:D2}", inf.Product.Replace("ServiceBusMQManager", "Service Bus MQ Manager"),
                                                        inf.LatestVersion.Major, inf.LatestVersion.Minor);

            Paragraph para = new Paragraph();
            para.Inlines.Add(new Bold(
                               new Run(title) { FontSize = 19 } ));

            if( inf.ReleaseDate > DateTime.MinValue )
              para.Inlines.Add( new Run(string.Concat(", Released: ", inf.ReleaseDate.ToShortDateString())) );

            tbFeatures.Document.Blocks.Add(para);

            var list = new System.Windows.Documents.List();

            foreach( var f in inf.Features )
              list.ListItems.Add( new ListItem(new Paragraph(new Run(f))) );

            tbFeatures.Document.Blocks.Add(list);

            if( !_url.IsValid() )
              _url = inf.Url;
              }
        }
开发者ID:thirkcircus,项目名称:ServiceBusMQManager,代码行数:27,代码来源:NewVersionDialog.xaml.cs


示例3: Bold

        /// <summary>
        /// This method returns a simple paragraph text of header. 
        /// </summary>
        /// <param name="patternName">The name of pattern we want to display</param>
        /// <param name="hitStart">Start position of our hit</param>
        /// <param name="hitEnd">End position of our hit</param>
        /// <returns>A paragraph of text for our header.</returns>
        static public Paragraph GetRichHeader
                            (String patternName, int hitStart, int hitEnd)
        {
            // Create our bold header bold text.
            Bold myBold = new Bold();
            myBold.Inlines.Add("Sequence Hits Viewer");

            Run myRun2 = new Run();
            myRun2.Text = "================";
            myRun2.Text += NEWLINE;
            myRun2.Text += NEWLINE;
            myRun2.Text += "Matched Start Position : [ " + hitStart + " ]";
            myRun2.Text += NEWLINE;
            myRun2.Text += "Matched End   Position : [ " + hitEnd + " ]";
            myRun2.Text += NEWLINE;
            myRun2.Text += NEWLINE;
            myRun2.Text += "================ " + patternName + " ================";
            myRun2.Text += NEWLINE;

            Paragraph Header = new Paragraph();

            Header.Inlines.Add(myBold);
            Header.Inlines.Add(myRun2);

            return Header;
        }
开发者ID:SamuelToh,项目名称:Masters_Degree_Major_Project,代码行数:33,代码来源:ResultDisplayLogic.cs


示例4: CreateDiffTextForDisplay

		public Paragraph CreateDiffTextForDisplay(string diffText)
		{
			Paragraph diffParagraph = new Paragraph();

			string[] lines = diffText.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.None);

			foreach (string line in lines)
			{
				if (line.StartsWith("+"))
				{
					diffParagraph.Inlines.Add(new AddTextRun(line));
				}
				else if (line.StartsWith("-"))
				{
					diffParagraph.Inlines.Add(new DeleteTextRun(line));
				}
				else if (line.StartsWith("@@"))
				{
					diffParagraph.Inlines.Add(new LineBreak());
					diffParagraph.Inlines.Add(new LineNumberTextRun(line));
				}
				else
				{
					diffParagraph.Inlines.Add(new Run(line));
				}
				diffParagraph.Inlines.Add(new LineBreak());
			}

			return diffParagraph;
		}
开发者ID:guitarnana,项目名称:tfsk,代码行数:30,代码来源:DiffRichTextBox.cs


示例5: ConversationRendererRichText

        public ConversationRendererRichText(IDisplayOptionsReadOnly displayOptions, IConversation conversation)
            : base(displayOptions, conversation)
        {
            _currentParagraph = null;

            _fileSystem = new OsFileSystem();
        }
开发者ID:jzajac2,项目名称:AllYourTexts,代码行数:7,代码来源:ConversationRendererRichText.cs


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


示例7: TraverseParagraph

 /// <summary>
 /// Traverses only passed paragraph
 /// </summary>
 /// <param name="p"></param>
 public void TraverseParagraph(Paragraph p)
 {
     if (p.Inlines != null && p.Inlines.Count > 0)
     {
         Inline il = p.Inlines.FirstInline;
         while (il != null)
         {
             Run r = il as Run;
             if (r != null)
             {
                 VisualVisited(this, r, true);
                 il = il.NextInline;
                 continue;
             }
             InlineUIContainer uc = il as InlineUIContainer;
             if (uc != null && uc.Child != null)
             {
                 VisualVisited(this, uc.Child, true);
                 il = il.NextInline;
                 continue;
             }
             Figure fg = il as Figure;
             if (fg != null)
             {
                 TraverseBlockCollection(fg.Blocks);
             }
             il = il.NextInline;
         }
     }
 }
开发者ID:Klaudit,项目名称:inbox2_desktop,代码行数:34,代码来源:DocumentWalker.cs


示例8: AddParagraph

 public static Paragraph AddParagraph(this FlowDocument doc, string text)
 {
     var par = new Paragraph();
     par.Inlines.Add(text);
     doc.Blocks.Add(par);
     return par;
 }
开发者ID:kubaszostak,项目名称:KSz.Shared,代码行数:7,代码来源:FlowDocumentEx.cs


示例9: ConvertTextDocumentToBlock

		public static Block ConvertTextDocumentToBlock(TextDocument document, IHighlighter highlighter)
		{
			if (document == null)
				throw new ArgumentNullException("document");
//			Table table = new Table();
//			table.Columns.Add(new TableColumn { Width = GridLength.Auto });
//			table.Columns.Add(new TableColumn { Width = new GridLength(1, GridUnitType.Star) });
//			TableRowGroup trg = new TableRowGroup();
//			table.RowGroups.Add(trg);
			Paragraph p = new Paragraph();
			foreach (DocumentLine line in document.Lines) {
				int lineNumber = line.LineNumber;
//				TableRow row = new TableRow();
//				trg.Rows.Add(row);
//				row.Cells.Add(new TableCell(new Paragraph(new Run(lineNumber.ToString()))) { TextAlignment = TextAlignment.Right });
				HighlightedInlineBuilder inlineBuilder = new HighlightedInlineBuilder(document.GetText(line));
				if (highlighter != null) {
					HighlightedLine highlightedLine = highlighter.HighlightLine(lineNumber);
					int lineStartOffset = line.Offset;
					foreach (HighlightedSection section in highlightedLine.Sections)
						inlineBuilder.SetHighlighting(section.Offset - lineStartOffset, section.Length, section.Color);
				}
//				Paragraph p = new Paragraph();
//				row.Cells.Add(new TableCell(p));
				p.Inlines.AddRange(inlineBuilder.CreateRuns());
				p.Inlines.Add(new LineBreak());
			}
			return p;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:29,代码来源:DocumentPrinter.cs


示例10: CreateTemplateDocument

        public static FlowDocument CreateTemplateDocument(string pattern, Dictionary<string, ParamValue> parameters, ArrayList lines)
        {
            FlowDocument document = new FlowDocument();

            Paragraph paragraph = new Paragraph();
            foreach (string line in lines)
            {
                  MatchCollection matchReturn = Regex.Matches(line, pattern);
                if (matchReturn.Count != 0)
                {
                    int index = 0;
                    foreach (Match match in matchReturn)
                    {
                        paragraph.Inlines.Add(new Run(line.Substring(index, match.Index - index)));
                        index = match.Index + match.Length;

                        TextBlock textBlock = new TextBlock();
                        parameters[match.Value].TextControl.Add(textBlock);
                        textBlock.Text = parameters[match.Value].Value;
                        textBlock.Background = Brushes.Green;
                        paragraph.Inlines.Add(textBlock);
                    }
                    paragraph.Inlines.Add(new Run(line.Substring(index, line.Length - index)));
                }
                else
                {
                    paragraph.Inlines.Add(new Run(line));
                }
                paragraph.Inlines.Add(new LineBreak());
            }
            document.Blocks.Add(paragraph);

            return document;
        }
开发者ID:Finu,项目名称:continuumdump,代码行数:34,代码来源:TemplateHelper.cs


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


示例12: UpdateInlines

        private void UpdateInlines()
        {
            if (this.HightlightedText == null || this.Text == null)
            {
                return;
            }

            var p = new Paragraph();
            var parts = this.Text.Split(new[] { this.HightlightedText }, StringSplitOptions.None);
            for (var i = 0; i < parts.Length; ++i)
            {
                if (i != 0)
                {
                    p.Inlines.Add(new Run()
                    {
                        Text = this.HightlightedText,
                        Background = Brushes.Yellow,
                    });
                }

                p.Inlines.Add(new Run()
                {
                    Text = parts[i],
                    Background = Brushes.Transparent,
                });
            }
            this.TextBlock.Document = new FlowDocument(p);
        }
开发者ID:Koopakiller,项目名称:School,代码行数:28,代码来源:StringPartHighlightBox.xaml.cs


示例13: parse

 public Paragraph parse(string message)
 {
     Paragraph p = new Paragraph();
     p.LineHeight = 1;
     DateTime today = DateTime.Now;
     p.Inlines.Add("(" + today.ToString("HH:mm:ss") + ") ");
     int lastPos = 0;
     foreach (Match match in _regexUrl.Matches(message.Replace(Environment.NewLine,"")))
     {
         if (match.Index != lastPos) {
             // parse smileys before hyperlink
             p = _smiley.insertSmileys(p, message.Substring(lastPos, match.Index - lastPos));
             lastPos = match.Index + match.Length;
             // parse hyperlink
             Hyperlink textLink = new Hyperlink(new Run(match.Value));
             textLink.NavigateUri = new Uri(match.Value);
             textLink.RequestNavigate += new System.Windows.Navigation.RequestNavigateEventHandler(_openHyperlink);
             p.Inlines.Add(textLink);
             lastPos = match.Index + match.Length;
         }
     }
     // wenn text noch nicht zu ende, noch mal nach smileys schauen
     p = _smiley.insertSmileys(p, message.Substring(lastPos));
     return p;
 }
开发者ID:toniertl1988,项目名称:cuddychat,代码行数:25,代码来源:Parser.cs


示例14: Convert

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var text = value as string;
            if (text == null) throw new ArgumentException("Value must be of type string.");
            var fd = new FlowDocument();
            var paragraph = new Paragraph();
            var splitText = text.Split(' ');
            foreach (var word in splitText)
            {
                Uri uri;
                bool result = Uri.TryCreate(word, UriKind.Absolute, out uri) && uri.Scheme == Uri.UriSchemeHttp;
                if (result)
                {
                    var hl = new Hyperlink();
                    hl.Inlines.Add(uri.AbsoluteUri);
                    hl.NavigateUri = uri;
                    paragraph.Inlines.Add(hl);
                    paragraph.Inlines.Add(" ");
                }
                else
                {
                    paragraph.Inlines.Add(word);
                    paragraph.Inlines.Add(" ");
                }
            }

            fd.Blocks.Add(paragraph);

            return fd;
        }
开发者ID:rocky3598,项目名称:OpenChat,代码行数:30,代码来源:StringToIRCFlowDocument.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: insertSmileys

        public Paragraph insertSmileys(Paragraph p, string text)
        {
            int lastPos = 0;
            foreach (Match match in _fixSmileyRegex.Matches(text)) {
                if (match.Index != lastPos) {
                    p.Inlines.Add(text.Substring(lastPos, match.Index - lastPos));
                    // Bild hinzufugen falls vorhanden
                    try {
                        BitmapImage bitmapSmiley = new BitmapImage();
                        bitmapSmiley.BeginInit();
                        bitmapSmiley.UriSource = new Uri("pack://application:,,,/Smileys/" + (string)_fixSmileys[match.Value]);
                        bitmapSmiley.EndInit();
                        System.Windows.Controls.Image smiley = new System.Windows.Controls.Image();
                        smiley.Source = bitmapSmiley;
                        smiley.Width = bitmapSmiley.Width;
                        smiley.Height = bitmapSmiley.Height;
                        smiley.SnapsToDevicePixels = true;
                        ImageBehavior.SetAnimatedSource(smiley, bitmapSmiley);
                        p.Inlines.Add(smiley);
                    }
                    catch (FileNotFoundException)
                    {
                        // Loggen file not found

                        // Text einfuegen statt Smiley
                        p.Inlines.Add(match.Value);
                    }
                    lastPos = match.Index + match.Length;
                }
            }
            if (lastPos < text.Length) {
                p.Inlines.Add(text.Substring(lastPos));
            }
            return p;
        }
开发者ID:toniertl1988,项目名称:cuddychat,代码行数:35,代码来源:Smiley.cs


示例17: InitBox

        private void InitBox()
        {
            msgBox.Document.Blocks.Clear();
            paragraph = new Paragraph();

            msgBox.Document.Blocks.Add(paragraph);
        }
开发者ID:svargy,项目名称:arma3beclient,代码行数:7,代码来源:ChatControl.xaml.cs


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


示例19: InvalidUinMsg

 public static void InvalidUinMsg(Window owner, string uin)
 {
     Paragraph paragraph = new Paragraph();
     AddNormalText(paragraph.Inlines, Global.InvalidUinMsg);
     AddLinkText(paragraph.Inlines, "[详情请点击]", new HyperLinkObj_Url(string.Format("http://exp.qq.com/cgi-bin/present/tec_cgi_index?source_flag=0&uin={0}", uin)));
     IAMessageBox.Show(owner, paragraph.Inlines, "QQ");
 }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:7,代码来源:IMMessageBox.cs


示例20: OnContentChanged

        private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            RichTextBox richTextBox = d as RichTextBox;
            if (richTextBox == null)
                return;

            HtmlDocument content = (HtmlDocument)e.NewValue;
            if (content == null)
                return;

            var HyperlinkForeground = Application.Current.Resources["DefaultGreenBrush"] as SolidColorBrush;
            if (HyperlinkForeground == null)
                HyperlinkForeground = new SolidColorBrush(Color.FromArgb(255, 245, 222, 179));

            richTextBox.Blocks.Clear();
            var p = new Paragraph();
            foreach (var item in content.DocumentNode.ChildNodes)
            {
                var r = new Run();
                if (item.NodeType == HtmlNodeType.Element)
                    r.Foreground = HyperlinkForeground;
                else
                    r.Foreground = richTextBox.Foreground;

                r.Text = item.InnerText;
                p.Inlines.Add(r);
            }
            richTextBox.Blocks.Add(p);


        }
开发者ID:oxcsnicho,项目名称:SanzaiGuokr,代码行数:31,代码来源:RTBNavigationService.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Documents.Run类代码示例发布时间:2022-05-26
下一篇:
C# Documents.List类代码示例发布时间: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