Freigeben über


ContextNode.CreateSubNode-Methode

Erstellt ein neues untergeordnetes ContextNode-Objekt.

Namespace:  Microsoft.Ink
Assembly:  Microsoft.Ink.Analysis (in Microsoft.Ink.Analysis.dll)

Syntax

'Declaration
Public Function CreateSubNode ( _
    type As Guid _
) As ContextNode
'Usage
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

Parameter

  • type
    Typ: System.Guid
    Der Typ des zu erstellenden Kontextknotens. Verwenden Sie zur Angabe des zu erstellenden Typs eine der GUIDs, die in der ContextNodeType-Klasse definiert sind.

Rückgabewert

Typ: Microsoft.Ink.ContextNode
Das neu erstellte ContextNode-Objekt, dessen übergeordnetes Element dieser ContextNode ist.

Hinweise

Wenn bereits untergeordnete Knoten vorhanden sind, wird der neu erstellte ContextNode als letzter untergeordneter Knoten in die Auflistung derSubNodes aufgenommen.

Wenn Ihre Anwendung versehentlich versucht, einen falschen Knoten hinzuzufügen – beispielsweise einen Schreibbereich anstelle eines erwarteten ImageNode-Knotens –, dann löst der Code eine Ausnahme von CreateSubNode aus.

Beispiele

In diesem Beispiel werden alle Zeilen in eigene Absätze eingefügt. Es verwendet die Zeilen eines InkAnalyzer mit dem Namen theInkAnalyzer;, erstellt einen neuen Absatz-Unterknoten für jeden von ihnen und ordnet die Zeilen denen der neuen Absätze zu.

' 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);
            }

Plattformen

Windows Vista

.NET Framework und .NET Compact Framework unterstützen nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen für .NET Framework.

Versionsinformationen

.NET Framework

Unterstützt in: 3.0

Siehe auch

Referenz

ContextNode-Klasse

ContextNode-Member

Microsoft.Ink-Namespace

ContextNode.DeleteSubNode

Microsoft.Ink.ContextNodeType