ObjectNode Class
Represents a ContextNode for a node that is returned from an object custom recognizer.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink.Analysis (in Microsoft.Ink.Analysis.dll)
Syntax
'Declaration
Public NotInheritable Class ObjectNode _
Inherits ContextNode
'Usage
Dim instance As ObjectNode
public sealed class ObjectNode : ContextNode
public ref class ObjectNode sealed : public ContextNode
public final class ObjectNode extends ContextNode
Remarks
For more information about how object recognizers work, see Object Recognizers.
An ObjectNode cannot contain any child elements.
ObjectNode objects are only contained by a CustomRecognizerNode object.
Examples
The following example loops through the child nodes of a CustomRecognizerNode object, musicRecognizer. It then finds each ObjectNode and retrieves the relevant properties. The application treats each ObjectNode as a note. The custom recognizer has added five properties (letter, octave, measure, withinMeasure, and duration) to describe the note. The ContextNode.GetPropertyData method retrieves the data with the following Guid members: noteLetterId, noteOctaveId, noteMeasureId, noteWithinMeasureId, and noteDurationId. After all the data is collected, the DrawNote method draws the note.
Dim subNode As ContextNode
For Each subNode In musicRecognizer.SubNodes
If TypeOf subNode Is ObjectNode Then
' Assume all object nodes represent notes
Dim noteObject As ObjectNode = CType(subNode, ObjectNode)
Dim letter As String
If noteObject.ContainsPropertyData(Me.noteLetterId) Then
letter = CType(noteObject.GetPropertyData(Me.noteLetterId), String)
Else
letter = ""
End If
Dim octave As Integer
If noteObject.ContainsPropertyData(Me.noteOctaveId) Then
octave = CType(noteObject.GetPropertyData(Me.noteOctaveId), Integer)
Else
octave = -1
End If
Dim measure As Integer
If noteObject.ContainsPropertyData(Me.noteMeasureId) Then
measure = CType(noteObject.GetPropertyData(Me.noteMeasureId), Integer)
Else
measure = -1
End If
Dim withinMeasure As Integer
If noteObject.ContainsPropertyData(Me.noteWithinMeasureId) Then
withinMeasure = CType(noteObject.GetPropertyData(Me.noteWithinMeasureId), Integer)
Else
withinMeasure = -1
End If
Dim duration As Integer
If noteObject.ContainsPropertyData(Me.noteDurationId) Then
duration = CType(noteObject.GetPropertyData(Me.noteDurationId), Integer)
Else
duration = -1
End If
' Draw note if all data is valid
If (letter.Length > 0 And octave >= 0 And measure >= 0 And _
withinMeasure >= 0 And duration >= 0) Then
DrawNote(letter, octave, measure, withinMeasure, duration)
End If
End If
Next subNode
foreach (ContextNode subNode in musicRecognizer.SubNodes)
{
if (subNode is ObjectNode)
{
// Assume all object nodes represent notes
ObjectNode noteObject = (ObjectNode)subNode;
string letter;
if (noteObject.ContainsPropertyData(this.noteLetterId))
letter = (string)noteObject.GetPropertyData(this.noteLetterId);
else
letter = "";
int octave;
if (noteObject.ContainsPropertyData(this.noteOctaveId))
octave = (int)noteObject.GetPropertyData(this.noteOctaveId);
else
octave = -1;
int measure;
if (noteObject.ContainsPropertyData(this.noteMeasureId))
measure = (int)noteObject.GetPropertyData(this.noteMeasureId);
else
measure = -1;
int withinMeasure;
if (noteObject.ContainsPropertyData(this.noteWithinMeasureId))
withinMeasure = (int)noteObject.GetPropertyData(this.noteWithinMeasureId);
else
withinMeasure = -1;
int duration;
if (noteObject.ContainsPropertyData(this.noteOctaveId))
duration = (int)noteObject.GetPropertyData(this.noteDurationId);
else
duration = -1;
// Draw note if all data is valid
if (letter.Length > 0 && octave >= 0 && measure >= 0 &&
withinMeasure >= 0 && duration >= 0)
{
DrawNote(letter, octave, measure, withinMeasure, duration);
}
}
}
Inheritance Hierarchy
System.Object
Microsoft.Ink.ContextNode
Microsoft.Ink.ObjectNode
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Windows 7, Windows Vista, Windows Server 2008 R2, Windows Server 2008
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.
Version Information
.NET Framework
Supported in: 3.0
See Also
Reference
Microsoft.Ink.CustomRecognizerNode