Exemplo n.º 1
0
 private static void OnSaveSettingsExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     e.ExtractDataContext <ITransaction>(vm =>
     {
         vm.Commit();
         (sender as DependencyObject).CloseParentWindow(true);
     });
 }
Exemplo n.º 2
0
 private static void OnOptionCloseExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     e.ExtractDataContext <ITransaction>(vm =>
     {
         if (vm != null)
         {
             vm.Rollback();
         }
         (sender as DependencyObject).CloseParentWindow(false);
     });
 }
Exemplo n.º 3
0
        private static void OnOptionExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var  viewModel    = e.ExtractDataContext <ClearMineViewModel>();
            bool shouldResume = false;

            if (viewModel.Game.GameState == GameState.Started)
            {
                shouldResume = true;

                // Pause the game may takes long time. Needn't wait that finish;
                Application.Current.Dispatcher.BeginInvoke(new Action(viewModel.Game.PauseGame), DispatcherPriority.Background);
            }

            var result = MessageManager.SendMessage <ShowDialogMessage>(e.OriginalSource, PopupDialog.Options, new OptionsViewModel());

            if ((bool)result)
            {
                viewModel.StartNewGame();
            }
            else if (shouldResume)
            {
                viewModel.Game.ResumeGame();
            }
        }
Exemplo n.º 4
0
        private static void OnOpenExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            var openFileDialog = new OpenFileDialog();

            openFileDialog.DefaultExt = Settings.Default.SavedGameExt;
            openFileDialog.Filter     = ResourceHelper.FindText("SavedGameFilter", Settings.Default.SavedGameExt);
            if (openFileDialog.ShowDialog() == true)
            {
                Infrastructure.Container.GetExportedValue <IGameSerializer>().LoadGame(openFileDialog.FileName,
                                                                                       e.ExtractDataContext <ClearMineViewModel>().Game.GetType());
            }
        }
Exemplo n.º 5
0
 private static void OnSaveAsExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     Infrastructure.Container.GetExportedValue <IGameSerializer>().SaveGame(e.ExtractDataContext <ClearMineViewModel>().Game);
 }
Exemplo n.º 6
0
 private static void OnRefreshExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     e.ExtractDataContext <ClearMineViewModel>().Game.Restart();
 }
Exemplo n.º 7
0
 private static void OnNewGameExecuted(object sender, ExecutedRoutedEventArgs e)
 {
     e.ExtractDataContext <ClearMineViewModel>().StartNewGame();
 }