zoukankan      html  css  js  c++  java
  • wp7分析IP知道你的位置

        <!--LayoutRoot 是包含所有页面内容的根网格-->
        <Grid x:Name="LayoutRoot" Background="#666">
            <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" FontSize="35" Text="我的应用程序" Style="{StaticResource PhoneTextNormalStyle}"/>
                <TextBlock  Foreground="Black" x:Name="PageTitle" Text="Ip 地址分析器" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
            </StackPanel>


            <!--ContentPanel - 在此处放置其他内容-->
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="auto"/>
                    </Grid.ColumnDefinitions>


                    <TextBlock FontSize="35" Grid.Column="0" VerticalAlignment="Center" Text="IP地址:"/>
                    <TextBox Name="txtIP" Grid.Column="1"/>
                    <Button Grid.Column="2" Click="onQuery">
                        <Button.Content>
                            <Path Data="M0,10 L20,10 M5,0 L20,10 M5,20 L20,10"
                                  VerticalAlignment="Stretch"
                                  HorizontalAlignment="Stretch"
                                  Stroke="White" StrokeThickness="3"/>
                        </Button.Content>
                    </Button>
                </Grid>
                <StackPanel Grid.Row="1">
                    <TextBlock  Foreground="Black" Name="txbTip"/>
                    <TextBlock  Foreground="Black"  TextWrapping="Wrap" Name="txbResult" Margin="2,12,2,0" FontSize="32"  Height="140" Width="449" />
                    <TextBlock Foreground="Black" Height="373" FontSize="40" Name="textBlock1" Text="IP地址分析器,如果在同一网络的IP会直接提示与您在同一网络中,如果不是,则显示该IP的实际地址" TextWrapping="Wrap" />
                </StackPanel>
            </Grid>

        </Grid>

     

    后台代码:

            private void onQuery(object sender, RoutedEventArgs e)
            {
                txbResult.Text = "";
                // 第一步,实例化客户端代理类
                IPQueryWebService.IpAddressSearchWebServiceSoapClient MyClient = new IPQueryWebService.IpAddressSearchWebServiceSoapClient();
                // 第二步,绑定回调事件
                MyClient.getCountryCityByIpCompleted += (s, arg) =>
                {
                    // 取得结果
                    txbTip.Text = "请求完成。";
                    if (arg.Error != null)
                    {
                        txtIP.Text = string.Format("错误:{0}", arg.Error.Message);
                        return;
                    }
                    string[] res = arg.Result;
                    if (res != null)
                    {
                        if (res.Length > 1)
                        {
                            txbResult.Text = string.Format("结果查询:{0}", res[1]);
                        }
                    }
                };
                // 第三步,调用异步方法
                txbTip.Text = "正在请求,请等候……";
                MyClient.getCountryCityByIpAsync(txtIP.Text);
            }

    记得添加服务引用

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

  • 相关阅读:
    jquery 序列化form表单
    nginx for windows 安装
    nodejs idea 创建项目 (一)
    spring 配置 shiro rememberMe
    idea 2018 解决 双击shift 弹出 search everywhere 搜索框的方法
    redis 在windows 集群
    spring IOC控制反转和DI依赖注入
    redis 的安装
    shiro 通过jdbc连接数据库
    handlebars的用法
  • 原文地址:https://www.cnblogs.com/qiqiBoKe/p/3130478.html
Copyright © 2011-2022 走看看