LoadGrammarCompletedEventArgs.Grammar Property
Gets the grammar object that has completed loading.
Namespace: Microsoft.Speech.Recognition
Assembly: Microsoft.Speech (in microsoft.speech.dll)
Syntax
'Declaration
Public ReadOnly Property Grammar As Grammar
public Grammar Grammar { get; }
public:
property Grammar^ Grammar {
Grammar^ get ();
}
/** @property */
public Grammar get_Grammar ()
public function get Grammar () : Grammar
Property Value
An instance of Grammar, which contains a full description of a speech recognition grammar loaded by a recognition engine.
Remarks
Grammar returns the Grammar specified by an application making calls to LoadGrammar
or LoadGrammarAsync
.
Example
In the example below, a handler for SpeechRecognitionEngine.LoadGrammarCompleted used the Grammar property to update a display of loaded Grammar objects.
//On load we actuall update the display.
//A hash table is used to get the node information we added in AddToTree.
_recognizer.LoadGrammarCompleted +=
delegate(object sender, LoadGrammarCompletedEventArgs eventArgs) {
Grammar grammar = eventArgs.Grammar;
SrgsDocument document;
document = _grammarDocumentList[grammar] as SrgsDocument;
if (grammar != null) {
//Should probably do a sanity check and remove node if it exists.
TreeNode grammarNode = new TreeNode(grammar.Name);
grammarNode.Checked = grammar.Enabled;
grammarNode.Tag = grammar;
if (document != null) {
foreach (SrgsRule rule in document.Rules) {
TreeNode ruleNode = new TreeNode(rule.Id);
if (document.Root == rule) {
ruleNode.ForeColor = Color.Red;
}
ruleNode.Tag = rule;
ruleNode.Checked = true;
grammarNode.Nodes.Add(ruleNode);
}
}
_grammarTreeView.Nodes.Add(grammarNode);
grammarNode.ExpandAll();
}
};
Thread Safety
All public static (Shared in Visual Basic) members of this type are thread-safe. Instance members are not guaranteed to be thread-safe.
Platforms
Development Platforms
Windows XP Professional with Service Pack 2 (SP2), Windows Server 2003, Windows Vista Ultimate Edition, Windows Vista Business Edition, Windows Vista Enterprise Edition
Target Platforms
See Also
Reference
LoadGrammarCompletedEventArgs Class
LoadGrammarCompletedEventArgs Members
Microsoft.Speech.Recognition Namespace
Grammar Class
LoadGrammar
LoadGrammar
LoadGrammarAsync
LoadGrammarCompletedEventArgs Class