ObjectNode 類別
表示從物件自訂辨識器傳回之節點的 ContextNode。
命名空間: Microsoft.Ink
組件: Microsoft.Ink.Analysis (在 Microsoft.Ink.Analysis.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. 執行迴圈 (Loop),然後再尋找每個 ObjectNode 並擷取相關的屬性。應用程式會將每個 ObjectNode 視為節點。自訂辨識器已經加入五個屬性 (letter、octave、measure、withinMeasure 和 duration) 來描述節點。ContextNode.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 = 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);
}
}
}
繼承階層架構
System.Object
Microsoft.Ink.ContextNode
Microsoft.Ink.ObjectNode
執行緒安全
這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。
平台
Windows Vista
.NET Framework 和 .NET Compact Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱 .NET Framework 系統需求。
版本資訊
.NET Framework
支援版本:3.0
請參閱
參考
Microsoft.Ink.CustomRecognizerNode