This documentation is archived and is not being maintained.
ContextNodeBase Class
Visual Studio 2008
Represents a node in a tree of objects that are created as part of ink analysis.
Assembly: IACore (in IACore.dll)
This example takes an InkAnalyzerBase named theInkAnalyzer, and uses its ContextNodeBase tree to fill a System.Windows.Forms.TreeView named theTreeView. When a node in the tree view is selected, those strokes are set to appear in red. The Tag property is used to map between tree nodes and the context nodes that they represent.
Private Sub BuildTree() Me.theTreeView.Nodes.Clear() Dim rootNode As New TreeNode(Me.theInkAnalyzerBase.RootNode.ToString()) Me.theTreeView.Nodes.Add(rootNode) rootNode.Tag = Me.theInkAnalyzerBase.RootNode WalkTree(Me.theInkAnalyzerBase.RootNode, rootNode) End Sub 'BuildTree Private Sub WalkTree(ByVal parentContextNode As ContextNodeBase, ByVal parentTreeNode As TreeNode) Dim cNode As ContextNodeBase For Each cNode In parentContextNode.SubNodes Dim newTNode As New TreeNode(cNode.ToString()) If cNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkWord AndAlso _ cNode.ContainsPropertyData(PropertyGuidsForContextNodesBase.RecognizedString) Then newTNode.Text = newTNode.Text + _ ": " + CType(cNode.GetPropertyData(PropertyGuidsForContextNodesBase.RecognizedString), _ String) ElseIf cNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkDrawing AndAlso _ cNode.ContainsPropertyData(PropertyGuidsForContextNodesBase.ShapeName) Then Dim shapeName As String = CType(cNode.GetPropertyData(PropertyGuidsForContextNodesBase.ShapeName), _ String) If shapeName <> "" Then newTNode.Text = newTNode.Text + ": " + shapeName End If End If WalkTree(cNode, newTNode) parentTreeNode.Nodes.Add(newTNode) ' Add the context node as a tag of the tree node newTNode.Tag = cNode Next cNode End Sub 'WalkTree Private Sub theTreeView_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles theTreeView.AfterSelect ' Get the context node Dim selectedNode As ContextNodeBase = CType(e.Node.Tag, ContextNodeBase) MarkNodeAsRed(selectedNode) timeStampLabel.Text = "" ' Show selected results If Not (selectedNode Is Nothing) Then If (selectedNode.ContainsPropertyData(PropertyGuidsForContextNodesBase.RecognizedString) AndAlso _ (selectedNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.WritingRegion OrElse _ selectedNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Paragraph OrElse _ selectedNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.CustomRecognizer OrElse _ selectedNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Object OrElse _ selectedNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Line)) Then selectedResultsTextBox.Text = _ CType(selectedNode.GetPropertyData(PropertyGuidsForContextNodesBase.RecognizedString), String) ElseIf (selectedNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkWord) Then Dim parentNode As ContextNodeBase = selectedNode.ParentNode If (parentNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.Line AndAlso _ parentNode.ContainsPropertyData(PropertyGuidsForContextNodesBase.RecognizedString)) Then ' Put parent line's recognized string into the text box selectedResultsTextBox.Text = _ CType(parentNode.GetPropertyData(PropertyGuidsForContextNodesBase.RecognizedString), String) ' Select the text that corresponds to the ink word Dim subNodes As New ContextNodeBaseCollection(theInkAnalyzerBase) subNodes.Add(selectedNode) Dim start As Integer Dim length As Integer theInkAnalyzerBase.GetTextRangeFromNodes(subNodes, start, length) If (start >= 0 AndAlso length > 0) Then selectedResultsTextBox.Select(start, length) End If End If ElseIf (selectedNode.Type = System.Windows.Ink.AnalysisCore.ContextNodeTypeBase.InkDrawing AndAlso _ selectedNode.ContainsPropertyData(PropertyGuidsForContextNodesBase.ShapeName)) Then selectedResultsTextBox.Text = _ CType(selectedNode.GetPropertyData(PropertyGuidsForContextNodesBase.ShapeName), String) End If End If Me.currentNode = selectedNode End Sub 'theTreeView_AfterSelect Private Sub MarkNodeAsRed(ByVal selectedNode As ContextNodeBase) Dim selectedNodeStrokes As Strokes = Nothing If Not selectedNode Is Nothing Then selectedNodeStrokes = theInk.CreateStrokes(selectedNode.GetStrokeIds()) End If ' Set all node strokes to black, but this one to red Dim stroke As Stroke For Each stroke In Me.theInkCollector.Ink.Strokes If (Not selectedNodeStrokes Is Nothing And _ selectedNodeStrokes.Contains(stroke)) Then stroke.DrawingAttributes = New DrawingAttributes(Color.Red) Else stroke.DrawingAttributes = Me.theInkCollector.DefaultDrawingAttributes End If Next theNotesPanel.Refresh() End Sub
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: