Exemplo n.º 1
0
        void DisplayBestRuleForConcept(string concept, string factstring)
        {
            ObservableCollectionOfRules collection = (ObservableCollectionOfRules)this.FindResource("RulesMatchingDebuggerCriterion");

            collection.Clear();
            System.Collections.Generic.SortedList <string, string> facts = new System.Collections.Generic.SortedList <string, string>();
            facts.Add("concept", concept);
            AddColumnColonToDictionary(facts, factstring);

            foreach (KeyValuePair <Rule, float> pair in RRSys.FindAllRulesMatchingCriteria(facts))
            {
                collection.Add(pair);
            }

            /*
             * Rule bestMatchingRule = RRSys.FindBestMatchingRule( facts );
             * if ( bestMatchingRule != null )
             * {
             *  collection.Add(bestMatchingRule);
             * }
             */
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            // MessageBox.Show("CLICK!");
            // MessageBox.Show(Resources["AppSystem"].ToString());
            // AppSystemWrapper appSys = new AppSystemWrapper();
            // CritGrid.ItemsSource = RRSys.CriteriaBinding;
            // Resources["CritGrid"].ItemsSource = RRSys.CriteriaBinding;

            // get a filename from the dialog box.
            string filename = null;

            {
                // Configure open file dialog box
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.FileName   = "response_rules.txt"; // Default file name
                dlg.DefaultExt = ".txt";               // Default file extension
                dlg.Filter     = "Text (.txt)|*.txt";  // Filter files by extension
                string searchdir = System.IO.Path.Combine(Environment.GetEnvironmentVariable("VGAME"),
                                                          Environment.GetEnvironmentVariable("VMOD"));
                if (searchdir.Length > 4)
                {
                    dlg.InitialDirectory = System.IO.Path.Combine(searchdir, "scripts/talker");
                }
                else
                {
                    dlg.InitialDirectory = Directory.GetCurrentDirectory();
                }

                // Show open file dialog box
                Nullable <bool> result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    // Open document
                    filename = dlg.FileName;
                }
                else
                {   // cancelled
                    return;
                }
            }

            if (System.IO.File.Exists(filename))
            {
                // get the local modpath directory from the given filename.
                string basedir = System.IO.Path.GetDirectoryName(filename);

                // check to make sure that "scripts/talker" is in there somewhere,
                // and if not, bitch.
                bool bIsScriptsTalkerDir = (basedir.Contains("scripts/talker") || basedir.Contains("scripts\\talker"));
                if (!bIsScriptsTalkerDir)
                {
                    MessageBox.Show("File is not in a 'scripts/talker' directory; #includes may not work properly.",
                                    "Minor Annoyance");
                }
                else
                {
                    // walk up two levels in the directory name.
                    basedir = Directory.GetParent(basedir).Parent.FullName;
                }

                AppSys.SetFileSystemSearchRoot(basedir);

                // load just the bare file name.
                RRSys.LoadFromFile(filename);
            }
            else
            {
                MessageBox.Show("That was a bad file name; no responses loaded.");
            }


            /*
             * foreach ( Object i in (System.Collections.IEnumerable)(RRSys.CriteriaBinding) )
             * {
             *  Criterion c = (Criterion)i.GetType().GetProperty("Val").GetValue(i, null);
             *  // MessageBox.Show( c.GetType().GetProperty("Key").GetValue(c,null).ToString() );
             * }
             */
        }