本文整理汇总了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);
}
}
示例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;
}
}
}
}
示例3: AddToParentParagraph
public Paragraph AddToParentParagraph(Inline text)
{
var paragraph = new Paragraph();
paragraph.Inlines.Add(text);
Add(paragraph);
return paragraph;
}
示例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 });
}
}
示例5: ApplyParagraphStyles
protected static void ApplyParagraphStyles(Paragraph paragraph, ParagraphStyle style)
{
if (style != null)
{
BindingOperations.SetBinding(paragraph, Paragraph.MarginProperty, CreateBinding(style, "Margin"));
ApplyTextStyles(paragraph, style);
}
}
示例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);
}
示例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;
}
示例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));
}
示例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;
}
示例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);
}
示例11: CreateTextBlock
private Block CreateTextBlock(string content)
{
var para = new Paragraph();
var run = new Run() { Text = content };
para.Inlines.Add(run);
return para;
}
示例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);
}
示例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 });
}
}
}
示例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;
}
示例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);
}
}