コード例 #1
0
ファイル: CoreCommands.cs プロジェクト: bbjreyes/NORSI
        internal static IEnumerable <string> EvaluateCommand(string response)
        {
            string temp = string.Empty;

            switch (response.ToLower())
            {
            case "showparents":
                return(KeywordFactory.GetParentNames());

            case "showparents -c":
                return(KeywordFactory.GetParentNames(true));

            case "getdefault":
                return((!string.IsNullOrWhiteSpace(KeywordFactory.DefaultParent)) ? new string[] { KeywordFactory.DefaultParent } : new string[] { "Not Set" });

            case "removedefault":
                return(new string[] { KeywordFactory.RemoveParent() });

            default:
                return(new string[] { "Command not found." });
            }
        }
コード例 #2
0
        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);
            }
        }