windows phone 7 series

Post on 28-Nov-2014

1.880 Views

Category:

Devices & Hardware

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

Windows Phone 7 Series Balaji Damodaran

-ThoughtWorks

Before we start,

a confession…

Microsoft

did not pay us.

The Players

And Cross Platform

APIs (mostly)

New kid

on the block

Old(ish) wine in

a new(ish) bottle

Demo

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

Metro

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.

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.

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.

Silverlight

Components

Silverlight Essentials

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

UI Controls

• ListBox

• Grid

• Canvas

• StackPanel

• Border

• Map

• Slider

• ProgressBar

• TextBlock

• more…

Panorama & Pivot

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

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

Isolated Storage

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.

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; }

}

WP7 ↔ Web Services

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

Data Binding

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.

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}">

Data Binding - Modes

Mode determines how changes are synchronized:

a. OneTime

b. OneWay

c. TwoWay

Application Bar

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.

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.

Application Life Cycle

Application Life Cycle

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

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.

Launchers and

Choosers

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

Launchers

EmailComposeTask

MarketplaceDetailTask

MarketplaceHubTask

MarketplaceReviewTask

MarketplaceSearchTask

MediaPlayerLauncher

PhoneCallTask

SearchTask

SMSComposeTask

WebBrowserTask

EmailComposeTask emailComposeTask = new EmailComposeTask(); emailComposeTask.To = "user@example.com"; emailComposeTask.Body = "Email message body"; emailComposeTask.Cc = "user2@example.com"; emailComposeTask.Subject = "Email subject"; emailComposeTask.Show();

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; } }

Location Services

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

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; }

Push Notifications

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.

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.

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();

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>");

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(); }

Touch & Gestures

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.

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: } }

Animations –

Expression Blend

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.

There are more..

APIs for

Accelerometer

Vibration Controller

Bing Maps

Web Browser

Charting

Advertising

XNA Game

Trial Version

LG Quantum HTC 7

Surround

HTC HD7

Samsung

Focus

Samsung

Omnia 7

Dell Venue Pro

HTC 7

Trophy

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

top related