public NewGameViewModel(NewGame newGame) { _newGame = newGame; LevelCommand = new DelegateCommand <string>(GetLevel); NewGameCommand = new DelegateCommand(NewGame); Level = 8; }
/// <summary> /// This method opens the new game window. The board is set with mines, /// based on the difficulty chosen. The number of mines neighboring each square /// is calculated. Lastly, the buttons are placed on the board and are binded /// to Cells. /// </summary> /// <param name="panelWidth"></param> private void NewGame(object panelWidth) { var startNewGame = new NewGame(); var startNewGameViewModel = new NewGameViewModel(startNewGame); startNewGame.DataContext = startNewGameViewModel; startNewGame.ShowDialog(); GameLevel = startNewGameViewModel.Level; _board = new Board(GameLevel); _board.SetDifficulty(GameLevel * .05); _board.SetupLiveNeighbors(_board); _board.CalculateLiveNeighbors(_board); double widthOfPanel = Convert.ToDouble(panelWidth); SetupBoard(widthOfPanel); }