public GameGrid(int x, int y, Form1 app, FlagsCounting box) { this.difficulty = new Dictionary <int, string>(3); this.collection = app.collection; this.timecounter.Interval = 100; this.timecounter.Tick += new EventHandler(TimeUpdate); this.box = box; this.app = app; this.mode = this.app.mode; this.nrows = x; this.ncols = y; this.button = new RestartButton(this, this.nrows); this.tabs = new Square[nrows, ncols]; for (int i = 0; i < nrows; i++) { for (int j = 0; j < ncols; j++) { this.index.Add(Tuple.Create <int, int>(i, j)); this.tabs[i, j] = new Square(i, j, this, box); } } this.difficulty.Add(0, "easy"); this.difficulty.Add(1, "normal"); this.difficulty.Add(2, "expert"); }
private void Form1_Load(object sender, EventArgs e) { FlagsCounting box = new FlagsCounting(); game = new GameGrid(this.rows, this.cols, this, box) { nflags = mines }; this.Controls.Add(game.button); this.Controls.Add(box); game.Start(); }
public Square(int i, int j, GameGrid game, FlagsCounting box) { this.Font = new Font("Segoe UI", 12, FontStyle.Bold); this.FlatAppearance.BorderColor = Color.Black; this.FlatStyle = FlatStyle.Flat; this.box = box; this.Location = new Point(i * 30, (j + 1) * 30); this.Size = new Size(30, 30); this.BackColor = Color.FromArgb(180, 180, 180); this.game = game; this.row_pos = i; this.col_pos = j; this.mined = false; this.flagged = false; this.revealed = false; this.mines_nearby = 0; this.MouseDown += new MouseEventHandler(SquareClick); }