共用方式為


ContextNode.CreatePartiallyPopulatedSubNode 方法

建立子系 ContextNode 物件,其中只包含下列資訊:TypeIdLocation

命名空間:  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

參數

傳回值

型別:Microsoft.Ink.ContextNode
新的 ContextNode 物件,其中只包含 TypeIdLocation 的相關資訊。這個新節點是 ContextNode 的子節點。

備註

這個方法可做為資料 Proxy 的方式,在內容節點樹狀目錄中提供所有資訊之前,在其中建立 ContextNode 物件。其他相關資訊可於之後加入。

範例

下列範例是一個稱為 CreatePartiallyPopulatedNode 的方法 (來自範例程式碼),它會使用 System.Windows.Forms.TreeView (英文) 做為文件模型,示範如何使用資料 Proxy 來儲存和載入 InkAnalyzer 的內容節點樹狀目錄。DocumentNodeData 類別會透過將每個 TreeNode (英文) 物件的 Tag (英文) 屬性設定為 DocumentNodeData 物件,在文件模型中儲存 ContextNode 資料。CreatePartiallyPopulatedNode 方法會使用 TreeNode (英文) 物件和 InkAnalyzer 物件,在對應於文件模型中之 TreeNode (英文) 的 InkAnalyzer 內容節點樹狀目錄中建立部分填入的節點。在這個範例中,會將所有節點都建立為部分填入節點。然後將它們放入節點的佇列,方便以後再完整填入所有節點資料。

這個方法會先從傳入的 TreeNode (英文) 物件之 Tag (英文) 屬性取得節點資料,然後使用 Id 確認該節點目前不在內容節點樹狀目錄中,再使用樹狀目錄檢視父節點來尋找 InkAnalyzer 中對應的父節點。如果父節點目前不存在於內容節點樹狀目錄中,則會使用遞迴將它加入。如果父節點已存在於樹狀目錄中,它應該是部分填入;如果已完整填入,它就會包含其所有子節點,而且不需加入新的父節點。因此,PartiallyPopulated 屬性會驗證父節點是否為部分填入,如果是,則父節點會加入至佇列,方便以後再完整填入。如果父節點不是部分填入的,則會擲回例外狀況。最後,會在父節點上呼叫 CreatePartiallyPopulatedSubNode,而且剛建立的節點會加入至節點佇列,來進行完整填入。如此會傳回新的 ContextNode 物件。如需資料 Proxy 的詳細資訊,請參閱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

請參閱

參考

ContextNode 類別

ContextNode 成員

Microsoft.Ink 命名空間

ContextNode.PartiallyPopulated

Microsoft.Ink.ContextNodeType