Поделиться через


ContextNode.CreateSubNode - метод

Обновлен: Ноябрь 2007

Creates a new child ContextNode object.

Пространство имен:  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
    The type of context node to create. Use one of the GUIDs defined in the ContextNodeType class to specify which type to create.

Возвращаемое значение

Тип: Microsoft.Ink.ContextNode
The newly created ContextNode object whose parent is this ContextNode.

Заметки

When existing child nodes already exist, the newly created ContextNode is added as the last child in the collection of SubNodes.

If your application inadvertently tries to add an improper node—for example, a writing region where an ImageNode node is expected—the code throws an exception from CreateSubNode.

Примеры

This example puts all the lines into their own paragraphs. It uses the lines from an InkAnalyzer, theInkAnalyzer; creates a new paragraph subnode for each of them; and reparents the lines to those new paragraphs.

' 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