예제 #1
0
        private void ButtonClick(object sender, EventArgs e)
        {
            if ((sender as Button).Text == order.ToString())
            {
                (sender as Button).Visible = false;
                numbers.Remove(int.Parse((sender as Button).Text));
                Suffler.Shuffle(numbers, random);

                for (int i = 0, j = 0; i < all_buttons.Count; i++)
                {
                    if (all_buttons[i].Visible == true)
                    {
                        all_buttons[i].Text = numbers[j].ToString();
                        j++;
                    }
                }

                order++;
            }
            else
            {
                numbers = new List <int>();
                for (int i = 1; i <= 16; i++)
                {
                    numbers.Add(i);
                }

                Suffler.Shuffle(numbers, random);
                for (int i = 0; i < all_buttons.Count; i++)
                {
                    all_buttons[i].Visible = true;
                    all_buttons[i].Text    = numbers[i].ToString();
                }
                order = 1;
            }

            if (order == 17)
            {
                boxik.Text = "Nice work!!!";
            }
        }
예제 #2
0
        private void AddButtons()
        {
            int x = 50, y = 20;
            int margin = 60;
            int count  = 0;

            for (int i = 0; i < 16; i++)
            {
                button          = new Button();
                button.Size     = new Size(30, 25);
                button.Location = new Point(x, y);

                count++;
                x += margin;

                if (count == 4)
                {
                    y    += 40;
                    x     = 50;
                    count = 0;
                }

                button.Click += new EventHandler(ButtonClick);

                this.tabControl1.TabPages[1].Controls.Add(button);
                all_buttons.Add(button);
            }

            for (int i = 1; i <= 16; i++)
            {
                numbers.Add(i);
            }

            Suffler.Shuffle(numbers, random);

            for (int i = 0; i < 16; i++)
            {
                all_buttons[i].Text = numbers[i].ToString();
            }
        }