本文整理汇总了C#中System.Windows.Documents.Run.SetResourceReference方法的典型用法代码示例。如果您正苦于以下问题:C# Run.SetResourceReference方法的具体用法?C# Run.SetResourceReference怎么用?C# Run.SetResourceReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.Run
的用法示例。
在下文中一共展示了Run.SetResourceReference方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decorate
/// <summary>
/// Transform collection of inlines
/// </summary>
public List<Inline> Decorate(IConferenceMessage msg, List<Inline> inlines)
{
string style = "timestampStyle";
var timestampInline = new Run(msg.Timestamp.ToString("[hh:mm:ss] "));
timestampInline.SetResourceReference(FrameworkContentElement.StyleProperty, style);
inlines.Insert(0, timestampInline);
return inlines;
}
示例2: Decorate
public static Inline Decorate(IConferenceMessage msg, string message)
{
string style = "commonMessageStyle";
if (msg is SystemConferenceMessage)
style = "systemMessageStyle";
if (msg is SystemConferenceMessage && ((SystemConferenceMessage)msg).IsErrorMessage)
style = "errorMessageStyle";
Run messageInline = new Run(message);
messageInline.SetResourceReference(FrameworkContentElement.StyleProperty, style);
return messageInline;
}
示例3: Decorate
/// <summary>
/// Transform collection of inlines
/// </summary>
public List<Inline> Decorate(IConferenceMessage msg, List<Inline> inlines)
{
string style = "nickStyle";
string nick = msg.Author;
if (string.IsNullOrEmpty(msg.Author))
{
style = "systemNickStyle";
nick = "System";
}
Run nickInline = new Run(string.Format("{0}: ", nick));
nickInline.SetResourceReference(FrameworkContentElement.StyleProperty, style);
inlines.Insert(0, nickInline);
return inlines;
}
示例4: Render
/// <summary>
/// Renders the specified chat node to the client.
/// </summary>
/// <param name="node">The node to append.</param>
/// <remarks>
/// <para>The return value of this function is a reference to the outermost <see cref="Inline">Inline</see> constructed
/// by this function. It may create additional inner elements as needed.</para>
/// </remarks>
/// <returns>
/// Returns an object instance of <see cref="Inline">Inline</see> that can be appended to the HTML document.
/// </returns>
public virtual Inline Render(ChatNode node)
{
Inline result;
if (node == ChatNode.NewLine)
{
result = new LineBreak();
}
else if (node.LinkUri == null)
{
Run run = new Run();
if (node.CssClass != null)
{
run.Style = ResourceProvider[node.CssClass] as Style;
run.SetResourceReference(FrameworkContentElement.StyleProperty, node.CssClass);
}
else if (node.Color != GdiColor.Empty)
{
run.Foreground = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, node.Color.R, node.Color.G, node.Color.B));
}
run.Text = node.Text;
result = run;
}
else // need to make a link.
{
Hyperlink link = new Hyperlink();
link.Inlines.Add(new Run(node.Text));
link.NavigateUri = node.LinkUri;
if (node.CssClass != null)
{
link.SetResourceReference(FrameworkContentElement.StyleProperty, node.CssClass);
}
else if (node.Color != GdiColor.Empty)
{
link.Foreground = new SolidColorBrush(WpfColor.FromArgb(255, node.Color.R, node.Color.G, node.Color.B));
}
link.ToolTip = string.Format(CultureInfo.CurrentUICulture, "Link to {0}", node.LinkUri.ToString());
result = link;
}
return result;
}
示例5: InsertWriter
private static void InsertWriter(ICollection<Inline> textblock, Token t)
{
var name = t.text;
if (string.IsNullOrEmpty(name))
return;
var run = new Run(t.text);
run.SetResourceReference(Control.ForegroundProperty, "MetroColorFeatureBrush");
textblock.Add(run);
textblock.Add(new Run(":"));
}