ContextNode.SetStrokes 方法
在 ContextNode 对象上设置指定的笔画。
命名空间: Microsoft.Ink
程序集: Microsoft.Ink.Analysis(在 Microsoft.Ink.Analysis.dll 中)
语法
声明
Public Sub SetStrokes ( _
strokes As Strokes _
)
用法
Dim instance As ContextNode
Dim strokes As Strokes
instance.SetStrokes(strokes)
public void SetStrokes(
Strokes strokes
)
public:
void SetStrokes(
Strokes^ strokes
)
public void SetStrokes(
Strokes strokes
)
public function SetStrokes(
strokes : Strokes
)
参数
- strokes
类型:Microsoft.Ink.Strokes
ContextNode 对象获取的 Strokes。
备注
此方法不更新 DirtyRegion。
如果已经在 InkAnalyzer 上设置了笔画集合中的任何指定笔画,则引发 ArgumentException。
示例
下面的示例是一段示例代码中一个名为 PopulateNode 的方法,该示例代码使用 System.Windows.Forms.TreeView 作为一个文档模型来演示如何使用数据代理来存储和加载 InkAnalyzer 的上下文节点树。当每个 TreeNode 对象的 Tag 属性都设置为一个 DocumentNodeData 对象时,DocumentNodeData 类在该文档模型中存储 ContextNode 数据。
PopulateNode 方法通过从 InkAnalyzer 对象添加笔画、属性数据、批注类型、子节点和链接来完全填充 ContextNode 对象。该方法使用 SetStrokes 添加笔画。数据来自从对应的 TreeNode 获取的 DocumentNodeData 对象。
this[analyzerNode.Id] 是文档模型类的一个索引器,该索引器将 Guid 映射到 TreeNode。(在 VB.NET 中为 Me(analyzerNode.Id))
AddLinksToAnalyer 是文档模型类用于将链接添加到 ContextNode 的方法。
在节点完全填充之后,PartiallyPopulated 属性设置为 false。有关数据代理的更多信息,请参见Data Proxy with Ink Analysis。
Sub PopulateNode(ByVal analyzerNode As Microsoft.Ink.ContextNode, _
ByVal theInkAnalyzer As Microsoft.Ink.InkAnalyzer) _
Implements IDocumentModel.PopulateNode
System.Diagnostics.Debug.WriteLine( _
String.Format("IDocumentModel.PopulateNode: populate {0} {1}.", _
TreeViewDocumentModel.GetContextNodeTypeName(analyzerNode.Type), analyzerNode.Id))
System.Diagnostics.Debug.Indent()
' Get the document node associated with the analyzer node.
Dim documentNode As TreeNode = Me(analyzerNode.Id)
If documentNode Is Nothing Then
Throw New ApplicationException("The requested node does not exist in the document model.")
End If
' Get the data associated with the node.
Dim nodeData As DocumentNodeData = documentNode.Tag '
' Copy any application specific data associated with the node to the
' partially populated ContextNode.
Dim identifier As Guid
For Each identifier In nodeData.GetPropertyDataIds()
analyzerNode.AddPropertyData(identifier, nodeData.GetPropertyData(identifier))
Next identifier
' Check if the partially populated ContextNode is an ink leaf node.
If nodeData.IsInkLeafNode Then
' Add the strokes to the context node.
analyzerNode.SetStrokes(nodeData.Strokes)
Else
' Add each child subnode as a partially populated ContextNode.
Dim documentSubNode As TreeNode
For Each documentSubNode In documentNode.Nodes
' Get the DocumentNode data for the
Dim subNodeData As DocumentNodeData = documentSubNode.Tag
If analyzerNode.SubNodes.IndexOf(nodeData.Id) <> -1 Then
analyzerNode.CreatePartiallyPopulatedSubNode( _
subNodeData.Type, subNodeData.Id, subNodeData.Location)
End If
Next documentSubNode
End If
' Add links to the ContextNode.
Me.AddLinksToAnalyzer(documentNode, analyzerNode, theInkAnalyzer)
' Update the partially populated flag.
analyzerNode.PartiallyPopulated = False
System.Diagnostics.Debug.Unindent()
End Sub 'IDocumentModel.PopulateNode
void IDocumentModel.PopulateNode(
Microsoft.Ink.ContextNode analyzerNode,
Microsoft.Ink.InkAnalyzer theInkAnalyzer)
{
System.Diagnostics.Debug.WriteLine(string.Format(
"IDocumentModel.PopulateNode: populate {0} {1}.",
TreeViewDocumentModel.GetContextNodeTypeName(analyzerNode.Type),
analyzerNode.Id));
System.Diagnostics.Debug.Indent();
// Get the document node associated with the analyzer node.
TreeNode documentNode = this[analyzerNode.Id];
if (null == documentNode)
{
throw new ApplicationException(
"The requested node does not exist in the document model.");
}
// Get the data associated with the node.
DocumentNodeData nodeData = documentNode.Tag as DocumentNodeData;
// Copy any application specific data associated with the node to the
// partially populated ContextNode.
foreach (Guid identifier in nodeData.GetPropertyDataIds())
{
analyzerNode.AddPropertyData(
identifier, nodeData.GetPropertyData(identifier));
}
// Check if the partially populated ContextNode is an ink leaf node.
if (nodeData.IsInkLeafNode)
{
// Add the strokes to the context node.
analyzerNode.SetStrokes(nodeData.Strokes);
}
else
{
// Add each child subnode as a partially populated ContextNode.
foreach (TreeNode documentSubNode in documentNode.Nodes)
{
// Get the DocumentNode data for the
DocumentNodeData subNodeData = documentSubNode.Tag as DocumentNodeData;
if (analyzerNode.SubNodes.IndexOf(nodeData.Id) != -1)
{
analyzerNode.CreatePartiallyPopulatedSubNode(
subNodeData.Type, subNodeData.Id, subNodeData.Location);
}
}
}
// Add links to the ContextNode.
this.AddLinksToAnalyzer(documentNode, analyzerNode, theInkAnalyzer);
// Update the partially populated flag.
analyzerNode.PartiallyPopulated = false;
System.Diagnostics.Debug.Unindent();
}
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
版本信息
.NET Framework
受以下版本支持:3.0