共用方式為


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
)

參數

備註

這個方法不會更新 DirtyRegion

如果筆劃集合中任何指定的筆劃已在 InkAnalyzer 上設定,則會擲回 ArgumentException (英文)。

範例

下列範例是一個稱為 PopulateNode 的方法 (來自範例程式碼),它會使用 System.Windows.Forms.TreeView (英文) 做為文件模型,示範如何使用資料 Proxy 來儲存和載入 InkAnalyzer 的內容節點樹狀目錄。DocumentNodeData 類別會在每個 TreeNode (英文) 物件的 Tag (英文) 屬性設定為 DocumentNodeData 物件時,儲存文件模型中的 ContextNode 資料。

PopulateNode 方法會透過從 InkAnalyzer 物件加入筆劃、屬性資料、註釋型別、子節點和連結,完整地填入 ContextNode 物件。這個方法會使用 SetStrokes 加入筆劃。資料來自 DocumentNodeData 物件,而該物件是從對應的 TreeNode (英文) 取得。

  • this[analyzerNode.Id] 是文件模型類別上的索引子 (Indexer),會將 Guid (英文) 對應至 TreeNode (英文) (在 VB.NET 中為 Me(analyzerNode.Id))。

  • AddLinksToAnalyer 是文件模型類別上的方法,會將連結加入至 ContextNode

完整填入節點之後,PartiallyPopulated 屬性會設定為 false。如需資料 Proxy 的詳細資訊,請參閱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

請參閱

參考

ContextNode 類別

ContextNode 成員

Microsoft.Ink 命名空間