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


C# Documents.Paragraph类代码示例

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


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

示例1: DisplayMessage

        private void DisplayMessage()
        {
            ChatMessage msg = null;
            while ((msg = DequeueChatMessage()) != null)
            {
                // create the paragraph
                Paragraph p = new Paragraph();
                Run rnMyText = new Run();
                p.FontWeight = FontWeights.Bold;

                // if the message is from the currently logged in user, then set the color to gray
                if (msg.From == _username)
                {
                    p.Foreground = new SolidColorBrush(Colors.Gray);
                    rnMyText.Text = string.Format("{0} (me): {1}", msg.From, msg.MessageText);
                }
                else
                {
                    p.Foreground = new SolidColorBrush(Colors.Green);
                    rnMyText.Text = string.Format("{0}: {1}", msg.From, msg.MessageText);
                }

                // add the text to the paragraph tag
                p.Inlines.Add(rnMyText);

                // add the paragraph to the rich text box
                rtbChatLog.Blocks.Add(p);
            }
        }
开发者ID:jixer,项目名称:wcf-windows-8-web-sockets,代码行数:29,代码来源:ChatRoom.xaml.cs

示例2: FixUpXaml

        public static void FixUpXaml(Paragraph paragraph)
        {
            for(int i = 0; i < paragraph.Inlines.Count; i++)
            {
                Inline inline = paragraph.Inlines[i];
                ImageInline imageInline;
                if (TryCreate(inline, out imageInline))
                {
                    BitmapImage bi = new BitmapImage(new Uri(imageInline.FilePath));
                    Image image = new Image();
                    image.Source = bi;
                    image.Stretch = Stretch.Uniform;
                    InlineUIContainer container = new InlineUIContainer();
                    image.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
                    image.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center;
                    image.Stretch = Stretch.Uniform;
                    container.Child = image;
                    paragraph.Inlines[i] = container;

                    // if this is an image only paragraph. Center it
                    if (paragraph.Inlines.Count == 1)
                    {
                        paragraph.TextAlignment = Windows.UI.Xaml.TextAlignment.Center;
                    }
                }
            }
        }
开发者ID:kasparov,项目名称:StoryTeller,代码行数:27,代码来源:ImageInline.cs

示例3: AddToParentParagraph

 public Paragraph AddToParentParagraph(Inline text)
 {
     var paragraph = new Paragraph();
     paragraph.Inlines.Add(text);
     Add(paragraph);
     return paragraph;
 }
开发者ID:Prog-Party,项目名称:ProgParty.BoredPanda,代码行数:7,代码来源:RichTextBlockTextContainer.cs

示例4: OnStatusChanged

        private static void OnStatusChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var parent = (RichTextBlock)sender;
            parent.Blocks.Clear();

            var atSomeonePattern = new Regex(@"(?<someone>\@[^#\@\s\b\n\r\0:,.;!?'""。,:;!?”“‘’]+)");
            var text = e.NewValue as string;
            var ms = atSomeonePattern.Matches(text);

            int nextOffset = 0;
            var paragraph = new Paragraph();
            parent.Blocks.Add(paragraph);

            foreach (Match m in ms)
            {
                paragraph.Inlines.Add(new Run { Text = text.Substring(nextOffset, m.Index - nextOffset) });
                paragraph.Inlines.Add(new Run { Text = m.Groups["someone"].Value, Foreground = AtPatternColorBrush });
                nextOffset = m.Index + m.Length;
            }

            if (nextOffset == 0)
            {
                paragraph.Inlines.Add(new Run { Text = text });
            }
        }
开发者ID:JDCB,项目名称:JDCB,代码行数:25,代码来源:StatusConverter.cs

示例5: ApplyParagraphStyles

 protected static void ApplyParagraphStyles(Paragraph paragraph, ParagraphStyle style)
 {
     if (style != null)
     {
         BindingOperations.SetBinding(paragraph, Paragraph.MarginProperty, CreateBinding(style, "Margin"));
         ApplyTextStyles(paragraph, style);
     }
 }
开发者ID:ridomin,项目名称:waslibs,代码行数:8,代码来源:HtmlWriter.cs

示例6: appendLog

 /// <summary>
 /// Helper to create log entries
 /// </summary>
 /// <param name="logEntry"></param>
 void appendLog(string logEntry, Color c)
 {
     Run r = new Run();
     r.Text = logEntry;
     Paragraph p = new Paragraph();
     p.Foreground = new SolidColorBrush(c);
     p.Inlines.Add(r);
     logResults.Blocks.Add(p);
 }
开发者ID:ckc,项目名称:WinApp,代码行数:13,代码来源:Scenario6_ScriptNotify.xaml.cs

示例7: LandingPage

 public LandingPage()
 {
     this.InitializeComponent();
     TopAppBar = NavigationBar.GetNavBar();
     var paragraph = new Paragraph();
     paragraph.Inlines.Add(new Run {Text = "Welcomming text"});
     RichTextBlock_main.Blocks.Add(paragraph);
     RichTextBlock_main.IsTextSelectionEnabled = false;
 }
开发者ID:Toudahl,项目名称:SoftwareDesignHelper,代码行数:9,代码来源:LandingPage.xaml.cs

示例8: RenderElement

 public virtual void RenderElement(IElement element, ITextContainer parent, RenderContextBase context)
 {
     var paragraph = new Paragraph()
     {
         TextAlignment = TextAlignment.Center
     };
     parent.Add(paragraph);
     context.RenderNode(element, new ParagraphContainer(paragraph));
 }
开发者ID:sahirmemon,项目名称:SoftwareKobo.HtmlRender,代码行数:9,代码来源:CenterRender.cs

示例9: RefreshView

        private void RefreshView()
        {
            // anything?
            if (string.IsNullOrEmpty(Markup))
            {
                this.Content = null;
                return;
            }

            // get the lines...
            var lines = new List<string>();
            using (var reader = new StringReader(this.Markup))
            {
                while(true)
                {
                    string buf = reader.ReadLine();
                    if (buf == null)
                        break;
                    lines.Add(buf);
                }
            }

            // walk...
            var block = new RichTextBlock();
            for (int index = 0; index < lines.Count; index++)
            {
                string nextLine = null;
                if (index < lines.Count - 1)
                    nextLine = lines[index + 1];

                // create a paragraph... and add it to the block...
                var para = new Paragraph();
                block.Blocks.Add(para);

                // create a "run" and add it to the paragraph...
                var run = new Run();
                run.Text = lines[index];
                para.Inlines.Add(run);

                // heading?
                if (nextLine != null && nextLine.StartsWith("="))
                {
                    // make it bigger, and then skip the next line...
                    para.FontSize = 20;
                    index++;
                }
                else if (nextLine != null && nextLine.StartsWith("-"))
                {
                    para.FontSize = 18;
                    index++;
                }
            }

            // set...
            this.Content = block;
        }
开发者ID:jimgrant,项目名称:ProgrammingWindowsStoreApps,代码行数:56,代码来源:MarkupViewer.cs

示例10: OnPlainTextChanged

 /// <summary>
 /// Handles changes to the PlainText property.
 /// </summary>
 /// <param name="d">
 /// The <see cref="DependencyObject"/> on which
 /// the property has changed value.
 /// </param>
 /// <param name="e">
 /// Event data that is issued by any event that
 /// tracks changes to the effective value of this property.
 /// </param>
 private static void OnPlainTextChanged(
     DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     string oldPlainText = (string)e.OldValue;
     string newPlainText = (string)d.GetValue(PlainTextProperty);
     ((RichTextBlock)d).Blocks.Clear();
     var paragraph = new Paragraph();
     paragraph.Inlines.Add(new Run { Text = newPlainText });
     ((RichTextBlock)d).Blocks.Add(paragraph);
 }
开发者ID:kasparov,项目名称:StoryTeller,代码行数:21,代码来源:RichTextBlockExtensions.cs

示例11: CreateTextBlock

        private Block CreateTextBlock(string content)
        {
            var para = new Paragraph();

            var run = new Run() { Text = content };

            para.Inlines.Add(run);

            return para;
        }
开发者ID:twfx7758,项目名称:DoubanGroup.UWP,代码行数:10,代码来源:TopicContentBehavior.cs

示例12: EscribirEnRichTextBox

        void EscribirEnRichTextBox(string texto, RichTextBlock rtb)
        {
            rtb.Blocks.Clear();

            Run run = new Run();
            run.Text = texto;

            Paragraph parrafo = new Paragraph();
            parrafo.Inlines.Add(run);

            rtb.Blocks.Add(parrafo);
        }
开发者ID:icebeam7,项目名称:Ahorcado_Estados,代码行数:12,代码来源:DetalleEstado.xaml.cs

示例13: OnTextContent

        public static void OnTextContent(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var richText = (RichTextBlock)d;
            var textContent = (string)e.NewValue;

            richText.Blocks.Clear();

            if(string.IsNullOrEmpty(textContent)) {
                return;
            }
            var paragraph = new Paragraph();
            richText.Blocks.Add(paragraph);

            var matches = UrlRegex.Matches(textContent);
            if(matches.Count == 0) {
                paragraph.Inlines.Add(new Run { Text = textContent });
                return;
            }
            int index = 0;
            foreach(Match match in matches) {
                Uri uri = null;
                Uri.TryCreate(match.Value, UriKind.Absolute, out uri);
                if(match.Index > 0) {
                    var length = match.Index - index;
                    if(length > 0) {
                        paragraph.Inlines.Add(new Run { Text = textContent.Substring(index, length) });
                    }
                }

                var underline = new Underline();
                underline.Inlines.Add(new Run { Text = uri.Host });
                var linkContent = new TextBlock();
                linkContent.Inlines.Add(underline);
                var hyperlink = new HyperlinkButton {
                    NavigateUri = uri,
                    Content = linkContent,
                    Style = (Style)Application.Current.Resources["TextButtonStyle"],
                    Margin = new Thickness(0, 0, 0, -4)
                };
                paragraph.Inlines.Add(
                    new InlineUIContainer {
                        Child = hyperlink
                    });
                index = match.Index + match.Length;
            }
            if(index < textContent.Length - 1) {
                var lastRunText = textContent.Substring(index);
                if(lastRunText.Length > 0) {
                    paragraph.Inlines.Add(new Run { Text = lastRunText });
                }
            }
        }
开发者ID:k0st1x,项目名称:JuickW8,代码行数:52,代码来源:RichTextBlockBehavior.cs

示例14: Convert

        public object Convert(object value, Type targetType, object parameter, string language)
        {
            var source = (value as string) ?? string.Empty;
            try
            {
                return Parse(source);
            }
            catch (Exception uiEx) { Frontend.UIError(uiEx); }

            var p = new Paragraph();
            p.Inlines.Add(new Run() { Text = source });
            return p;
        }
开发者ID:peterluo0822,项目名称:Chat,代码行数:13,代码来源:ConversationConverter.cs

示例15: Add

 public virtual void Add(Inline inline)
 {
     var paragraph = _richTextBlock.Blocks.LastOrDefault() as Paragraph;
     if (paragraph == null)
     {
         paragraph = new Paragraph();
         paragraph.Inlines.Add(inline);
         Add(paragraph);
     }
     else
     {
         paragraph.Inlines.Add(inline);
     }
 }
开发者ID:sahirmemon,项目名称:SoftwareKobo.HtmlRender,代码行数:14,代码来源:RichTextBlockContainer.cs


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