Business.xaml.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Documents;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Animation;
  11. using System.Windows.Shapes;
  12. using Microsoft.Phone.Controls;
  13. using Microsoft.Phone.Tasks;
  14. using System.Windows.Media.Imaging;
  15. using System.IO;
  16. using System.IO.IsolatedStorage;
  17. using Microsoft.Xna.Framework.Media;
  18. using Microsoft.Devices;
  19. using Microsoft.Phone;
  20. namespace IDTemplate
  21. {
  22. public partial class Business : PhoneApplicationPage
  23. {
  24. PhotoChooserTask photo = new PhotoChooserTask();
  25. CameraCaptureTask cct = new CameraCaptureTask();
  26. ImageBrush imgBrush = new ImageBrush();
  27. BitmapImage bmp = new BitmapImage();
  28. BitmapImage bimg = new BitmapImage();
  29. public Business()
  30. {
  31. InitializeComponent();
  32. }
  33. private void image1_Tap(object sender, GestureEventArgs e)
  34. {
  35. cct.Completed += new EventHandler<PhotoResult>(cct_Completed);
  36. try
  37. {
  38. cct.Show();
  39. }
  40. catch (System.InvalidOperationException ex)
  41. {
  42. MessageBox.Show("An error occurred.");
  43. }
  44. }
  45. void photoChooserTask_Completed(object sender, PhotoResult e)
  46. {
  47. if (e.TaskResult == TaskResult.OK)
  48. {
  49. MessageBox.Show(e.ChosenPhoto.Length.ToString());
  50. //Code to display the photo on the page in an image control named myImage.
  51. bmp.SetSource(e.ChosenPhoto);
  52. imgBrush.ImageSource = bmp;
  53. ContentPanel.Background = imgBrush;
  54. }
  55. }
  56. void cct_Completed(object sender, PhotoResult e)
  57. {
  58. if (e.TaskResult == TaskResult.OK)
  59. {
  60. bimg.SetSource(e.ChosenPhoto);
  61. image1.Source = bimg;
  62. }
  63. }
  64. private void textBox1_Tap(object sender, GestureEventArgs e)
  65. {
  66. textBox1.Text = "";
  67. }
  68. private void PageTitle_Tap(object sender, GestureEventArgs e)
  69. {
  70. try
  71. {
  72. photo.Show();
  73. photo.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);
  74. }
  75. catch (System.InvalidOperationException ex)
  76. {
  77. MessageBox.Show("An error occurred.");
  78. }
  79. }
  80. private void textBox2_Tap(object sender, GestureEventArgs e)
  81. {
  82. textBox2.Text = "";
  83. }
  84. private void textBox3_Tap(object sender, GestureEventArgs e)
  85. {
  86. textBox3.Text = "";
  87. }
  88. private void textBox4_Tap(object sender, GestureEventArgs e)
  89. {
  90. textBox4.Text = "";
  91. }
  92. }
  93. }