本文整理汇总了C#中System.Windows.Documents.Paragraph.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# Paragraph.AddChild方法的具体用法?C# Paragraph.AddChild怎么用?C# Paragraph.AddChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.Paragraph
的用法示例。
在下文中一共展示了Paragraph.AddChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildObjectTree
internal object BuildObjectTree()
{
IAddChild root;
switch (_type)
{
case ElementType.Table:
root = new Table();
break;
case ElementType.TableRowGroup:
root = new TableRowGroup();
break;
case ElementType.TableRow:
root = new TableRow();
break;
case ElementType.TableCell:
root = new TableCell();
break;
case ElementType.Paragraph:
root = new Paragraph();
break;
case ElementType.Hyperlink:
Hyperlink link = new Hyperlink();
link.NavigateUri = GetValue(NavigateUriProperty) as Uri;
link.RequestNavigate += new RequestNavigateEventHandler(ClickHyperlink);
AutomationProperties.SetHelpText(link, (String)this.GetValue(HelpTextProperty));
AutomationProperties.SetName(link, (String)this.GetValue(NameProperty));
root = link;
break;
default:
Debug.Assert(false);
root = null;
break;
}
ITextPointer pos = ((ITextPointer)_start).CreatePointer();
while (pos.CompareTo((ITextPointer)_end) < 0)
{
TextPointerContext tpc = pos.GetPointerContext(LogicalDirection.Forward);
if (tpc == TextPointerContext.Text)
{
root.AddText(pos.GetTextInRun(LogicalDirection.Forward));
}
else if (tpc == TextPointerContext.EmbeddedElement)
{
root.AddChild(pos.GetAdjacentElement(LogicalDirection.Forward));
}
else if (tpc == TextPointerContext.ElementStart)
{
object obj = pos.GetAdjacentElement(LogicalDirection.Forward);
if (obj != null)
{
root.AddChild(obj);
pos.MoveToNextContextPosition(LogicalDirection.Forward);
pos.MoveToElementEdge(ElementEdge.BeforeEnd);
}
}
pos.MoveToNextContextPosition(LogicalDirection.Forward);
}
return root;
}