首页 > 代码库 > Windows Phone 7 中常用Task

Windows Phone 7 中常用Task

      1、//PhoneCallTask :打电话

private void btnPhoneCall_Click(object sender, RoutedEventArgs e)
{
    PhoneCallTask task = new PhoneCallTask();
    task.PhoneNumber = "110";
    task.DisplayName = "秋月光璇";
    task.Show();
}

     2、//SmsComposeTask:发送短信 

     private void btnComposeSms_Click(object sender, RoutedEventArgs e)

{
    SmsComposeTask task = new SmsComposeTask();
    task.To = "110";
    task.Body = "你好!.";
    task.Show();
}

3、//EmailComposeTask:发送邮件 

EmailComposeTask task = new EmailComposeTask();
task.To = "252456098@qq.com";
task.Cc = "ycproc@163.com";
task.Subject = "秋月光璇测试";
task.Body = "Hello world!";
task.Show();


4、//WebBrowserTask:开启Web浏览器
private void btnLaunchWebBrowser_Click(object sender, RoutedEventArgs e)
{
    WebBrowserTask task = new WebBrowserTask();

    task.URL = "<a href="http://http://www.cnblogs.com/qiuyueguangxuan/">http://www.cnblogs.com/qiuyueguangxuan</a>";
    task.Show();
}

5、//SearchTask:搜索功能
private void btnLaunchSearch_Click(object sender, RoutedEventArgs e)
{
    SearchTask task = new SearchTask();
    task.SearchQuery = "秋月光璇";
    task.Show();
}

6、//MediaPlayerLauncher:启动媒体播放器
MediaPlayerLauncher task = new MediaPlayerLauncher();
task.Media = new Uri(@"http://www.baidu.com/11.wmv");
task.Show();


7、//CameraCaptureTask: 拍照的task
private void button1_Click(object sender,RoutedEventArgs e)
{
    CameraCaptureTask camerTask=new CameraCaptureTask();
    camerTask.Completed+=new EventHandler<PhotoResult>(cameraTask_Completed);
    cameraTask.Show();
}

void cameraTask_Completed(object sender, PhotoResult e)
{
    //执行拍照完成后的代码
    BitmapImage image=new BitmapImage();
    image.SetSource(e.ChosenPhoto);
    image1.Source=image;
}


8、//PhotoChooserTask 调用图片程序,选择图片,并且可以静心裁剪
PhotoChooserTask photo=new PhotoChooserTask();
public MultipleMediaTask()//构造函数
{
    InitializeComponent();
    photoCompleted += new EventHandler<PhotoResult>(photo_Completed);
}

void photo_Completed(object sender, PhotoResult e)
{
    BitmapImage image=new BitmapImage();
    image.SetSource(e.ChosenPhoto);
    image1.Source=image;
}

9、//SaveEmailAddressTask 调用联系人程序,并将设置的Email Address保存到选定的联系人或新建联系人
private void EmailSaveBtn_Click(object sender, RoutedEventArgs e)
{
    SaveEmailAddressTask emailsave = new SaveEmailAddressTask();
    emailsave.Email = "888888888888@qq.com"; emailsave.Completed += new EventHandler<TaskEventArgs>(emailsave_Completed);
    emailsave.Show();
}
void emailsave_Completed(object sender, TaskEventArgs e)
{
    //处理保存完毕后执行代码
}

10、//EmailAddressChooserTask 打开联系人程序,选取联系人Email Address</p>
private void EmailChooser_Click(object sender, RoutedEventArgs e)
{
    EmailAddressChooserTask emailchooser = new EmailAddressChooserTask();
    emailchooser.Completed += new EventHandler&lt;EmailResult&gt;(emailchooser_Completed);
    emailchooser.Show();
}

void emailchooser_Completed(object sender, EmailResult e)
{
    this.PageTitle.Text = e.Email;
}








 

Windows Phone 7 中常用Task