Exemple #1
0
        public Options()
        {
            _gameOptions = GameOptions.Create();
            DataContext  = _gameOptions;

            InitializeComponent();
        }
 private void CommandExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     if (e.Command == ApplicationCommands.Close)
     {
         this.Close();
     }
     if (e.Command == GameViewModel.StartGameCommand)
     {
         var       model           = new GameViewModel();
         StartGame startGameDialog = new StartGame();
         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 Options();
         var result = dialog.ShowDialog();
         if (result.HasValue && result.Value == true)
         {
             DataContext = new GameViewModel(); // Clear current game
         }
     }
     if (e.Command == GameViewModel.ShowAboutCommand)
     {
         var dialog = new About();
         dialog.ShowDialog();
     }
     e.Handled = true;
 }
Exemple #3
0
 public GameViewModel()
 {
     _players     = new List <Player>();
     _gameOptions = GameOptions.Create();
 }