ContextNodeBase.Reparent 方法

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

命名空间:  System.Windows.Ink.AnalysisCore
程序集:  IACore(在 IACore.dll 中)

语法

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

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

参数

示例

此示例获取 TypeLine 的所有 ContextNodeBase 对象,并将这些对象放入其各自的、类型为 ParagraphContextNodeBase 对象中。它使用 InkAnalyzerBase (theInkAnalyzerBase) 中的行,为每一行新建一个段落子节点,将这些行的父级重新设置为这些新段落,然后删除原来的段落。

' Take each line and make it its own paragraph
Dim originalParagraphs As ContextNodeBaseCollection = _
    theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Paragraph)
Dim lines As ContextNodeBaseCollection = _
    theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Line)
Dim lineNode As ContextNodeBase
For Each lineNode In lines
    ' Create a new alignment level and paragraph
    Dim lineParagraph As ContextNodeBase = lineNode.ParentNode
    Dim writingRegion As ContextNodeBase = lineParagraph.ParentNode
    Dim newParagraph As ContextNodeBase = _
        writingRegion.CreateSubNode(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Paragraph)
    ' Reparent the line
    lineNode.Reparent(newParagraph)
Next lineNode
' Remove original paragraphs and alignment nodes
Dim originalParagraph As ContextNodeBase
For Each originalParagraph In originalParagraphs
    Dim originalAlignmentLevel As ContextNodeBase = originalParagraph.ParentNode
    originalAlignmentLevel.DeleteSubNode(originalParagraph)
    originalAlignmentLevel.ParentNode.DeleteSubNode(originalAlignmentLevel)
Next originalParagraph
// Take each line and make it its own paragraph
ContextNodeBaseCollection originalParagraphs =
    theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Paragraph);
ContextNodeBaseCollection lines =
    theInkAnalyzerBase.FindNodesOfType(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Line);
foreach (ContextNodeBase lineNode in lines)
{
    // Create a new paragraph
    ContextNodeBase paragraph = lineNode.ParentNode;
    ContextNodeBase writingRegion = paragraph.ParentNode;
    ContextNodeBase newParagraph =
        writingRegion.CreateSubNode(System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Paragraph);
    // Reparent the line
    lineNode.Reparent(newParagraph);
}
// Remove original paragraphs 
foreach (ContextNodeBase originalParagraph in originalParagraphs)
{
    ContextNodeBase originalWritingRegion = originalParagraph.ParentNode;
    originalWritingRegion.DeleteSubNode(originalParagraph);
}

平台

Windows Vista, Windows XP SP2, Windows Server 2003

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

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

ContextNodeBase 类

ContextNodeBase 成员

System.Windows.Ink.AnalysisCore 命名空间