コード例 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            AutoCompelete f = new AutoCompelete();

            string text = txt_search.Text.ToString();

            List <Tuple <int, string> > myfile = AutoCompelete.loadfile();
            List <Tuple <int, string> > result = AutoCompelete.getresults(text, myfile);

            string[] arr = new string[1000];
            //this.txt_search.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            //this.txt_search.AutoCompleteSource = AutoCompleteSource.CustomSource;

            for (int i = 0; i < myfile.Count; i++)
            {
                arr[i] = myfile[i].Item2;
            }


            AutoCompleteStringCollection collection = new AutoCompleteStringCollection();

            collection.AddRange(arr);

            this.txt_search.AutoCompleteCustomSource = collection;
        }
コード例 #2
0
        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {
            AutoCompelete f = new AutoCompelete();

            string text = richTextBox1.Text.ToString();

            #region "Wrong word"

            if (text.Length > 1 && text[text.Length - 1] == ' ')
            {
                string[] txt = richTextBox1.Text.Split(' ');

                for (int i = 0; i < txt.Length; i++)
                {
                    string word = txt[i];
                    if (word.Length > 1)
                    {
                        if (!Class1.IsCorrect(word))
                        {
                            this.CheckKeyword(word, Color.Red, 0);

                            Class1.getsuggestion(word);
                            List <Tuple <int, string> > ls = Class1.nearwords;


                            var Item2Result = ls.Select(item => item.Item2).ToArray();
                            list_result.DataSource = Item2Result;

                            MessageBox.Show("\n\n");
                        }
                        else
                        {
                            this.CheckKeyword(word, Color.Black, 0);
                        }
                    }
                }
            }
            #endregion

            #region "if the user enter right word"
            List <Tuple <int, string> > result = Class1.getresults(text);

            if (QuickSort.Checked)
            {
                int n = Class1.get_length(result);
                List <Tuple <int, string> > sort = Class1.quicksort(result, 0, n - 1);
                var Item2Result = sort.Select(item => item.Item2).ToArray();
                list_result.DataSource = Item2Result;
            }
            else if (MergeSort.Checked)
            {
                List <Tuple <int, string> > sort = Class1.mergesort(result);
                var Item2Result = sort.Select(item => item.Item2).ToArray();
                list_result.DataSource = Item2Result;
            }
            else if (BubbleSort.Checked)
            {
                List <Tuple <int, string> > sort = Class1.bubblesort(result);
                var Item2Result = sort.Select(item => item.Item2).ToArray();
                list_result.DataSource = Item2Result;
            }
            #endregion

            if (text == string.Empty)
            {
                list_result.DataSource = null;
            }
        }