本文整理汇总了C#中RenderContext.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# RenderContext.Clone方法的具体用法?C# RenderContext.Clone怎么用?C# RenderContext.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RenderContext
的用法示例。
在下文中一共展示了RenderContext.Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderQuote
/// <summary>
/// Renders a quote element.
/// </summary>
/// <param name="element"></param>
/// <param name="blockUIElementCollection"></param>
private void RenderQuote(QuoteBlock element, UIElementCollection blockUIElementCollection, RenderContext context)
{
if (QuoteForeground != null)
{
context = context.Clone();
context.Foreground = QuoteForeground;
}
var stackPanel = new StackPanel();
RenderBlocks(element.Blocks, stackPanel.Children, context);
var border = new Border();
border.Margin = QuoteMargin;
border.Background = QuoteBackground;
border.BorderBrush = QuoteBorderBrush ?? context.Foreground;
border.BorderThickness = QuoteBorderThickness;
border.Padding = QuotePadding;
border.Child = stackPanel;
blockUIElementCollection.Add(border);
}
示例2: RenderMarkdownLink
/// <summary>
/// Renders a link element
/// </summary>
/// <param name="inlineCollection"> The list to add to. </param>
/// <param name="element"> The parsed inline element to render. </param>
/// <param name="parent"> The container element. </param>
/// <param name="context"> Persistent state. </param>
private void RenderMarkdownLink(InlineCollection inlineCollection, MarkdownLinkInline element, TextElement parent, RenderContext context)
{
// Avoid crash when link text is empty.
if (element.Inlines.Count == 0)
return;
// Attempt to resolve references.
element.ResolveReference(this.document);
if (element.Url == null)
{
// The element couldn't be resolved, just render it as text.
RenderInlineChildren(inlineCollection, element.Inlines, parent, context);
return;
}
// HACK: Superscript is not allowed within a hyperlink. But if we switch it around, so
// that the superscript is outside the hyperlink, then it will render correctly.
// This assumes that the entire hyperlink is to be rendered as superscript.
if (AllTextIsSuperscript(element) == false)
{
// Regular ol' hyperlink.
var link = new Hyperlink();
// Register the link
this.linkRegister.RegisterNewHyperLink(link, element.Url);
// Remove superscripts.
RemoveSuperscriptRuns(element, insertCaret: true);
// Render the children into the link inline.
var childContext = context.Clone();
childContext.WithinHyperlink = true;
RenderInlineChildren(link.Inlines, element.Inlines, link, childContext);
context.TrimLeadingWhitespace = childContext.TrimLeadingWhitespace;
// Add it to the current inlines
inlineCollection.Add(link);
}
else
{
// THE HACK IS ON!
// Create a fake superscript element.
var fakeSuperscript = new SuperscriptTextInline();
fakeSuperscript.Inlines = new List<MarkdownInline> { element };
// Remove superscripts.
RemoveSuperscriptRuns(element, insertCaret: false);
// Now render it.
RenderSuperscriptRun(inlineCollection, fakeSuperscript, parent, context);
}
}