ContextNode.CreateSubNode 方法

创建一个新的子 ContextNode 对象。

命名空间:  Microsoft.Ink
程序集:  Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.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
    要创建的上下文节点的类型。使用 ContextNodeType 类中定义的某个 GUID 指定要创建的类型。

返回值

类型:Microsoft.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(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 命名空间

ContextNode.DeleteSubNode

Microsoft.Ink.ContextNodeType