Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Model.Stories      stories = Model.MyDatabase.getStories();
            List <Model.Story> list    = stories.getStories();

            comboBox1.DataSource = list;
        }
Example #2
0
 public ResultSearch(Form home, HomePage homepage, string input, Model.Story story)
 {
     this.home     = home;
     this.homepage = homepage;
     this.input    = input;
     if (story != null)
     {
         stories = new Model.Stories();
         stories.addStory(story);
     }
     else
     {
         stories = Model.MyDatabase.stories;
     }
     InitializeComponent();
     TimKiem();
 }
        private void HomePage_Load(object sender, EventArgs e)
        {
            resize();
            Model.Stories      stories = Model.MyDatabase.getStories();
            List <Model.Story> list    = stories.getStories();

            liststory.DataSource = list;


            MyRegex regex = new MyRegex();

            regex.InputString = "Phong Điền Khí";
            regex.Content     = "tiền bối Phong Thanh ... gã khi Điền Bá .. bên tông phái";
            Match match = regex.GenerateRegexAllMatch();

            if (match != null)
            {
                MessageBox.Show(match.Value);
            }
            else
            {
                List <Result> results = regex.FuzzyMethod();
            }
        }
        public void Search()
        {
            List <string> results = new List <string>();

            Model.Stories stories = Model.MyDatabase.getStories();

            foreach (Model.Story story in stories.getStories())
            {
                foreach (Model.Chapter chap in story.getChapters())
                {
                    MyRegex regex = new MyRegex();
                    regex.InputString = input;
                    regex.Content     = chap.content;
                    Match match = regex.GenerateRegexAllMatch();
                    if (match != null)
                    {
                        MessageBox.Show("Tìm thấy tại " + story.name + " - " + chap.name);
                        this.Dispose();
                        return;
                    }
                    else
                    {
                        List <Result> result = regex.FuzzyMethod();
                        foreach (Result rs in result)
                        {
                            int start = rs.begin;
                            int len   = rs.end - rs.begin;
                            results.Add(story.name + " - " + chap.name + ": (" + rs.numberRhythmsMatch + ")" + chap.content.Substring(start, len));
                        }
                    }
                }
            }

            listBox1.DataSource = results;
            this.Show();
        }