public static IEnumerable <ChildKeyword> GetChildren(ParentKeyword p) { var children = (from parent in Parents where parent == p select parent.Children).FirstOrDefault(); return(children); }
private static void OnSpeechRecognized(object sender, SpeechRecognizedEventArgs e) { List <ChildKeyword> children = null; int childIndex = -1; ParentKeyword parent = null; bool defaultParentIsUsed = !(KeywordFactory.GetParentNames().Any(s => s == e.Result.Words[0].Text)); if (!string.IsNullOrWhiteSpace(KeywordFactory.DefaultParent) && defaultParentIsUsed) { parent = KeywordFactory.GetParent(KeywordFactory.DefaultParent); } else { parent = KeywordFactory.GetParent(e.Result.Words[0].Text); } if (parent != null) { children = KeywordFactory.GetChildren(parent).ToList(); string wordToCheck = GetChildKeywordToCheck(e, !string.IsNullOrEmpty(KeywordFactory.DefaultParent) && defaultParentIsUsed); childIndex = children.FindIndex(c => c.Keyword == wordToCheck); } if (children != null && childIndex > -1) { string sequence = children[childIndex].KeySequence; int result = 0; if (int.TryParse(e.Result.Words[e.Result.Words.Count - 1].Text, out result)) { int index = sequence.IndexOf('}'); sequence = sequence.Insert(index, " " + result.ToString()); } SendKeys.SendWait(sequence); } }
public static IEnumerable <string> GetChildrenNames(ParentKeyword p) { return((from c in p.Children select c.Keyword).ToList()); }