當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。