ContextNode.CreatePartiallyPopulatedSubNode Method
Creates a child ContextNode object that contains only the following information: Type, Id, and Location.
Namespace: System.Windows.Ink
Assembly: IAWinFX (in IAWinFX.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
type
Type: System.GuidThe type of ContextNode object that is created.
nodeId
Type: System.GuidThe identifier for the new node.
nodeLocation
Type: System.Windows.Ink.AnalysisRegionThe location of the new node.
Return Value
Type: System.Windows.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, that uses a [System.Windows.Controls.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 ContextNode data in the document model by setting the [System.Windows.FrameworkElement.Tag] property of each TreeViewItem object to a DocumentNodeData object. The CreatePartiallyPopulatedNode method uses a TreeViewItem object and an InkAnalyzer object to create the partially populated node in the InkAnalyzer context node tree that corresponds to the TreeViewItem in the document model. In this sample, all the nodes are created as partially populated. They are then placed in a queue of nodes that is fully populated with node data at a later date.
The method obtains node data from the [System.Windows.FrameworkElement.Tag] property of the TreeViewItem object that is passed in. Then the method uses the Id to verify that the node is not currently in the context node tree: it 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 be fully populated at a later date. If it is not partially populated, an exception is thrown. Finally, [M:System.Windows.Ink.ContextNode.CreatePartiallyPopulatedSubNode (System.Windows.Ink.ContextNodeType,System.Guid,System.Windows.Ink.AnalysisRegion)] 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 Data Proxy with Ink Analysis.
Private Function CreatePartiallyPopulatedNode(ByVal documentNode As TreeViewItem, ByVal theInkAnalyzer As InkAnalyzer) As 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 parentNode As TreeViewItem = documentNode.Parent '
If parentNode Is Nothing Then
Throw New Exception("parentNode is not a TreeViewItem")
End If
Dim parentNodeData As DocumentNodeData = parentNode.Tag
Dim analyzerParentNode As ContextNode = theInkAnalyzer.FindNode(parentNodeData.Id)
If Nothing = analyzerParentNode Then
' The parent analyzer node does not exist yet. Create one.
analyzerParentNode = Me.CreatePartiallyPopulatedNode(parentNode, 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 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 ContextNode CreatePartiallyPopulatedNode(
TreeViewItem documentNode, 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.
TreeViewItem parentNode = documentNode.Parent as TreeViewItem;
if (parentNode == null)
{
throw new Exception("parentNode is not a TreeViewItem");
}
DocumentNodeData parentNodeData =
parentNode.Tag as DocumentNodeData;
ContextNode analyzerParentNode =
theInkAnalyzer.FindNode(parentNodeData.Id);
if (null == analyzerParentNode)
{
// The parent analyzer node does not exist yet. Create one.
analyzerParentNode =
this.CreatePartiallyPopulatedNode(
parentNode, 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.
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 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