コード例 #1
0
        private void Minesweeper_Load(object sender, EventArgs e)
        {
            int posX = 0;
            int posY = 0;
            MinesweeperButton cellBtn;

            for (int i = 0; i < btnBoard.GetLength(0); i++)
            {
                for (int j = 0; j < btnBoard.GetLength(1); j++)
                {
                    cellBtn        = new MinesweeperButton(i, j);
                    cellBtn.Width  = 20;
                    cellBtn.Height = 20;
                    cellBtn.Left   = posX;
                    cellBtn.Top    = posY;
                    ButtonPanel.Controls.Add(cellBtn);
                    btnBoard[i, j]   = cellBtn;
                    posX            += 20;
                    cellBtn.MouseUp += new MouseEventHandler(cellBtn_MouseUp);
                }
                posX  = 0;
                posY += 20;
            }
            btns = new Buttons(btnBoard, game);
        }
コード例 #2
0
        private void cellBtn_MouseUp(object sender, MouseEventArgs e)
        {
            MinesweeperButton temp = (MinesweeperButton)sender;

            if (e.Button == MouseButtons.Right)
            {
                if (temp.Text == "#")
                {
                    temp.Text = "";
                }
                else if (temp.Text == "")
                {
                    temp.Text = "#";
                }
            }
            else if (e.Button == MouseButtons.Left)
            {
                btns.clickButton(temp.X, temp.Y);
            }
        }
コード例 #3
0
        public void clickButton(int x, int y)
        {
            MinesweeperButton temp = btnBoard[x, y];

            temp.Text    = game.clickCell(x, y);
            temp.Enabled = false;
            if (temp.Text == "x")
            {
                //btnQueue.Enqueue(temp);
            }
            else if (temp.Text == "0")
            {
                Queue <MinesweeperButton> btnQueue = new Queue <MinesweeperButton>();
                while (btnQueue.Count != 0)
                {
                }
            }
            else
            {
            }
        }