예제 #1
0
        private void UseResult(RecognitionResult rr)
        {
            string text = "";

            foreach (RecognizedWordUnit rwu in rr.Words)
            {
                text += " " + rwu.LexicalForm;
            }

            text = text.Replace('.', ' ').Trim();

            Console.WriteLine(text);

            VoiceAction action = analyser.FindByName(text);

            if (action != null)
            {
                Console.WriteLine("Firing " + action.label);
                action.Fire();
            }
            else
            {
                Console.WriteLine("Not found");
            }
        }
        public void AddVoiceActions(GeckoDocument document, string tagName)
        {
            foreach (GeckoElement element in document.GetElementsByTagName(tagName))
            {
                VoiceAction action = new VoiceAction();
                action.label = element.TextContent.Trim();

                if (tagName == "button")
                {
                    action.task += () =>
                    {
                        GeckoButtonElement button = new GeckoButtonElement(element.DomObject);
                        button.Click();
                    };
                }

                if (tagName == "a")
                {
                    action.task += () =>
                    {
                        GeckoAnchorElement anchor = new GeckoAnchorElement(element.DomObject);
                        anchor.Click();
                    };
                }

                if (tagName == "iframe")
                {
                    action.task += () =>
                    {
                        GeckoButtonElement iframe = new GeckoButtonElement(element.DomObject);
                        iframe.Click();
                    };
                }
                actions.Add(action);
            }
        }