Partager via


ContextNode.Reparent, méthode

Mise à jour : November 2007

Supprime ce ContextNode de son parent actuel et l'ajoute à un autre parent.

Espace de noms :  Microsoft.Ink
Assembly :  Microsoft.Ink.Analysis (dans Microsoft.Ink.Analysis.dll)

Syntaxe

'Déclaration
Public Sub Reparent ( _
    newParentNode As ContextNode _
)
'Utilisation
Dim instance As ContextNode
Dim newParentNode As ContextNode

instance.Reparent(newParentNode)
public void Reparent(
    ContextNode newParentNode
)
public:
void Reparent(
    ContextNode^ newParentNode
)
public void Reparent(
    ContextNode newParentNode
)
public function Reparent(
    newParentNode : ContextNode
)

Paramètres

Exemples

Cet exemple place toutes les lignes dans leurs paragraphes respectifs. Il utilise les lignes d'un InkAnalyzer. theInkAnalyzer;, crée un sous-nœud de paragraphe pour chacun d'eux et assigne les lignes à ces nouveaux paragraphes avant de supprimer les paragraphes d'origine.

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

Plateformes

Windows Vista

Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Informations de version

.NET Framework

Pris en charge dans : 3.0

Voir aussi

Référence

ContextNode, classe

Membres ContextNode

Microsoft.Ink, espace de noms