|
关注WP 7 好久了,也在网上看牛人写的博客很好,从他们中学到了很多的东西。记录新技术的学习过程,并帮助别人一起学习它。学习的宗旨“一起学习共同进步”;
今天写了两个常用的小工具特与大家分享。
说明:这个两个小工具都要用到第三方提供的服务。
小工具一:手机号归属地查询。
运行结果如下:
代码如下:
private void btnQuery_Click(object sender, RoutedEventArgs e)
{
client.getMobileCodeInfoCompleted += new EventHandler(client_getMobileCodeInfoCompleted);
progressBar.Visibility = System.Windows.Visibility.Visible;
if (tbPhone.Text != "")
{
client.getMobileCodeInfoAsync(tbPhone.Text, "");
}
else
{
MessageBox.Show("电话号不能为空!", "提示", MessageBoxButton.OK);
}
}
void client_getMobileCodeInfoCompleted(object sender, Mobile.getMobileCodeInfoCompletedEventArgs e)
{
if (e.Error == null)
{
tbDisplayAddress.Text = e.Result;
}
}
小工具二:邮政编码查询。
运行结果如下:
代码如下:
void btnQuery_Click(object sender, RoutedEventArgs e)
{
client.getAddressByZipCodeCompleted += new EventHandler(client_getAddressByZipCodeCompleted);
if (txtPostCode.Text == "")
{
txtAddress.Text = "没有联接数据!";
}
else
{
client.getAddressByZipCodeAsync(txtPostCode.Text, "");
}
}
void client_getAddressByZipCodeCompleted(object sender, ChinaZip.getAddressByZipCodeCompletedEventArgs e)
{
if (e.Error == null)
{
txtAddress.Text = e.Result.Nodes[0].Value.ToString();
}
}
非常简单的两个小程序,代码非常的简单。
程序只用着学习使用,不用作商业应用。
原本想上传代码的,可是SkyDrive上传有问题,以后。 |
|
|