Windows phone 7 series


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Windows phone 7 series

  1. 1. Windows Phone 7 Series Balaji Damodaran -ThoughtWorks
  2. 2. Before we start, a confession…
  3. 3. Microsoftdid not pay us.
  4. 4. The Players
  5. 5. And Cross Platform APIs (mostly)
  6. 6. New kidon the block
  7. 7. Old(ish) wine ina new(ish) bottle
  8. 8. Demo
  9. 9. Source:
  10. 10. Metro
  11. 11. Metro Design and TypefaceThe Windows Phone OS 7 User Interface (UI) is based on a design that isinternally named Metro, and echoes the visual language of airport and metrosystem signage in its design and typeface.
  12. 12. TilesTiles are links to applications, features, functionsand individual items (such as contacts, webpages, applications or media items). Users canadd, rearrange, or remove Tiles. Tiles aredynamic and update in real timeTiles that use the Tile Notification feature canupdate the Tile graphic or title text, orincrement a counter.
  13. 13. ThemesA Theme is a user-selected combination of background and accent colors thatpersonalizes the visual elements on a Windows Phone for that user.
  14. 14. SilverlightComponents
  15. 15. Silverlight EssentialsXaml – Extensible Application Markup Language (ala HTML types)Xaml.cs – Backend Program that controls the UI state and data (ala JavaScript)
  16. 16. UI Controls• ListBox• Grid• Canvas• StackPanel• Border• Map• Slider• ProgressBar• TextBlock• more…
  17. 17. Panorama & Pivot
  18. 18. Panorama ApplicationUnlike standard applications that are designed to fit within the confines ofthe phone screen, these applications offer a unique way to view controls,data, and services by using a long horizontal canvas that extends beyondthe confines of the screen
  19. 19. Pivot ApplicationA pivot control provides a quick way to manage views or pages within theapplication. The control places individual views horizontally next to each other,and manages the left and right navigation. Flicking or panning horizontally onthe page cycles the pivot functionality.
  20. 20. Isolated Storage
  21. 21. Isolated Storage - DefinedIsolated storage enables managed applications to create and maintain localstorage. Application developers have the ability to store data locally on thephone, leveraging all the benefits of isolated storage including protecting datafrom other applications.
  22. 22. Isolated Storing System.IO.IsolatedStorageusing (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; }}
  23. 23. WP7 ↔ Web Services
  24. 24. featuresNot 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
  25. 25. Data Binding
  26. 26. Data Binding - DefinedData 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.
  27. 27. Data Binding - Setting Defining the data source: a. DataContext property of any containing Element b. ItemSource of a List control – (ObservableCollection type) <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}"> Binding the Data:<TextBlock Grid.Column="0" Text="{Binding TimeSlot}" Style="{StaticResource PhoneTextSubtleStyle}"/>
  28. 28. Data Binding - ModesMode determines how changes are synchronized:a. OneTimeb. OneWayc. TwoWay
  29. 29. Application Bar
  30. 30. Application Bar - DefinedThe Application Bar provides a place for developers to display up to four of themost common application tasks and views as icon buttons.
  31. 31. 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 ofconverting it into respective dark color when the theme changes from dark tolight.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.
  32. 32. Application Life Cycle
  33. 33. Application Life Cycle
  34. 34. TombstoningThe procedure in which the operating system terminates an application’s processwhen the user navigates away from the application. The operating system maintainsstate information about the application. If the user navigates back to the application,the operating system restarts the application process and passes the state data backto the application.
  35. 35. App.xamlApplication_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.
  36. 36. Launchers and Choosers
  37. 37. Launchers and Choosers - Defined The Launcher and Chooser APIs invoke distinct built-in applications that replacethe currently running application.Launcher:A Launcher is an API that launches one of the built-in applications throughwhich a user completes a task, and in which no data is returned to the callingapplication. E.g. Phone CallChooser:A Chooser is an API that launches one of the built-in applications through whicha user completes a task, and which returns some kind of data to the callingapplication E.g. Choosing a Photo
  38. 38. LaunchersEmailComposeTaskMarketplaceDetailTaskMarketplaceHubTask EmailComposeTask emailComposeTask = new EmailComposeTask();MarketplaceReviewTask emailComposeTask.To = "";MarketplaceSearchTask emailComposeTask.Body = "Email message body"; emailComposeTask.Cc = "";MediaPlayerLauncher emailComposeTask.Subject = "Email subject";PhoneCallTask emailComposeTask.Show();SearchTaskSMSComposeTaskWebBrowserTask
  39. 39. ChoosersCameraCaptureTask // Initialize the CameraCaptureTask and assign the Completed handler in the page constructor.EmailAddressChooserTask cameraCaptureTask = new CameraCaptureTask();PhoneNumberChooserTask cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed);PhotoChooserTask cameraCaptureTask.Show();SaveEmailAddressTask void cameraCaptureTask_Completed(object sender, PhotoResult e)SavePhoneNumberTask { if (e.TaskResult == TaskResult.OK) { BitmapImage bmp = new BitmapImage(); bmp.SetSource(e.ChosenPhoto); myImage.Source = bmp; } }
  40. 40. Location Services
  41. 41. 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. System.Device.Location GeoCoordinateWatcher// 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();
  42. 42. GeoPosition Statusesswitch (e.Status) {case GeoPositionStatus.Disabled:// The Location Service is disabled or unsupported. Check to see if the user has disabled theLocation 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;}
  43. 43. Push Notifications
  44. 44. Push NotificationsPush Notification Service in Windows Phone offers a dedicated, and persistentchannel to send information and updates to a mobile application from a web service.
  45. 45. 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.
  46. 46. Send a push notification to service// The URI that the Push Notification Service returns to the Push Client when creating anotification channel.string subscriptionUri = “"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 isreturned 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();
  47. 47. Send a push notification to service – Pay LoadsRaw notification new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};Tile notification <?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>Toast 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>");
  48. 48. Receive a Push Notification Microsoft.Phone.Notification HttpNotificationChannel// Only one notification channel name is supported per = new HttpNotificationChannel("channel","");channel.Open();//receiving a raw notificationchannel.HttpNotificationReceived += newEventHandler<HttpNotificationEventArgs>(channel_HttpNotificationReceived);// If the application is running in the foreground, the toast notification is instead routed to += newEventHandler<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();}
  49. 49. Touch & Gestures
  50. 50. Available Gestures• Tap• DoubleTap• Hold• FreeDrag• VerticalDrag Touch Gestures is available only in XNA framework, though the library can be used in• HorizontalDrag a Silverlight application.• DragComplete• Flick• Pinch• PinchComplete
  51. 51. Gesture Sample Microsoft.Xna.Framework.Input.Touch//enable the gestures we care must set EnabledGestures before you can use any ofthe 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 thegestureswhile(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: }}
  52. 52. Animations –Expression Blend
  53. 53. Expression Blend 4 - DefinedThe Microsoft Expression Blend Software Development Kit (SDK) forWindows Phone provides conceptual topics and programming referencefor behaviors, which are reusable pieces of packaged code that can bedragged onto any object and then fine-tuned by changing theirproperties.
  54. 54. There are more..
  55. 55. APIs forAccelerometerVibration ControllerBing MapsWeb BrowserChartingAdvertisingXNA GameTrial Version…
  56. 56. LG Quantum HTC 7 HTC HD7 Dell Venue Pro Surround Samsung Samsung HTC 7 Focus Omnia 7 Trophy
  57. 57. Resources