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

  • 相关阅读:
    开发移动端项目如何利用Chrome浏览器连接真机测试
    有关浏览器开发者工具使用的技巧
    有关前端实时可视化工具的使用 ==实现边改代码边看效果
    vue的生命周期介绍beforeCreate(创建前)、created(创建后)、beforeMount(载入前)、mounted(载入后)、beforeUpdate(更新前)、updated(更新后)、beforeDestroy(销毁前)、destroyed(销毁后)
    echart中重新定义引导线的文字换行<br>不起作用
    使用mock数据填写表格同时带点击查看更多
    有关前后端分离前端如何使用mock数据
    echar图柱状图和折线图混合加双侧y轴坐
    【Oracle】DBMS_STATS.GATHER_TABLE_STATS
    【PostgreSQL-9.6.3】Red Hat 4.4.7下的安装
  • 原文地址:https://www.cnblogs.com/qiqiBoKe/p/3130478.html
Copyright © 2011-2022 走看看