Beispiel #1
0
        private void skinButton2_Click(object sender, EventArgs e)
        {
            string text = File_tools.read_rules(Environment.CurrentDirectory + "\\rules1.txt");



            var l1 = text.Split(":".ToCharArray());

            this.richTextBox2.Clear();

            foreach (var tmp in l1)
            {
                this.richTextBox2.AppendText(tmp + "\r\n");
            }
        }
Beispiel #2
0
        private void skinButton1_Click(object sender, EventArgs e)
        {
            string path = Environment.CurrentDirectory + "\\rules1.txt";

            string text = ":" + this.richTextBox1.Text;

            try
            {
                File_tools.update_rules(path, text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return;
            }

            MessageBox.Show("添加成功!", "成功", MessageBoxButtons.OK);
        }
Beispiel #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            int i, j;

            string path = Environment.CurrentDirectory + "\\rules1.txt";

            string tmp;

            tmp = File_tools.read_rules(path);

            var rules = tmp.Split(":".ToCharArray());

            for (i = 0; i < rules.Length; i++)//取出每一条规则放入规则字典中
            {
                var rule_pre_post = rules[i].Split(" ".ToCharArray());

                List <string> rule_pre = new List <string>();

                for (j = 0; j < rule_pre_post.Length; j++)
                {
                    if (j == rule_pre_post.Length - 1)//读到结论,把前提和结论全加入到dir中
                    {
                        dir.Add(rule_pre, rule_pre_post[j]);
                    }
                    else//读到前提
                    {
                        rule_pre.Add(rule_pre_post[j]);
                    }
                }
            }//初始化规则字典完毕

            //根据规则字典生成可供选择的事实

            List <string> l1 = new List <string>();

            foreach (var key in dir.Keys)
            {
                foreach (var pre in key)
                {
                    if (l1.Contains(pre))
                    {
                        continue;
                    }
                    else
                    {
                        l1.Add(pre);
                    }
                }
            }

            int x1 = this.listBox1.Location.X;

            int y1 = this.listBox1.Location.Y - 50;

            i = 0;

            foreach (var pre in l1)
            {
                CheckBox c1 = new CheckBox();

                c1.ForeColor = Color.Violet;

                c1.Text = pre;

                c1.Visible = true;
                if (i % 2 == 0)
                {
                    c1.Location = new Point(x1, y1);
                }
                else
                {
                    c1.Location = new Point(x1 + 110, y1);

                    y1 += 20;
                }


                this.listBox1.Controls.Add(c1);

                i++;
            }
        }