This forum is in archive mode. You will not be able to post new content.

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - h4nn1b4L

Pages: [1]
1
.NET Framework / Re: [C#] LocateIP 0.2
« on: January 30, 2016, 11:44:36 PM »
Wow great work. :) i really admire your work doddy. anyway i also made mine. simple and short code. :)

Screenshot:
 

Source Code:
Code: [Select]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Net;
using System.Text;
using System.Windows.Forms;
using System.Xml;

/* <copyright file=xfrmMaim>
   Copyright (c) 2016 All Rights Reserved
   </copyright>
   <author>h4nn1b4L</author>
   <date>1/31/2016 6:26AM</date>
   <summary>Simple and Short Ip Tracer Code on c#</summary>*/

namespace TraceIP
{
    public partial class xfrmMain : Form
    {
        private IpInfo Info = new IpInfo();
        public xfrmMain()
        {
            InitializeComponent();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            Invoke((MethodInvoker)delegate
               {
                   Parse(txtIpaddress.Text);
               });
        }
        private class IpInfo
        {
            public string CountryName { get; set; }
            public string RegionName { get; set; }
            public string City { get; set; }
            public double Latitude { get; set; }
            public double Longitude { get; set; }

        }
        private void Parse(string ip)
        {
            try
            {
                string url          = "http://freegeoip.net/xml/";
                string furl         = url + ip;

                XmlDocument doc = new XmlDocument();
                doc.Load(furl);
                XmlElement root     = doc.DocumentElement;
                XmlNode node        = root.SelectSingleNode("/Response");

                Info.CountryName    = node["CountryName"].InnerText;
                Info.RegionName     = node["RegionName"].InnerText;
                Info.City           = node["City"].InnerText;
                Info.Latitude       = Convert.ToDouble(node["Latitude"].InnerText);
                Info.Longitude      = Convert.ToDouble(node["Longitude"].InnerText);

                LoadData();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }

        private void LoadData()
        {
            txtCountry.Text         = Info.CountryName;
            txtCity.Text            = Info.City;
            txtRegion.Text          = Info.RegionName;
            txtLat.Text             = Info.Latitude.ToString();
            txtLng.Text             = Info.Longitude.ToString();
        }
    }
}

2
Thanks for this mate.

Pages: [1]


Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.