• 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

  • 相关阅读:
    Firefly官方教程之DBentrust使用文档
    《烽烟OL》简介
    《暗黑世界》简介
    CrossApp简介
    内联元素于与块元素的转换 相对定位、绝对定位以及fixed定位 Z轴覆盖
    div介绍 盒子模型边框属性 CSS初始化 文字排版 边框调整 溢出
    CSS样式补充第二天
    CSS样式
    form表单以及内嵌框架标签
    html对a标签的运用以及属性,img图像标签的属性及应用
  • 原文地址:https://www.cnblogs.com/qiqiBoKe/p/3130478.html
Copyright © 2020-2023  润新知