Thông tin tài liệu
www.it-ebooks.info
800 East 96th Street, Indianapolis, Indiana 46240 USA
Adam Nathan
101 Windows
®
Phone 7 Apps,
VOLUME I: DEVELOPING APPS 1-50
www.it-ebooks.info
101 Windows® Phone 7 Apps,Volume I
Copyright © 2011 by Adam Nathan
All rights reserved. No part of this book shall be reproduced, stored in a retrieval
system, or transmitted by any means, electronic, mechanical, photocopying, record-
ing, or otherwise, without written permission from the publisher. No patent liability is
assumed with respect to the use of the information contained herein. Although every
precaution has been taken in the preparation of this book, the publisher and author
assume no responsibility for errors or omissions. Nor is any liability assumed for
damages resulting from the use of the information contained herein.
ISBN-13: 978-0-672-33552-5
ISBN-10: 0-672-33552-2
Library of Congress Cataloging-in-Publication Data
Nathan, Adam, 1977-
101 Windows phone 7 apps / Adam Nathan.
v. cm.
Includes index.
Contents: v. 1. Developing apps 1-50.
ISBN-13: 978-0-672-33552-5 (v. 1)
ISBN-10: 0-672-33119-5 (v. 1)
1. Application software—Development. 2. Windows phone (Computer file) 3.
Smartphones—Programming. 4. Mobile computing. I.Title. II. Title: One hundred one
Windows phone 7 apps.
QA76.76.A65N378 2011
004.165—dc22
2011010335
Printed in the United States of America
First Printing April 2011
Trademarks
All terms mentioned in this book that are known to be trademarks or service marks
have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of
this information. Use of a term in this book should not be regarded as affecting the
validity of any trademark or service mark.
Warning and Disclaimer
Every effort has been made to make this book as complete and as accurate as possi-
ble, but no warranty or fitness is implied.The information provided is on an “as is”
basis.The author(s) and the publisher shall have neither liability nor responsibility to
any person or entity with respect to any loss or damages arising from the information
contained in this book or from the use of the programs accompanying it.
Bulk Sales
Sams Publishing offers excellent discounts on this book when ordered in quantity for
bulk purchases or special sales. For more information, please contact
U.S. Corporate and Government Sales
1-800-382-3419
corpsales@pearsontechgroup.com
For sales outside of the U.S., please contact
International Sales
international@pearsoned.com
EDITOR-IN-CHIEF
Greg Wiegand
EXECUTIVE EDITOR
Neil Rowe
DEVELOPMENT EDITOR
Mark Renfrow
MANAGING EDITOR
Kristy Hart
PROJECT EDITOR
Betsy Harris
SENIOR INDEXER
Cheryl Lenser
PROOFREADER
Apostrophe Editing
Services
TECHNICAL EDITOR
Dave Relyea
PUBLISHING
COORDINATOR
Cindy Teeters
BOOK DESIGNERS
Gary Adair
Adam Nathan
COMPOSITOR
Bronkella Publishing LLC
www.it-ebooks.info
Introduction 1
part I getting started
1 Tally (App Basics) 17
2 Flashlight (Application Bar) 39
3 In Case of Emergency (Orientation & Keyboards) 61
4 Stopwatch (Grid & User Controls) 89
5 Ruler (Canvas & Vector Graphics) 123
6 Baby Sign Language (Page Navigation & Data Binding) 153
7 Date Diff (Silverlight for Windows Phone Toolkit) 185
8 Vibration Composer (Vibration & Running While Locked) 191
9 Fake Call (Resources & Styles) 207
10 Tip Calculator (Application Lifecycle & Control Templates) 235
11 XAML Editor (Dynamic XAML & Popup) 271
part II transforms & animations
12 Silly Eye (Intro to Animation) 301
13 Metronome (Intro to 2D Transforms) 327
14 Love Meter (Keyframe Animations) 347
15 Mood Ring (Color, Object & Point Animations) 361
16 Lottery Numbers Picker (Sharing Animations) 377
17 Pick a Card Magic Trick (3D Transforms) 395
18 Cocktails (Quick Jump Grid) 413
19 Animation Lab (Custom Controls & VSM) 441
contents at a glance
www.it-ebooks.info
part III storing & retrieving local data
20 Alarm Clock (Settings,Toggle Switch, Custom Font) 463
21 Passwords & Secrets (Encryption & Observable Collections) 493
22 Notepad (Reading & Writing Files) 527
23 Baby Milestones (Reading & Writing Pictures) 545
24 Baby Name Eliminator (Local Databases & Embedded Resources) 565
25 Book Reader (Pagination & List Picker) 587
part IV pivot, panorama, charts, & graphs
26 TODO List (Pivot & Context Menu) 611
27 Groceries (Panorama) 649
28 Alphabet Flashcards (Filmstrip-Style Swiping) 675
29 Weight Tracker (Charts & Graphs) 681
part V audio & video
30 Cowbell (Sound Effects) 711
31 Trombone (Sound Manipulation) 719
32 Local FM Radio (Radio Tuner) 731
33 Subservient Cat (Video) 743
part VI microphone
34 Bubble Blower (Sound Detection) 759
35 Talking Parrot (Recording & Playing) 775
36 Sound Recorder (Saving Audio Files & Playing Sound Backward) 797
Contents at a Glance
iv
www.it-ebooks.info
part VII touch & multi-touch
37 Reflex Test (Single Touch) 827
38 Musical Robot (Multi-Touch) 839
39 Paint (Ink Presenter) 847
40 Darts (Gesture Listener & Flick Gesture) 875
41 Deep Zoom Viewer (Pinch, Stretch, & Double Tap Gestures) 897
42 Jigsaw Puzzle (Drag Gesture & WriteableBitmap) 913
43 Spin the Bottle! (Rotate Gesture & Simulating Inertia) 945
part VIII accelerometer tricks
44 Boxing Glove (Accelerometer Basics) 951
45 Coin Toss (Throw) 965
46 Noise Maker (Shake) 981
47 Moo Can (Turn Over) 993
48 Level (Determining Angle) 1007
49 Balance Test (2D) 1019
50 Pedometer (Walking Motion) 1035
part IX appendices
A Lessons Index 1049
B XAML Reference 1059
C Theme Resources Reference 1073
D Animation Easing Reference 1083
E Geometry Reference 1089
Index 1097
Contents at a Glance
v
www.it-ebooks.info
Progress Bar
Visibility
Orientation Lock
5 Ruler 123
Canvas
Vector Graphics
Slider
Repeat Button
Hardware Back, Start, & Search
Buttons
Hit Testing
Content Controls
6 Baby Sign Language 153
Page Navigation
Data Binding
Data Templates
List Box
Image
Resource Versus Content Build
Actions
7 Date Diff 185
Silverlight for Windows Phone
Toolkit
Date Picker
8 Vibration Composer 191
Vibration
Wrap Panel
Running While the Screen is
Locked
Getting Coordinates of an
Element
The Tag Property
Line Breaks
Introduction 1
part I getting started
1 Tally 17
The Application Manifest
Capabilities
Icons
Splash Screen
XML Namespaces
Status Bar
Phone Theme Resources
Naming XAML-Defined Elements
Button
2 Flashlight 39
Application Bar
Timers
Brushes
Message Box
3 In Case of Emergency 61
Orientation
On-Screen Keyboard
Hardware Keyboard
Text Box
Input Scopes
Scroll Viewer
Size Properties
Margins and Padding
Emulator-Specific Code
4 Stopwatch 89
Grid
StackPanel
User Controls
Alignment
table of contents
www.it-ebooks.info
14 Love Meter 347
Keyframe Animations
Animating Scale
Checking Storyboard Status
15 Mood Ring 361
Color Animations
Property Paths
Gradient Brushes
Object Animations
Point Animations
Drop Shadows
16 Lottery Numbers Picker 377
Sharing Animations
Creating Animations in C#
Looping Selector
17 Pick a Card Magic Trick 395
3D Transforms
Opacity Masks
Image Brush
One-Time Actions
18 Cocktails 413
Quick Jump Grid
Dependency Properties
URL Encoding & Decoding
Storyboards as Timers
Indeterminate Progress Bars
Long List Selector
19 Animation Lab 441
Custom Controls
Visual State Manager
Bitmap Caching
Tilt Effect
9 Fake Call 207
Resources
Styles
Time Picker
Text Line Height
Disabling Automatic Screen Lock
10 Tip Calculator 235
Application Lifecycle
Control Templates
Routed Events
Theme Detection
Toggle Button, Radio Button,
& Check Box Controls
List Box Items
Data Binding to a Named Element
11 XAML Editor 271
Dynamic XAML
Popup
TextBox Manipulation
Background Worker
Copy & Paste
part II transforms &
animations
12 Silly Eye 301
Animation
Event Triggers
Named Resources
Settings Page
Color Picker
Clipping
13 Metronome 327
2D Transforms
Animating Rotation
Animation Completed Event
Frame Rate Counter
Table of Contents
vii
www.it-ebooks.info
part IV pivot, panorama, charts,
& graphs
26 TODO List 611
Pivot
Context Menu
Data Contract Attributes
27 Groceries 649
Panorama
28 Alphabet Flashcards 675
Filmstrip-Style Swiping
29 Weight Tracker 681
Charts & Graphs
part V audio & video
30 Cowbell 711
Playing Sound Effects
Composition Target’s Rendering
Event
31 Trombone 719
Sound Manipulation
Sound Looping
SoundEffectInstance
32 Local FM Radio 731
Radio Tuner
The
NetworkInterface.InterfaceType
Property
33 Subservient Cat 743
Playing Video
MediaElement
part III storing & retrieving
local data
20 Alarm Clock 463
Isolated Storage
Settings
Settings Page Guidelines
Toggle Switch
Using Custom Fonts
Runs
21 Passwords & Secrets 493
Encryption & Decryption
Password Box
Value Converters
DateTimeOffset
Observable Collections
INotifyPropertyChanged
22 Notepad 527
Reading & Writing Files
23 Baby Milestones 545
Reading & Writing Pictures
Serialization
Two-Way Data Binding
24 Baby Name Eliminator 565
Local Databases
Shipping Data with Your App
25 Book Reader 587
Pagination
List Picker
Stretching List Box Items
Table of Contents
viii
www.it-ebooks.info
41 Deep Zoom Viewer 897
Pinch & Stretch Zooming Gestures
Double-Tap Gesture
MultiScaleImage
42 Jigsaw Puzzle 913
Drag Gesture
Image Cropping
WriteableBitmap
Taking Phone Screenshots
43 Spin the Bottle! 945
Rotate Gesture
Simulating Inertia
part VIII accelerometer tricks
44 Boxing Glove 951
Accelerometer Basics
45 Coin Toss 965
Throwing Detection
46 Noise Maker 981
Shaking Detection
47 Moo Can 993
Turning-Over Detection
AccelerometerHelper
Data Smoothing
Accelerometer Calibration
48 Level 1007
Determining the Phone’s Angle
49 Balance Test 1019
2D Motion
50 Pedometer 1035
Analyzing Walking Motion
part VI microphone
34 Bubble Blower 759
Sound Detection
Reversing a Slider
35 Talking Parrot 775
Microphone Audio Playback
36 Sound Recorder 797
Saving Audio Files
Playing Sound Backwards
Multi-Selection List Box
part VII touch & multi-touch
37 Reflex Test 827
The Touch.FrameReported Event
Touch Points
38 Musical Robot 839
Multi-Touch
Tracking Individual Fingers
39 Paint 847
Ink Presenter
Manual Serialization and
Deserialization
XmlSerializer
DataContractSerializer
DataContractJsonSerializer
Undo & Redo
40 Darts 875
Gesture Listener
Manipulation Events
Flick Gesture
Direct Hit Testing
Table of Contents
ix
www.it-ebooks.info
[...]... developers as well Can I write a game for Windows Phone with OpenGL? No Your best bet is to use XNA Software Requirements This book targets Windows Phone 7 (all phone models running Windows Phone OS 7. 0) and the corresponding Windows Phone Developer Tools Other than the desktop operating system you use for development (which can be Windows Vista or later, but not Windows Server), getting the most out of... The Windows Phone Developer Tools, a free download at http://developer.windowsphone.com, includes ➔ Visual Studio 2010 Express for Windows Phone, used for developing Silverlight apps ➔ Expression Blend 4 for Windows Phone, which can optionally be used for designing Silverlight-based vector graphics, animations, and control templates ➔ XNA Game Studio 4.0, used for developing XNA apps ➔ Windows Phone. .. good introduction to developing for Windows Phone Compared to other chapters, this chapter is much less about the app itself and more about understanding the structure and basic features of a Windows Phone project in Visual Studio www.it-ebooks.info Button 18 Chapter 1 TALLY Why do Windows Phone apps often look so plain? It’s an artistic choice Windows Phone and its apps are designed to communicate relevant... of Silverlight for Windows Phone to be mostly compatible with Silverlight for Windows and Mac, and by the goal of XNA for Windows Phone to be mostly compatible with XNA for Xbox, Windows, and Zune HD The result is some duplication of functionality and arbitrary distinctions between technologies For example, although Windows Phone has a single class for interacting with the microphone, it is an XNA... your apps on a PC rather than a real phone This book has been tested with the January 2011 update of the tools, which adds copy/paste support to the emulator’s version of the Windows Phone operating system (version 7. 0 .73 38.0) ➔ The Silverlight for Windows Phone Toolkit, a free download at http://silverlight.codeplex.com, which contains numerous controls and important features missing from the Windows. .. Runtime Intelligence for Windows Phone (http://preemptive.com/windowsphone7), which enables obfuscation, optimizations, and analytics Hardware Requirements You’re going to need a computer that can run the software listed in the preceding section In addition, although technically not required, I recommend testing any apps you submit to the Windows Phone Marketplace on a real phone www.it-ebooks.info... Nokia Windows Phones) yet a relatively small number of www.it-ebooks.info Conventions Used in This Book 2 Introduction developers Your apps have a pretty good chance of standing out in the still-young Windows Phone Marketplace So let’s get started building some apps! I’ve been writing programming books for a long time, but I’ve never been more excited about the topic than I am for Windows Phone 7 I feel... Another subtle difference between the intended design of Windows Phone apps and iPhone apps is that iPhone encourages the use of literal real-world visuals (such as a Notes app that looks like a physical paper notepad) whereas Windows Phone encourages user interfaces that don’t mimic the real world so closely Instead, excluding games and novelty apps, the experience should be “authentically digital.”... Nathan” in the Windows Phone Marketplace (or visiting http://adamnathanapps.com) to examine the relative popularity of this book’s apps Although I’ve enhanced some of my apps in the marketplace compared to what is in this book, many of them are identical I’m really interested to see what apps you publish based on apps in this book! Send me a tweet with details, and I might highlight your apps I’m @adamnathan... Silverlight or with Windows Phone www.it-ebooks.info Choosing a Technology 3 As my wife will attest, even nonprogrammers can follow along to some degree and tweak the apps in this book If you’ve got a knack for graphic design and you have some good ideas for ways to re-theme the apps in this book, you could be quite successful in the Windows Phone Marketplace! If you’re thinking about tweaking some apps in this . Indiana 46240 USA
Adam Nathan
101 Windows
®
Phone 7 Apps,
VOLUME I: DEVELOPING APPS 1-50
www.it-ebooks.info
101 Windows Phone 7 Apps, Volume I
Copyright ©. herein.
ISBN-13: 978 -0- 672 -33552-5
ISBN-10: 0- 672 -33552-2
Library of Congress Cataloging-in-Publication Data
Nathan, Adam, 1 977 -
101 Windows phone 7 apps / Adam
Ngày đăng: 08/03/2014, 17:20
Xem thêm: 101 Windows Phone 7 Apps doc, 101 Windows Phone 7 Apps doc