wp7之手机号码归属地查询
初学wp7开发,也在园子里看了好多大牛关于wp7的文章,让我受益匪浅.但是学习不能只靠阅读,重要的是自己动手.
个人觉得移动开发是个趋势,我们要把握住时机.(纯属个人观点,元芳,你怎么看?)。
本人没有美术功底,界面肯定是丑了一点,希望大家不要嫌弃.如图:
功能主要包括:查询本地号码、查询输入的号码、拨打号码、保存号码。
一下是各个功能的代码实现:
1、选择本地号码查询
/// <summary>/// 选择本地号码/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnChoose_Click(object sender, RoutedEventArgs e){ PhoneNumberChooserTask task = new PhoneNumberChooserTask(); task.Completed += (_s, _e) => { if (_e.Error == null) txtNumber.Text = _e.PhoneNumber; }; task.Show();}
2、查询归属地
/// <summary>/// 查询归属地/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnSearch_Click(object sender, RoutedEventArgs e){ if (!CheckNumber()) { MessageBox.Show("您输入的号码有误."); return; } ServiceNumber.MobileCodeWSSoapClient client = new ServiceNumber.MobileCodeWSSoapClient(); client.getMobileCodeInfoAsync(txtNumber.Text.Trim(), ""); client.getMobileCodeInfoCompleted += (_s, _e) => { try { if (_e.Error == null) this.txtMsg.Text = _e.Result.ToString().Substring(12); } catch { MessageBox.Show("网络出现错误或系统出现异常!"); } };}
3、拨打号码
/// <summary>/// 拨打电话/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnCall_Click(object sender, RoutedEventArgs e){ if (!CheckNumber()) { MessageBox.Show("您输入的手机号码有误."); return; } PhoneCallTask task = new PhoneCallTask() { PhoneNumber = this.txtNumber.Text }; task.Show();}
4、保存号码
/// <summary>/// 号码保存/// </summary>/// <param name="sender"></param>/// <param name="e"></param>private void btnSave_Click(object sender, RoutedEventArgs e){ if (!CheckNumber()) { MessageBox.Show("您输入的手机号码有误."); return; } SavePhoneNumberTask task = new SavePhoneNumberTask() { PhoneNumber = this.txtNumber.Text }; task.Completed += (_s, _e) => { if (_e.Error == null) MessageBox.Show("保存成功!"); else MessageBox.Show("保存失败!"); }; task.Show();}
功能很简单
参考博客:http://www.cnblogs.com/wildfeng/archive/2012/03/21/2409174.html
webservice地址:
源码下载:源码
界面有点丑,大家多多包涵!!
TAG: