コード例 #1
0
ファイル: App.xaml.cs プロジェクト: mozsik/BlackHoleGame
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            dataAccess = new BlackHoleGameFileDataAccess();
            model = new BlackHoleGameModel(dataAccess);
            viewModel = new BlackHoleGameViewModel(model);

            model.GameWon += new EventHandler<GameWonEventArgs>(Model_GameWon);
            viewModel.SaveGame += new EventHandler(ViewModel_SaveGame);
            viewModel.LoadGame += new EventHandler(ViewModel_LoadGame);

            Frame rootFrame = new Frame();
            rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];
            rootFrame.DataContext = viewModel;
            rootFrame.NavigationFailed += OnNavigationFailed;
            Window.Current.Content = rootFrame;

            if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                LoadAppState();
            }

            if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
            {
                throw new Exception("Failed to create initial page");
            }

            Window.Current.Activate();
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: mozsik/BlackHoleGame
        private void App_Startup(object sender, StartupEventArgs e)
        {
            gameModel = new BlackHoleGameModel(new BlackHoleGameFileDataAccess());
            gameModel.GameWon += new EventHandler<GameWonEventArgs>(Model_GameWon);

            gameViewModel = new BlackHoleGameViewModel(gameModel);
            gameViewModel.SaveGame += new EventHandler(ViewModel_SaveGame);
            gameViewModel.LoadGame += new EventHandler(ViewModel_LoadGame);
            gameViewModel.ExitGame += new EventHandler(ViewModel_ExitGame);
           
            gameView = new MainWindow();
            gameView.DataContext = gameViewModel;
            gameView.Closing += new CancelEventHandler(View_Exit);
            gameView.Show();
        }