ObjectNode 类

表示从对象自定义识别器返回的节点的 ContextNode

命名空间:  System.Windows.Ink
程序集:  IAWinFX(在 IAWinFX.dll 中)

语法

声明
Public NotInheritable Class ObjectNode _
    Inherits ContextNode
用法
Dim instance As ObjectNode
public sealed class ObjectNode : ContextNode
public ref class ObjectNode sealed : public ContextNode
public final class ObjectNode extends ContextNode
public final class ObjectNode extends ContextNode

备注

有关对象识别器如何工作的更多信息,请参见Object Recognizers

ObjectNode 不能包含任何子元素。

ObjectNode 对象只能包含在 CustomRecognizerNode 对象中。

示例

下面的示例遍历 CustomRecognizerNode 对象 musicRecognizer 的子节点。然后,查找每个 ObjectNode 并检索相关属性。应用程序将每个 ObjectNode 视为音符进行处理。自定义识别器添加了五个属性(letter、octave、measure、withinMeasure 和 duration)用于描述音符。GetPropertyData 方法检索具有以下 Guid 成员的数据:noteLetterId、noteOctaveId、noteMeasureId、noteWithinMeasureId 和 noteDurationId。收集所有数据后,DrawNote 方法绘制该注释。

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 = CStr(noteObject.GetPropertyData(Me.noteLetterId))
        Else
            letter = ""
        End If 
        Dim octave As Integer
        If noteObject.ContainsPropertyData(Me.noteOctaveId) Then
            octave = Fix(noteObject.GetPropertyData(Me.noteOctaveId))
        Else
            octave = - 1
        End If 
        Dim measure As Integer
        If noteObject.ContainsPropertyData(Me.noteMeasureId) Then
            measure = Fix(noteObject.GetPropertyData(Me.noteMeasureId))
        Else
            measure = - 1
        End If 
        Dim withinMeasure As Integer
        If noteObject.ContainsPropertyData(Me.noteWithinMeasureId) Then
            withinMeasure = Fix(noteObject.GetPropertyData(Me.noteWithinMeasureId))
        Else
            withinMeasure = - 1
        End If 
        Dim duration As Integer
        If noteObject.ContainsPropertyData(Me.noteOctaveId) Then
            duration = Fix(noteObject.GetPropertyData(Me.noteDurationId))
        Else
            duration = - 1
        End If 
        ' Draw note if all data is valid
        If letter.Length > 0 AndAlso octave >= 0 AndAlso _
            measure >= 0 AndAlso withinMeasure >= 0 AndAlso 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);
        }
    }
}

继承层次结构

System.Object
  System.Windows.Ink.ContextNode
    System.Windows.Ink.ObjectNode

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

平台

Windows Vista

.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求

版本信息

.NET Framework

受以下版本支持:3.0

另请参见

参考

ObjectNode 成员

System.Windows.Ink 命名空间

System.Windows.Ink.CustomRecognizerNode

其他资源

Object Recognizers