Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (button2.Text == "test solution")
            {
                //get needed info from form controlls

                int value = TrBgoodChar.Value;
                richTextBox2.Text += '\n' + value.ToString();
                //words.Remove(textBox2.Text);
                cWord word = new cWord();
                if ((string)comboBox1.SelectedItem == null)
                {
                    word.SetWord(comboBox1.Text);
                }
                else
                {
                    word.SetWord( (string)comboBox1.SelectedItem);
                }

                words.AppendSearch(word, value);

                /*
                if (words.Contains(word))
                {
                    words.Remove(word);
                }

                //get char list from word to check to and copy word list to append in

                //List<char> abc = textBox2.Text.Select(c => c).ToList();
                List<char> InputWord = word.Select(c => c).ToList();
                List<string> corr = new List<string>();
                corr = words.ToList<string>();

                //check every word in m_collection

                foreach (string i in words)
                {
                    //get char list from word to check and create bool list to find the good charsin good places
                    List<char> CheckWord = i.Select(c => c).ToList();
                    List<bool> correction = new List<bool>();
                    int index = 0;

                    //check which chars are on the same place. bool list will state true on index of match and false on index of non-match

                    foreach (char t in InputWord)
                    {
                        //correction.Add(ab.Contains(t));
                        correction.Add(CheckWord.ElementAt<char>(index) == t);
                        index++;
                    }

                    //if the amount of matched chars is the same as the correct value than word still qualifies.

                    if (correction.FindAll(v => v == true).Count == value)
                    {

                    }

                    // if not word does not qualify than word is removes from m_collection

                    else
                    {
                        corr.Remove(i);
                    }
                }

                //appended list is merged with original list.

                words.Clear();
                words = corr.ToList<string>();

                //char values are redetermined

                letters2.Clear();
                foreach (string i in words)
                {
                    foreach (char t in i)
                    {
                        letters2.Add(t);
                    }
                }

                //word values are redetermined

                GetWordsValue();

                */

                //combobox is updated

                refreshList(words.ConvertToString());
            }

            //only used to change a word
            else if (button2.Text == "append word")
            {
                //word is removed and the mew one is added at the end of the list(arengment is of no concern.
                cWord WordToChange = new cWord((string)comboBox1.SelectedItem);
                cWord ChangeToWord = new cWord(textBox2.Text);

                words.ChangeWordTo(WordToChange, ChangeToWord);

                /*
                words.Remove(word);
                textBox1.Text = textBox2.Text;
                button1.PerformClick();
                letters2.Clear();
                foreach (string i in words)
                {
                    foreach (char t in i)
                    {
                        letters2.Add(t);
                    }
                }
                */
                
                refreshList(words.ConvertToString());
            }
        }