ObjectNode Class
Collapse the table of content
Expand the table of content

ObjectNode Class

Represents a ContextNode for a node that is returned from an object custom recognizer.

Namespace:  System.Windows.Ink
Assembly:  IAWinFX (in IAWinFX.dll)

public sealed class ObjectNode : ContextNode

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.

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 musical note. The custom recognizer adds five properties (letter, octave, measure, withinMeasure, and duration) to describe the note. The 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.

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);
            letter = "";

        int octave;
        if (noteObject.ContainsPropertyData(this.noteOctaveId))
            octave = (int)noteObject.GetPropertyData(this.noteOctaveId);
            octave = -1;

        int measure;
        if (noteObject.ContainsPropertyData(this.noteMeasureId))
            measure = (int)noteObject.GetPropertyData(this.noteMeasureId);
            measure = -1;

        int withinMeasure;
        if (noteObject.ContainsPropertyData(this.noteWithinMeasureId))
            withinMeasure = (int)noteObject.GetPropertyData(this.noteWithinMeasureId);
            withinMeasure = -1;

        int duration;
        if (noteObject.ContainsPropertyData(this.noteOctaveId))
            duration = (int)noteObject.GetPropertyData(this.noteDurationId);
            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);

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.0

Community Additions

© 2015 Microsoft