ContextNode.Reparent 方法

将此 ContextNode 从其当前父级移除,并将其添加到另一个父级。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)

语法

声明
Public Sub Reparent ( _
    newParentNode As ContextNode _
)
用法
Dim instance As ContextNode
Dim newParentNode As ContextNode

instance.Reparent(newParentNode)
public void Reparent(
    ContextNode newParentNode
)
public:
void Reparent(
    ContextNode^ newParentNode
)
public void Reparent(
    ContextNode newParentNode
)
public function Reparent(
    newParentNode : ContextNode
)

参数

示例

此示例将所有行放入各自的段落中。它使用 InkAnalyzer (theInkAnalyzer) 中的行,为每一行新建一个段落子节点,将这些行的父级重新设置为这些新段落,然后删除原来的段落。

' Take each line and make it its own paragraph
Dim originalParagraphs As ContextNodeCollection = _
    theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Paragraph)
Dim lines As ContextNodeCollection = _
    theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Line)
Dim lineNode As ContextNode
For Each lineNode In lines
    ' Create a new alignment level and paragraph
    Dim lineParagraph As ContextNode = lineNode.ParentNode
    Dim writingRegion As ContextNode = lineParagraph.ParentNode
    Dim newParagraph As ParagraphNode = _
        CType(writingRegion.CreateSubNode(Microsoft.Ink.ContextNodeType.Paragraph), ParagraphNode)
    ' Reparent the line
    lineNode.Reparent(newParagraph)
Next lineNode
' Remove original paragraphs and alignment nodes
Dim originalParagraph As ContextNode
For Each originalParagraph In originalParagraphs
    Dim originalAlignmentLevel As ContextNode = originalParagraph.ParentNode
    originalAlignmentLevel.DeleteSubNode(originalParagraph)
    originalAlignmentLevel.ParentNode.DeleteSubNode(originalAlignmentLevel)
Next originalParagraph
            // Take each line and make it its own paragraph
            ContextNodeCollection originalParagraphs = 
                theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Paragraph);
            ContextNodeCollection lines = 
                theInkAnalyzer.FindNodesOfType(Microsoft.Ink.ContextNodeType.Line);
            foreach (ContextNode lineNode in lines)
            {
                // Create a new paragraph
                ContextNode paragraph = lineNode.ParentNode;
                ContextNode writingRegion = paragraph.ParentNode;
                ParagraphNode newParagraph = (ParagraphNode)
                    writingRegion.CreateSubNode(Microsoft.Ink.ContextNodeType.Paragraph);
                // Reparent the line
                lineNode.Reparent(newParagraph);
            }
            // Remove original paragraphs 
            foreach (ContextNode originalParagraph in originalParagraphs)
            {
                ContextNode originalWritingRegion = originalParagraph.ParentNode;
                originalWritingRegion.DeleteSubNode(originalParagraph);
            }

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

ContextNode 类

ContextNode 成员

Microsoft.Ink 命名空间