ContextNode.DeleteSubNode 方法

删除一个子 ContextNode 对象。

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

语法

声明
Public Sub DeleteSubNode ( _
    subNodeToDelete As ContextNode _
)
用法
Dim instance As ContextNode
Dim subNodeToDelete As ContextNode

instance.DeleteSubNode(subNodeToDelete)
public void DeleteSubNode(
    ContextNode subNodeToDelete
)
public:
void DeleteSubNode(
    ContextNode^ subNodeToDelete
)
public void DeleteSubNode(
    ContextNode subNodeToDelete
)
public function DeleteSubNode(
    subNodeToDelete : ContextNode
)

参数

备注

如果 subNodeToDelete 不是此 ContextNode 的子级,则会引发 ArgumentException

示例

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

' Take each line and make it its own paragraph
Dim originalParagraphs As ContextNodeCollection = _
    theInkAnalyzer.FindNodesOfType(ContextNodeType.Paragraph)

Dim lines As ContextNodeCollection = _
    theInkAnalyzer.FindNodesOfType(ContextNodeType.Line)

For Each lineNode As ContextNode In lines
    ' Create a new paragraph
    Dim paragraph As ContextNode = lineNode.ParentNode
    Dim writingRegion As ContextNode = paragraph.ParentNode
    Dim newParagraph As ParagraphNode = CType(writingRegion.CreateSubNode(ContextNodeType.Paragraph), ParagraphNode)
    ' Reparent the line
    lineNode.Reparent(newParagraph)
Next lineNode

' Remove original paragraphs 
For Each originalParagraph As ContextNode In originalParagraphs
    Dim originalWritingRegion As ContextNode = originalParagraph.ParentNode
    originalWritingRegion.DeleteSubNode(originalParagraph)
Next originalParagraph
// Take each line and make it its own paragraph
ContextNodeCollection originalParagraphs =
    theInkAnalyzer.FindNodesOfType(ContextNodeType.Paragraph);
ContextNodeCollection lines =
    theInkAnalyzer.FindNodesOfType(ContextNodeType.Line);
foreach (ContextNode lineNode in lines)
{
    // Create a new paragraph
    ContextNode paragraph = lineNode.ParentNode;
    ContextNode writingRegion = paragraph.ParentNode;
    ParagraphNode newParagraph = (ParagraphNode)
        writingRegion.CreateSubNode(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 成员

System.Windows.Ink 命名空间

ContextNode.CreateSubNode