ContextNode.CreateSubNode 方法

创建一个新的子 ContextNode 对象。

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

语法

声明
Public Function CreateSubNode ( _
    type As Guid _
) As ContextNode
用法
Dim instance As ContextNode
Dim type As Guid
Dim returnValue As ContextNode

returnValue = instance.CreateSubNode(type)
public ContextNode CreateSubNode(
    Guid type
)
public:
ContextNode^ CreateSubNode(
    Guid type
)
public ContextNode CreateSubNode(
    Guid type
)
public function CreateSubNode(
    type : Guid
) : ContextNode

参数

  • type
    类型:System.Guid
    要创建的上下文节点的类型。

返回值

类型:System.Windows.Ink.ContextNode
新创建的 ContextNode 对象将当前 ContextNode 作为其父节点。

备注

如果存在现有子节点,新创建的 ContextNode 将添加为 SubNodes 集合中的最后一个子级。

如果应用程序意外尝试添加不正确的节点(例如一个需要 ImageNode 节点的书写区域),则代码将从 CreateSubNode 引发异常。

示例

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

' 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.DeleteSubNode