LoadGrammarCompletedEventArgs..::..Grammar Property |
LoadGrammarCompletedEventArgs Class Example See Also Send Feedback |
Gets the Grammar object that has completed loading.
Namespace:
Microsoft.Speech.Recognition
Assembly:
Microsoft.Speech (in Microsoft.Speech.dll)
Syntax
Visual Basic (Declaration) |
---|
Public ReadOnly Property Grammar As Grammar Get |
Visual Basic (Usage) |
---|
Dim instance As LoadGrammarCompletedEventArgs Dim value As Grammar value = instance.Grammar |
C# |
---|
public Grammar Grammar { get; } |
Property Value
Type: Microsoft.Speech.Recognition..::..GrammarThe Grammar object that has completed loading.
Remarks
The Grammar property returns the Grammar that an application specifies in a call to LoadGrammarAsync or LoadGrammarAsync(Grammar).
Examples
In the example below, a handler for SpeechRecognitionEngine..::..LoadGrammarCompleted uses the Grammar property to update a display of loaded Grammar objects.
Copy Code | |
---|---|
//On load we 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(); } }; |