Пример #1
0
        private void NumberCell(Button current, Cell currentCell)
        {
            int surroundingMines = currentCell.getNumber();

            currentCell.MakeVisible();

            if (surroundingMines == 0)
            {
                current.BackColor = Color.BlanchedAlmond;
                current.Text      = " ";
            }
            else
            {
                current.BackColor = Color.AntiqueWhite;
                current.Text      = surroundingMines + "";
            }

            current.ForeColor = Color.Blue;
        }
Пример #2
0
        private void CheckSurroundingCells(int x, int y, Cell currentCell)
        {
            for (int i = -25; i <= 25; i += 25)
            {
                for (int j = -25; j <= 25; j += 25)
                {
                    var adjacentX = i + x;
                    var adjacentY = j + y;

                    if (adjacentX < 0)
                    {
                        continue;
                    }
                    if (adjacentY < 50)
                    {
                        continue;
                    }
                    if (adjacentX > 475)
                    {
                        continue;
                    }
                    if (adjacentY > 525)
                    {
                        continue;
                    }
                    if (i == 0 && j == 0)
                    {
                        continue;
                    }

                    Cell adjacentCell = cells.Find(c => c.getX() == adjacentX && c.getY() == adjacentY);
                    int  adjacentI = adjacentCell.getI(), adjacentJ = adjacentCell.getJ();

                    if (adjacentCell.isMine() || currentCell.getNumber() != 0)
                    {
                        continue;
                    }
                    buttons_MouseDown(buttons[adjacentI, adjacentJ], new MouseEventArgs(MouseButtons.Left, 0, 0, 0, 0));
                }
            }
        }