List of Listings

Chapter 2. Creating your first Windows Phone application

Listing 2.1. HelloPage’s content as created by the project template

Listing 2.2. Drawing the globe

Listing 2.3. GreetingPage’s content

Listing 2.4. Pinning a secondary tile

Chapter 3. Fast application switching and resume

Listing 3.1. Generated application lifetime event handlers

Listing 3.2. Defining the ContentPanel’s layout

Listing 3.3. Using a DispatcherTimer to update the user interface

Listing 3.4. UI controls showing construction times

Listing 3.5. Restoring tombstoned application data

Listing 3.6. Restoring navigatedFromTime

Listing 3.7. Adding Obscured and Unobscured event handlers

Listing 3.8. Controlling the timer in adherence to the certification requirements

Listing 3.9. Pinning a secondary tile to the Start Screen

Chapter 4. Scheduled actions

Listing 4.1. ApplicationBar markup and click event handlers

Listing 4.2. XAML markup declaring the ContentPanel for the Reminder page

Listing 4.3. Implementing a custom full-mode item template

Listing 4.4. Building a list of notifications

Listing 4.5. Displaying a notification in the LongListSelector

Listing 4.6. Creating a reminder

Listing 4.7. Saving the reminder

Listing 4.8. Sending a reminder’s Name to the Reminder page

Listing 4.9. Using the name parameter to find an existing reminder

Listing 4.10. Saving an edited reminder using Replace

Listing 4.11. Updating a Live Tile

Listing 4.12. Creating a PeriodicTask

Chapter 5. Launching tasks and choosers

Listing 5.1. Markup for the PhoneTask application’s main page

Listing 5.2. Launching the Phone Dialer with PhoneCallTask

Listing 5.3. Composing an email with EmailComposeTask

Listing 5.4. Using IsTrial to customize the home page button’s text

Listing 5.5. Wiring up the completed event handler

Listing 5.6. Saving a ringtone with SaveRingtoneTask

Listing 5.7. Retrieving the phone number from PhoneNumberChooserTask

Chapter 6. Contacts and calendars

Listing 6.1. XAML markup for the contact PivotItem

Listing 6.2. Searching for a contact

Listing 6.3. Displaying contact properties with a DataTemplate and data binding

Listing 6.4. The appointments pivot application bar markup

Listing 6.5. Searching for appointments

Listing 6.6. Displaying an appointment

Listing 6.7. The XAML markup for the data entry form

Listing 6.8. Saving a new contact

Listing 6.9. Navigating to the contact page to edit a contact

Listing 6.10. Finding and loading an existing contact

Chapter 7. Storing data

Listing 7.1. Displaying high scores

Listing 7.2. Creating a collection of HighScores

Listing 7.3. Adding a HighScore with random values

Listing 7.4. Loading scores from a file

Listing 7.5. Saving high scores to a file

Listing 7.6. Updating the HighScore class

Listing 7.7. Creating the HighScores database

Listing 7.8. Loading scores for specific levels

Listing 7.9. Upgrading an existing database

Listing 7.10. A better database upgrade implementation

Chapter 8. Working with the camera

Listing 8.1. Displaying the selected photograph

Listing 8.2. The camera Click event handler

Listing 8.3. Reading supported resolutions in the Initialized event

Listing 8.4. Checking for errors in the CaptureCompleted event handler

Listing 8.5. Extracting the Exif orientation value from the image stream

Listing 8.6. Copy pixels from original bitmap to new bitmap

Listing 8.7. Decoding the image stream

Listing 8.8. Adding a stamp to the current image

Listing 8.9. Saving an image to local storage

Listing 8.10. Loading an image from local storage

Chapter 9. Integrating with the Photos and Music + Videos Hubs

Listing 9.1. Saving a picture to the media library

Listing 9.2. Reading a picture from the media library

Listing 9.3. Using the Photos Hub token to display the selected photo

Listing 9.4. Adding controls to MainPage.xaml

Listing 9.5. Recording with the Microphone

Listing 9.6. Stopping the recording

Listing 9.7. Saving audio data to isolated storage

Listing 9.8. Displaying stored recordings

Listing 9.9. Playing the recorded voice

Listing 9.10. Handling Click events for the Play button

Listing 9.11. Creating a MediaHistoryItem

Chapter 10. Using sensors

Listing 10.1. Markup for the Bar control

Listing 10.2. Calculating bar height with the Scale and Value properties

Listing 10.3. Markup for MainPage.xaml

Listing 10.4. Reading acceleration

Listing 10.5. Reading Compass data

Listing 10.6. Initializing the Gyrometer in the Start method

Listing 10.7. Reading Gyrometer data

Listing 10.8. Initializing the Inclinometer and OrientationSensor

Listing 10.9. Displaying inclinometer data

Listing 10.10. Transforming a point with orientation data

Chapter 11. Network communication with push notifications

Listing 11.1. Reading DeviceNetworkInformation properties

Listing 11.2. Loading network information on a background thread

Listing 11.3. Loading information for all interfaces

Listing 11.4. The markup for MainPage.xaml’s Pivot control

Listing 11.5. Finding and constructing channels

Listing 11.6. Receiving toast notifications

Listing 11.7. Finding and launching the NotificationSimulator

Listing 11.8. Posting a notification using HttpWebRequest

Listing 11.9. Writing the payload to the request stream

Listing 11.10. Receiving the response

Listing 11.11. Markup for entering a toast notification into the simulator

Listing 11.12. Payload XML format for a tile notification

Listing 11.13. XAML markup for sending a tile notification from the simulator

Listing 11.14. The SendTile Click handler

Listing 11.15. Building the tile payload

Chapter 12. Using the Speech API

Listing 12.1. Basic text-to-speech example code

Listing 12.2. LanguagesListBox and VoicesListBox

Listing 12.3. Language and voice properties

Listing 12.4. Updating voices ListBox

Listing 12.5. Setting voice used by the SpeechSynthesizer

Listing 12.6. Setting voice when new voice is selected

Listing 12.7. Creating an SSML string with XDocument

Listing 12.8. Loading SSML from a file

Listing 12.9. p and s element examples

Listing 12.10. Voice gender, characters, break, and pitch examples

Listing 12.11. say-as examples

Listing 12.12. Speed, substitution, and voice variant examples

Listing 12.13. BookmarkReached event example

Listing 12.14. Sample Voice Command Definition file

Listing 12.15. Registering a VCD file

Listing 12.16. Updating a phrase list

Listing 12.17. Sample VCD file

Listing 12.18. Recognizing speech

Listing 12.19. Turning a grammar on and off

Listing 12.20. Adding Dictation grammar

Listing 12.21. Adding webSearch grammar

Listing 12.22. Adding a list grammar

Listing 12.23. SpeechRecognizer example

Listing 12.24. Checking the TextConfidence property

Listing 12.25. Checking an error code

Chapter 13. ApplicationBar and context menus

Listing 13.1. Declaring application bar buttons and menu items

Listing 13.2. Click event handler for application bar items

Listing 13.3. Toggle button icon and text

Listing 13.4. Adding a ContextMenu to a TextBlock

Listing 13.5. A MenuItem with complex header content

Chapter 14. Panorama and pivot controls

Listing 14.1. Panorama markup created by the item template

Listing 14.2. PanoramaItem content markup

Listing 14.3. Adding an image and two title lines to the Panorama control

Listing 14.4. Pivot markup created by the item template

Listing 14.5. Generating sample data with the SampleData class

Listing 14.6. The DataTemplate used to display SampleData

Listing 14.7. Loading ListBox data in response to a LoadedPivotItem event

Listing 14.8. Clearing the ItemsSource property when an item is unloaded

Chapter 15. Building a media player

Listing 15.1. MediaPlayback’s ApplicationBar

Listing 15.2. Copying content files into isolated storage

Listing 15.3. Handling menu item clicks and launching the media player

Listing 15.4. User interface skeleton

Listing 15.5. MediaPlayback’s ApplicationBar Buttons

Listing 15.6. Loading media files from local storage

Chapter 16. Using Maps

Listing 16.1. Launching Maps

Listing 16.2. Launching Maps to calculate directions

Listing 16.3. The XAML markup for the LocationsAndMaps main page

Listing 16.4. Reading the device’s current location

Listing 16.5. Formatting longitude or latitude

Listing 16.6. Add a UserLocationMarker

Listing 16.7. Executing a ReverseGeocodeQuery

Listing 16.8. Formatting the query results for display

Listing 16.9. Initializing continuous tracking with high accuracy

Listing 16.10. Handling the PositionChanged event

Listing 16.11. Display location in the user interface

Listing 16.12. Updating the route shown in the map

Listing 16.13. Stopping continuous tracking and releasing the Geolocator

Chapter 17. Building HTML applications

Listing 17.1. MainPage.xaml markup generated by the project template

Listing 17.2. HTML5 for the application’s main page

Listing 17.3. CSS styles for the application and page titles

Listing 17.4. SVG markup for a globe

Chapter 18. Releasing and monetizing apps

Listing 18.1. AdControl use in XAML

Listing 18.2. Adding AdControl in C#

Listing 18.3. App.xaml.cs caching isTrial status

Listing 18.4. App.xaml.cs caching isTrial status with conditional compilation

Listing 18.5. Getting all products for the current app

Listing 18.6. Processing an in-app purchase

Listing 18.7. Using conditional compilation

Listing 18.8. Using the mock purchase library in debug mode

Listing 18.9. MockProducts.xml

Appendix A. XAML, the Extensible Application Markup Language

Listing A.1. XAML generated by the Windows Phone Application project template

Listing A.2. Implementing INotifyPropertyChanged

Listing A.3. Creating a DataTemplate for a ContentControl

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.37.89