wp7 手机归属地查询

ps:之前一直看卤面网,看博客园里强人关于wp7开发介绍等也快大半个月了,不得不说实践是检验真理的唯一标准,还得自己动手做,这个是我做的第一个wp7小程序:手机归属地查询。不废话,先上图:

wp7 手机归属地查询

wp7 手机归属地查询

此应用拥有3个功能,查询手机归属地、拨号、保存号码。应用很简单,感觉wp7美工很重要,可惜我就会点ps。

查询功能:

这里查询所用的服务端为webxml提供的webservice。

http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx

添加webservice

wp7 手机归属地查询

后台代码:

 private void btnseach_Click(object sender, RoutedEventArgs e)
        {
            progressBar1.Maximum = 0;
            progressBar1.IsIndeterminate = true;
            progressBar1.Visibility = Visibility.Visible;
            JudgeInfo();
            progressBar1.Maximum = 10000;

            for (int i = 1; i <= 10000; i++)
            {
                progressBar1.Value++;
            }
        }

这里用了一个progressbar来显示查询过程。

 public void JudgeInfo()
        {
            string phoneNumber = txtphone.Text;
            if (string.IsNullOrEmpty(phoneNumber))
            {
                MessageBox.Show("请 输 入 您 的 电 话 号 码!");
                txtphone.Text = "";
                progressBar1.Visibility = Visibility.Collapsed;
                progressBar1.IsIndeterminate = false;
                return;
            }
            else if (phoneNumber.Length < 11)
            {
                MessageBox.Show("您 输 入 的 手 机 号 码 不 合 规 范,请 重 新 输 入 !");
                txtphone.Focus();
                txtphone.Text = "";
                return;
            }
            //信息合法则直接显示
            GetPhoneNumberInfo();
        }

   public void GetPhoneNumberInfo()
        {
            try
            {
                MobilePhone.MobileCodeWSSoapClient mobilPhone = new MobilePhone.MobileCodeWSSoapClient();
                mobilPhone.getMobileCodeInfoCompleted += new EventHandler<MobilePhone.getMobileCodeInfoCompletedEventArgs>(mobilPhone_getMobileCodeInfoCompleted);
                mobilPhone.getMobileCodeInfoAsync(txtphone.Text, "");
            }
            catch
            {
                MessageBox.Show("请 确 保 您 的 网 络 畅 通");
            }
        }

打电话代码:

 private void btncall_Click(object sender, RoutedEventArgs e)
        {
            PhoneCallTask task = new PhoneCallTask();
            task.DisplayName = "号码";
            task.PhoneNumber = txtphone.Text;
            task.Show(); 
        }

保存电话代码

 private void btnsave_Click(object sender, RoutedEventArgs e)
        {
            SavePhoneNumberTask task = new SavePhoneNumberTask();
            task.PhoneNumber = txtphone.Text;
            task.Show(); 
        }

代码下载链接:http://download.csdn.net/detail/huangyuancao/4281908

参考博客http://www.cnblogs.com/wildfeng/archive/2012/03/21/2409174.html

你可能感兴趣的:(wp7)