Пример #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();
         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;
 }