次の方法で共有


ContextNode.CreatePartiallyPopulatedSubNode メソッド

TypeId、および Location の情報のみが含まれている子 ContextNode オブジェクトを作成します。

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

パラメータ

  • nodeId
    型 : System.Guid
    新しいノードの識別子。

戻り値

型 : System.Windows.Ink.ContextNode
TypeId、および Location の情報のみが含まれている新しい ContextNode オブジェクト。この新しいノードは、ContextNode の子です。

解説

このメソッドは、ツリーに関するすべての情報が使用可能になる前に ContextNode オブジェクトをコンテキスト ノード ツリーで作成する方法としてデータ プロキシに使用します。他の情報を後で追加することもできます。

次の例では、[System.Windows.Controls.TreeView] をドキュメント モデルとして使用して、InkAnalyzer のコンテキスト ノード ツリーの格納と読み込みにデータ プロキシを使用する方法を示す、CreatePartiallyPopulatedNode というメソッドを示します。各 TreeViewItem オブジェクトの [System.Windows.FrameworkElement.Tag] プロパティを DocumentNodeData オブジェクトに設定することにより、DocumentNodeData クラスは、ContextNode データをドキュメント モデルに格納します。CreatePartiallyPopulatedNode メソッドは、TreeViewItem オブジェクトと InkAnalyzer オブジェクトを使用して、ドキュメント モデル内の TreeViewItem に対応する InkAnalyzer コンテキスト ノード ツリーに部分的に設定されたノードを作成します。このサンプルでは、すべてのノードが部分的に設定されたノードとして作成されます。次に、後日完全にノード データが設定されたノードのキューに配置されます。

このメソッドは、渡された 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 オブジェクトが返されます。データ プロキシの詳細については、「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