Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

Windows Phone Launchers and Choosers

With Launchers and Choosers in Windows Phone, 3rd party apps integrate more closely into the underlying operating system while allowing end-users to perform common tasks. With Launchers and Choosers you will provide more functionality to your end-users while still maintaining that consistent user experience that will make your app feel like a native app. In this session we’ll cover how to use Windows Phone resources including camera, video and Bing maps. We’ll also cover accessing contacts and calendar as well as sensors (including accelerometer, compass, gyroscope and motion).

  • Inicia sesión para ver los comentarios

Windows Phone Launchers and Choosers

  1. 1. Follow me on Twitter or the Puppy gets it @benriga
  2. 2. Reading Contactsand Calendars
  3. 3. <Capabilities> <Capability Name="ID_CAP_LOCATION"/> <Capability Name="ID_CAP_MEDIALIB"/> ... other capabilities here <Capability Name="ID_CAP_CONTACTS"/> <Capability Name="ID_CAP_APPOINTMENTS"/></Capabilities>
  4. 4. Other contact CalendarData provider Contact name Contact picture data appointmentsWindows Phone Device Yes Yes Yes YesWindows Live Social Yes Yes Yes YesWindows Live Rolodex Yes Yes Yes YesExchange Accounts(Contacts from local address book only, not Yes Yes Yes YesGlobal Address List.)Mobile Operator Address Book Yes Yes Yes NoFacebook Yes Yes No NoWindows Live Aggregated Networks No No No No(Twitter, LinkedIn, etc.)
  5. 5. using Microsoft.Phone.UserData;...Contacts cons;private void loadButton_Click(object sender, RoutedEventArgs e){ cons = new Contacts(); cons.SearchCompleted += new EventHandler <ContactsSearchEventArgs>(cons_SearchCompleted); cons.SearchAsync(String.Empty,FilterKind.None, "Contacts Load");}
  6. 6. void cons_SearchCompleted(object sender, ContactsSearchEventArgs e){ //Bind the results to the user interface. ContactsListBox.DataContext = e.Results;}
  7. 7. <ListBox Name="ContactsListBox" ItemsSource="{Binding}" Height="347" Margin="24,0,0,0" > <ListBox.ItemTemplate> <DataTemplate> <TextBlock Name="ContactResults" Text="{Binding Path=DisplayName, Mode=OneWay}" /> </DataTemplate> </ListBox.ItemTemplate></ListBox>
  8. 8. // enumerate the results we got back and get the sourceforeach (Contact contact in e.Results){ foreach (Account account in contact.Accounts) { Debug.WriteLine(contact.DisplayName + ": " + account.Name); }}
  9. 9. Demo 1:Contact Display
  10. 10. cons.SearchAsync("Ro", FilterKind.DisplayName, "Contacts Load");// Find all the contacts with names beginning "Ro"
  11. 11. apps.SearchAsync( new DateTime(2000, 1, 1), new DateTime(2012, 1, 1), "Appointment search");
  12. 12. Creating a Contact
  13. 13. 18
  14. 14. using Microsoft.Phone.Tasks;...SaveContactTask saveContact; //Declare with page scopepublic MainPage(){ saveContact = new SaveContactTask(); saveContact.Completed += new EventHandler <SaveContactResult>(saveContact_Completed);}private void MakeContactButton_Click(object sender, RoutedEventArgs e){ saveContact.FirstName = FirstNameTextBox.Text; saveContact.LastName = LastNameTextBox.Text; saveContact.Show();}
  15. 15. void saveContact_Completed(object sender, SaveContactResult e){ if (e.TaskResult == TaskResult.OK) { MessageBox.Show("Saved OK"); }}
  16. 16. 21
  17. 17. Demo 2:Make a Contact 22
  18. 18. 23
  19. 19. Action Chooser TaskGet addresses, phone numbers and email AddressChooserTask,addresses PhoneNumberChooserTask, EmailAddressChooserTaskSelect a picture from the media store PhotoChooserTaskCapture a picture using the camera CameraCaptureTaskInvite players to a multi-game session GameInviteTask(XBL only)Save email addresses or phone numbers SaveEmailAddressTask, SavePhoneNumberTaskSave ringtones SaveRingtoneTask
  20. 20. Action TaskOpen a web page WebBrowserTaskSearch the Marketplace and find applications MarketplaceSearchTask, MarketPlaceHubTaskShow Marketplace App Details and Review MarketplaceDetailTask,Apps MarketplaceReviewTaskPlace a phone call PhoneCallTaskSend an email EmailComposeTaskSend an SMS message SMSComposeTaskPlay media MediaPlayerTaskStart a search using Bing SearchTaskShow maps and directions from Bing Maps BingMapsTask, BingMapsDirectionsTask
  21. 21. Using the Camera 27
  22. 22. 28
  23. 23. cameraTask = new CameraCaptureTask();cameraTask.Completed += new EventHandler<PhotoResult> (cameraTask_Completed);cameraTask.Show();
  24. 24. void cameraCapture_Completed(object sender, PhotoResult e){ if (e.TaskResult == TaskResult.OK) { photoImage.Source = new BitmapImage( new Uri(e.OriginalFileName)); }}
  25. 25. Demo 3:Take a Picture 31
  26. 26. 32
  27. 27. using Microsoft.Devices;...PhotoCamera camera;...camera = new PhotoCamera();//Set the VideoBrush source to the cameraviewfinderBrush.SetSource(camera);camera.CaptureImageAvailable +=new EventHandler<ContentReadyEventArgs> (camera_CaptureImageAvailable);
  28. 28. <Rectangle Width="320" Height="240" HorizontalAlignment="Left" > <Rectangle.Fill> <VideoBrush x:Name="viewfinderBrush" /> </Rectangle.Fill></Rectangle>
  29. 29. private void PhotoButton_Click(object sender, RoutedEventArgs e){ camera.CaptureImage();}
  30. 30. using Microsoft.Xna.Framework.Media;...void camera_CaptureImageAvailable(object sender, ContentReadyEventArgs e){ Deployment.Current.Dispatcher.BeginInvoke(delegate() { string fileName = DateTime.Now.Ticks.ToString() + ".jpg"; MediaLibrary library = new MediaLibrary(); library.SavePictureToCameraRoll(fileName, e.ImageStream); });}
  31. 31. using System.Windows.Media.Imaging;...void camera_CaptureImageAvailable(object sender, ContentReadyEventArgs e){ Deployment.Current.Dispatcher.BeginInvoke(delegate() { BitmapImage b = new BitmapImage(); b.CreateOptions = BitmapCreateOptions.None; b.SetSource(e.ImageStream); PictureImage.Source = b; });}
  32. 32. using System.IO;using System.IO.IsolatedStorage;...using (IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication()) { using (IsolatedStorageFileStream targetStream = isStore.OpenFile(fileName, FileMode.Create, FileAccess.Write)) { WriteableBitmap bitmap = new WriteableBitmap(b); bitmap.SaveJpeg(targetStream, bitmap.PixelWidth, bitmap.PixelHeight, 0, 100); }}
  33. 33. Demo 4:In-AppCamera 39
  34. 34. 40
  35. 35. internal int FunkyColor(int color){ int a = color >> 24; int r = (color & 0x00ff0000) >> 16; int g = (color & 0x0000ff00) >> 8; int b = (color & 0x000000ff); r += redOffset; g += greenOffset; b += blueOffset; return ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);}
  36. 36. camera = new Microsoft.Devices.PhotoCamera();// Create the destination for the processed imagewb = new WriteableBitmap(640, 480);this.ProcessedImage.Source = wb;// Start the image pump when the camera is readycamera.Initialized += new EventHandler<CameraOperationCompletedEventArgs> (camera_Initialized);
  37. 37. void camera_Initialized(object sender, CameraOperationCompletedEventArgs e){ pumpARGBFrames = true; ARGBFramesThread = new System.Threading.Thread(PumpARGBFrames); ARGBFramesThread.Start();}
  38. 38. int[] ARGBPx = new int[640 * 480];...captureEvent.WaitOne();pauseFramesEvent.WaitOne(); //Thread sync with camera//Copies the current viewfinder frame into a buffercamera.GetPreviewBufferArgb32(ARGBPx);//Conversion to funky coloursfor (int i = 0; i < ARGBPx.Length; i++){ ARGBPx[i] = FunkyColor(ARGBPx[i]);}
  39. 39. private WriteableBitmap wb;...pauseFramesEvent.Reset();Deployment.Current.Dispatcher.BeginInvoke(delegate(){ //Copy to WriteableBitmap ARGBPx.CopyTo(wb.Pixels, 0); wb.Invalidate(); pauseFramesEvent.Set();});
  40. 40. Demo 6:FunkyCamera 46
  41. 41. Using the Microphone
  42. 42. http://msdn.microsoft.com/en-us/library/gg442302.aspx
  43. 43. Using Sensors
  44. 44. using Microsoft.Devices.Sensors;
  45. 45. if (Gyroscope.IsSupported){ // we have a gyro on the phone}
  46. 46. 54
  47. 47. using Microsoft.Devices.Sensors;...Motion motion;...motion = new Motion();motion.TimeBetweenUpdates = TimeSpan.FromMilliseconds(20);motion.CurrentValueChanged += new EventHandler <SensorReadingEventArgs<MotionReading>> (motion_CurrentValueChanged);
  48. 48. // Try to start the Motion API.try{ motion.Start();}catch (Exception){ MessageBox.Show("unable to start the Motion API.");}
  49. 49. private void CurrentValueChanged(MotionReading e){ if (motion.IsDataValid) { // Show the numeric values for attitude. yawTextBlock.Text = "YAW: " + MathHelper.ToDegrees(e.Attitude.Yaw).ToString("0") + "°"; pitchTextBlock.Text = "PITCH: " + MathHelper.ToDegrees(e.Attitude.Pitch).ToString("0") + "°"; rollTextBlock.Text = "ROLL: " + MathHelper.ToDegrees(e.Attitude.Roll).ToString("0") + "°"; }}
  50. 50. Video Content
  51. 51. <MediaElement Name= "MediaPlayback" Source= "myvideo.wmv" AutoPlay="True"/> http://msdn.microsoft.com/en-us/library/ff462087.aspx
  52. 52. <MediaElement Name= "MediaPlayback"Source="http://mschannel9.vo.msecnd.net/o9/mix/09/wmv/key01.wmv"AutoPlay="True"/>
  53. 53. private void pauseButton_Click(object sender, RoutedEventArgs e){ MediaPlayback.Pause();}
  54. 54. http://smf.codeplex.com/releases/view/63434#DownloadId=222617
  55. 55. 63
  56. 56. http://aka.ms/mbl-phone/starthttp://aka.ms/mbl-phone/toolshttp://aka.ms/mbl-phone/mangohttp://aka.ms/mbl-phone/register
  57. 57. Follow me on Twitter or the Puppy gets it @benriga

×