Pro windows 8 development with HTML5 and javascript

910 201 0
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 ... 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: 27/03/2019, 16:38

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

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

Tài liệu liên quan