Share via


ContextNode.CreatePartiallyPopulatedSubNode Method

Creates a child ContextNode object that contains only the following information: Type, Id, and Location.

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

Syntax

'Declaration
Public Function CreatePartiallyPopulatedSubNode ( _
    type As Guid, _
    nodeId As Guid, _
    nodeLocation As AnalysisRegion _
) As ContextNode
'Usage
Dim instance As ContextNode 
Dim type As Guid 
Dim nodeId As Guid 
Dim nodeLocation As AnalysisRegion 
Dim returnValue As ContextNode 

returnValue = instance.CreatePartiallyPopulatedSubNode(type, _
    nodeId, nodeLocation)
public ContextNode CreatePartiallyPopulatedSubNode(
    Guid type,
    Guid nodeId,
    AnalysisRegion nodeLocation
)
public:
ContextNode^ CreatePartiallyPopulatedSubNode(
    Guid type, 
    Guid nodeId, 
    AnalysisRegion^ nodeLocation
)
public function CreatePartiallyPopulatedSubNode(
    type : Guid, 
    nodeId : Guid, 
    nodeLocation : AnalysisRegion
) : ContextNode

Parameters

  • nodeId
    Type: System.Guid

    The identifier for the new node.

Return Value

Type: Microsoft.Ink.ContextNode
A new ContextNode object that contains only information about Type, Id, and Location. This new node is a child of the ContextNode.

Remarks

This method is used for data proxy as a way to create a ContextNode object in the context node tree before all the information about it is available. The other information about it can be added at a later point.

Examples

The following example is a method called CreatePartiallyPopulatedNode, from sample code that uses a System.Windows.Forms.TreeView as a document model to show how data proxy can be used to store and load a context node tree for an InkAnalyzer. The DocumentNodeData class stores the ContextNode data in the document model by setting the Tag property of each TreeNode object to a DocumentNodeData object. The CreatePartiallyPopulatedNode method uses a TreeNode object and an InkAnalyzer object to create the partially populated node in the InkAnalyzer context node tree that corresponds to the TreeNode in the document model. In this sample, all the nodes are created as partially populated. They are then placed in a queue of nodes to later be fully populated with all the node data.

The method first obtains the node data from the Tag property of the TreeNode object that is passed in. Then it uses the Id to verify that the node is not currently in the context node tree. It then uses the tree view parent node to find the corresponding parent node in the InkAnalyzer. If the parent node does not yet exist in the context node tree, it is added using recursion. If the parent node does exist in the tree, it should be partially populated; if it were fully populated, it would already contain all its subnodes and there would be no need to add a new one. Therefore, the PartiallyPopulated property verifies that the parent node is partially populated, in which case it is added to a queue to later populate fully. If it is not partially populated, an exception is thrown. Finally, CreatePartiallyPopulatedSubNode is called on the parent node and the newly created node is added to the queue of nodes to be fully populated. The new ContextNode object is returned. For more information about data proxy, see the Data Proxy with Ink Analysis.

Private Function CreatePartiallyPopulatedNode(ByVal documentNode As TreeNode, _
    ByVal theInkAnalyzer As Microsoft.Ink.InkAnalyzer) As Microsoft.Ink.ContextNode

    Dim nodeData As DocumentNodeData = documentNode.Tag '

    ' Check that the node does not already exist in the InkAnalyzer. 
    If Nothing <> theInkAnalyzer.FindNode(nodeData.Id) Then 
        Throw New ApplicationException("The node already exists in the InkAnalyzer.")
    End If 

    ' Find the parent analyzer node. 
    Dim parentNodeData As DocumentNodeData = documentNode.Parent.Tag

    Dim analyzerParentNode As Microsoft.Ink.ContextNode = _
        theInkAnalyzer.FindNode(parentNodeData.Id)

    If Nothing = analyzerParentNode Then 
        ' The parent analyzer node does not exist yet. Create one.
        analyzerParentNode = Me.CreatePartiallyPopulatedNode(documentNode.Parent, theInkAnalyzer)
    ElseIf analyzerParentNode.PartiallyPopulated Then 
        ' The parent analyzer node exists and is partially populated. Add it 
        ' to the stack of nodes to fully populate. 
        Me.QueueNodeToPopulate(analyzerParentNode)
    Else 
        ' The parent analyzer node exists and is fully populated. This 
        ' should not happen. 
        Throw New ApplicationException("The parent analyzer node is fully populated.")
    End If 

    ' Create the partially populated node under its parent analyzer node. 
    Dim analyzerNode As Microsoft.Ink.ContextNode = _
        analyzerParentNode.CreatePartiallyPopulatedSubNode(nodeData.Type, _
        nodeData.Id, nodeData.Location)

    ' Add the new node to the stack of nodes to fully populate. 
    Me.QueueNodeToPopulate(analyzerNode)

    Return analyzerNode

End Function 'CreatePartiallyPopulatedNode
      private Microsoft.Ink.ContextNode CreatePartiallyPopulatedNode(
            TreeNode documentNode, Microsoft.Ink.InkAnalyzer theInkAnalyzer)
        {
            DocumentNodeData nodeData = documentNode.Tag as DocumentNodeData;

            // Check that the node does not already exist in the InkAnalyzer. 
            if (null != theInkAnalyzer.FindNode(nodeData.Id))
            {
                throw new ApplicationException(
                    "The node already exists in the InkAnalyzer.");
            }

            // Find the parent analyzer node.
            DocumentNodeData parentNodeData =
                documentNode.Parent.Tag as DocumentNodeData;
            Microsoft.Ink.ContextNode analyzerParentNode =
                theInkAnalyzer.FindNode(parentNodeData.Id);
            if (null == analyzerParentNode)
            {
                // The parent analyzer node does not exist yet. Create one.
                analyzerParentNode =
                    this.CreatePartiallyPopulatedNode(
                        documentNode.Parent, theInkAnalyzer);
            }
            else if (analyzerParentNode.PartiallyPopulated)
            {
                // The parent analyzer node exists and is partially populated. Add it 
                // to the stack of nodes to fully populate. 
                this.QueueNodeToPopulate(analyzerParentNode);
            }
            else
            {
                // The parent analyzer node exists and is fully populated. This 
                // should not happen. 
                throw new ApplicationException(
                    "The parent analyzer node is fully populated.");
            }

            // Create the partially populated node under its parent analyzer node.
            Microsoft.Ink.ContextNode analyzerNode =
                analyzerParentNode.CreatePartiallyPopulatedSubNode(
                    nodeData.Type, nodeData.Id, nodeData.Location);

            // Add the new node to the stack of nodes to fully populate. 
            this.QueueNodeToPopulate(analyzerNode);

            return analyzerNode;
        }

Platforms

Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008

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

See Also

Reference

ContextNode Class

ContextNode Members

Microsoft.Ink Namespace

ContextNode.PartiallyPopulated

Microsoft.Ink.ContextNodeType