public void Button_PreviewMouseDown(Button btn, MouseButton e) { var cell = (Сell)btn.Tag; var mark = false; Сell value; if (e == MouseButton.Right) { mark = true; } if (e == MouseButton.Middle) { value = TestAlgorithm.GetСhoice(gameField.VisibleСells, gameField.Marks, gameField.Size, gameField.CountMines); } else { value = new Сell(cell.Row, cell.Column, mark); } gameField.OpenCell(value); if (gameField.Status == GameStatus.Play) { Current = value; } else { OnPropertyChanged("Status"); } Fill(); }
private static void Main(string[] args) { Write("Select a size field row: "); var sizeRow = int.Parse(ReadLine()); Write("Select a size field column: "); var sizeColumn = int.Parse(ReadLine()); Write("Select a count mine: "); var mine = int.Parse(ReadLine()); var game = new GameField(sizeRow, sizeColumn, mine); game.GenerateMines(); var field = new Сell(0, 0); do { Clear(); WriteLine("Size: R ={0,4} C ={1,4}; Count mine: {2,4};", game.Size.Row, game.Size.Column, game.CountMines); Write(game); if (game.Status == GameStatus.Play) { WriteLine("Press the key"); WriteLine("1. Enter your cell"); WriteLine("2. Use the algorithm"); switch (ReadKey().Key) { case ConsoleKey.NumPad1: WriteLine(); field = SelectCell(); break; default: field = TestAlgorithm.GetСhoice(game.VisibleСells, game.Marks, game.Size, game.CountMines); break; } WriteLine(field); game.OpenCell(field); Write(game); } else { WriteLine(field); Write(game.Status); } }while (ReadKey().Key != ConsoleKey.Q); }