123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using Microsoft.Phone.Controls;
- using Microsoft.Phone;
- using Microsoft.Phone.Tasks;
- using System.Windows.Media.Imaging;
- namespace IDTemplate
- {
- public partial class Student : PhoneApplicationPage
- {
- PhotoChooserTask photo = new PhotoChooserTask();
- PhotoChooserTask image = new PhotoChooserTask();
- CameraCaptureTask cct = new CameraCaptureTask();
- BitmapImage bmp = new BitmapImage();
- ImageBrush imgBrush = new ImageBrush();
- BitmapImage bmp1 = new BitmapImage();
- ImageBrush imgBrush1 = new ImageBrush();
- BitmapImage bimg= new BitmapImage();
- public Student()
- {
- InitializeComponent();
- }
- private void textBox5_Tap(object sender, GestureEventArgs e)
- {
- textBox5.Text = "";
- }
- private void textBox1_Tap(object sender, GestureEventArgs e)
- {
- textBox1.Text = "";
- }
- private void textBox2_Tap(object sender, GestureEventArgs e)
- {
- textBox2.Text = "";
- }
- private void textBox3_Tap(object sender, GestureEventArgs e)
- {
- textBox3.Text = "";
- }
- private void image2_Tap(object sender, GestureEventArgs e)
- {
- cct.Completed += new EventHandler<PhotoResult>(cct_Completed);
- try
- {
- cct.Show();
- }
- catch (System.InvalidOperationException ex)
- {
- MessageBox.Show("An error occurred.");
- }
- }
- void photoChooserTask_Completed(object sender, PhotoResult e)
- {
- if (e.TaskResult == TaskResult.OK)
- {
- MessageBox.Show(e.ChosenPhoto.Length.ToString());
- //Code to display the photo on the page background control named ContentPanel.
-
- bmp.SetSource(e.ChosenPhoto);
- imgBrush.ImageSource = bmp;
- ContentPanel.Background = imgBrush;
- }
-
- }
-
- void imageChooserTask_Completed(object sender, PhotoResult e)
- {
- if (e.TaskResult == TaskResult.OK)
- {
- MessageBox.Show(e.ChosenPhoto.Length.ToString());
- //Code to display the photo on the page in an image control named Image1.
-
- bmp1.SetSource(e.ChosenPhoto);
- imgBrush1.ImageSource = bmp1;
- image1.Source = bmp1;
- }
- }
- void cct_Completed(object sender, PhotoResult e)
- {
- if (e.TaskResult == TaskResult.OK)
- {
- bimg.SetSource(e.ChosenPhoto);
- image2.Source = bimg;
- }
- }
- private void PageTitle_Tap_1(object sender, GestureEventArgs e)
- {
- try
- {
- photo.Show();
- photo.Completed += new EventHandler<PhotoResult>(photoChooserTask_Completed);
- }
- catch (System.InvalidOperationException ex)
- {
- MessageBox.Show("An error occurred.");
- }
- }
- private void image1_Tap(object sender, GestureEventArgs e)
- {
- try
- {
- image.Show();
- image.Completed += new EventHandler<PhotoResult>(imageChooserTask_Completed);
-
- }
- catch (System.InvalidOperationException ex)
- {
- MessageBox.Show("An error occurred.");
- }
- }
- }
- }
|