X hits on this document

275 views

0 shares

0 downloads

0 comments

93 / 102

{

   SaveActiveGameState(true);

}

/// <summary>

/// Occurs when the game class (and application) activated during return from tombstoned state

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

void GameActivated(object sender, ActivatedEventArgs e)

{

   ReloadLastGameState(true);

}

#endregion

In the event handlers we use functions SaveActiveGameState that saves the application state and ReloadLastGameState that restores the application state. We pass those functions a Boolean argument that indicates what capability to use: if the argument is true, we use Tombstoning, else, we use Isolation Storage.

194.

Add to the class the following code fragment that implements functions that we call from event handlers:

C#

#region Private functionality

/// <summary>

/// Reload last active game state from Isolated Storage or State object

/// </summary>

/// <param name="isTombstoning"></param>

private void ReloadLastGameState(bool isTombstoning)

{

   int playerScore = 0;

   int computerScore = 0;

   bool isHumanTurn = false;

   bool isLoaded = false;

   if (isTombstoning)

       isLoaded = LoadFromStateObject(out playerScore, out computerScore, out isHumanTurn);

   else

   {

       isLoaded = LoadFromIsolatedStorage(ref playerScore, ref computerScore, ref isHumanTurn);

       if (isLoaded)

       {

Page | 93

Document info
Document views275
Page views275
Page last viewedFri Dec 09 05:06:34 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments