Employee.xaml.cs 2.9 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 System.Windows.Media.Imaging;
  14. using Microsoft.Xna.Framework.Media;
  15. using Microsoft.Devices;
  16. using Microsoft.Phone;
  17. using Microsoft.Phone.Tasks;
  18. namespace IDTemplate
  19. {
  20. public partial class Employee : PhoneApplicationPage
  21. {
  22. PhotoChooserTask photo = new PhotoChooserTask();
  23. CameraCaptureTask cct = new CameraCaptureTask();
  24. ImageBrush imgBrush = new ImageBrush();
  25. BitmapImage bmp = new BitmapImage();
  26. BitmapImage bimg = new BitmapImage();
  27. public Employee()
  28. {
  29. InitializeComponent();
  30. }
  31. private void textBox5_Tap(object sender, GestureEventArgs e)
  32. {
  33. textBox5.Text = "";
  34. }
  35. private void textBox1_Tap(object sender, GestureEventArgs e)
  36. {
  37. textBox1.Text = "";
  38. }
  39. private void textBox2_Tap(object sender, GestureEventArgs e)
  40. {
  41. textBox2.Text = "";
  42. }
  43. private void textBox3_Tap(object sender, GestureEventArgs e)
  44. {
  45. textBox3.Text = "";
  46. }
  47. private void image1_Tap(object sender, GestureEventArgs e)
  48. {
  49. cct.Completed += new EventHandler<PhotoResult>(cct_Completed);
  50. try
  51. {
  52. cct.Show();
  53. }
  54. catch (System.InvalidOperationException ex)
  55. {
  56. MessageBox.Show("An error occurred.");
  57. }
  58. }
  59. void photoChooserTask_Completed(object sender, PhotoResult e)
  60. {
  61. if (e.TaskResult == TaskResult.OK)
  62. {
  63. MessageBox.Show(e.ChosenPhoto.Length.ToString());
  64. //Code to display the photo on the page background control named ContentPanel.
  65. bmp.SetSource(e.ChosenPhoto);
  66. imgBrush.ImageSource = bmp;
  67. ContentPanel.Background = imgBrush;
  68. }
  69. }
  70. void cct_Completed(object sender, PhotoResult e)
  71. {
  72. if (e.TaskResult == TaskResult.OK)
  73. {
  74. bimg.SetSource(e.ChosenPhoto);
  75. image1.Source = bimg;
  76. }
  77. }
  78. private void PageTitle_Tap_1(object sender, GestureEventArgs e)
  79. {
  80. try
  81. {
  82. photo.Show();
  83. photo.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);
  84. }
  85. catch (System.InvalidOperationException ex)
  86. {
  87. MessageBox.Show("An error occurred.");
  88. }
  89. }
  90. }
  91. }