private void Content(object sender, EventArgs e)
        {
            this.Hide();
            Button        b     = (Button)sender;
            WordSelection words = new WordSelection();
            string        path  = "Files\\" + b.Name + ".txt";

            string selectedword = words.getWord(path).ToUpper();

            Console.WriteLine("sleected" + selectedword);
            Form frm = new Selection(selectedword);

            frm.ShowDialog();
            this.Close();
        }
Ejemplo n.º 2
0
        private void ScramblewordGame_Load(object sender, EventArgs e)
        {
            BtnArray = new Button[] { Btn1, Btn2, Btn3, Btn4, Btn5 };
            foreach (var i in BtnArray)
            {
                i.BackColor = Color.Chocolate;
            }

            minutes = 0;
            seconds = 0;

            timer2.Start();

            string        path  = "Files\\Scrumbledwords.txt";
            WordSelection words = new WordSelection();

            selectedword = words.getWord(path).ToUpper();

            char[] selectedwordArray = selectedword.ToArray();


            Random ob = new Random();
            int    number;
            bool   check       = false;
            string jumbledword = "";

            while (true)
            {
                check = true;
                for (int i = 0; i < selectedwordArray.Length; i++)
                {
                    if (selectedwordArray[i] != '0')
                    {
                        check = false;
                    }
                }



                number = ob.Next(0, selectedwordArray.Length);
                if (selectedwordArray[number] != '0')
                {
                    jumbledword += selectedwordArray[number];
                    selectedwordArray[number] = '0';
                }

                if (selectedword.Equals(jumbledword))
                {
                    selectedwordArray = selectedword.ToCharArray();
                }



                else if (check == true)
                {
                    break;
                }
            }


            for (int i = 0; i < BtnArray.Length; i++)
            {
                BtnArray[i].Text = jumbledword[i].ToString();
            }
        }