ContextNode.SetStrokes 方法

ContextNode 对象上设置指定的笔画。

命名空间:  System.Windows.Ink
程序集:  IAWinFX(在 IAWinFX.dll 中)

语法

声明
Public Sub SetStrokes ( _
    strokes As StrokeCollection _
)
用法
Dim instance As ContextNode
Dim strokes As StrokeCollection

instance.SetStrokes(strokes)
public void SetStrokes(
    StrokeCollection strokes
)
public:
void SetStrokes(
    StrokeCollection^ strokes
)
public void SetStrokes(
    StrokeCollection strokes
)
public function SetStrokes(
    strokes : StrokeCollection
)

参数

备注

此方法不更新 DirtyRegion

如果已经在 InkAnalyzer 上设置了笔画集合中的任何指定笔画,则会引发 ArgumentException

示例

下面的示例是名为 PopulateNode 的方法,该方法使用 TreeView 作为一个文档模型来演示如何使用数据代理存储和加载 InkAnalyzer 的上下文节点树。当每个 TreeViewItem 对象的 Tag 属性都设置为 DocumentNodeData 对象时,DocumentNodeData 类将 ContextNode 数据存储在该文档模型中。

PopulateNode 方法通过从 InkAnalyzer 对象添加笔画、属性数据、批注类型、子节点和链接来完全填充 ContextNode 对象。该方法使用 SetStrokes 添加笔画。数据来自从对应的 TreeViewItem 获取的 DocumentNodeData 对象。

  • this[analyzerNode.Id] 是文档模型类上的一个索引器,该索引器将 Guid 映射到 TreeViewItem。(在 VB.NET 中为 Me(analyzerNode.Id))

  • AddLinksToAnalyer 是文档模型类的方法,用于将链接添加到 ContextNode

在节点完全填充之后,PartiallyPopulated 属性将设置为 false。有关数据代理的更多信息,请参见Data Proxy with Ink Analysis

Sub PopulateNode(ByVal analyzerNode As ContextNode, ByVal theInkAnalyzer As InkAnalyzer)  Implements IDocumentModel.PopulateNode

    System.Diagnostics.Debug.WriteLine(String.Format("IDocumentModel.PopulateNode: populate {0} {1}.", analyzerNode.ToString(), GetRecognizedString(analyzerNode)))
    System.Diagnostics.Debug.Indent()

    ' Get the document node associated with the analyzer node.
    Dim documentNode As TreeViewItem = 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.
    For Each identifier As Guid 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 TreeViewItem
        For Each documentSubNode In  documentNode.Items
            ' 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(
            ContextNode analyzerNode,
            InkAnalyzer theInkAnalyzer)
        {
            System.Diagnostics.Debug.WriteLine(string.Format(
                "IDocumentModel.PopulateNode: populate {0} {1}.",
                analyzerNode.ToString(), GetRecognizedString(analyzerNode)));
            System.Diagnostics.Debug.Indent();

            // Get the document node associated with the analyzer node.
            TreeViewItem 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 (TreeViewItem documentSubNode in documentNode.Items)
                {
                    // 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

另请参见

参考

ContextNode 类

ContextNode 成员

System.Windows.Ink 命名空间