23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

queries; just search for this class in the ui.js file of WinJS and you’ll find it. Along the way, you’ll run into<br />

one more set of WinRT APIs—perhaps the bottom of the hole!—that I wanted to mention before<br />

wrapping up this subject: Windows.Storage.BulkAccess. These actually exist solely for use by<br />

StorageDataSource and are not intended for direct use in apps. Even if you create your own data source<br />

or collection control, it’s best to just use the enumeration and prefetch APIs we’ve already discussed, as<br />

they give identical performance.<br />

Here My Am! Update<br />

To bring together some of the topics we’ve covered in this chapter, the companion content includes<br />

another revision of the Here My Am! app with the following changes and additions (mostly to<br />

pages/home/home.js unless noted):<br />

• It now incorporates the Bing Maps SDK so that the control is part of the package rather than<br />

loaded from a remote source. This eliminates the iframe we’ve been using to host the map, so all<br />

the code from html/map.html can move into js/default.js. Note that to run this sample in Visual<br />

Studio you need to download and install the SDK yourself.<br />

• Instead of copying pictures taken with the camera to app data, those are now copied to a<br />

HereMyAm folder in the Pictures library. The Pictures Library capability has been declared.<br />

• Instead of saving a pathname to the last captured image file, which is used when the app is<br />

terminated and restarted, the StorageFile is saved in Windows.Storage.AccessCache to<br />

guarantee future programmatic access.<br />

• An added appbar command allows you to use the File Picker to select an image to load instead<br />

of relying solely on the camera. This also allows you to use a camera app, if desired. Note that we<br />

use a particular settingsIdentifier with the picker in this case to distinguish from the picker for<br />

recent images.<br />

• Another appbar command allows you to choose from recent pictures from the camera. This<br />

defaults to our folder in the Pictures library and uses a different settingsIdentifier.<br />

• Additional commands for About, Help, and a Privacy Statement are included on the Settings<br />

pane using the WinJS.Application.onsettings event (see js/default.js). The first two display<br />

content from within the app whereas the third pulls down web content in an iframe; all the<br />

settings pages are found in the html folder of the project.<br />

360

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!