当前访客身份:游客 [ 登录 | 加入 OSCHINA ]

代码分享

当前位置:
代码分享 » WPF/SliverLight  » 手机App开发
迟浩东

WP7手机号码归属地源码Demo

迟浩东 发布于 2012年06月15日 11时, 1评/404阅
分享到: 
收藏 +0
1

代码片段(4) [全屏查看所有代码]

1. [代码][WPF/SliverLight]代码     跳至 [1] [2] [4] [全屏预览]

<phone:PhoneApplicationPage 
    x:Class="PhoneNumber.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot 是包含所有页面内容的根网格-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel 包含应用程序的名称和页标题-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="手机查询http://dev.ruanman.net" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="软曼手机查询" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - 在此处放置其他内容-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <TextBlock Height="49" HorizontalAlignment="Left" Margin="12,66,0,0" Name="des" Text="请输入你需要查询的手机号码" VerticalAlignment="Top" Width="284" />
            <TextBox Height="72" HorizontalAlignment="Left" Margin="6,106,0,0" Name="No" Text="" VerticalAlignment="Top" Width="415" />
            <Button Content="查询" Height="72" HorizontalAlignment="Left" Margin="12,184,0,0" Name="search" VerticalAlignment="Top" Width="140" Click="search_Click" />
            <TextBlock Height="211" HorizontalAlignment="Left" Margin="6,277,0,0" Name="information" Text="" VerticalAlignment="Top" Width="444" />
            <TextBlock Height="auto"  TextAlignment="Center" HorizontalAlignment="Center" Margin="6,510,0,0" Name="hugwp" Text="dev.ruanman.net" VerticalAlignment="Top" Width="444" />
            <Button Content="拨打" Height="72" HorizontalAlignment="Left" Margin="158,184,0,0" Name="button1" VerticalAlignment="Top" Width="120" Click="button1_Click" />
            <Button Content="保存" Height="72" HorizontalAlignment="Left" Margin="284,184,0,0" Name="button2" VerticalAlignment="Top" Width="126" Click="button2_Click" />
        </Grid>
    </Grid>

    <!--演示 ApplicationBar 用法的示例代码-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="按钮 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="按钮 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="菜单项 1"/>
                <shell:ApplicationBarMenuItem Text="菜单项 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>

2. [代码][WPF/SliverLight]代码     跳至 [1] [2] [4] [全屏预览]

        private void search_Click(object sender, RoutedEventArgs e)
        {

            //实例化一个web service代理的对象

            MobileReference.MobileCodeWSSoapClient proxy = new MobileReference.MobileCodeWSSoapClient();

            //getMobileCodeInfo方法调用结束之后 触发的事件

            proxy.getMobileCodeInfoCompleted += new EventHandler<MobileReference.getMobileCodeInfoCompletedEventArgs>(proxy_getMobileCodeInfoCompleted);

            //将调用信息包括方法名和参数加入到soap消息中通过http传送给web service服务端  

            //这里对应的是调用了web service的getMobileCodeInfo方法

            proxy.getMobileCodeInfoAsync(No.Text, "");

        }

        void proxy_getMobileCodeInfoCompleted(object sender, MobileReference.getMobileCodeInfoCompletedEventArgs e)
        {

              if (e.Error == null)  
              {  
                  string msg = e.Result;  
                  try  
                  {
                      information.Text = msg.Substring(12);  
     
                  } 
                  catch (Exception)  
                  {  
     
                      MessageBox.Show("网络出现问题,或者是手机号码错误");  
                  } 
              }  
              else  
              {  
                  MessageBox.Show("网络出现问题,或者是手机号码错误");  
              }  
      }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (null != No.Text)
            {
                PhoneCallTask task = new PhoneCallTask();
                task.DisplayName = "hugwp";
                task.PhoneNumber = No.Text;
                task.Show();
            }
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (null != No.Text)
            {
                SavePhoneNumberTask task = new SavePhoneNumberTask();
                task.PhoneNumber = No.Text;
                task.Show();
            } 
        }

3. [图片] 20120615111335.jpg    

4. [代码][WPF/SliverLight]代码     跳至 [1] [2] [4] [全屏预览]

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


开源中国-程序员在线工具:Git代码托管 API文档大全(120+) JS在线编辑演示 二维码 更多»

发表评论 回到顶部 网友评论(1)

开源从代码分享开始 分享代码
迟浩东的其它代码 全部(2)...