Ejemplo n.º 1
0
        public void create(Familiar_Document document, string filename)
        {
            parent_document = document;
            name            = parent_document.name;
            file_name       = filename;

#if !DEBUG
            try
            {
#endif
            grammar.CmdLoadFromFile(file_name, SpeechLoadOption.SLOStatic);

#if !DEBUG
        }
        catch (Exception ex)
        {
            Feedback.print(file_name, Feedback.Status.info);
            Feedback.print(ex);
            return;
        }
#endif

            grammar.CmdSetRuleIdState(0, SpeechRuleState.SGDSActive);
            grammar.State = SpeechGrammarState.SGSDisabled;
            //          ++next_id;
        }
Ejemplo n.º 2
0
        public static void add_word_dialog(string grammar, string old_word)
        {
            string[]          split     = grammar.Split('#');
            Familiar_Document document  = Familiar_Document.find_document(split[0]);
            string            rule_name = "";

            if (split.Length > 1)
            {
                rule_name = split[1];
            }
            else
            {
                rule_name = "rule_name";
            }

            Element_Word word = null;

            if (old_word != null && old_word != "")
            {
                word = document.get_word(old_word, rule_name);
            }
            else
            {
                word = new Element_Word();
            }

            Generic_Form dialog = new Generic_Form(word, "Add New Word");

            if (dialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                if (old_word == null || old_word == "")
                {
                    document.add_word(word, rule_name);
                }
                document.save();
                reload();
            }
            catch (Exception ex)
            {
                Feedback.print(ex);
            }
        }
Ejemplo n.º 3
0
        private void initialize(string new_grammar, string filename, Dictionary <string, Target_Path> target)
        {
            //file_name = Global.configuration.settings_path(file_name);
            target.Clear();

            Global.configuration.load_block(filename, (file_name) =>
            {
                try
                {
                    Familiar_Document grammar_document = Familiar_Document.find_document(new_grammar);
                    if (grammar_document == null)
                    {
                        throw new Exception("Could not find Grammar!");
                    }

                    choices = grammar_document.get_rule_choice("pages");
                    //choices.children.Clear();

                    //if (!File.Exists(file_name))
                    //    throw new Exception("Could not find File!");

                    XmlDocument document = new XmlDocument();
                    document.Load(file_name);
                    foreach (XmlElement element in document.ChildNodes[1].ChildNodes)
                    {
                        Target_Path program = new Target_Path();
                        program.path        = element.GetAttribute("path");
                        program.command     = element.FirstChild.InnerText;
                        if (target.ContainsKey(program.command))
                        {
                            continue;
                        }
                        target.Add(program.command, program);
                        Element_Base new_item = choices.create_child(typeof(Element_Item));
                        new_item.text         = program.command;
                    }
                }
                catch
                {
                }
            });
        }
Ejemplo n.º 4
0
        public static void reload()
        {
            //Global.Main_Window.timer.Stop();
            sleep();
            Global.debug_string  = "";
            Global.thread_busy   = true;
            Global.debug_string += "b";
            Thread.Sleep(500);
            lock (Global.thread_control)
            {
                Global.debug_string += "1";
                Familiar_Document.reset();
                //     Global.load_plugins();
                engine.reload();

                Feedback.print("Finished Reloading.", Feedback.Status.story);
            }

            Global.thread_busy = false;
            wake_up();
            //Global.Main_Window.timer.Start();
        }
Ejemplo n.º 5
0
        public void initialize_external_programs(Familiar_Document new_library)
        {
            Familiar_Document library = new_library;
            Element_Choice    choices = library.get_rule_choice("programs");

            choices.children.Clear();
            programs.Clear();

            XmlDocument document = new XmlDocument();

            document.Load(Global.configuration.settings_path("external_programs.xml"));
            foreach (XmlElement element in document.ChildNodes[1].ChildNodes)
            {
                Target_Path program = new Target_Path();
                program.path              = element.GetAttribute("path");
                program.arguments         = get_element_text(element, "arguments");
                program.working_directory = get_element_text(element, "directory");
                string command = get_element_text(element, "command");
                programs.Add(command, program);
                Element_Base new_item = choices.create_child(typeof(Element_Item));
                new_item.text = command;
            }
        }