dareks_

  • Dokumenty2 821
  • Odsłony706 906
  • Obserwuję404
  • Rozmiar dokumentów32.8 GB
  • Ilość pobrań346 348

Real World Windows 10 Development, 2nd Edition - Edward Moemeka, Elizabeth Moemeka (2015)

Dodano: 6 lata temu

Informacje o dokumencie

Dodano: 6 lata temu
Rozmiar :14.4 MB
Rozszerzenie:pdf

Real World Windows 10 Development, 2nd Edition - Edward Moemeka, Elizabeth Moemeka (2015).pdf

dareks_ EBooki Infornatyka
Użytkownik dareks_ wgrał ten materiał 6 lata temu. Od tego czasu zobaczyło go już 63 osób, 69 z nich pobrało dokument.

Komentarze i opinie (0)

Transkrypt ( 25 z dostępnych 617 stron)

Real World Windows 10 Development Second Edition — Edward Moemeka Elizabeth Moemeka THE EXPERT’S VOICE® IN WINDOWS DEVELOPMENT www.it-ebooks.info

Real World Windows 10 Development Second Edition Edward Moemeka Elizabeth Moemeka www.it-ebooks.info

Real World Windows 10 Development Copyright © 2015 by Edward Moemeka and Elizabeth Moemeka This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law. ISBN-13 (pbk): 978-1-4842-1450-3 ISBN-13 (electronic): 978-1-4842-1449-7 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director: Welmoed Spahr Lead Editor: James DeWolf Technical Reviewer: Fabio Cladio Ferracchiati Editorial Board: Steve Anglin, Pramila Balen, Louise Corrigan, Jim DeWolf, Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, Michelle Lowman, James Markham, Susan McDermott, Matthew Moodie, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Gwenan Spearing Coordinating Editor: Melissa Maldonado Copy Editor: Mary Behr Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springer.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail rights@apress.com, or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this text is available to readers at www.apress.com. For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/. www.it-ebooks.info

This book is dedicated to my father, Professor Andrew Azukaego Moemeka, who has been my greatest inspiration. —Edward Moemeka We also both dedicate this book, in loving memory, to William “Bill” Brown. www.it-ebooks.info

v Contents at a Glance About the Authors����������������������������������������������������������������������������������������������������xv About the Technical Reviewers�����������������������������������������������������������������������������xvii Acknowledgments��������������������������������������������������������������������������������������������������xix Introduction������������������������������������������������������������������������������������������������������������xxi ■■Chapter 1: The Windows 10 Ethos and Environment��������������������������������������������� 1 ■■Chapter 2: Basic Controls������������������������������������������������������������������������������������ 53 ■■Chapter 3: Data Controls����������������������������������������������������������������������������������� 101 ■■Chapter 4: Layout and Custom Controls������������������������������������������������������������ 135 ■■Chapter 5: Building an Adaptive Experience����������������������������������������������������� 179 ■■Chapter 6: File IO����������������������������������������������������������������������������������������������� 209 ■■Chapter 7: Working with Media������������������������������������������������������������������������� 257 ■■Chapter 8: Location and Mapping���������������������������������������������������������������������� 305 ■■Chapter 9: Background Tasks���������������������������������������������������������������������������� 343 ■■Chapter 10: Shell Integration���������������������������������������������������������������������������� 377 ■■Chapter 11: Communicating Between Apps������������������������������������������������������ 419 ■■Chapter 12: Leveraging Cortana and Speech���������������������������������������������������� 471 ■■Chapter 13: App Monetization��������������������������������������������������������������������������� 521 ■■Chapter 14: Leveraging Existing Code��������������������������������������������������������������� 543 ■■Chapter 15: Distributing Universal Apps����������������������������������������������������������� 565 Index��������������������������������������������������������������������������������������������������������������������� 599 www.it-ebooks.info

vii Contents About the Authors����������������������������������������������������������������������������������������������������xv About the Technical Reviewers�����������������������������������������������������������������������������xvii Acknowledgments��������������������������������������������������������������������������������������������������xix Introduction������������������������������������������������������������������������������������������������������������xxi ■■Chapter 1: The Windows 10 Ethos and Environment��������������������������������������������� 1 RIP Windows 8������������������������������������������������������������������������������������������������������������������ 1 Hello, Windows 10������������������������������������������������������������������������������������������������������������ 3 A Not-So-Brief Introduction���������������������������������������������������������������������������������������������� 7 The New All-New Taskbar���������������������������������������������������������������������������������������������� 12 Building Windows 10 UWP Apps������������������������������������������������������������������������������������� 15 Supported Languages���������������������������������������������������������������������������������������������������������������������������17 Developing for Windows 10 UWP Apps�������������������������������������������������������������������������� 20 Setting Up Your Environment����������������������������������������������������������������������������������������������������������������20 The Visual Studio IDE����������������������������������������������������������������������������������������������������������������������������20 Creating Your First Project��������������������������������������������������������������������������������������������������������������������24 Sidebar: Exploring the App Manifest�����������������������������������������������������������������������������������������������������26 Back to Your First Project���������������������������������������������������������������������������������������������������������������������31 Notes on XAML�������������������������������������������������������������������������������������������������������������������������������������38 Summary������������������������������������������������������������������������������������������������������������������������ 51 www.it-ebooks.info

viii ■ Contents ■■Chapter 2: Basic Controls������������������������������������������������������������������������������������ 53 Setting Up a Project�������������������������������������������������������������������������������������������������������� 53 So Just What Are Controls?�������������������������������������������������������������������������������������������� 59 Incorporating Controls���������������������������������������������������������������������������������������������������� 59 Window�������������������������������������������������������������������������������������������������������������������������������������������������61 Frame���������������������������������������������������������������������������������������������������������������������������������������������������63 Page������������������������������������������������������������������������������������������������������������������������������������������������������64 Button���������������������������������������������������������������������������������������������������������������������������������������������������65 CalendarDatePicker������������������������������������������������������������������������������������������������������������������������������69 TimePicker��������������������������������������������������������������������������������������������������������������������������������������������71 AutoSuggestBox�����������������������������������������������������������������������������������������������������������������������������������72 CommandBar����������������������������������������������������������������������������������������������������������������������������������������75 AppBarButton���������������������������������������������������������������������������������������������������������������������������������������77 DatePicker��������������������������������������������������������������������������������������������������������������������������������������������79 MenuFlyout�������������������������������������������������������������������������������������������������������������������������������������������80 TextBox�������������������������������������������������������������������������������������������������������������������������������������������������83 PasswordBox����������������������������������������������������������������������������������������������������������������������������������������84 ComboBox��������������������������������������������������������������������������������������������������������������������������������������������86 Slider����������������������������������������������������������������������������������������������������������������������������������������������������87 Image����������������������������������������������������������������������������������������������������������������������������������������������������88 WebView�����������������������������������������������������������������������������������������������������������������������������������������������92 Noteworthy Mentions���������������������������������������������������������������������������������������������������������������������������94 Summary������������������������������������������������������������������������������������������������������������������������ 98 ■■Chapter 3: Data Controls����������������������������������������������������������������������������������� 101 Modifying the Project��������������������������������������������������������������������������������������������������� 101 Creating a Control Corral Model���������������������������������������������������������������������������������������������������������101 Persisting to the File System��������������������������������������������������������������������������������������������������������������107 Setting Up the Pages��������������������������������������������������������������������������������������������������������������������������110 www.it-ebooks.info

ix ■ Contents Listing Reservations with ListBox�������������������������������������������������������������������������������� 114 Viewing Individual Reservations with FlipView������������������������������������������������������������ 117 Revisiting AutoSuggestBox������������������������������������������������������������������������������������������ 122 Revisiting ComboBox��������������������������������������������������������������������������������������������������� 124 Showing Customers with GridView������������������������������������������������������������������������������ 126 Displaying Today’s Reservations with ListView������������������������������������������������������������ 130 Summary���������������������������������������������������������������������������������������������������������������������� 133 ■■Chapter 4: Layout and Custom Controls������������������������������������������������������������ 135 Layout Controls������������������������������������������������������������������������������������������������������������ 135 Understanding the Layout System������������������������������������������������������������������������������������������������������136 Alignment, Margins, and Padding�������������������������������������������������������������������������������������������������������137 The Layout Controls����������������������������������������������������������������������������������������������������������������������������141 Building Your Own Controls������������������������������������������������������������������������������������������ 168 User Controls��������������������������������������������������������������������������������������������������������������������������������������168 Templated Controls�����������������������������������������������������������������������������������������������������������������������������172 Your Own Layout Controls������������������������������������������������������������������������������������������������������������������175 Summary���������������������������������������������������������������������������������������������������������������������� 177 ■■Chapter 5: Building an Adaptive Experience����������������������������������������������������� 179 Device Families������������������������������������������������������������������������������������������������������������ 180 Adapting the User Interface����������������������������������������������������������������������������������������� 183 Triggered States���������������������������������������������������������������������������������������������������������������������������������183 Visual States���������������������������������������������������������������������������������������������������������������������������������������194 XAML Views����������������������������������������������������������������������������������������������������������������������������������������196 Adapting the Code�������������������������������������������������������������������������������������������������������� 203 The ApiInformation Class��������������������������������������������������������������������������������������������������������������������204 Summary���������������������������������������������������������������������������������������������������������������������� 206 www.it-ebooks.info

x ■ Contents ■■Chapter 6: File IO����������������������������������������������������������������������������������������������� 209 Creating the ResumeManager Project������������������������������������������������������������������������� 209 Files������������������������������������������������������������������������������������������������������������������������������ 211 Storage Folders������������������������������������������������������������������������������������������������������������ 215 The Package Install Location��������������������������������������������������������������������������������������������������������������215 The Isolated Storage Area�������������������������������������������������������������������������������������������������������������������219 RoamingFolder�����������������������������������������������������������������������������������������������������������������������������������224 TemporaryFolder���������������������������������������������������������������������������������������������������������������������������������231 The User’s Known Folders������������������������������������������������������������������������������������������������������������������231 External Known Folders����������������������������������������������������������������������������������������������������������������������235 The Downloads Folder������������������������������������������������������������������������������������������������������������������������236 Final Thoughts on Storage via the ApplicationData Class�������������������������������������������������������������������238 Using Pickers���������������������������������������������������������������������������������������������������������������� 238 Sharing Files with Custom Pickers������������������������������������������������������������������������������� 242 Summary���������������������������������������������������������������������������������������������������������������������� 256 ■■Chapter 7: Working with Media������������������������������������������������������������������������� 257 Creating a New Project������������������������������������������������������������������������������������������������� 257 Visualizing Media��������������������������������������������������������������������������������������������������������� 260 Images������������������������������������������������������������������������������������������������������������������������������������������������260 Audio��������������������������������������������������������������������������������������������������������������������������������������������������287 Video���������������������������������������������������������������������������������������������������������������������������������������������������296 Background Audio������������������������������������������������������������������������������������������������������������������������������300 Using WebView to Display Render Media��������������������������������������������������������������������� 303 Summary���������������������������������������������������������������������������������������������������������������������� 304 ■■Chapter 8: Location and Mapping���������������������������������������������������������������������� 305 Location Awareness����������������������������������������������������������������������������������������������������� 305 Enabling Location Functionality����������������������������������������������������������������������������������������������������������306 Requesting Access to Location Data��������������������������������������������������������������������������������������������������307 Getting the Current Location���������������������������������������������������������������������������������������������������������������311 More on Permissions��������������������������������������������������������������������������������������������������������������������������314 www.it-ebooks.info

xi ■ Contents Responding to Location Updates��������������������������������������������������������������������������������������������������������316 Geofencing������������������������������������������������������������������������������������������������������������������������������������������316 Mapping����������������������������������������������������������������������������������������������������������������������� 323 Launching Maps via URI���������������������������������������������������������������������������������������������������������������������324 Adding Maps into Your App�����������������������������������������������������������������������������������������������������������������325 Displaying Streetside Views���������������������������������������������������������������������������������������������������������������330 Handling Events, User Interaction, and Changes��������������������������������������������������������������������������������331 Working with POIs (Points of Interest)������������������������������������������������������������������������������������������������332 Geocoding�������������������������������������������������������������������������������������������������������������������������������������������335 Displaying Directions��������������������������������������������������������������������������������������������������������������������������336 Displaying Routes�������������������������������������������������������������������������������������������������������������������������������339 Summary���������������������������������������������������������������������������������������������������������������������� 341 ■■Chapter 9: Background Tasks���������������������������������������������������������������������������� 343 Before You Begin���������������������������������������������������������������������������������������������������������� 344 Running in the Background������������������������������������������������������������������������������������������ 350 Defining a Task to Run in the Background������������������������������������������������������������������������������������������353 Registering a Background Task����������������������������������������������������������������������������������������������������������354 Implementing Triggers������������������������������������������������������������������������������������������������������������������������357 Reporting Progress�����������������������������������������������������������������������������������������������������������������������������363 Conditions�������������������������������������������������������������������������������������������������������������������������������������������365 More on Triggers���������������������������������������������������������������������������������������������������������������������������������366 Revisiting Background Audio��������������������������������������������������������������������������������������������������������������368 Monitoring the Contact Store��������������������������������������������������������������������������������������������������������������372 Background Transfers�������������������������������������������������������������������������������������������������� 376 Summary���������������������������������������������������������������������������������������������������������������������� 376 ■■Chapter 10: Shell Integration���������������������������������������������������������������������������� 377 Launch Conditions�������������������������������������������������������������������������������������������������������� 377 Windowing������������������������������������������������������������������������������������������������������������������� 381 Opening New Windows�����������������������������������������������������������������������������������������������������������������������382 Sizing Windows����������������������������������������������������������������������������������������������������������������������������������386 TitleBar�����������������������������������������������������������������������������������������������������������������������������������������������388 www.it-ebooks.info

xii ■ Contents Lock Screen������������������������������������������������������������������������������������������������������������������ 393 The Notification Process���������������������������������������������������������������������������������������������� 395 Toast Notifications�������������������������������������������������������������������������������������������������������� 396 Generating Toast Notifications������������������������������������������������������������������������������������������������������������397 Adding Images to Toasts���������������������������������������������������������������������������������������������������������������������400 Adding Sound to Toasts����������������������������������������������������������������������������������������������������������������������401 Scheduling Toasts�������������������������������������������������������������������������������������������������������������������������������403 Responding to Toast Notification Events��������������������������������������������������������������������������������������������403 Adaptive Toasts�����������������������������������������������������������������������������������������������������������������������������������405 Tile Notifications����������������������������������������������������������������������������������������������������������� 411 Generating Tile Notifications���������������������������������������������������������������������������������������������������������������412 Presenting Text Content with a Heading���������������������������������������������������������������������������������������������414 Text-Only Content�������������������������������������������������������������������������������������������������������������������������������414 Templates for Summaries�������������������������������������������������������������������������������������������������������������������415 Creating a Cleaner Template���������������������������������������������������������������������������������������������������������������415 Adding Images to Tile Notifications����������������������������������������������������������������������������������������������������416 Scheduling Tile Notifications��������������������������������������������������������������������������������������������������������������416 Summary���������������������������������������������������������������������������������������������������������������������� 417 ■■Chapter 11: Communicating Between Apps������������������������������������������������������ 419 Before You Get Started������������������������������������������������������������������������������������������������� 419 Changing the Object Model����������������������������������������������������������������������������������������������������������������420 Applying SplitView to ApplicationHostPage����������������������������������������������������������������������������������������425 Communicating Through URI Launching���������������������������������������������������������������������� 434 Launching a Specific App�������������������������������������������������������������������������������������������������������������������438 Launching a URI and Waiting for Results��������������������������������������������������������������������������������������������440 Querying URI Support�������������������������������������������������������������������������������������������������������������������������443 File Launching�������������������������������������������������������������������������������������������������������������� 444 Communicating Through Sharing Files (Shared Storage)�������������������������������������������� 448 Application Services����������������������������������������������������������������������������������������������������� 453 Sharing Data Between the Apps You Created��������������������������������������������������������������� 459 www.it-ebooks.info

xiii ■ Contents Sharing Contracts��������������������������������������������������������������������������������������������������������� 461 Sharing as a Source���������������������������������������������������������������������������������������������������������������������������462 Sharing as a Target�����������������������������������������������������������������������������������������������������������������������������465 Summary���������������������������������������������������������������������������������������������������������������������� 469 ■■Chapter 12: Leveraging Cortana and Speech���������������������������������������������������� 471 Making Your Program Speak���������������������������������������������������������������������������������������� 472 Using SSML����������������������������������������������������������������������������������������������������������������������������������������474 Recognizing Speech����������������������������������������������������������������������������������������������������� 477 Constraints and Grammars�����������������������������������������������������������������������������������������������������������������480 Using Cortana��������������������������������������������������������������������������������������������������������������� 483 Setting Up for Cortana������������������������������������������������������������������������������������������������������������������������484 Launching Your App in the Foreground with Cortana�������������������������������������������������������������������������496 Launching Your App in the Background with Cortana�������������������������������������������������� 502 State Management������������������������������������������������������������������������������������������������������� 506 Deep Linking���������������������������������������������������������������������������������������������������������������� 508 Prompting the User������������������������������������������������������������������������������������������������������ 513 Multi-Command Interactions���������������������������������������������������������������������������������������� 515 The Final Command����������������������������������������������������������������������������������������������������� 519 Summary���������������������������������������������������������������������������������������������������������������������� 519 ■■Chapter 13: App Monetization��������������������������������������������������������������������������� 521 Selling Your App����������������������������������������������������������������������������������������������������������� 522 App Trial Mode������������������������������������������������������������������������������������������������������������������������������������524 Licensing Your App (Trial Mode)����������������������������������������������������������������������������������������������������������525 Purchasing the App�����������������������������������������������������������������������������������������������������������������������������532 Selling Within an App��������������������������������������������������������������������������������������������������� 533 Adding In-App Purchasing to an App��������������������������������������������������������������������������������������������������534 Implementing In-App Purchasing�������������������������������������������������������������������������������������������������������535 Summary���������������������������������������������������������������������������������������������������������������������� 542 www.it-ebooks.info

xiv ■ Contents ■■Chapter 14: Leveraging Existing Code��������������������������������������������������������������� 543 Sharing Code���������������������������������������������������������������������������������������������������������������� 544 Portable Class Libraries (PCL)�������������������������������������������������������������������������������������� 553 Creating a PCL������������������������������������������������������������������������������������������������������������������������������������553 Localhost Access���������������������������������������������������������������������������������������������������������� 557 Summary���������������������������������������������������������������������������������������������������������������������� 562 ■■Chapter 15: Distributing Universal Apps����������������������������������������������������������� 565 Registering with the Dev Center���������������������������������������������������������������������������������� 565 Creating an App Package��������������������������������������������������������������������������������������������� 568 Side Loading���������������������������������������������������������������������������������������������������������������������������������������569 Windows Store Distribution����������������������������������������������������������������������������������������������������������������571 Verifying Your App Package������������������������������������������������������������������������������������������ 576 Submitting Your App����������������������������������������������������������������������������������������������������� 577 Naming Your App��������������������������������������������������������������������������������������������������������������������������������584 Selling Details�������������������������������������������������������������������������������������������������������������������������������������586 Advanced Properties���������������������������������������������������������������������������������������������������������������������������588 Uploading Your App������������������������������������������������������������������������������������������������������ 590 Description�����������������������������������������������������������������������������������������������������������������������������������������591 Notes to Testers����������������������������������������������������������������������������������������������������������������������������������594 Getting Your App Certified�������������������������������������������������������������������������������������������� 595 Updating Your App�������������������������������������������������������������������������������������������������������� 596 Summary���������������������������������������������������������������������������������������������������������������������� 597 Index��������������������������������������������������������������������������������������������������������������������� 599 www.it-ebooks.info

xv About the Authors Edward Moemeka is an enterprise architect with a career spanning two decades. His experience in building, integrating, and delivering high-profile, large-scale applications for clients has made him a known commodity in the technology field. He is the Principal Architect at e-builder, a class leader in project management software for large-scale capital projects. Follow Edward at Twitter handle @moemeka, on YouTube at www.youtube.com/user/sineofreason, and on Facebook at www.facebook.com/edwardmoemeka. Elizabeth Moemeka is a communications specialist whose experience spans writing, marketing, and project support. She has used her creative expertise towards designing Windows apps. She blogs on technology and other subjects of personal interest. She has spent time in many parts of the United States and currently lives with her husband, two sons, and cat in Connecticut. www.it-ebooks.info

xvii About the Technical Reviewers Fabio Claudio Ferracchiati is a senior consultant and a senior analyst/developer using Microsoft technologies. He works for Blu Arancio (www.bluarancio.com). 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 co-authored more than ten books on a variety of computer topics. Damien Foggon is a developer, writer, and technical reviewer of cutting-edge technologies and has contributed to more than 50 books on .NET, C#, Visual Basic, and ASP.NET. He is the co-founder of the Newcastle-based user group NEBytes (online at www.nebytes.net), is a multiple MCPD in .NET 2.0 onwards, and can be found online at http://blog.fasm.co.uk. www.it-ebooks.info

xix Acknowledgments We would like to thank Nick Spano, Mike Soranno, John Leum, and Jonner Londono for their help and support. We would also like to thank the staff at Apress for this opportunity and for putting their faith in us, with special thanks to Melissa Maldonado, Damien Foggon, and Fabio Claudio Ferracchiati for their involvement in this process. www.it-ebooks.info

xxi Introduction Welcome to Real World App Development for Windows 10, your step-by-step, one-stop guide to going from a great idea to a published app in the Windows desktop and mobile platforms. Windows 10, already a hugely successful implementation of the venerable Microsoft operating system, offers great potential for effective and innovative apps. Who This Book Is For Maybe you’ve been a lifelong fan and follower of Microsoft. Maybe you’re taking a look at the Windows OS for the first time. Either way, Windows 10 and, specifically, its dynamic environment for app inclusion in the overlapping spheres of desktop and mobile, lends itself to an expansive environment, replete with creative potential for developers and practical potential for users. If you have a passion for cutting-edge technology, a working knowledge of HTML, and creative ideas about how we can better interface with technological tools daily in our lives, this book is for you. The following chapters hold a rich store of knowledge to get you on your way creating, developing, and publishing apps in the Windows 10 platform. The approach of this book is to lay out the steps towards app publication clearly, concisely, and systematically to make the process as simple as possible. What This Book Covers While this book covers an end-to-end explanation of app development in the Windows 10 environment, its reach is more comprehensive than this. First, we begin with a thorough introduction to the Windows 10 environment. Following the app development process, we expand into the ins and outs of the submission process, even touching on monetizing your app and making you app successful in other respects as well. As the book takes you through app development, instruction is given for every step of the process. In addition, the instruction relies heavily upon samples in which you are also given the code to build, thus making the text an interactive, hands-on process. While you can utilize this book as a desktop reference text, referring to chapters, sections, and topics as needed, we believe it is worthwhile to read front-to-back; by building the examples in order you’ll build a thorough knowledge of exactly how to create a fully realized app in the Windows 10 platform in the process. The pages ahead contain a comprehensive curriculum that, with a solid foundation in technology and a working knowledge of Windows 10, will answer all the questions you will come across as your build you own Windows app. So sit back, crack open the book, and get on your way to creating your very own Windows platform application! All content for this book can be downloaded from www.apress.com/9781484214503?gtmf=s. www.it-ebooks.info

1 Chapter 1 The Windows 10 Ethos and Environment RIP Windows 8 In July, 2013, Windows 8, an operating system as innovative as it is disjointed, turned the computing world upside down with a boldly reimagined user experience that focused on touch as a first-class citizen. Windows 8 introduced us to the start screen, the charms bar, tiles, and dedicated full screen applications. For many, this was a dream come true, a fast and fluid version of Windows with far fewer hardware requirements, a beautiful touch-first user interface complete with fluid, intuitive edge-driven interaction patterns, and access to the legacy desktop when needed for running old-school Win32 applications. Despite the forward progress Microsoft made with Windows 8, however, it was widely panned as an operating system fit only for the schizophrenic; see Figure 1-1. Figure 1-1.  Windows 8 Start screen www.it-ebooks.info

Chapter 1 ■ The Windows 10 Ethos and Environment 2 Many found that although it offered great innovations, the lack of consistency between the two operating environments running within the overarching OS made using it quite confusing at times. Users would open files that would launch them into a full screen experience in one situation, while other file types would jarringly bring them out of the full screen immersive experience into the desktop! The touch- first nature of Windows 8 was another common complaint, as it appeared that Microsoft had foregone any consideration for users working with a mouse and keyboard. Indeed, what seemed easy to do with the finger proved laborious when working with a Windows 8 device that had no touch interface included. Finally, and probably most importantly, the choice to do away from the Start menu proved to be too much of a deviation from what users were comfortable with.■ ■ Note There are some third-party applications that can be purchased to enhance the Windows 8 experience with a Start menu, such as Start8 from Stardock. The arguments from all sides were the same. Customers wanted input into the decision-making process for features of the Microsoft operating system; they had largely been shunned by Microsoft all through the Windows 8 development cycle despite months of clamoring for the inclusion of a Start menu feature and windowed Modern apps running on the desktop (after all, the OS *was* called “Windows”). Despite all the metrics Microsoft consistently threw at Windows 7 users who wanted to see a Start menu, customers still felt quite strongly that a Start menu was needed–or they at least wanted the freedom to pick one option (having a Start menu) versus the other (using the Start screen). Windowed applications were also a critical ask from customers and a reason behind Windows 8 not being fully embraced. The shift to full screen applications that Windows 8 introduced seemed to most like a gigantic step backwards from all the innovations of the Windows-of-old genre. Microsoft, it seemed, had ventured too far towards the tablet world for really no reason at all. Tablet operating systems had that limitation because the hardware they ran on (screen, chip, memory) had that limitation, not because it was an innovation on user experience. It worked for phones because the screens were too small for multitasking. It worked for tablets because there was hardly enough stored energy, memory, and processing power to keep things running the way windowed applications required them to be kept running. Full-fledged workstations and laptops had no such constraints: they had large enough screens to do multiple things at one time, they had plenty of processing power, and they were not intended to be used in full fidelity mobility scenarios like tablets and phones are. What Microsoft needed with its next operating system endeavor was an OS that continued with the powerful new innovations they had introduced with Windows 8 while dialing down the tablet-focused mindset. They needed an operating system that was able to smoothly merge both operating environments: the modern, touch-friendly, secure operating environment with the legacy tools and features of the Windows 7 paradigm. Windows 10 unites these two worlds seamlessly into one while continuing on the path of innovation that Windows 8 began.■ ■ Note Microsoft published a comprehensive blog outlining the details or the rationale behind many of the Windows 8 features. One blog post highlights the complex research that led Microsoft to using the Start screen in Windows 8 in favor of the old Start menu. If you would like to find out more about this, head to the Building Windows 8 blog at http://blogs.msdn.com/b/b8/. The specific blog post that walks through the evolution of the Windows Start screen can be found at http://blogs.msdn.com/b/b8/archive/2011/10/03/ evolving-the-start-menu.aspx. www.it-ebooks.info

Chapter 1 ■ The Windows 10 Ethos and Environment 3 Hello, Windows 10 Welcome to the brave new world of Windows 10! In this introductory chapter, you will take a walk through yet another “new user interface” for Windows that might appear familiar to some and drastically, even jarringly, different to others. If you are coming from Windows 7 or anything previous, Windows 10 will seem like a major upgrade to you, but one that you will quite possibly cognitively recognize from the standpoint of usability and user experience. Unfortunately for Windows 8/8.1 users, Windows has once again been reimagined, but this time for the better. An interesting thing happened between the end of development of Windows 8/8.1 and the beginning of Windows 10 development. For whatever reason, Microsoft finally decided that perhaps their customers knew a thing or two about how they would like to use the operating system, so Microsoft began listening! As a result, Windows 10 reintroduces the Start menu as a combination of both the original Windows 7 Start menu and the Windows 8 Start screen, adds support for windowed applications, merges the operating environments, standardizing on the continued use of the desktop, and even adds back transparency, Aero blurs, and depth to the operating system! And it doesn’t stop there. Windows 10 continues with the legacy of innovation initiated with Windows 8/8.1 by building out a one-OS architecture which not only allows Windows 10 to be installed on a wide variety of devices, but also allows Modern apps built to target Windows 10 to run on any of the many devices that Windows 10 can run on. Figure 1-2 shows the reincarnated Start menu in Windows 10. Figure 1-2.  Windows 10 Start menu ■ ■ Note  Presently, Windows 10 is the only operating system that can run on an IOT device, phone, tablet, workstation, Surface Hub, HoloLense, and even Xbox. www.it-ebooks.info

Chapter 1 ■ The Windows 10 Ethos and Environment 4 The new Windows 10 Start menu functions basically the same as the Start screen from Windows 8/8.1 but does not automatically take up the full screen. Note that the Start menu is transparent with a blur applied to it, similar to the aero look from Windows Vista/7. Figure 1-2 also shows a number of Modern apps running on the desktop. As can be seen from the image, these apps run within a Windows 10 window, meaning they can be treated like any other system window. One of the shortcomings of Windows 8/8.1 was in the forcing of drastic paradigm shifts onto the masses without providing many ways to fall back to previous approaches. Indeed, this author recalls using the “Windows 2000 theme” on Windows XP for a good three years following its release before finally making a switch to the standard XP theme. In fact, I don’t believe I would have ever purchased a Windows XP license had the option to continue to use an old approach not been available to me. The evidence of an awareness of this resistance to change is clear in Windows 10 in a number of ways, but two major inclusions in the operating system drive this mindset home. Firstly, although the legacy charms bar is not present in this release, Modern apps that were written using the Windows 8 SDK can still access the bar through the app’s hamburger menu (located on the top left corner of the app title bar). This allows apps that were built in the previous application development model to be available for use within Windows 10 without the need for recompilation. Figure 1-3 shows the Windows 8 charms bar as displayed when a user activates it by swiping in from the right edge of their tablet. From the top, the icons will invoke the search experience, sharing, launch the Start screen, launch interactions with devices, or open the Settings pane. Apps that were developed with Windows 8 in mind would undoubtedly be dependent on any one of these features to function as intended. It is safe to say that making sure that all of the popular Modern apps worked with the new OS was a good idea. Figure 1-3.  The Windows 8 charms bar in all its glory ■ ■ Note Mouse and keyboard gestures were also available for accessing the Windows 8 charms bar. Discussion on these is beyond the scope of this book but can be found in Chapter 1 of Real World Windows 8 App Development with JavaScript (Apress). www.it-ebooks.info

Chapter 1 ■ The Windows 10 Ethos and Environment 5 Not only would users be frustrated by the presumed failure of the operating system to run their apps, but the developers of the given apps would be frustrated by having to, at the very least, recompile and republish their perfectly fine Windows 8 Modern apps to the Windows 10 platform. Having the charms bar accessible when running these apps alleviates this. It provides a stop-gap solution to the software upgrade problem so developers can take their time and republish to the Windows 10 platform when they have the bandwidth to so. Figure 1-4 shows a Windows 8 Modern app running on Windows 10. Note that the charms bar now appears within the app instead of as a fly-out overlay to the right of the screen. Also note that only three of the original five charms are available. Figure 1-4.  The Windows 8 charms bar now shows within the Windows 8 Modern app hamburger menu when running on Windows 10 The second major evidence of an awareness of backwards compatibility is the inclusion of a “Tablet Mode” in Windows 10 across all workstation form factors. Tablet Mode brings your Windows 10 device back in line with the Windows 8 user experience by locking the user into the same single-full-screen-app-at-a- time model that Windows 8/8.1 utilized. Figure 1-5 shows a desktop in Tablet Mode. Note that the taskbar has been cleared of any running items and that no taskbar shortcuts are present. In Tablet Mode, they are removed to streamline the user experience, but many of these behaviors can be modified through various settings in the operating system. www.it-ebooks.info

Chapter 1 ■ The Windows 10 Ethos and Environment 6 Figure 1-5.  Windows 10 Start screen (Tablet Mode) www.it-ebooks.info

Chapter 1 ■ The Windows 10 Ethos and Environment 7 In our last book, Real World Windows 8 App Development with JavaScript, we claimed that Windows 8 was a hugely significant opportunity for developers. Windows 10 is a continuation, an expansion, on this vast realm of possibilities. Not only does Windows 10 allow you to capitalize on the billion plus devices that will be running the operating system within the next three years, it also allows those who have built Windows 8 Modern apps to benefit from Windows 10 with literally no additional work. Windows 10 allows you to develop for it not only using a diverse set of languages like C#, JavaScript, and C++, but also allows iOS and Android applications to be cross-compiled to it so that they run natively in the Windows 10 environment, no emulation needed. This book explores the languages and technologies that can be used to build modern Windows 10 apps, and how you as a Windows 10 developer can use them to build powerful and immersive Windows 10 applications and experiences. A Not-So-Brief Introduction Now that we have given a brief, high-level overview of Windows 10, its driving principles (as we understand them to be), and how it matches up to and exceeds on the promise of Windows 8, it is important to provide an introduction to Windows 10 from a developer’s perspective, specifically focusing on how Modern apps work and are managed by the system. The discussion isn’t exhaustive, because the subject could probably span multiple books, but it should provide you with a baseline of information in order to understand the basics of Windows 10 and Windows 10 app development using the Windows SDK and Runtime. For the purpose of explanation, let’s walk through the Windows 10 UI artifacts, not because you don’t already understand how Windows works, but for those of you who may not yet have access to the operating system. The Windows 10 shell has taken the Windows 8 “digital reverse mullet” theme (party time in the front, and good old-fashioned business behind that) and converged it into a single user experience across all application types. Whether they be legacy Win32 applications, Windows 8 Modern apps, or Windows 10 Universal Windows Platform apps, the user experience is the same, save a few nuances.■ ■ Note As you’ve already seen, Windows 8 Modern apps running on Windows 10 have an additional title bar item, a hamburger menu at the top left of the window can be used to access the Search, Share, and Settings charms, and the Modern app’s command bars. At first glimpse, in Windows 10 you should see the good old Windows desktop with what will appear to you as a well-overdue user interface touch up. Unless you are on a device that has been specifically earmarked by the manufacturer as a tablet, the default experience for a laptop is to take you to the desktop once signed in. Figure 1-6 shows the default Windows 10 desktop with the Start menu activated. www.it-ebooks.info

Chapter 1 ■ The Windows 10 Ethos and Environment 8 The new Windows 10 Start menu, which for the most part is the Windows 8 start screen with a few additional capabilities (first and foremost being that it no longer needs to run exclusively in full screen mode), continues to serve as a powerful launch pad for applications. In Figure 1-6, the colored rectangles with images in them are a combo launch-point for applications. These magical rectangular surfaces are commonly referred to as live tiles and combine the application shortcut, particularly the version of the shortcut you might find on your Windows desktop, with the representation of the notification mechanism of your applications, found in the system tray area. Figure 1-7 shows two states of the Calendar application live tile. The image to the left is the default state; when a meeting is approaching, the tile takes on a different appearance (right). Figure 1-6.  Windows 10 Desktop with Start menu showing Figure 1-7.  Two states of a Windows 10 Modern app tile Let’s take a real world case where live tiles can consolidate these kinds of functions. Skype, for instance, may have a system tray icon that changes appearance when it switches from online to offline, a beautiful shortcut on the Windows desktop. The Windows 10 live tile encapsulates those two functions in one. Through the live tile, you can of course launch the application, but as shown in Figure 1-7 tiles can also display notifications based on things happening in the application or even things happening while the application is not running. Not all tiles on the Start screen are live tiles. Legacy applications such as Visual Studio, Microsoft Word, and Adobe Photoshop can also appear on the Start screen as tiles, but these tiles aren’t “live;” they don’t possess the ability to present dynamic content on their surface. Legacy Windows application tiles function more or less like the application icons of old (we say “more or less” because Windows 10 exposes some shortcut features to these sorts of tiles that follow patterns similar to their live alternatives, such as being able to launch in administrator mode). Applications built using the new paradigm, which can express www.it-ebooks.info