1586 pro windows 8 development with HTML5 and javascript

910 199 0
1586 pro windows 8 development with HTML5 and javascript

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

BOOKS FOR PROFESSIONALS BY PROFESSIONALS ® Freeman RELATED Pro Windows Development with HTML5 and JavaScript Pro Windows Development with HTML5 and JavaScript shows you how to build on your web development experience to create apps that go beyond the browser and take advantage of the Windows platform features in a way that regular web apps can’t offer Led by an IT pro, you’ll follow the complete cycle of a Windows app, from an initial basic implementation, through to advanced features, and to its final release You’ll discover the different techniques, libraries, and features available to take advantage of Windows and the app environment Throughout, examples demonstrate both the power and the subtlety of Windows 8, Windows Runtime, and JavaScript You’ll learn how to: • Create an app that is dynamic, adaptive, and responsive • Effectively use the extensive asynchronous programming support that runs through the Windows app development libraries • Adapt your app layout to the capabilities and configuration of the device it’s running on • Prepare an app and go through the process for publishing it on the Windows Store Bring rich, engaging experiences to both tablet and desktop users with Pro Windows Development with HTML5 and JavaScript This book shows you how you can build on your existing knowledge of JavaScript, HTML, and CSS to create dynamic Windows apps US $59.99 Shelve in Windows / General User level: Intermediate–Advanced SOURCE CODE ONLINE www.apress.com www.it-ebooks.info For your convenience Apress has placed some of the front matter material after the index Please use the Bookmarks and Contents at a Glance links to access them www.it-ebooks.info Contents at a Glance ■ About the Author .xxiv ■ About the Technical Reviewers xxv ■ Acknowledgments xxvi Part I ■ Getting Started ■ Chapter 1: Putting Windows in Context ■ Chapter 2: Getting Started 11 ■ Chapter 3: Your First Windows App 33 ■ Chapter 4: Completing the App 53 Part II ■ Core Development 79 ■ Chapter 5: The Single-Page Model 81 ■ Chapter 6: Creating an Adaptive Layout 107 ■ Chapter 7: Commands & Navigation 135 ■ Chapter 8: View Models & Data Binding 161 ■ Chapter 9: Using Promises .193 Part III ■ UI Development .229 ■ Chapter 10: Creating the UI Controls Example Framework 231 ■ Chapter 11: Using the ToggleSwitch, Rating and Tooltip Controls 259 ■ Chapter 12: Using the Time/Date Pickers & Flyouts .281 ■ Chapter 13: Using Menus & Dialogs 303 ■ Chapter 14: Using the FlipView Control 325 ■ Chapter 15: Using the ListView Control 351 ■ Chapter 16: Using Semantic Zoom 381 ■ Chapter 17: Using Pointers & Gestures 405 ■ Chapter 18: Using Animations & Utilities 437 Part IV ■ Platform Integration .467 ■ Chapter 19: Understanding the App Lifecycle 469 iv www.it-ebooks.info ■ contents at a glance ■ Chapter 20: Working with Settings & App Data 505 ■ Chapter 21: The Search Contract .537 ■ Chapter 22: Working with Files 565 ■ Chapter 23: Integrating File Services 595 ■ Chapter 24: The File Activation & Picker Contracts 623 ■ Chapter 25: The Sharing Contract 653 ■ Chapter 26: The AutoPlay, Protocol Activation and Print Contracts .683 ■ Chapter 27: Working with App Tiles 713 ■ Chapter 28: Using Toast and the System Launcher 747 ■ Chapter 29: Working with Sensors 775 Part V ■ Selling Apps 801 ■ Chapter 30: Creating an App to Publish 803 ■ Chapter 31: Windows Store Integration 821 ■ Chapter 32: Selling Upgrades 843 ■ Chapter 33: Publishing to the Windows Store 875 ■ Index 889 v www.it-ebooks.info P a r t ■■■ Getting Started I begin this book by setting the scene for the content and style, putting Windows development in context and showing you how easily you can build on existing knowledge of web app development to create a simple Windows app www.it-ebooks.info chapter ■■■ Putting Windows in Context Windows represents Microsoft’s desire to break out of the traditional desktop computing market and make an impact in the mobile world, which has been dominated by Android devices and, of course, Apple products Microsoft’s plan is to offer the user consistency across devices, allowing the same apps to operate on the user’s data irrespective of which device, or which kind of device, the user has at hand This is attractive to many users and it leverages Microsoft’s greatest asset—the leading position in the desktop computing market—to drive sales, acceptance, and credibility in the tablet and smart-phone markets The traditional Windows desktop isn’t a good model for consistency across different types of devices, and attempts to add touch support and rework the interface for smaller screens have not ended well Trying to extend the old Windows model to small devices is part of the reason Microsoft’s previous forays into the mobile world have fared so badly And that’s where Windows apps come in Rather than perpetuate its existing application model, Microsoft has decided to create a new one Windows Store applications, more commonly known as apps, are available on every device that can run Windows and its derivatives (Windows Phone 8, Windows RT, etc.) More important, Windows apps run as well on large-screen desktop machines with a mouse and keyboard as they on a moderately sized touch-screen tablet Windows Store apps are a big departure from regular Windows desktop apps: they fill the screen, don’t have title bars and buttons, and have a completely different look and feel Another big departure for Microsoft is that you can use web technologies to create apps, which is the reason I have written this book and, most likely, the reason you are reading it By embracing HTML, CSS, and JavaScript, Microsoft has embraced a completely new community of developers, who can take their knowledge of web app development and apply it to Windows app development n Note  Microsoft uses the term Windows Store App, which I find awkward and I can’t bring myself to use it throughout this book Instead, I’ll refer to Windows apps and, often, just plain apps I’ll leave you to mentally insert the official Microsoft names as you see fit Putting App Development in Context Windows apps are at the heart of Microsoft’s effort to present a consistent user experience across a range of different device types, including traditional desktop PCs, tablets, and smart phones Windows apps offer www.it-ebooks.info chapter ■ Putting Windows in Context fast and fluid user interactions, support touch and keyboard/mouse input, and integrate tightly into Microsoft’s cloud services, allowing users to replicate their data everywhere they work and on every device they use Apps are very different from traditional Windows desktop applications Windows apps fill the screen by default, are chromeless (which means there is no surrounding window, title bar, or buttons), and can’t be resized or overlapped the way desktop apps can Users don’t close apps and there are no Close or Exit buttons Only one app is displayed at a time, so there is no need for windows or title bars Key dialogs that require input from the user, such as file pickers, are also full screen and are like miniapps in their own right In fact, they look and feel a lot like apps you might see on an iPhone, iPad, or Android device—which is, of course, no accident With Windows 8, Microsoft aims to gain some of the lucrative smart-phone and tablet market and hopes to leverage its dominance in the desktop world by making apps available across a wide range of platforms, including regular PCs Apps benefit from a range of integration services, known as contracts, which make it easy to create apps that are tightly integrated into the Windows platform and can share data with other apps If you have just installed Windows and have been wondering what some of the icons on Charm Bar are for, then wonder no more Apps use contracts to provide services to the user through the Charm Bar It may seem like an awkward tool when you are new to Windows, but it becomes second nature pretty quickly Developing Windows Apps with JavaScript and HTML One of the biggest departures for Microsoft with Windows has been making JavaScript and HTML firstclass citizens for app development This is a big deal for two reasons: the first is that Microsoft has invested heavily in the NET platform over the years and has been reluctant to open up Windows development for tools and languages that are not part of the NET family, such as C# That has changed completely with Windows The second reason is that Microsoft has stuck to the standards The JavaScript and HTML that you have used to write web apps is the same JavaScript and HTML that you use to write Windows apps There are still new libraries and techniques to learn—hence this book—but if you have developed a web app, then you already have a big chunk of the knowledge and experience you will need for app development I demonstrate this in Chapter 3, where I show you how to create your first app using little more than regular JavaScript and HTML This web-driven theme runs deep: apps written in JavaScript/HTML are executed using Internet Explorer 10 (although this isn’t evident to the user, who won’t be able to tell which technology family you have used to create your app) You don’t get to change which browser is used to execute your app, but after a while, you won’t really want to—IE10 turns out to be pretty good and has some good support for the new HTML5 and CSS3 features (There are some Microsoft-specific extensions, but they occur when the W3C standard is still being developed or where the feature is very app-specific.) Developing Apps with Visual Studio Unlike with regular web development, you can’t choose your own development tools when writing apps using JavaScript and HTML: you must use Visual Studio 2012, which is the same tool required for development targeting any Microsoft platform So, the bad news is that you have to learn a new development environment, but the good news is that Visual Studio is excellent and Microsoft has taken the time to make the JavaScript and HTML support as good as any of the tools and editors I use for regular web development I have to admit, though, that I already had a soft spot for Visual Studio from my time writing C# apps and services, and you may find that the learning curve is steep as you grapple with a new set of tools and a new kind of application development This isn’t a book about Visual Studio, but in Chapter I give you a quick tour of the essential features to help get you started www.it-ebooks.info chapter ■ Putting Windows in Context Publishing Windows Apps Most Windows apps are sold through the Windows Store The exception is apps written for the enterprise, which can be installed like traditional desktop apps (although this is available only in the Windows versions targeted at corporations) The Windows Store is much like any other app store—users can search for apps, see rankings of successful apps, and get updates for their apps And, like any other app store, the Windows Store operates by taking a cut from your app sales I’ll explain how you use the Windows Store as a developer in Part IV of this book, but it will be helpful if you bear in mind that publishing via the Windows Store is the ultimate goal of app development What Is in This Book? In this book, I show you how to use your knowledge of web app technologies and techniques and apply them to create rich, fluid, and dynamic Windows apps I start by showing you these web technologies can be used to create a simple app using the same approach that you would encounter in regular web app deployment and then show you the different techniques, libraries, and features available to take advantage of Windows and the app environment Who Is This Book For? You are an experienced web developer who already knows the basics of JavaScript, HTML, and CSS and who wants to develop apps for Windows You want to build on your web experience to create apps that go beyond the browser and take advantage of the Windows platform features in a way that regular web apps can’t offer What Do I Need to Know Before I Read This Book? You need to know how to write a simple web app, using HTML, CSS, and JavaScript You need to understand HTML elements and attributes, CSS styles, and JavaScript concepts such as functions and events You don’t have to be an expert in any of these technologies, but you need some experience I don’t provide an introduction to web development in this book, and you will struggle to follow the examples if you are new to the world of web technologies Windows app development uses HTML5 and CSS3, but it isn’t critical if you are up to speed with the latest drafts of the HTML5 specifications The new features in HTML5 and CSS3 are largely evolutionary, and a good understanding of HTML4 will give you enough of a foundation to figure out what you don’t know n Tip  The HTML5-related features I use most often in this book are actually the new CSS3 layout features, which make it easy to create fluid interfaces You can use the new elements and APIs, but for the most part you don’t need to, and some key features are exposed more conveniently through the app-specific APIs What If I Don’t Have That Experience? You may still get some benefit from this book, but you will find it very hard going and you’ll have to figure out a lot of the basic techniques required for app development on your own I have written a couple of www.it-ebooks.info chapter ■ Putting Windows in Context other books you might find useful If you are new to HTML, read The Definitive Guide to HTML5 This explains everything you need to create regular web content and basic web apps I explain how to use HTML markup and CSS3 (including the new HTML5 elements) and how to use the DOM API and the HTML5 APIs (including a JavaScript primer if you are new to the language) If you want to learn more about practical web app development, then read Pro jQuery jQuery is a very popular JavaScript library that simplifies web app development I don’t use jQuery in this book, but you will improve your understanding of all aspects of web development by learning how to use jQuery effectively (and since you can use jQuery for Windows app development, the time you spend will stand you in good stead later) For more advanced topics, read Pro JavaScript for Web Apps, in which I describe the development tricks and techniques I use in my own web development projects All three of these books are published by Apress What Don’t I Need to Know? You don’t need to have any experience in Windows desktop development or other Microsoft technologies (such as C#, XAML, or the NET framework) Developing apps with web technologies builds on what you already use for web app development, and while there is a lot to learn, you don’t have to worry about other programming languages or markups But Don’t I Have to Know C# for the Advanced Features? No, honestly Microsoft has done a pretty good job of putting JavaScript on a par with C# and the other NET languages and making HTML a good alternative to XAML (which is the way user interfaces are defined in most NET apps) When you get deep into app development, you will become aware that you are using libraries of JavaScript objects that are shared with the NET languages This is evident only because some of the object and property names are a bit odd—in all other respects you won’t even know that other languages are supported I have been writing Windows apps in both HTML/JavaScript and XAML/C# for a while and I have yet to find any feature available to NET programmers that is unavailable to web technology programmers HTML and JavaScript are first-class technologies in the world of app development What Tools and Technologies Do I Need? You need two things for app development: a PC running Windows and Visual Studio 2012 If you get serious about app development, you’ll need to buy a copy of Windows 8, but if you are just curious, you can get a 90-day trial from Microsoft—I’ll explain how later in Chapter Visual Studio 2012 is Microsoft’s development environment The good news is that Microsoft makes a basic version of Visual Studio, available free of charge, and that’s the version I’ll be using throughout this book It has the catchy name of Visual Studio 2012 Express for Windows and I’ll tell you how to get it later in this chapter Paid versions of Visual Studio are available, and you can use any of the different Visual Studio editions with this book Microsoft tends to charge for features such as enterprise integration, version control, and test management, and while they are all useful features, none of them are essential for app development and I don’t rely on them in any way www.it-ebooks.info chapter ■ Putting Windows in Context What Is the Structure of This Book? In this chapter, I introduce you to Visual Studio and show you how to create a simple project I give you a quick tour of the key parts of the Visual Studio interface, explain what each of the files in a Windows app development project looks like, and show you how to run and test an app using the app simulator tool, which is included with Visual Studio In Chapter 3, I show you how to build your first app I focus on using basic HTML, CSS, and JavaScript features to demonstrate how much of your existing web app development knowledge can be applied directly to Windows app development You’ll be pleasantly surprised by just how much you can Of course, you didn’t buy a Pro-level book for the basics, and most of the rest of the book shows you the different techniques and features that transform a basic app into one that provides a first-class app experience In the sections that follow, I briefly describe what you will learn in the other parts of the book Part II: Core Development There are some core features that almost all apps benefit from using In this part of the book, I explain these fundamentals techniques, showing you how to let the user navigate through your app’s content, how to adapt your app layout to the capabilities and configuration of the device it is running on, and how to make best use of the extensive asynchronous programming support that runs through pretty much all of the Windows app development libraries By the time you finish this part of the book, you’ll know how to create an app that is dynamic, adaptive, and responsive Part III: UI Development You can create the UI for a app, known as the layout, using the standard HTML elements, such as button and input, but you also have access to the WinJS UI library, which contains the interface controls that give Windows apps their distinctive look and feel In this part of the book, I take you on a tour of the controls, explain when they should be used and how they are applied to regular HTML elements, and give you many, many examples so you can see them in operation By the time you have finished this part of the book, you will know how to apply the distinctive Windows look and feel to create pretty, pretty apps Part IV: Platform Integration Once you have your application structure and layout in place, you can start to integrate your app into the features and services that Windows provides This includes making your app part of the file and data search process, working with the file system, telling Windows that your app supports different types of file and protocol, printing, and sharing data between apps I cover all of these topics in this part of the book and also show you how to create different kinds of notifications for your apps, including low-key live tiles and more intrusive toast notifications By the time you finish this part of the book, you will know how to make your app a first-class Windows citizen that is fully integrated into the wider platform and your user’s workflow Part V: Selling Apps In the final part of this book, I show you how to prepare an app and go through the process for publishing it in the Windows Store By the end of this part of the book, you will have seen the complete life of a Windows app, from an initial basic implementation through to advanced features and, finally, its release to the world www.it-ebooks.info ■ contents Creating the Proxy Object ��������������������������������������������������������������������������������������������������������������������������250 Detecting and Using the Proxy Object��������������������������������������������������������������������������������������������������������251 Responding to Proxy Object Property Changes������������������������������������������������������������������������������������������252 Generating the Other Element Types 253 Generating an Input Element����������������������������������������������������������������������������������������������������������������������253 Generating a Span Element������������������������������������������������������������������������������������������������������������������������254 Generating Button Elements�����������������������������������������������������������������������������������������������������������������������255 Generating ToggleSwitch Controls��������������������������������������������������������������������������������������������������������������257 Cleaning Up .258 Summary 258 ■ Chapter 11: Using the ToggleSwitch, Rating and Tooltip Controls 259 Using the ToggleSwitch Control 260 When to use the ToggleSwitch Control�������������������������������������������������������������������������������������������������������260 Demonstrating the ToggleSwitch Control���������������������������������������������������������������������������������������������������261 Applying and Configuring the ToggleSwitch Control�����������������������������������������������������������������������������������262 Styling the ToggleSwitch Control����������������������������������������������������������������������������������������������������������������263 Handling the ToggleSwitch Control Event���������������������������������������������������������������������������������������������������264 Using the Rating Control 265 When to use the Rating Control������������������������������������������������������������������������������������������������������������������266 Demonstrating the Rating Control��������������������������������������������������������������������������������������������������������������266 Applying and Configuring the Rating Control����������������������������������������������������������������������������������������������267 Styling the Rating Control���������������������������������������������������������������������������������������������������������������������������269 Handling the Rating Control Events������������������������������������������������������������������������������������������������������������271 Using the Tooltip Control 272 When to use the Tooltip Control������������������������������������������������������������������������������������������������������������������272 Demonstrating the Tooltip Control��������������������������������������������������������������������������������������������������������������272 Applying and Configuring the Tooltip Control���������������������������������������������������������������������������������������������274 Managing the Tooltip Control Programmatically�����������������������������������������������������������������������������������������278 Styling the Tooltip Control���������������������������������������������������������������������������������������������������������������������������278 Handling the Tooltip Events������������������������������������������������������������������������������������������������������������������������279 Summary 279 ■ Chapter 12: Using the Time/Date Pickers & Flyouts .281 Using the TimePicker Control 282 When to use the TimePicker Control�����������������������������������������������������������������������������������������������������������282 Demonstrating the TimePicker Control�������������������������������������������������������������������������������������������������������282 Applying and Configuring the TimePicker Control��������������������������������������������������������������������������������������284 xii www.it-ebooks.info ■ contents Managing the TimePicker Programmatically ���������������������������������������������������������������������������������������������287 Styling the TimePicker Control�������������������������������������������������������������������������������������������������������������������287 Responding to the TimePicker Event����������������������������������������������������������������������������������������������������������288 Using the DatePicker Control .289 When to use the DatePicker Control�����������������������������������������������������������������������������������������������������������290 Demonstrating the DatePicker Control�������������������������������������������������������������������������������������������������������290 Applying and Configuring the DatePicker Control��������������������������������������������������������������������������������������291 Managing the DatePicker Programmatically ���������������������������������������������������������������������������������������������293 Styling the DatePicker Control��������������������������������������������������������������������������������������������������������������������293 Responding to the DatePicker Event����������������������������������������������������������������������������������������������������������294 Revisiting the Flyout Control .295 When to use the Flyout Control������������������������������������������������������������������������������������������������������������������295 Demonstrating the Flyout Control���������������������������������������������������������������������������������������������������������������296 Applying and Configuring the Flyout Control����������������������������������������������������������������������������������������������298 Styling the Flyout Control���������������������������������������������������������������������������������������������������������������������������299 Handling the Flyout Events�������������������������������������������������������������������������������������������������������������������������300 Using the Flyout for User Interactions��������������������������������������������������������������������������������������������������������300 Summary 302 ■ Chapter 13: Using Menus & Dialogs 303 Using the Menu Control .304 When to use the Menu Control�������������������������������������������������������������������������������������������������������������������304 Demonstrating the Menu Control����������������������������������������������������������������������������������������������������������������305 Applying and Configuring the Menu Control�����������������������������������������������������������������������������������������������307 Managing the Menu Programmatically �����������������������������������������������������������������������������������������������������312 Styling the Menu Control����������������������������������������������������������������������������������������������������������������������������313 Handling the Menu Events��������������������������������������������������������������������������������������������������������������������������315 Using the MessageDialog Control .315 When to use the MessageDialog Control����������������������������������������������������������������������������������������������������316 Demonstrating the MessageDialog Control������������������������������������������������������������������������������������������������316 Using the MessageDialog Control ��������������������������������������������������������������������������������������������������������������319 Summary 323 ■ Chapter 14: Using the FlipView Control 325 Using the FlipView Control 326 When to use the FlipView Control���������������������������������������������������������������������������������������������������������������327 Creating the FlipView Control Example .327 Creating and Using a Data Source .331 xiii www.it-ebooks.info ■ contents Applying the Data Source���������������������������������������������������������������������������������������������������������������������������331 Fixing the First Image Problem 333 Solutions to the First Image Problem���������������������������������������������������������������������������������������������������������335 Configuring the FlipView Control .339 Setting the Orientation�������������������������������������������������������������������������������������������������������������������������������339 Setting the Item Spacing����������������������������������������������������������������������������������������������������������������������������340 Managing the FlipView Programmatically 341 Moving through the FlipView Items������������������������������������������������������������������������������������������������������������341 Manipulating the Data Source��������������������������������������������������������������������������������������������������������������������342 Responding to the FlipView Events 344 Styling the FlipView Control 346 Using Custom Animations 347 Applying Custom Animations����������������������������������������������������������������������������������������������������������������������347 Summary 350 ■ Chapter 15: Using the ListView Control 351 When to use the ListView Control 352 Adding the ListView Example 352 Defining the ListView HTML������������������������������������������������������������������������������������������������������������������������353 Defining the CSS�����������������������������������������������������������������������������������������������������������������������������������������354 Defining the JavaScript �����������������������������������������������������������������������������������������������������������������������������354 Working with the ListView Control 356 Selecting the Layout�����������������������������������������������������������������������������������������������������������������������������������357 Setting the Maximum Numbers of Grid Rows��������������������������������������������������������������������������������������������358 Displaying Groups���������������������������������������������������������������������������������������������������������������������������������������360 Handling the ListView Events 367 Dealing with Invoked Items������������������������������������������������������������������������������������������������������������������������367 Handling Item Selection�����������������������������������������������������������������������������������������������������������������������������369 Styling the ListView Control 371 Managing the ListView Control Programmatically 372 Searching for Elements������������������������������������������������������������������������������������������������������������������������������373 Working with the Data Source 374 Dealing with Keys���������������������������������������������������������������������������������������������������������������������������������������376 Adding Items without Keys�������������������������������������������������������������������������������������������������������������������������377 Suppressing Update Events������������������������������������������������������������������������������������������������������������������������377 Listening for Changes in the Data Source��������������������������������������������������������������������������������������������������378 xiv www.it-ebooks.info ■ contents Summary 379 ■ Chapter 16: Using Semantic Zoom 381 When to use the SemanticZoom Control 381 Adding the SemanticZoom Example 382 Defining the HTML File�������������������������������������������������������������������������������������������������������������������������������383 Defining the CSS�����������������������������������������������������������������������������������������������������������������������������������������385 Completing the Example�����������������������������������������������������������������������������������������������������������������������������385 Understanding the SemanticZoom Control 386 Creating the Zoomed In ListView Control���������������������������������������������������������������������������������������������������387 Creating the Zoomed Out ListView Control�������������������������������������������������������������������������������������������������388 Applying the SemanticZoom Control����������������������������������������������������������������������������������������������������������389 Navigating between the SemanticZoom views������������������������������������������������������������������������������������������391 Configuring the SemanticZoom Control 392 Enabling and Disabling the Zoom Out Button���������������������������������������������������������������������������������������������392 Setting the Zoom Factor�����������������������������������������������������������������������������������������������������������������������������392 Handling the SemanticZoom Control Event .393 Styling the SemanticZoom Control 393 An Alternative to the SemanticZoom Control .394 Creating the List Context Example��������������������������������������������������������������������������������������������������������������395 Adding the Event Handler Code for the List Context Example��������������������������������������������������������������������398 Summary 404 ■ Chapter 17: Using Pointers & Gestures 405 Creating the Example Project 406 Defining the CSS�����������������������������������������������������������������������������������������������������������������������������������������407 Defining the JavaScript �����������������������������������������������������������������������������������������������������������������������������407 Determining the Input Capabilities of the Device 409 Determining the Keyboard Capabilities������������������������������������������������������������������������������������������������������411 Determining the Mouse Capabilities�����������������������������������������������������������������������������������������������������������411 Determining Touch Capabilities �����������������������������������������������������������������������������������������������������������������413 Handling Pointer Events 415 Getting Pointer Information������������������������������������������������������������������������������������������������������������������������419 Handling Gestures .420 Performing Basic Gestures�������������������������������������������������������������������������������������������������������������������������423 Handling Manipulations .424 Performing Manipulation Gestures�������������������������������������������������������������������������������������������������������������426 xv www.it-ebooks.info ■ contents Handling the Manipulation Gesture Events�������������������������������������������������������������������������������������������������427 Using Content Zoom 430 Enabling the Content Zoom Feature�����������������������������������������������������������������������������������������������������������432 Applying Scaling Limits������������������������������������������������������������������������������������������������������������������������������432 Setting the Zoomed Content Style �������������������������������������������������������������������������������������������������������������433 Limiting the Range of Zoom Levels������������������������������������������������������������������������������������������������������������433 Working with Content Zoom Programmatically �����������������������������������������������������������������������������������������434 Summary 436 ■ Chapter 18: Using Animations & Utilities 437 Working with Animations 438 Creating the Example Project���������������������������������������������������������������������������������������������������������������������438 Working Directly with Elements�����������������������������������������������������������������������������������������������������������������440 Using the Core WinJS Animation Methods��������������������������������������������������������������������������������������������������445 Using the WinJS Animations�����������������������������������������������������������������������������������������������������������������������449 Using the WinJS Utilities 455 Querying the DOM��������������������������������������������������������������������������������������������������������������������������������������456 Determining the Size and Position of Elements�����������������������������������������������������������������������������������������456 Logging Messages��������������������������������������������������������������������������������������������������������������������������������������459 Summary 464 Part IV ■ Platform Integration .467 ■ Chapter 19: Understanding the App Lifecycle 469 Understanding the App Lifecycle .470 Activated�����������������������������������������������������������������������������������������������������������������������������������������������������470 Suspended��������������������������������������������������������������������������������������������������������������������������������������������������470 Resumed�����������������������������������������������������������������������������������������������������������������������������������������������������470 Terminated��������������������������������������������������������������������������������������������������������������������������������������������������470 Working with WinJS.Application 471 Building the Example App���������������������������������������������������������������������������������������������������������������������������472 Triggering Lifecycle Changes 477 Generating the Lifecycle Events in Windows 8�������������������������������������������������������������������������������������������478 Suspending the App������������������������������������������������������������������������������������������������������������������������������������479 Resuming the App��������������������������������������������������������������������������������������������������������������������������������������480 Terminating the App�����������������������������������������������������������������������������������������������������������������������������������480 Getting the Activation Type and Previous App State 481 Determining the Kind of Activation ������������������������������������������������������������������������������������������������������������481 Determining the Previous App State�����������������������������������������������������������������������������������������������������������482 xvi www.it-ebooks.info ■ contents Responding to Different Launch Types�������������������������������������������������������������������������������������������������������482 Capturing the Resuming Event 484 Responding to Lifecycle Changes 485 Dealing with the Splash Screen�����������������������������������������������������������������������������������������������������������������485 Dealing with App Termination���������������������������������������������������������������������������������������������������������������������494 Dealing with App Suspension���������������������������������������������������������������������������������������������������������������������498 Summary 504 ■ Chapter 20: Working with Settings & App Data 505 Preparing the Example App .506 Preparing the Example App������������������������������������������������������������������������������������������������������������������������506 Presenting Settings to the User 509 Defining the Flyout HTML���������������������������������������������������������������������������������������������������������������������������511 Responding to the settings Event���������������������������������������������������������������������������������������������������������������513 Making Settings Persistent .515 Storing Settings������������������������������������������������������������������������������������������������������������������������������������������516 Restoring Settings��������������������������������������������������������������������������������������������������������������������������������������518 Using Roaming Settings�����������������������������������������������������������������������������������������������������������������������������520 Using App Data Files 526 Obtaining the Folder and File Objects���������������������������������������������������������������������������������������������������������528 Writing to the File���������������������������������������������������������������������������������������������������������������������������������������529 Reading from the File���������������������������������������������������������������������������������������������������������������������������������531 Loading Files from the App Package 532 Summary 536 ■ Chapter 21: The Search Contract .537 Creating the Example App 538 Defining the View Model�����������������������������������������������������������������������������������������������������������������������������539 Defining the JavaScript Code���������������������������������������������������������������������������������������������������������������������541 Adding the App Images�������������������������������������������������������������������������������������������������������������������������������542 Testing the Example App����������������������������������������������������������������������������������������������������������������������������543 Implementing the Search Contract 543 Handle the Activation Event������������������������������������������������������������������������������������������������������������������������544 Working with the Search Pane 550 Activating Search����������������������������������������������������������������������������������������������������������������������������������������551 Providing Query Suggestions���������������������������������������������������������������������������������������������������������������������553 Adding Separators to Suggestions�������������������������������������������������������������������������������������������������������������558 xvii www.it-ebooks.info n contents Providing Result Suggestions .559 Working with the Suggestion History 562 Making Suggestions Asynchronously 563 Summary 564 n Chapter 22: Working with Files 565 Creating the Example App 565 Performing Basic File Operations 569 Copying Files 570 Deleting Files 578 Sorting and Filtering Files 579 Sorting Files 580 Filtering Files 583 Using the Advanced Query Syntax Properties 586 Using the Convenience Queries 588 Working with Virtual Folders 589 Grouping the Files .591 Processing the Grouped Files .592 Monitoring a Folder for New Files 592 Summary 594 n Chapter 23: Integrating File Services .595 Creating the Example Application .595 Declaring the File Location Capability 598 Displaying an Image File 599 Using the File and Folder Pickers .601 Using the Example 602 Understanding the Code .604 Using the File Save Picker 606 Using the Folder Picker 609 Caching Location Access 613 Using the Access Cache .616 Using File Data Sources .617 Creating the Data Source 620 Generating the Template Data 621 Summary 622 xviii www.it-ebooks.info ■ contents ■ Chapter 24: The File Activation & Picker Contracts 623 Creating the Example App 623 Defining the JavaScript������������������������������������������������������������������������������������������������������������������������������625 Testing the Example App����������������������������������������������������������������������������������������������������������������������������628 Adding the Images��������������������������������������������������������������������������������������������������������������������������������������629 Creating the Helper App 630 Implementing the File Activation Contract 632 Declaring the File Type Associations����������������������������������������������������������������������������������������������������������633 Handling the File Activation Event��������������������������������������������������������������������������������������������������������������635 Making the App the Default Handler�����������������������������������������������������������������������������������������������������������636 Implementing the App-to-App Picking Contracts 638 Implementing the Save Picker Contract�����������������������������������������������������������������������������������������������������638 Handling the Activated Event����������������������������������������������������������������������������������������������������������������������641 Implementing the Open Picker Contract�����������������������������������������������������������������������������������������������������646 Summary 651 ■ Chapter 25: The Sharing Contract 653 Creating the Example App 653 Create a Share Source .656 Registering as a Share Source�������������������������������������������������������������������������������������������������������������������658 Responding to the Event�����������������������������������������������������������������������������������������������������������������������������658 Packaging the Shared Data������������������������������������������������������������������������������������������������������������������������659 Testing the Share Source App��������������������������������������������������������������������������������������������������������������������662 Understanding a Common Sharing Problem����������������������������������������������������������������������������������������������662 Creating the Share Target 665 Updating the Manifest��������������������������������������������������������������������������������������������������������������������������������666 Responding to the Activation Event������������������������������������������������������������������������������������������������������������669 Processing the Share Operation�����������������������������������������������������������������������������������������������������������������669 Testing the Share Target Implementation���������������������������������������������������������������������������������������������������677 Creating a Quick Link 678 Creating a Quick Link���������������������������������������������������������������������������������������������������������������������������������678 Receiving a Quick Link�������������������������������������������������������������������������������������������������������������������������������680 Summary 681 ■ Chapter 26: The AutoPlay, Protocol Activation and Print Contracts .683 Revisiting the Example App .683 Implementing the AutoPlay Contract 684 xix www.it-ebooks.info ■ contents Updating the Manifest��������������������������������������������������������������������������������������������������������������������������������684 Responding to the Activation Event������������������������������������������������������������������������������������������������������������687 Testing the Contract Implementation����������������������������������������������������������������������������������������������������������690 Implementing the Protocol Activation Contract 694 Creating the Helper App������������������������������������������������������������������������������������������������������������������������������694 Adding Protocol Activation Support �����������������������������������������������������������������������������������������������������������696 Implementing the Printing Contract 699 Implementing Basic Printing����������������������������������������������������������������������������������������������������������������������699 Manipulating the App Layout for Printing ��������������������������������������������������������������������������������������������������705 Creating Print-Specific Content������������������������������������������������������������������������������������������������������������������709 Summary 712 ■ Chapter 27: Working with App Tiles 713 Creating the Example for this Chapter 714 Defining the JavaScript �����������������������������������������������������������������������������������������������������������������������������715 Setting the Tile Images�������������������������������������������������������������������������������������������������������������������������������716 Testing the Example App����������������������������������������������������������������������������������������������������������������������������717 Creating a Live Tile 717 Creating a More Useful Live Tile�����������������������������������������������������������������������������������������������������������������721 Using Templates with Images���������������������������������������������������������������������������������������������������������������������725 Clearing a Tile���������������������������������������������������������������������������������������������������������������������������������������������728 Using Badges .729 Advanced Tile Features .733 Using the Notification Queue����������������������������������������������������������������������������������������������������������������������737 Updating a Notification�������������������������������������������������������������������������������������������������������������������������������739 Scheduling Notifications�����������������������������������������������������������������������������������������������������������������������������740 Determining if Notifications are Enabled����������������������������������������������������������������������������������������������������743 Summary 745 ■ Chapter 28: Using Toast and the System Launcher 747 Using Toast Notifications 748 Creating the Example Application ��������������������������������������������������������������������������������������������������������������748 Creating a Basic Toast Notification�������������������������������������������������������������������������������������������������������������751 Configuring the Toast Notification��������������������������������������������������������������������������������������������������������������755 Dealing with Toast Activation and Dismissal����������������������������������������������������������������������������������������������758 Scheduling a Toast Notification������������������������������������������������������������������������������������������������������������������763 Determining Whether Toast Notifications Are Enabled�������������������������������������������������������������������������������764 xx www.it-ebooks.info ■ contents Using the App Launcher 766 Creating the Example App��������������������������������������������������������������������������������������������������������������������������766 Adding the Images��������������������������������������������������������������������������������������������������������������������������������������767 Defining the JavaScript Code���������������������������������������������������������������������������������������������������������������������768 Testing the Example App����������������������������������������������������������������������������������������������������������������������������771 Using the App Launcher������������������������������������������������������������������������������������������������������������������������������771 Summary 773 ■ Chapter 29: Working with Sensors 775 Creating the Example App 776 Working with Geolocation 778 Preparing the Geolocation Example������������������������������������������������������������������������������������������������������������779 Getting a Location Snapshot�����������������������������������������������������������������������������������������������������������������������781 Tracking the Location���������������������������������������������������������������������������������������������������������������������������������788 Using the Light Sensor .790 Taking a Snapshot of the Light Level����������������������������������������������������������������������������������������������������������791 Tracking the Light Level������������������������������������������������������������������������������������������������������������������������������792 Testing the Light Sensor Example��������������������������������������������������������������������������������������������������������������792 Using the Inclinometer 793 Getting the Device Tilt���������������������������������������������������������������������������������������������������������������������������������794 Using the Accelerometer 795 Getting the Device Acceleration �����������������������������������������������������������������������������������������������������������������796 Using the Compass 797 Getting the Device Direction ����������������������������������������������������������������������������������������������������������������������798 Summary 799 Part V ■ Selling Apps 801 ■ Chapter 30: Creating an App to Publish 803 Deciding On Your App 803 Deciding On Your Business Model .803 Getting Ready 804 Reserving the App Name����������������������������������������������������������������������������������������������������������������������������805 Creating the Visual Studio Project .807 Creating the Business Model Code�������������������������������������������������������������������������������������������������������������808 Creating the View Model State�������������������������������������������������������������������������������������������������������������������809 Defining the Layout������������������������������������������������������������������������������������������������������������������������������������810 Defining the CSS�����������������������������������������������������������������������������������������������������������������������������������������812 xxi www.it-ebooks.info ■ contents Defining the JavaScript Code���������������������������������������������������������������������������������������������������������������������813 Updating the Manifest��������������������������������������������������������������������������������������������������������������������������������817 Testing the Example App 818 Summary 819 ■ Chapter 31: Windows Store Integration 821 General Advice on App Licensing 821 Books and Apps Have a Lot in Common�����������������������������������������������������������������������������������������������������822 Focusing on What Matters��������������������������������������������������������������������������������������������������������������������������822 Dealing with a Basic Store Scenario 823 Creating the Scenario File��������������������������������������������������������������������������������������������������������������������������823 Using the License Information��������������������������������������������������������������������������������������������������������������������826 Enforcing the License Policy .831 Triggering the Capability Check������������������������������������������������������������������������������������������������������������������831 Dealing with Valid Trial Periods������������������������������������������������������������������������������������������������������������������833 Dealing with Expired Trial Periods��������������������������������������������������������������������������������������������������������������835 Adding Support for Buying the App������������������������������������������������������������������������������������������������������������838 Summary 841 ■ Chapter 32: Selling Upgrades 843 Defining the Products in the Scenario File 843 Defining the Remaining Products���������������������������������������������������������������������������������������������������������������845 Using the License Information 847 Processing the Product Licenses���������������������������������������������������������������������������������������������������������������848 Testing the License Information�����������������������������������������������������������������������������������������������������������������849 Correcting the License Entitlements�����������������������������������������������������������������������������������������������������������850 Selling Upgrades .851 Dispatching State Events ���������������������������������������������������������������������������������������������������������������������������851 Managing the Purchasing Process�������������������������������������������������������������������������������������������������������������852 Refreshing the App State����������������������������������������������������������������������������������������������������������������������������856 Buying the Upgrade������������������������������������������������������������������������������������������������������������������������������������856 Testing the Scenario�����������������������������������������������������������������������������������������������������������������������������������857 Creating an In-App Store-Front 860 Enhancing the ViewModel.Store Namespace���������������������������������������������������������������������������������������������860 Defining the Store Interactions�������������������������������������������������������������������������������������������������������������������863 Defining the Markup and Styles�����������������������������������������������������������������������������������������������������������������864 Writing the Code�����������������������������������������������������������������������������������������������������������������������������������������865 Testing the In-App Store Feature����������������������������������������������������������������������������������������������������������������869 xxii www.it-ebooks.info ■ contents Adding the Real Product Data���������������������������������������������������������������������������������������������������������������������871 Testing the In-App Store with Real Data�����������������������������������������������������������������������������������������������������873 Summary 874 ■ Chapter 33: Publishing to the Windows Store 875 Preparing the App Listing 875 Completing the Selling Details Section������������������������������������������������������������������������������������������������������876 Completing the Advanced Features Section�����������������������������������������������������������������������������������������������876 Completing the Age Rating Section������������������������������������������������������������������������������������������������������������877 Completing the Cryptography Section��������������������������������������������������������������������������������������������������������878 Associating the App with the Store 879 Providing a Store Logo�������������������������������������������������������������������������������������������������������������������������������880 Removing the Store Simulation Code 880 Building the App Package 881 Completing the App Listing .885 Completing the Packages Section��������������������������������������������������������������������������������������������������������������885 Completing the Description Section�����������������������������������������������������������������������������������������������������������885 Completing the Notes for Testers Section��������������������������������������������������������������������������������������������������886 Submitting Your App 886 Summary 887 ■ Index 889 xxiii www.it-ebooks.info About the Author  Adam Freeman is an experienced IT professional who has held senior positions in a range of companies, most recently serving as chief technology officer and chief operating officer of a global bank Now retired, he spends his time writing and running xxiv www.it-ebooks.info About the Technical Reviewers  Andy Olsen runs a software training company based in the UK, delivering training in NET, Java, web, and mobile technologies in Europe, the US, and Asia Andy has been working with NET since the days of the first beta and is actively involved with the latest features in the NET 4.5 platform Andy lives by the sea in Swansea with his wife, Jayne, and their children, Emily and Tom Andy enjoys running along the sea front (with copious coffee stops along the way), skiing, and following the Swans! Andy can be reached at andyo@olsensoft.com  Fabio Claudio Ferracchiati is a senior consultant and a senior analyst/developer using Microsoft technologies He works for Brain Force (www.brainforce.com) in its Italian branch (www.brainforce.it) He is a Microsoft Certified Solution Developer for NET, a Microsoft Certified Application Developer for NET, a Microsoft Certified Professional, and a prolific author and technical reviewer Over the past ten years, he’s written articles for Italian and international magazines and coauthored more than ten books on a variety of computer topics xxv www.it-ebooks.info Acknowledgments I would like to thank everyone at Apress for working so hard to bring this book to print In particular, I would like to thank Ewan Buckingham for commissioning and editing this title and Christine Ricketts for keeping track of everything I would also like to thank the technical reviewers, Andy and Fabio, whose efforts made this book far better than it otherwise would have been —Adam Freeman xxvi www.it-ebooks.info ... writing Windows apps in both HTML /JavaScript and XAML/C# for a while and I have yet to find any feature available to NET programmers that is unavailable to web technology programmers HTML and JavaScript. .. 87 5 ■ Index 88 9 v www.it-ebooks.info P a r t ■■■ Getting Started I begin this book by setting the scene for the content and style, putting Windows development in context and. .. new one Windows Store applications, more commonly known as apps, are available on every device that can run Windows and its derivatives (Windows Phone 8, Windows RT, etc.) More important, Windows

Ngày đăng: 06/03/2019, 14:54

Từ khóa liên quan

Mục lục

  • Cover

    • Contents at a Glance

    • Contents

    • About the Author

    • About the Technical Reviewers

    • Acknowledgments

  • Chapter 1 Putting Windows 8 in Context

    • Putting App Development in Context

      • Developing Windows Apps with JavaScript and HTML

      • Developing Apps with Visual Studio

      • Publishing Windows Apps

    • What Is in This Book?

    • Who Is This Book For?

    • What Do I Need to Know Before I Read This Book?

      • What If I Don’t Have That Experience?

    • What Don’t I Need to Know?

      • But Don’t I Have to Know C# for the Advanced Features?

    • What Tools and Technologies Do I Need?

    • What Is the Structure of This Book?

      • Part II: Core Development

      • Part III: UI Development

      • Part IV: Platform Integration

      • Part V: Selling Apps

    • Are There Lots of Examples in This Book?

      • What If I Want to Follow the Examples Myself?

    • Image Attribution

  • Chapter 2 Getting Started

    • Getting Set Up

      • Getting Visual Studio Ready

      • Optional Equipment

    • Getting Started

      • Creating the Visual Studio Project

      • Running the Project

    • Exploring the Project

      • Exploring the Project References

      • Exploring the Default Files

      • Understanding the Manifest

    • The Visual Studio Tools

      • The Visual Studio Editor

      • The JavaScript Console

      • The DOM Explorer

      • The Debugger

    • Summary

  • Chapter 3 Your First Windows 8 App

    • Understanding the App Structure

    • Revisiting the Example App Project

    • Creating the Navigation Infrastructure

      • Defining the Code

      • Dealing with the Global Namespace

      • Understanding Windows App Namespaces

      • Defining a Global Navigation Function

      • Displaying the Initial Page

    • Adding the Musical Note Font

    • Defining the App-Wide CSS

    • Adding the Selector Page

      • Defining the Selector Page CSS

      • Defining the Selector Page JavaScript Code

    • Summary

  • Chapter 4 Completing the App

    • Revisiting the Example App

    • Defining the Notes Data

      • Windows JavaScript Classes

      • Creating Namespaces

    • Adding the Flash Card Page

      • Adding the Page-Specific CSS

      • Defining the Code for the Flash Card Page

    • Using WinJS Data Binding

      • Defining the Data

      • Declaring the Bindings

      • Applying the Data to the Bindings

    • Configuring Buttons and Navigation

      • Configuring the Answer Buttons

    • Setting the State

      • Resetting the Other State Values

    • Showing the Flash Cards

    • Handling the Answer and Navigation Button Events

      • Relying on Data Bindings to Disseminate Data Updates

    • Updating the App Manifest

      • Setting the Tile Images and Color

      • Setting the App Name

    • Testing the Completed App

      • Windows Apps Build on Web Technologies

      • Windows Apps Are Not Web Apps

      • Data Binding Simplifies App Development

      • The WinJS API Is Written in JavaScript

    • Summary

  • Chapter 5 The Single-Page Model

    • Creating the Single-Page Project

      • Defining the Initial CSS

      • Defining the Initial JavaScript

    • Importing Content Declaratively

      • Understanding the Import Mechanism

    • Importing Content Programmatically

      • Using HtmlControl Programmatically

      • The Perils of Importing Interactive Content

    • Using the WinJS Pages Feature

      • Importing the Content

      • Registering the Callback

      • Ensuring the Content Order

      • Forcing a Content Order with Promises

    • Using the Navigation API

      • Handling the Navigation Events

      • Calling the Navigate Method

      • Using the Navigation History

    • Summary

  • Chapter 6 Creating an Adaptive Layout

    • Creating the Example Project

    • Understanding the Metro Views

    • Adapting to Views Using CSS

      • Adapting to the Filled View

      • Adapting to the Snapped View

    • Adapting to Views Using JavaScript

      • Detecting the Current View

      • Receiving View Change Events

    • Adapting to View Changes in Imported Content

    • Breaking Out of the Snapped View

    • Adapting to Device Orientation

      • Determining and Monitoring the Device Orientation

      • Using CSS to Adapt to Device Orientation

      • Expressing Your Device Orientation Preferences

    • Adapting to Pixel Density

      • Using Automatic Resource Loading

      • Adapting to Pixel Density Using JavaScript

    • Summary

  • Chapter 7 Commands & Navigation

    • Creating the Example Project

      • Defining and Loading the Content

      • Defining the JavaScript

      • Defining the CSS

    • Creating Application Commands

      • Declaring the AppBar Control

      • Adding Buttons to the AppBar

      • Responding to Commands

    • Creating Navigation Commands

      • Using a Standard NavBar

      • Using a Custom NavBar

      • Animating the Navigation Transition

    • Summary

  • Chapter 8 View Models & Data Binding

    • Revisiting the Example App

    • Decoupling App Components

      • Defining the View Model

      • Importing and Populating the View Model

      • Consuming the View Model

    • Separating Data from the Layout

      • Demonstrating the Problem

      • Applying the View Model

    • Using Data Binding

      • Making Objects Observable

      • Consuming Observable Object Events

      • Refactoring the Observable Properties

    • Using Declarative Bindings

      • Processing the Document

      • Declaring the Bindings

    • Creating Observable Arrays

      • Creating an Observable Array

      • Observing a List

    • Using Templates

      • Defining and Using the Template

    • Using Value Converters

      • Using an Open Value Converter

    • Summary

  • Chapter 9 Using Promises

    • Creating the Example Project

    • Dealing with the Basic Asynchronous Programming Flow

      • Using Asynchronous Callbacks

      • Creating Chains

      • Cancelling Promises

      • Passing a Result from a Promise

    • Coordinating Promises

      • Using the any method

      • Using the join method

      • Working with Timeouts

      • Applying the Same Callback Functions to Multiple Promises

    • Creating Custom Promises

      • Implementing the Promise

      • Deferring Execution

      • Implement Cancelation

    • Creating Synthetic Promises

      • Writing Your Own Synthetic Promise

      • Using the Wrapper Methods

    • Summary

  • Chapter 10 Creating the UI Controls Example Framework

    • Understanding the Final App

    • Creating the Basic Project Structure

      • Adding the Template Generation Code

      • Adding the Navigation Code

      • Adding the Other JavaScript Files

      • Adding the CSS

    • Creating the Test Content Page

      • Creating the Content page

    • Creating the Template System

      • Describing a Select Element

      • Adding the Element Generation Code

    • Generating a Select Element

      • Rendering the Template

      • Configuring & Populating the Select Element

      • Creating the Event Handler

      • Finishing Up

    • Using a Proxy Object

      • Adding the Definition Object

      • Creating the Proxy Object

      • Detecting and Using the Proxy Object

      • Responding to Proxy Object Property Changes

    • Generating the Other Element Types

      • Generating an Input Element

      • Generating a Span Element

      • Generating Button Elements

      • Generating ToggleSwitch Controls

    • Cleaning Up

    • Summary

  • Chapter 11 Using the ToggleSwitch, Rating and Tooltip Controls

    • Using the ToggleSwitch Control

      • When to use the ToggleSwitch Control

      • Demonstrating the ToggleSwitch Control

      • Applying and Configuring the ToggleSwitch Control

      • Styling the ToggleSwitch Control

      • Handling the ToggleSwitch Control Event

    • Using the Rating Control

      • When to use the Rating Control

      • Demonstrating the Rating Control

      • Applying and Configuring the Rating Control

      • Styling the Rating Control

      • Handling the Rating Control Events

    • Using the Tooltip Control

      • When to use the Tooltip Control

      • Demonstrating the Tooltip Control

      • Applying and Configuring the Tooltip Control

      • Managing the Tooltip Control Programmatically

      • Styling the Tooltip Control

      • Handling the Tooltip Events

    • Summary

  • Chapter 12 Using the Time/Date Pickers & Flyouts

    • Using the TimePicker Control

      • When to use the TimePicker Control

      • Demonstrating the TimePicker Control

      • Applying and Configuring the TimePicker Control

      • Managing the TimePicker Programmatically

      • Styling the TimePicker Control

      • Responding to the TimePicker Event

    • Using the DatePicker Control

      • When to use the DatePicker Control

      • Demonstrating the DatePicker Control

      • Applying and Configuring the DatePicker Control

      • Managing the DatePicker Programmatically

      • Styling the DatePicker Control

      • Responding to the DatePicker Event

    • Revisiting the Flyout Control

      • When to use the Flyout Control

      • Demonstrating the Flyout Control

      • Applying and Configuring the Flyout Control

      • Styling the Flyout Control

      • Handling the Flyout Events

      • Using the Flyout for User Interactions

    • Summary

  • Chapter 13 Using Menus & Dialogs

    • Using the Menu Control

      • When to use the Menu Control

      • Demonstrating the Menu Control

      • Applying and Configuring the Menu Control

      • Managing the Menu Programmatically

      • Styling the Menu Control

      • Handling the Menu Events

    • Using the MessageDialog Control

      • When to use the MessageDialog Control

      • Demonstrating the MessageDialog Control

      • Using the MessageDialog Control

    • Summary

  • Chapter 14 Using the FlipView Control

    • Using the FlipView Control

      • When to use the FlipView Control

    • Creating the FlipView Control Example

    • Creating and Using a Data Source

      • Applying the Data Source

    • Fixing the First Image Problem

      • Solutions to the First Image Problem

    • Configuring the FlipView Control

      • Setting the Orientation

      • Setting the Item Spacing

    • Managing the FlipView Programmatically

      • Moving through the FlipView Items

      • Manipulating the Data Source

    • Responding to the FlipView Events

    • Styling the FlipView Control

    • Using Custom Animations

      • Applying Custom Animations

    • Summary

  • Chapter 15 Using the ListView Control

    • When to use the ListView Control

    • Adding the ListView Example

      • Defining the ListView HTML

      • Defining the CSS

      • Defining the JavaScript

    • Working with the ListView Control

      • Selecting the Layout

      • Setting the Maximum Numbers of Grid Rows

      • Displaying Groups

    • Handling the ListView Events

      • Dealing with Invoked Items

      • Handling Item Selection

    • Styling the ListView Control

    • Managing the ListView Control Programmatically

      • Searching for Elements

    • Working with the Data Source

      • Dealing with Keys

      • Adding Items without Keys

      • Suppressing Update Events

      • Listening for Changes in the Data Source

    • Summary

  • Chapter 16 Using Semantic Zoom

    • When to use the SemanticZoom Control

    • Adding the SemanticZoom Example

      • Defining the HTML File

      • Defining the CSS

      • Completing the Example

    • Understanding the SemanticZoom Control

      • Creating the Zoomed In ListView Control

      • Creating the Zoomed Out ListView Control

      • Applying the SemanticZoom Control

      • Navigating between the SemanticZoom views

    • Configuring the SemanticZoom Control

      • Enabling and Disabling the Zoom Out Button

      • Setting the Zoom Factor

    • Handling the SemanticZoom Control Event

    • Styling the SemanticZoom Control

    • An Alternative to the SemanticZoom Control

      • Creating the List Context Example

      • Adding the Event Handler Code for the List Context Example

    • Summary

  • Chapter 17 Using Pointers & Gestures

    • Creating the Example Project

      • Defining the CSS

      • Defining the JavaScript

    • Determining the Input Capabilities of the Device

      • Determining the Keyboard Capabilities

      • Determining the Mouse Capabilities

      • Determining Touch Capabilities

    • Handling Pointer Events

      • Getting Pointer Information

    • Handling Gestures

      • Performing Basic Gestures

    • Handling Manipulations

      • Performing Manipulation Gestures

      • Handling the Manipulation Gesture Events

    • Using Content Zoom

      • Applying Scaling Limits

      • Setting the Zoomed Content Style

      • Limiting the Range of Zoom Levels

    • Summary

  • Chapter 18 Using Animations & Utilities

    • Working with Animations

      • Creating the Example Project

      • Working Directly with Elements

      • Using the Core WinJS Animation Methods

      • Using the WinJS Animations

    • Using the WinJS Utilities

      • Querying the DOM

      • Determining the Size and Position of Elements

      • Logging Messages

    • Summary

  • Chapter 19 Understanding the App Lifecycle

    • Understanding the App Lifecycle

      • Activated

      • Suspended

      • Resumed

      • Terminated

    • Working with WinJS.Application

      • Building the Example App

    • Triggering Lifecycle Changes

      • Generating the Lifecycle Events in Windows 8

      • Suspending the App

      • Resuming the App

      • Terminating the App

    • Getting the Activation Type and Previous App State

      • Determining the Kind of Activation

      • Determining the Previous App State

      • Responding to Different Launch Types

    • Capturing the Resuming Event

    • Responding to Lifecycle Changes

      • Dealing with the Splash Screen

      • Dealing with App Termination

      • Dealing with App Suspension

    • Summary

  • Chapter 20 Working with Settings & App Data

    • Preparing the Example App

      • Preparing the Example App

    • Presenting Settings to the User

      • Defining the Flyout HTML

      • Responding to the settings Event

    • Making Settings Persistent

      • Storing Settings

      • Restoring Settings

      • Using Roaming Settings

    • Using App Data Files

      • Obtaining the Folder and File Objects

      • Writing to the File

      • Reading from the File

    • Loading Files from the App Package

    • Summary

  • Chapter 21 The Search Contract

    • Creating the Example App

      • Defining the View Model

      • Defining the JavaScript Code

      • Adding the App Images

      • Testing the Example App

    • Implementing the Search Contract

      • Handle the Activation Event

    • Working with the Search Pane

      • Activating Search

      • Providing Query Suggestions

      • Adding Separators to Suggestions

      • Providing Result Suggestions

      • Working with the Suggestion History

      • Making Suggestions Asynchronously

    • Summary

  • Chapter 22 Working with Files

    • Creating the Example App

    • Performing Basic File Operations

      • Copying Files

      • Deleting Files

    • Sorting and Filtering Files

      • Sorting Files

      • Filtering Files

      • Using the Advanced Query Syntax Properties

      • Using the Convenience Queries

    • Working with Virtual Folders

      • Grouping the Files

      • Processing the Grouped Files

    • Monitoring a Folder for New Files

    • Summary

  • Chapter 23 Integrating File Services

    • Creating the Example Application

      • Declaring the File Location Capability

    • Displaying an Image File

    • Using the File and Folder Pickers

      • Using the Example

      • Understanding the Code

      • Using the File Save Picker

      • Using the Folder Picker

    • Caching Location Access

      • Using the Access Cache

    • Using File Data Sources

      • Creating the Data Source

      • Generating the Template Data

    • Summary

  • Chapter 24 The File Activation & Picker Contracts

    • Creating the Example App

      • Defining the JavaScript

      • Testing the Example App

      • Adding the Images

    • Creating the Helper App

    • Implementing the File Activation Contract

      • Declaring the File Type Associations

      • Handling the File Activation Event

      • Making the App the Default Handler

    • Implementing the App-to-App Picking Contracts

      • Implementing the Save Picker Contract

      • Handling the Activated Event

      • Implementing the Open Picker Contract

    • Summary

  • Chapter 25 The Sharing Contract

    • Creating the Example App

    • Create a Share Source

      • Registering as a Share Source

      • Responding to the Event

      • Packaging the Shared Data

      • Testing the Share Source App

      • Understanding a Common Sharing Problem

    • Creating the Share Target

      • Updating the Manifest

      • Responding to the Activation Event

      • Processing the Share Operation

      • Testing the Share Target Implementation

    • Creating a Quick Link

      • Creating a Quick Link

      • Receiving a Quick Link

    • Summary

  • Chapter 26 The AutoPlay, Protocol Activation and Print Contracts

    • Revisiting the Example App

    • Implementing the AutoPlay Contract

      • Updating the Manifest

      • Responding to the Activation Event

      • Testing the Contract Implementation

    • Implementing the Protocol Activation Contract

      • Creating the Helper App

      • Adding Protocol Activation Support

    • Implementing the Printing Contract

      • Implementing Basic Printing

      • Manipulating the App Layout for Printing

      • Creating Print-Specific Content

    • Summary

  • Chapter 27 Working with App Tiles

    • Creating the Example for this Chapter

      • Defining the JavaScript

      • Setting the Tile Images

      • Testing the Example App

    • Creating a Live Tile

      • Creating a More Useful Live Tile

      • Using Templates with Images

      • Clearing a Tile

    • Using Badges

    • Advanced Tile Features

      • Using the Notification Queue

      • Updating a Notification

      • Scheduling Notifications

      • Determining if Notifications are Enabled

    • Summary

  • Chapter 28 Using Toast and the System Launcher

    • Using Toast Notifications

      • Creating the Example Application

      • Creating a Basic Toast Notification

      • Configuring the Toast Notification

      • Dealing with Toast Activation and Dismissal

      • Scheduling a Toast Notification

      • Determining Whether Toast Notifications Are Enabled

    • Using the App Launcher

      • Creating the Example App

      • Adding the Images

      • Defining the JavaScript Code

      • Testing the Example App

      • Using the App Launcher

    • Summary

  • Chapter 29 Working with Sensors

    • Creating the Example App

    • Working with Geolocation

      • Preparing the Geolocation Example

      • Getting a Location Snapshot

      • Tracking the Location

    • Using the Light Sensor

      • Taking a Snapshot of the Light Level

      • Tracking the Light Level

      • Testing the Light Sensor Example

    • Using the Inclinometer

      • Getting the Device Tilt

    • Using the Accelerometer

      • Getting the Device Acceleration

    • Using the Compass

      • Getting the Device Direction

    • Summary

  • Chapter 30 Creating an App to Publish

    • Deciding On Your App

    • Deciding On Your Business Model

    • Getting Ready

      • Reserving the App Name

    • Creating the Visual Studio Project

      • Creating the Business Model Code

      • Creating the View Model State

      • Defining the Layout

      • Defining the CSS

      • Defining the JavaScript Code

      • Updating the Manifest

    • Testing the Example App

    • Summary

  • Chapter 31 Windows Store Integration

    • General Advice on App Licensing

      • Books and Apps Have a Lot in Common

      • Focusing on What Matters

    • Dealing with a Basic Store Scenario

      • Creating the Scenario File

      • Using the License Information

    • Enforcing the License Policy

      • Triggering the Capability Check

      • Dealing with Valid Trial Periods

      • Dealing with Expired Trial Periods

      • Adding Support for Buying the App

    • Summary

  • Chapter 32 Selling Upgrades

    • Defining the Products in the Scenario File

      • Defining the Remaining Products

    • Using the License Information

      • Processing the Product Licenses

      • Testing the License Information

      • Correcting the License Entitlements

    • Selling Upgrades

      • Dispatching State Events

      • Managing the Purchasing Process

      • Refreshing the App State

      • Buying the Upgrade

      • Testing the Scenario

    • Creating an In-App Store-Front

      • Enhancing the ViewModel.Store Namespace

      • Defining the Store Interactions

      • Defining the Markup and Styles

      • Writing the Code

      • Testing the In-App Store Feature

      • Adding the Real Product Data

      • Testing the In-App Store with Real Data

    • Summary

  • Chapter 33 Publishing to the Windows Store

    • Preparing the App Listing

      • Completing the Selling Details Section

      • Completing the Advanced Features Section

      • Completing the Age Rating Section

      • Completing the Cryptography Section

    • Associating the App with the Store

      • Providing a Store Logo

    • Removing the Store Simulation Code

    • Building the App Package

    • Completing the App Listing

      • Completing the Packages Section

      • Completing the Description Section

      • Completing the Notes for Testers Section

    • Submitting Your App

    • Summary

  • Index

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H

    • I

    • J, K

    • L

    • M

    • N

    • O

    • P, Q

    • R

    • S

    • T

    • U

    • V

    • W, X, Y, Z

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan