ContextNode.CreateSubNode Method
Creates a new child ContextNode object.
Namespace: System.Windows.Ink
Assembly: IAWinFX (in IAWinFX.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 function CreateSubNode(
type : Guid
) : ContextNode
Parameters
type
Type: System.GuidThe type of context node to create.
Return Value
Type: System.Windows.Ink.ContextNode
The newly created ContextNode object has the [T:System.Windows.Ink.ContextNode as its parent].
Remarks
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.
Examples
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(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);
}
Platforms
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information
.NET Framework
Supported in: 3.0