共用方式為


ContextNode.CreatePartiallyPopulatedSubNode 方法

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

命名空間:  System.Windows.Ink
組件:  IAWinFX (在 IAWinFX.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

參數

傳回值

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

備註

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

範例

下列範例是名為 CreatePartiallyPopulatedNode 的方法,它會使用 [System.Windows.Controls.TreeView] 做為文件模型,以顯示如何使用資料 Proxy 儲存和載入 InkAnalyzer 的內容節點樹狀目錄。DocumentNodeData 類別會藉由將每個 TreeViewItem 物件的 [System.Windows.FrameworkElement.Tag] 屬性設定為 DocumentNodeData 物件,將 ContextNode 資料儲存在文件模型中。CreatePartiallyPopulatedNode 方法會使用 TreeViewItem 物件和 InkAnalyzer 物件,在對應於文件模型之 TreeViewItemInkAnalyzer 內容節點樹狀目錄中建立部分填入節點。在這個範例中,會將所有節點都建立為部分填入節點。接著會將這些節點放入節點佇列中,日後將以節點資料完整填入該節點佇列。

這個方法會從所傳入 TreeViewItem 物件的 [System.Windows.FrameworkElement.Tag] 屬性取得節點資料,接著再使用 Id 確認節點目前是否不在內容節點樹狀目錄中;它會使用樹狀檢視父節點來尋找 InkAnalyzer 中的對應父節點。如果父節點目前不存在於內容節點樹狀目錄中,則會使用遞迴將它加入。如果父節點已存在於樹狀目錄中,它應該是部分填入;如果已完整填入,它就會包含其所有子節點,而且不需加入新的父節點。因此,PartiallyPopulated 屬性會驗證父節點是否為部分填入,如果是,則父節點會加入至佇列,供日後完整填入。如果父節點不是部分填入的,則會擲回例外狀況。最後,會在父節點上呼叫 [M:System.Windows.Ink.ContextNode.CreatePartiallyPopulatedSubNode (System.Windows.Ink.ContextNodeType,System.Guid,System.Windows.Ink.AnalysisRegion)],而且剛建立的節點會加入至節點佇列,來進行完整填入。如此會傳回新的 ContextNode 物件。如需資料 Proxy 的詳細資訊,請參閱Data Proxy with Ink Analysis

Private Function CreatePartiallyPopulatedNode(ByVal documentNode As TreeViewItem, ByVal theInkAnalyzer As InkAnalyzer) As 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 parentNode As TreeViewItem = documentNode.Parent '

    If parentNode Is Nothing Then
        Throw New Exception("parentNode is not a TreeViewItem")
    End If

    Dim parentNodeData As DocumentNodeData = parentNode.Tag
    Dim analyzerParentNode As ContextNode = theInkAnalyzer.FindNode(parentNodeData.Id)

    If Nothing = analyzerParentNode Then
        ' The parent analyzer node does not exist yet. Create one.
        analyzerParentNode = Me.CreatePartiallyPopulatedNode(parentNode, 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 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 ContextNode CreatePartiallyPopulatedNode(
            TreeViewItem documentNode, 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.
            TreeViewItem parentNode = documentNode.Parent as TreeViewItem;

            if (parentNode == null)
            {
                throw new Exception("parentNode is not a TreeViewItem");
            }

            DocumentNodeData parentNodeData =
                parentNode.Tag as DocumentNodeData;
            ContextNode analyzerParentNode =
                theInkAnalyzer.FindNode(parentNodeData.Id);
            if (null == analyzerParentNode)
            {
                // The parent analyzer node does not exist yet. Create one.
                analyzerParentNode =
                    this.CreatePartiallyPopulatedNode(
                        parentNode, 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.
            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 成員

System.Windows.Ink 命名空間

ContextNode.PartiallyPopulated