ContextNode.CreatePartiallyPopulatedSubNode 方法
创建一个只包含以下信息的子 ContextNode 对象:Type、Id 和 Location。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)
语法
声明
Public Function CreatePartiallyPopulatedSubNode ( _
type As Guid, _
nodeId As Guid, _
nodeLocation As AnalysisRegion _
) As ContextNode
用法
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 ContextNode CreatePartiallyPopulatedSubNode(
Guid type,
Guid nodeId,
AnalysisRegion nodeLocation
)
public function CreatePartiallyPopulatedSubNode(
type : Guid,
nodeId : Guid,
nodeLocation : AnalysisRegion
) : ContextNode
参数
- type
类型:System.Guid
要创建的 ContextNode 对象的类型。使用 ContextNodeType 类中定义的某个 GUID 指定要创建的类型。
- nodeId
类型:System.Guid
新节点的标识符。
- nodeLocation
类型:Microsoft.Ink.AnalysisRegion
新节点的位置。
返回值
类型:Microsoft.Ink.ContextNode
一个只包含有关 Type、Id 和 Location 的信息的新 ContextNode 对象。此新节点是 ContextNode 的子级。
备注
此方法用于数据代理,作为在有关某 ContextNode 对象的所有信息可用之前在上下文节点树中创建该对象的一种途径。可在以后添加有关该对象的其他信息。
示例
下面的示例是一段示例代码中一个名为 CreatePartiallyPopulatedNode 的方法,该示例代码使用 System.Windows.Forms.TreeView 作为一个文档模型来演示如何使用数据代理来存储和加载 InkAnalyzer 的上下文节点树。DocumentNodeData 类通过将每个 TreeNode 对象的 Tag 属性设置为一个 DocumentNodeData 对象,将 ContextNode 数据存储在该文档模型中。CreatePartiallyPopulatedNode 方法使用 TreeNode 对象和 InkAnalyzer 对象在对应于文档模型中的 TreeNode 的 InkAnalyzer 上下文节点树中创建部分填充的节点。在此示例中,所有节点都是以部分填充的方式创建的。然后,这些节点被放入节点队列,供以后用所有节点数据完全填充。
该方法首先从传入的 TreeNode 对象的 Tag 属性中获取节点数据,然后使用 Id 验证该节点当前是否不在上下文节点树中。然后,使用树视图父节点查找 InkAnalyzer 中对应的父节点。如果父节点尚未存在于上下文节点树中,则使用递归添加该父节点。如果父节点存在于树中,则应是部分填充的;如果父节点已完全填充,则该节点应当已经包含其所有子节点,因而无需添加新的子节点。因此 PartiallyPopulated 属性验证父节点是否是部分填充的,如果是,则将该节点添加到队列中供以后完全填充。如果该节点不是部分填充的,则引发异常。最后,对父节点调用 CreatePartiallyPopulatedSubNode,并将新创建的节点添加到节点队列中以供完全填充。将返回新的 ContextNode 对象。有关数据代理的更多信息,请参见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;
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0