예제 #1
0
 private void CommandExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     if (e.Command == ApplicationCommands.Close)
     {
         this.Close();
     }
     if (e.Command == GameViewModel.StartGameCommand)
     {
         var model           = new GameViewModel();
         var startGameDialog = new StartGameWindow();
         var options         = GameOptions.Create();
         startGameDialog.DataContext = options;
         var result = startGameDialog.ShowDialog();
         if (result.HasValue && result.Value == true)
         {
             options.Save();
             model.StartNewGame();
             DataContext = model;
         }
     }
     if (e.Command == GameOptions.OptionsCommand)
     {
         var dialog = new OptionsWindow();
         var result = dialog.ShowDialog();
         if (result.HasValue && result.Value == true)
         {
             DataContext = new GameViewModel(); // Clear current game
         }
     }
     if (e.Command == GameViewModel.ShowAboutCommand)
     {
         var dialog = new AboutWindow();
         dialog.ShowDialog();
     }
     e.Handled = true;
 }
예제 #2
0
 public GameViewModel()
 {
     Players     = new List <Player>();
     gameOptions = GameOptions.Create();
 }