WP7手机号码归属地源码Demo

首先上个图片看效果

18 分钟前 上传
下载附件 (29.97 KB)
 



其实很简单  添加一个WebServices服务

前台给页面布局
  1. <phone:PhoneApplicationPage
  2.     x:Class="PhoneNumber.MainPage"
  3.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5.     xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
  6.     xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
  7.     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  8.     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  9.     mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
  10.     FontFamily="{StaticResource PhoneFontFamilyNormal}"
  11.     FontSize="{StaticResource PhoneFontSizeNormal}"
  12.     Foreground="{StaticResource PhoneForegroundBrush}"
  13.     SupportedOrientations="Portrait" Orientation="Portrait"
  14.     shell:SystemTray.IsVisible="True">
  15.     <!--LayoutRoot 是包含所有页面内容的根网格-->
  16.     <Grid x:Name="LayoutRoot" Background="Transparent">
  17.         <Grid.RowDefinitions>
  18.             <RowDefinition Height="Auto"/>
  19.             <RowDefinition Height="*"/>
  20.         </Grid.RowDefinitions>
  21.         <!--TitlePanel 包含应用程序的名称和页标题-->
  22.         <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
  23.             <TextBlock x:Name="ApplicationTitle" Text="手机查询http://dev.ruanman.net" Style="{StaticResource PhoneTextNormalStyle}"/>
  24.             <TextBlock x:Name="PageTitle" Text="软曼手机查询" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
  25.         </StackPanel>
  26.         <!--ContentPanel - 在此处放置其他内容-->
  27.         <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
  28.             <TextBlock Height="49" HorizontalAlignment="Left" Margin="12,66,0,0" Name="des" Text="请输入你需要查询的手机号码" VerticalAlignment="Top" Width="284" />
  29.             <TextBox Height="72" HorizontalAlignment="Left" Margin="6,106,0,0" Name="No" Text="" VerticalAlignment="Top" Width="415" />
  30.             <Button Content="查询" Height="72" HorizontalAlignment="Left" Margin="12,184,0,0" Name="search" VerticalAlignment="Top" Width="140" Click="search_Click" />
  31.             <TextBlock Height="211" HorizontalAlignment="Left" Margin="6,277,0,0" Name="information" Text="" VerticalAlignment="Top" Width="444" />
  32.             <TextBlock Height="auto"  TextAlignment="Center" HorizontalAlignment="Center" Margin="6,510,0,0" Name="hugwp" Text="dev.ruanman.net" VerticalAlignment="Top" Width="444" />
  33.             <Button Content="拨打" Height="72" HorizontalAlignment="Left" Margin="158,184,0,0" Name="button1" VerticalAlignment="Top" Width="120" Click="button1_Click" />
  34.             <Button Content="保存" Height="72" HorizontalAlignment="Left" Margin="284,184,0,0" Name="button2" VerticalAlignment="Top" Width="126" Click="button2_Click" />
  35.         </Grid>
  36.     </Grid>
  37.     <!--演示 ApplicationBar 用法的示例代码-->
  38.     <!--<phone:PhoneApplicationPage.ApplicationBar>
  39.         <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
  40.             <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="按钮 1"/>
  41.             <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="按钮 2"/>
  42.             <shell:ApplicationBar.MenuItems>
  43.                 <shell:ApplicationBarMenuItem Text="菜单项 1"/>
  44.                 <shell:ApplicationBarMenuItem Text="菜单项 2"/>
  45.             </shell:ApplicationBar.MenuItems>
  46.         </shell:ApplicationBar>
  47.     </phone:PhoneApplicationPage.ApplicationBar>-->
  48. </phone:PhoneApplicationPage>
后台实现方式
        private void search_Click(object sender, RoutedEventArgs e)
  1.         {
  2.             //实例化一个web service代理的对象
  3.             MobileReference.MobileCodeWSSoapClient proxy = new MobileReference.MobileCodeWSSoapClient();
  4.             //getMobileCodeInfo方法调用结束之后 触发的事件
  5.             proxy.getMobileCodeInfoCompleted += new EventHandler<MobileReference.getMobileCodeInfoCompletedEventArgs>(proxy_getMobileCodeInfoCompleted);
  6.             //将调用信息包括方法名和参数加入到soap消息中通过http传送给web service服务端  
  7.             //这里对应的是调用了web service的getMobileCodeInfo方法
  8.             proxy.getMobileCodeInfoAsync(No.Text, "");
  9.         }
  10.         void proxy_getMobileCodeInfoCompleted(object sender, MobileReference.getMobileCodeInfoCompletedEventArgs e)
  11.         {
  12.               if (e.Error == null)  
  13.               {  
  14.                   string msg = e.Result;  
  15.                   try  
  16.                   {
  17.                       information.Text = msg.Substring(12);  
  18.      
  19.                   }
  20.                   catch (Exception)  
  21.                   {  
  22.      
  23.                       MessageBox.Show("网络出现问题,或者是手机号码错误");  
  24.                   }
  25.               }  
  26.               else  
  27.               {  
  28.                   MessageBox.Show("网络出现问题,或者是手机号码错误");  
  29.               }  
  30.       }
  31.         private void button1_Click(object sender, RoutedEventArgs e)
  32.         {
  33.             if (null != No.Text)
  34.             {
  35.                 PhoneCallTask task = new PhoneCallTask();
  36.                 task.DisplayName = "hugwp";
  37.                 task.PhoneNumber = No.Text;
  38.                 task.Show();
  39.             }
  40.         }
  41.         private void button2_Click(object sender, RoutedEventArgs e)
  42.         {
  43.             if (null != No.Text)
  44.             {
  45.                 SavePhoneNumberTask task = new SavePhoneNumberTask();
  46.                 task.PhoneNumber = No.Text;
  47.                 task.Show();
  48.             }
  49.         }

源码下载地址:http://dev.ruanman.net/thread-41-1-1.html

我们地主页:http://www.ruanman.net 我们地论坛:http://bbs.ruanman.net

转载于:https://my.oschina.net/AQ8RINEso/blog/62444

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值