示例#1
0
        /// <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();
        }
 public BlackHoleGameModel(IBlackHoleGameDataAccess dataAccess)
 {
     this.dataAccess = dataAccess;
 }