64
Windows Phone 7 Series Balaji Damodaran -ThoughtWorks

Windows phone 7 series

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Windows phone 7 series

Windows Phone 7 Series Balaji Damodaran

-ThoughtWorks

Page 2: Windows phone 7 series

Before we start,

a confession…

Page 3: Windows phone 7 series

Microsoft

did not pay us.

Page 4: Windows phone 7 series

The Players

Page 5: Windows phone 7 series
Page 6: Windows phone 7 series

And Cross Platform

APIs (mostly)

Page 7: Windows phone 7 series
Page 8: Windows phone 7 series

New kid

on the block

Page 9: Windows phone 7 series
Page 10: Windows phone 7 series

Old(ish) wine in

a new(ish) bottle

Page 11: Windows phone 7 series
Page 12: Windows phone 7 series

Demo

Page 13: Windows phone 7 series

Source: https://github.com/openbala/xconf-pune

Page 14: Windows phone 7 series

Metro

Page 15: Windows phone 7 series

Metro Design and Typeface

The Windows Phone OS 7 User Interface (UI) is based on a design that is

internally named Metro, and echoes the visual language of airport and metro

system signage in its design and typeface.

Page 16: Windows phone 7 series
Page 17: Windows phone 7 series

Tiles

Tiles are links to applications, features, functions

and individual items (such as contacts, web

pages, applications or media items). Users can

add, rearrange, or remove Tiles. Tiles are

dynamic and update in real time

Tiles that use the Tile Notification feature can

update the Tile graphic or title text, or

increment a counter.

Page 18: Windows phone 7 series

Themes

A Theme is a user-selected combination of background and accent colors that

personalizes the visual elements on a Windows Phone for that user.

Page 19: Windows phone 7 series

Silverlight

Components

Page 20: Windows phone 7 series

Silverlight Essentials

Xaml – Extensible Application Markup Language (ala HTML types) Xaml.cs – Backend Program that controls the UI state and data (ala JavaScript)

Page 21: Windows phone 7 series

UI Controls

• ListBox

• Grid

• Canvas

• StackPanel

• Border

• Map

• Slider

• ProgressBar

• TextBlock

• more…

Page 22: Windows phone 7 series

Panorama & Pivot

Page 23: Windows phone 7 series

Unlike standard applications that are designed to fit within the confines of

the phone screen, these applications offer a unique way to view controls,

data, and services by using a long horizontal canvas that extends beyond

the confines of the screen

Panorama Application

Page 24: Windows phone 7 series

A pivot control provides a quick way to manage views or pages within the

application. The control places individual views horizontally next to each other,

and manages the left and right navigation. Flicking or panning horizontally on

the page cycles the pivot functionality.

Pivot Application

Page 25: Windows phone 7 series

Isolated Storage

Page 26: Windows phone 7 series

Isolated Storage - Defined

Isolated storage enables managed applications to create and maintain local

storage. Application developers have the ability to store data locally on the

phone, leveraging all the benefits of isolated storage including protecting data

from other applications.

Page 27: Windows phone 7 series

Isolated Storing

System.IO.IsolatedStorage

using (IsolatedStorageFile isoStorage = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream stream = isoStorage.OpenFile("xconfpune.dat", FileMode.OpenOrCreate))

{ DataContractSerializer serializer = new DataContractSerializer(typeof(XConfSession)); XConfSession info = serializer.ReadObject(stream) as XConfSession; }

}

Page 28: Windows phone 7 series

WP7 ↔ Web Services

Page 29: Windows phone 7 series

features

Not Supported:

• Duplex communication over HTTP

• WCF Data Services.

• Custom bindings, sockets, RSS and Atom feeds

• WS proxy cannot be generated dynamically using ‘CreateChannel’.

Supported:

• Asynchronous communication over HTTP

• Silverlight 3 SDK feature support for WCF.

• Compile time proxy through ‘Add Service Reference’ in VS2010

Page 30: Windows phone 7 series

Data Binding

Page 31: Windows phone 7 series

Data Binding - Defined

Data binding is a way of linking user input to program data automatically.

a. User input will fire property changed events.

b. Changing a property in the program will update the display.

Page 32: Windows phone 7 series

Data Binding - Setting

<TextBlock Grid.Column="0" Text="{Binding TimeSlot}" Style="{StaticResource PhoneTextSubtleStyle}"/>

Defining the data source:

a. DataContext property of any containing Element

b. ItemSource of a List control – (ObservableCollection type)

Binding the Data:

<phone:PhoneApplicationPage.Resources> <local:DamageClass x:Key="DamageClass" /> </phone:PhoneApplicationPage.Resources> <!--LayoutRoot contains the root grid where all other page content is placed--> <Grid x:Name="LayoutRoot" Background="Transparent" DataContext="{StaticResource DamageClass}">

Page 33: Windows phone 7 series

Data Binding - Modes

Mode determines how changes are synchronized:

a. OneTime

b. OneWay

c. TwoWay

Page 34: Windows phone 7 series

Application Bar

Page 35: Windows phone 7 series

Application Bar - Defined

The Application Bar provides a place for developers to display up to four of the

most common application tasks and views as icon buttons.

Page 36: Windows phone 7 series

Application Bar

<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True"> <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/> <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/> <shell:ApplicationBar.MenuItems> <shell:ApplicationBarMenuItem Text="MenuItem 1"/> <shell:ApplicationBarMenuItem Text="MenuItem 2"/> </shell:ApplicationBar.MenuItems> </shell:ApplicationBar>

Icons need to be developed only in white, Windows Phone API will take care of

converting it into respective dark color when the theme changes from dark to

light.

Text hint is mandatory. A maximum of 4 icons are allowed in the application bar.

A maximum of 5 menu items are allowed under the application bar.

Page 37: Windows phone 7 series

Application Life Cycle

Page 38: Windows phone 7 series

Application Life Cycle

Page 39: Windows phone 7 series

The procedure in which the operating system terminates an application’s process

when the user navigates away from the application. The operating system maintains

state information about the application. If the user navigates back to the application,

the operating system restarts the application process and passes the state data back

to the application.

Tombstoning

Page 40: Windows phone 7 series

App.xaml

Application_Launching - Triggered on starting the app, not on activation after being tomstoned. Application_Activated - Triggered on reactivating the app after being tomstoned. Application_Deactivated - Triggered when an app is being tomstoned. Application_Closing - Triggered on closing the application.

Page 41: Windows phone 7 series

Launchers and

Choosers

Page 42: Windows phone 7 series

Launchers and Choosers - Defined

The Launcher and Chooser APIs invoke distinct built-in applications that replace

the currently running application.

Launcher:

A Launcher is an API that launches one of the built-in applications through

which a user completes a task, and in which no data is returned to the calling

application. E.g. Phone Call

Chooser:

A Chooser is an API that launches one of the built-in applications through which

a user completes a task, and which returns some kind of data to the calling

application E.g. Choosing a Photo

Page 43: Windows phone 7 series

Launchers

EmailComposeTask

MarketplaceDetailTask

MarketplaceHubTask

MarketplaceReviewTask

MarketplaceSearchTask

MediaPlayerLauncher

PhoneCallTask

SearchTask

SMSComposeTask

WebBrowserTask

EmailComposeTask emailComposeTask = new EmailComposeTask(); emailComposeTask.To = "[email protected]"; emailComposeTask.Body = "Email message body"; emailComposeTask.Cc = "[email protected]"; emailComposeTask.Subject = "Email subject"; emailComposeTask.Show();

Page 44: Windows phone 7 series

Choosers

CameraCaptureTask

EmailAddressChooserTask

PhoneNumberChooserTask

PhotoChooserTask

SaveEmailAddressTask

SavePhoneNumberTask

// Initialize the CameraCaptureTask and assign the Completed handler in the page constructor. cameraCaptureTask = new CameraCaptureTask(); cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed); cameraCaptureTask.Show(); void cameraCaptureTask_Completed(object sender, PhotoResult e) { if (e.TaskResult == TaskResult.OK) { BitmapImage bmp = new BitmapImage(); bmp.SetSource(e.ChosenPhoto); myImage.Source = bmp; } }

Page 45: Windows phone 7 series

Location Services

Page 46: Windows phone 7 series

Location Services

The Location Service allows you to create location-aware applications. The service

obtains location data from multiple sources such as GPS, Wi-Fi, and cellular.

// The watcher variable was declared as type GeoCoordinateWatcher. if (watcher == null) { watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); // using high accuracy watcher.MovementThreshold = 20; // to ignore noise in the signal in metres. watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(w_StatusChanged); watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(w_PositionChanged); } watcher.Start();

System.Device.Location

GeoCoordinateWatcher

Page 47: Windows phone 7 series

GeoPosition Statuses

switch (e.Status) { case GeoPositionStatus.Disabled: // The Location Service is disabled or unsupported. Check to see if the user has disabled the Location Service. if (watcher.Permission == GeoPositionPermission.Denied) { // The user has disabled the Location Service on their device. } else { //location is not functioning on this device } break; case GeoPositionStatus.Initializing: // The Location Service is initializing. break; case GeoPositionStatus.NoData: // The Location Service is working, but it cannot get location data. break; case GeoPositionStatus.Ready: // The Location Service is working and is receiving location data. break; }

Page 48: Windows phone 7 series

Push Notifications

Page 49: Windows phone 7 series

Push Notifications

Push Notification Service in Windows Phone offers a dedicated, and persistent

channel to send information and updates to a mobile application from a web service.

Page 50: Windows phone 7 series

Types of Push Notifications

1. Tile Notification 1. Image, Count, Title can be notified

2. Toast Notification 1. Displayed on top of the screen for 10 seconds.

3. Raw Notification 1. To send raw information to application if running.

Page 51: Windows phone 7 series

Send a push notification to service

// The URI that the Push Notification Service returns to the Push Client when creating a notification channel. string subscriptionUri = “http://hostedlive.com/hello" HttpWebRequest sendNotificationRequest = (HttpWebRequest)WebRequest.Create(subscriptionUri); // HTTP POST is the only allowed method to send the notification. sendNotificationRequest.Method = "POST"; // The custom header X-MessageID uniquely identifies a message. If it is present, the same value is returned in the notification response. sendNotificationRequest.Headers.Add("X-MessageID", "<UUID>"); // Sets the web request content length. sendNotificationRequest.ContentLength = notificationMessage.Length; // Sets the notification payload to send. byte[] notificationMessage = new byte[] {<payload>}; using (Stream requestStream = sendNotificationRequest.GetRequestStream()) { requestStream.Write(notificationMessage, 0, notificationMessage.Length); } // Sends the notification and gets the response. HttpWebResponse response = (HttpWebResponse)sendNotificationRequest.GetResponse();

Page 52: Windows phone 7 series

Send a push notification to service – Pay Loads

Raw notification

Tile notification

Toast notification

new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};

<?xml version=1.0 encoding=utf-8?> <wp:Notification xmlns:wp=WPNotification> <wp:Tile> <wp:BackgroundImage><background image path></wp:BackgroundImage> <wp:Count>5</wp:Count> <wp:Title>xconf_pune</wp:Title> </wp:Tile> </wp:Notification>

<?xml version=1.0 encoding=utf-8?> <wp:Notification xmlns:wp=WPNotification> <wp:Toast> <wp:Text1><string></wp:Text1> <wp:Text2><string></wp:Text2> </wp:Toast> </wp:Notification>

sendNotificationRequest.ContentType = "text/xml"; sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", "token"); sendNotificationRequest.Headers.Add("X-NotificationClass", "<batching interval>");

Page 53: Windows phone 7 series

Receive a Push Notification

Microsoft.Phone.Notification

HttpNotificationChannel

// Only one notification channel name is supported per application. channel = new HttpNotificationChannel("channel","www.contoso.com"); channel.Open(); //receiving a raw notification channel.HttpNotificationReceived += new EventHandler<HttpNotificationEventArgs>(channel_HttpNotificationReceived); // If the application is running in the foreground, the toast notification is instead routed to the application. channel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(channel_ShellToastNotificationReceived); // Binding a notification channel to a tile notification. if (!channel.IsShellTileBound) { channel.BindToShellTile(); } // Binding a notification channel to a toast notification. if (!channel.IsShellToastBound) { channel.BindToShellToast(); }

Page 54: Windows phone 7 series

Touch & Gestures

Page 55: Windows phone 7 series

Available Gestures

• Tap

• DoubleTap

• Hold

• FreeDrag

• VerticalDrag

• HorizontalDrag

• DragComplete

• Flick

• Pinch

• PinchComplete

Touch Gestures is available only in XNA

framework, though the library can be used in

a Silverlight application.

Page 56: Windows phone 7 series

Gesture Sample

Microsoft.Xna.Framework.Input.Touch

//enable the gestures we care about.you must set EnabledGestures before you can use any of the other gesture APIs. TouchPanel.EnabledGestures=GestureType.Hold|GestureType.Tap|GestureType.FreeDrag; //since we may have multiple gestures available, we use a loop to read in all of the gestures while(TouchPanel.IsGestureAvailable) { //read the next gesture from the queue GestureSample gesture=TouchPanel.ReadGesture(); //we can use the type of gesture to determine our behavior switch(gesture.GestureType) { case GestureType.Tap: case GestureType.DoubleTap: case GestureType.Hold: case GestureType.FreeDrag: case GestureType.Flick: case GestureType.Pinch: } }

Page 57: Windows phone 7 series

Animations –

Expression Blend

Page 58: Windows phone 7 series

Expression Blend 4 - Defined

The Microsoft Expression Blend Software Development Kit (SDK) for

Windows Phone provides conceptual topics and programming reference

for behaviors, which are reusable pieces of packaged code that can be

dragged onto any object and then fine-tuned by changing their

properties.

Page 59: Windows phone 7 series
Page 60: Windows phone 7 series
Page 61: Windows phone 7 series

There are more..

Page 62: Windows phone 7 series

APIs for

Accelerometer

Vibration Controller

Bing Maps

Web Browser

Charting

Advertising

XNA Game

Trial Version

Page 63: Windows phone 7 series

LG Quantum HTC 7

Surround

HTC HD7

Samsung

Focus

Samsung

Omnia 7

Dell Venue Pro

HTC 7

Trophy

Page 64: Windows phone 7 series

Resources

http://borntolearn.mslearn.net/wp7/m/default.aspx

http://wp7dev.wikispaces.com

http://channel9.msdn.com/learn/courses/WP7TrainingKit

http://www.charlespetzold.com/phone/

http://images.google.com

http://www.jeffblankenburg.com/post/31-Days-of-Windows-Phone-7.aspx

http://go.microsoft.com/fwlink/?LinkID=183218