X hits on this document

219 views

0 shares

0 downloads

0 comments

100 / 102

3.

Add the following field to the MainMenuScreen class definition

4.

Locate the “Using Statements” region and add there the following statement:

C#

#region Fields

PhoneNumberChooserTask phoneNumberChooserTask;

#endregion

5.

Locate the constructor and replace it with the following code:

C#

public MainMenuScreen()

   : base(String.Empty)

{

   IsPopup = true;

   // Create our menu entries.

   MenuEntry startGameMenuEntry = new MenuEntry("Play");

   MenuEntry shareMenuEntry = new MenuEntry("Tell a Friend");

   MenuEntry exitMenuEntry = new MenuEntry("Exit");

   // Hook up menu event handlers.

   startGameMenuEntry.Selected += StartGameMenuEntrySelected;

   shareMenuEntry.Selected += ShareMenuEntrySelected;

   exitMenuEntry.Selected += OnCancel;

   // Add entries to the menu.

   MenuEntries.Add(startGameMenuEntry);

   MenuEntries.Add(shareMenuEntry);

   MenuEntries.Add(exitMenuEntry);

}

Note the highlighted statements. Those statements introduce a new menu item, which will launch the Phone Book and send SMS to the chosen number.

6.

Locate “Event Handlers for Menu Items” and add there the following code:

C#

/// <summary>

/// Handler "Share" menu item selection

/// </summary>

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

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

void ShareMenuEntrySelected(object sender, EventArgs e)

{

   // Create a new instance or chooser and subscribe to the Completed event

   phoneNumberChooserTask = new PhoneNumberChooserTask();

   phoneNumberChooserTask.Completed += (s, args) =>

Page | 100

Document info
Document views219
Page views219
Page last viewedSat Dec 03 14:25:37 UTC 2016
Pages102
Paragraphs3115
Words17333

Comments