/// <summary> /// Event handler for when the user lifts the mouse button. /// If it is left, reveal the tile (possibly ending the game). /// If it is right, try to flag or unflag a tile. /// </summary> private void Button_MouseUp(object sender, MouseEventArgs e) { MineSweeperButton button = (MineSweeperButton)sender; Tile tile = button.Tile; // double click //TODO if (e.Button == MouseButtons.Left) { HandleLeftClick(tile); } else if (e.Button == MouseButtons.Right) { HandleRightClick(tile); } button.ReplaceImage(); }
private void LinkButtonsToTiles(int numCols, int numRows) { FastChangeGamePanel(gp => { for (int x = 0; x < numCols; x++) { for (int y = 0; y < numRows; y++) { // Add a new connection. Tile tile = _field.GetTile(x, y); MineSweeperButton button = new MineSweeperButton(tile); _connections.Add(tile, button); gp.Controls.Add(button, x, y); button.MouseUp += Button_MouseUp; button.DoubleClick += Button_DoubleClick; } } }); }