public MainMenuViewModel()
        {
            NewGameCommand = new Command(() =>
            {
                App.Current.MainWindow.Content = new Game();
            });

            OpenLoadGameWindowCommand = new ParameterizedCommand(async(arg) =>
            {
                Saves      = await SaveManager.GetSaveList(1);
                var childs = ((Grid)arg).Children;
                childs.Clear();
                childs.Add(new Load());
            });

            LoadGameCommand = new ParameterizedCommand(async(arg) =>
            {
                var dataGrid = (arg as DataGrid);
                var id       = ((Save)dataGrid.Items[dataGrid.SelectedIndex]).Id;
                var memento  = await SaveManager.LoadGame(id);

                var board = GameFacade.CreateGame(GameType.Simple, memento.col, memento.row);
                board.RestoreState(memento);

                var gamePage         = new Game();
                gamePage.DataContext = new GameViewModel();

                ((GameViewModel)gamePage.DataContext).Board = board;
                App.Current.MainWindow.Content = gamePage;
            });
        }
Beispiel #2
0
 public bool CreateNewGame(string gameName, string username, string creatorName)
 {
     try
     {
         _gameManager.CreateGame(gameName, username, creatorName);
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }