Click here to Skip to main content
15,886,422 members
Articles / Programming Languages / C#

Website Investigator

Rate me:
Please Sign up or sign in to vote.
4.36/5 (27 votes)
5 Aug 2009CPOL5 min read 47.4K   1.1K   50  
Gets website registration information
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Net.NetworkInformation;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace QIP_Country_Match
{

    public class Form1 : Form
    {
        
        #region Designer Code

        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.txtIP = new System.Windows.Forms.TextBox();
            this.lbl_CountryName = new System.Windows.Forms.Label();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
            this.restoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.panel1 = new System.Windows.Forms.Panel();
            this.pb_Minimize = new System.Windows.Forms.PictureBox();
            this.lblLastUpdate = new System.Windows.Forms.Label();
            this.tmrSearch = new System.Windows.Forms.Timer(this.components);
            this.progressBar1 = new System.Windows.Forms.ProgressBar();
            this.label3 = new System.Windows.Forms.Label();
            this.txtWebsite = new System.Windows.Forms.TextBox();
            this.label4 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
            this.databaseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.basicToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.advancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.websiteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
            this.aboutToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.label12 = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            this.lstIPs = new System.Windows.Forms.ListBox();
            this.lstAliases = new System.Windows.Forms.ListBox();
            this.btn_Match = new System.Windows.Forms.Button();
            this.pbox_Map = new System.Windows.Forms.PictureBox();
            this.label13 = new System.Windows.Forms.Label();
            this.lblRegion = new System.Windows.Forms.Label();
            this.lblSubRegion = new System.Windows.Forms.Label();
            this.lblAssignmentDate = new System.Windows.Forms.Label();
            this.lblCountryCode = new System.Windows.Forms.Label();
            this.grpAdvanced = new System.Windows.Forms.GroupBox();
            this.contextMenuStrip1.SuspendLayout();
            this.panel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pb_Minimize)).BeginInit();
            this.menuStrip1.SuspendLayout();
            this.groupBox1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pbox_Map)).BeginInit();
            this.grpAdvanced.SuspendLayout();
            this.SuspendLayout();
            // 
            // txtIP
            // 
            this.txtIP.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtIP.ForeColor = System.Drawing.Color.SteelBlue;
            this.txtIP.Location = new System.Drawing.Point(9, 74);
            this.txtIP.MaxLength = 15;
            this.txtIP.Name = "txtIP";
            this.txtIP.Size = new System.Drawing.Size(180, 22);
            this.txtIP.TabIndex = 0;
            this.txtIP.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.txtIP.TextChanged += new System.EventHandler(this.txtIP_TextChanged);
            this.txtIP.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtIP_KeyDown);
            this.txtIP.MouseHover += new System.EventHandler(this.txtIP_MouseHover);
            // 
            // lbl_CountryName
            // 
            this.lbl_CountryName.AutoSize = true;
            this.lbl_CountryName.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lbl_CountryName.ForeColor = System.Drawing.Color.SteelBlue;
            this.lbl_CountryName.Location = new System.Drawing.Point(56, 106);
            this.lbl_CountryName.Name = "lbl_CountryName";
            this.lbl_CountryName.Size = new System.Drawing.Size(28, 13);
            this.lbl_CountryName.TabIndex = 2;
            this.lbl_CountryName.Text = "N/A";
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(9, 59);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(63, 13);
            this.label1.TabIndex = 3;
            this.label1.Text = "IP Address:";
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(9, 106);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(50, 13);
            this.label2.TabIndex = 4;
            this.label2.Text = "Country:";
            // 
            // notifyIcon1
            // 
            this.notifyIcon1.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info;
            this.notifyIcon1.BalloonTipText = "You may show the main screen any time by double clicking this icon";
            this.notifyIcon1.BalloonTipTitle = "QSoft - Website Investigator ";
            this.notifyIcon1.ContextMenuStrip = this.contextMenuStrip1;
            this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
            this.notifyIcon1.Text = "QSoft - Website Investigator ";
            this.notifyIcon1.Visible = true;
            this.notifyIcon1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDoubleClick);
            // 
            // contextMenuStrip1
            // 
            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.restoreToolStripMenuItem,
            this.aboutToolStripMenuItem,
            this.exitToolStripMenuItem});
            this.contextMenuStrip1.Name = "contextMenuStrip1";
            this.contextMenuStrip1.Size = new System.Drawing.Size(110, 70);
            // 
            // restoreToolStripMenuItem
            // 
            this.restoreToolStripMenuItem.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.restoreToolStripMenuItem.Name = "restoreToolStripMenuItem";
            this.restoreToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
            this.restoreToolStripMenuItem.Text = "&Show";
            this.restoreToolStripMenuItem.Click += new System.EventHandler(this.restoreToolStripMenuItem_Click);
            // 
            // aboutToolStripMenuItem
            // 
            this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
            this.aboutToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
            this.aboutToolStripMenuItem.Text = "&About";
            this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
            // 
            // exitToolStripMenuItem
            // 
            this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
            this.exitToolStripMenuItem.Size = new System.Drawing.Size(109, 22);
            this.exitToolStripMenuItem.Text = "E&xit";
            this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
            // 
            // panel1
            // 
            this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.panel1.Controls.Add(this.pb_Minimize);
            this.panel1.Controls.Add(this.lblLastUpdate);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.panel1.Location = new System.Drawing.Point(0, 273);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(665, 23);
            this.panel1.TabIndex = 8;
            // 
            // pb_Minimize
            // 
            this.pb_Minimize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.pb_Minimize.Image = global::QIP_Country_Match.Properties.Resources.DowndArrow;
            this.pb_Minimize.Location = new System.Drawing.Point(634, 3);
            this.pb_Minimize.Name = "pb_Minimize";
            this.pb_Minimize.Size = new System.Drawing.Size(16, 16);
            this.pb_Minimize.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
            this.pb_Minimize.TabIndex = 5;
            this.pb_Minimize.TabStop = false;
            this.pb_Minimize.MouseLeave += new System.EventHandler(this.pb_Minimize_MouseLeave);
            this.pb_Minimize.Click += new System.EventHandler(this.pb_Minimize_Click);
            this.pb_Minimize.MouseEnter += new System.EventHandler(this.pb_Minimize_MouseEnter);
            // 
            // lblLastUpdate
            // 
            this.lblLastUpdate.AutoSize = true;
            this.lblLastUpdate.Location = new System.Drawing.Point(1, 3);
            this.lblLastUpdate.Name = "lblLastUpdate";
            this.lblLastUpdate.Size = new System.Drawing.Size(170, 13);
            this.lblLastUpdate.TabIndex = 15;
            this.lblLastUpdate.Text = "Database last update: 3 Jan 2008";
            // 
            // tmrSearch
            // 
            this.tmrSearch.Interval = 10;
            this.tmrSearch.Tick += new System.EventHandler(this.tmrSearch_Tick);
            // 
            // progressBar1
            // 
            this.progressBar1.Location = new System.Drawing.Point(9, 133);
            this.progressBar1.Name = "progressBar1";
            this.progressBar1.Size = new System.Drawing.Size(295, 11);
            this.progressBar1.TabIndex = 9;
            this.progressBar1.Visible = false;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(9, 19);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(50, 13);
            this.label3.TabIndex = 11;
            this.label3.Text = "Website:";
            // 
            // txtWebsite
            // 
            this.txtWebsite.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtWebsite.ForeColor = System.Drawing.Color.SteelBlue;
            this.txtWebsite.Location = new System.Drawing.Point(9, 34);
            this.txtWebsite.Name = "txtWebsite";
            this.txtWebsite.Size = new System.Drawing.Size(295, 22);
            this.txtWebsite.TabIndex = 10;
            this.txtWebsite.Text = "www.qsoft-online.com";
            this.txtWebsite.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.txtWebsite.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtWebsite_KeyDown);
            this.txtWebsite.Enter += new System.EventHandler(this.txtWebsite_Enter);
            this.txtWebsite.MouseHover += new System.EventHandler(this.txtWebsite_MouseHover);
            this.txtWebsite.MouseEnter += new System.EventHandler(this.txtWebsite_MouseEnter);
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label4.Location = new System.Drawing.Point(9, 201);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(42, 11);
            this.label4.TabIndex = 14;
            this.label4.Text = "Region:";
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label5.Location = new System.Drawing.Point(134, 200);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(68, 11);
            this.label5.TabIndex = 14;
            this.label5.Text = "Sub - region:";
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label6.Location = new System.Drawing.Point(134, 213);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(91, 11);
            this.label6.TabIndex = 14;
            this.label6.Text = "Assignment date:";
            // 
            // menuStrip1
            // 
            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.databaseToolStripMenuItem,
            this.viewToolStripMenuItem,
            this.helpToolStripMenuItem});
            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new System.Drawing.Size(665, 24);
            this.menuStrip1.TabIndex = 17;
            this.menuStrip1.Text = "menuStrip1";
            // 
            // databaseToolStripMenuItem
            // 
            this.databaseToolStripMenuItem.Name = "databaseToolStripMenuItem";
            this.databaseToolStripMenuItem.Size = new System.Drawing.Size(118, 20);
            this.databaseToolStripMenuItem.Text = "Update Database...";
            this.databaseToolStripMenuItem.Click += new System.EventHandler(this.databaseToolStripMenuItem_Click);
            // 
            // viewToolStripMenuItem
            // 
            this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.basicToolStripMenuItem,
            this.advancedToolStripMenuItem});
            this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
            this.viewToolStripMenuItem.Size = new System.Drawing.Size(45, 20);
            this.viewToolStripMenuItem.Text = "View";
            // 
            // basicToolStripMenuItem
            // 
            this.basicToolStripMenuItem.CheckOnClick = true;
            this.basicToolStripMenuItem.Name = "basicToolStripMenuItem";
            this.basicToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.basicToolStripMenuItem.Text = "&Basic";
            this.basicToolStripMenuItem.Click += new System.EventHandler(this.basicToolStripMenuItem_Click);
            // 
            // advancedToolStripMenuItem
            // 
            this.advancedToolStripMenuItem.Checked = true;
            this.advancedToolStripMenuItem.CheckOnClick = true;
            this.advancedToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
            this.advancedToolStripMenuItem.Name = "advancedToolStripMenuItem";
            this.advancedToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
            this.advancedToolStripMenuItem.Text = "&Details";
            this.advancedToolStripMenuItem.Click += new System.EventHandler(this.advancedToolStripMenuItem_Click);
            // 
            // helpToolStripMenuItem
            // 
            this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.websiteToolStripMenuItem,
            this.aboutToolStripMenuItem1});
            this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
            this.helpToolStripMenuItem.Size = new System.Drawing.Size(45, 20);
            this.helpToolStripMenuItem.Text = "Help";
            // 
            // websiteToolStripMenuItem
            // 
            this.websiteToolStripMenuItem.Name = "websiteToolStripMenuItem";
            this.websiteToolStripMenuItem.Size = new System.Drawing.Size(118, 22);
            this.websiteToolStripMenuItem.Text = "Website";
            this.websiteToolStripMenuItem.Click += new System.EventHandler(this.websiteToolStripMenuItem_Click);
            // 
            // aboutToolStripMenuItem1
            // 
            this.aboutToolStripMenuItem1.Name = "aboutToolStripMenuItem1";
            this.aboutToolStripMenuItem1.Size = new System.Drawing.Size(118, 22);
            this.aboutToolStripMenuItem1.Text = "About";
            this.aboutToolStripMenuItem1.Click += new System.EventHandler(this.aboutToolStripMenuItem1_Click);
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.label12);
            this.groupBox1.Controls.Add(this.label11);
            this.groupBox1.Controls.Add(this.lstIPs);
            this.groupBox1.Controls.Add(this.lstAliases);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.btn_Match);
            this.groupBox1.Controls.Add(this.lbl_CountryName);
            this.groupBox1.Controls.Add(this.label3);
            this.groupBox1.Controls.Add(this.txtIP);
            this.groupBox1.Controls.Add(this.progressBar1);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Controls.Add(this.txtWebsite);
            this.groupBox1.Location = new System.Drawing.Point(7, 33);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(318, 232);
            this.groupBox1.TabIndex = 18;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Search";
            // 
            // label12
            // 
            this.label12.AutoSize = true;
            this.label12.Location = new System.Drawing.Point(6, 150);
            this.label12.Name = "label12";
            this.label12.Size = new System.Drawing.Size(44, 13);
            this.label12.TabIndex = 21;
            this.label12.Text = "Aliases:";
            // 
            // label11
            // 
            this.label11.AutoSize = true;
            this.label11.Location = new System.Drawing.Point(192, 150);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(74, 13);
            this.label11.TabIndex = 21;
            this.label11.Text = "IP Addresses:";
            // 
            // lstIPs
            // 
            this.lstIPs.FormattingEnabled = true;
            this.lstIPs.Location = new System.Drawing.Point(195, 165);
            this.lstIPs.Name = "lstIPs";
            this.lstIPs.ScrollAlwaysVisible = true;
            this.lstIPs.Size = new System.Drawing.Size(109, 56);
            this.lstIPs.TabIndex = 20;
            // 
            // lstAliases
            // 
            this.lstAliases.FormattingEnabled = true;
            this.lstAliases.Location = new System.Drawing.Point(9, 165);
            this.lstAliases.Name = "lstAliases";
            this.lstAliases.ScrollAlwaysVisible = true;
            this.lstAliases.Size = new System.Drawing.Size(180, 56);
            this.lstAliases.TabIndex = 20;
            // 
            // btn_Match
            // 
            this.btn_Match.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
            this.btn_Match.Image = global::QIP_Country_Match.Properties.Resources.Search1;
            this.btn_Match.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.btn_Match.Location = new System.Drawing.Point(195, 71);
            this.btn_Match.Name = "btn_Match";
            this.btn_Match.Size = new System.Drawing.Size(109, 29);
            this.btn_Match.TabIndex = 1;
            this.btn_Match.Text = "Investigate";
            this.btn_Match.UseVisualStyleBackColor = true;
            this.btn_Match.Click += new System.EventHandler(this.btn_Match_Click);
            // 
            // pbox_Map
            // 
            this.pbox_Map.Image = global::QIP_Country_Match.Properties.Resources.all_countries;
            this.pbox_Map.Location = new System.Drawing.Point(11, 19);
            this.pbox_Map.Name = "pbox_Map";
            this.pbox_Map.Size = new System.Drawing.Size(300, 176);
            this.pbox_Map.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
            this.pbox_Map.TabIndex = 13;
            this.pbox_Map.TabStop = false;
            // 
            // label13
            // 
            this.label13.AutoSize = true;
            this.label13.Font = new System.Drawing.Font("Tahoma", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label13.Location = new System.Drawing.Point(9, 213);
            this.label13.Name = "label13";
            this.label13.Size = new System.Drawing.Size(74, 11);
            this.label13.TabIndex = 14;
            this.label13.Text = "Country code:";
            // 
            // lblRegion
            // 
            this.lblRegion.AutoSize = true;
            this.lblRegion.Font = new System.Drawing.Font("Tahoma", 7F);
            this.lblRegion.Location = new System.Drawing.Point(50, 200);
            this.lblRegion.Name = "lblRegion";
            this.lblRegion.Size = new System.Drawing.Size(23, 12);
            this.lblRegion.TabIndex = 21;
            this.lblRegion.Text = "N/A";
            // 
            // lblSubRegion
            // 
            this.lblSubRegion.AutoSize = true;
            this.lblSubRegion.Font = new System.Drawing.Font("Tahoma", 7F);
            this.lblSubRegion.Location = new System.Drawing.Point(200, 199);
            this.lblSubRegion.Name = "lblSubRegion";
            this.lblSubRegion.Size = new System.Drawing.Size(23, 12);
            this.lblSubRegion.TabIndex = 21;
            this.lblSubRegion.Text = "N/A";
            // 
            // lblAssignmentDate
            // 
            this.lblAssignmentDate.AutoSize = true;
            this.lblAssignmentDate.Font = new System.Drawing.Font("Tahoma", 7F);
            this.lblAssignmentDate.Location = new System.Drawing.Point(224, 212);
            this.lblAssignmentDate.Name = "lblAssignmentDate";
            this.lblAssignmentDate.Size = new System.Drawing.Size(23, 12);
            this.lblAssignmentDate.TabIndex = 21;
            this.lblAssignmentDate.Text = "N/A";
            // 
            // lblCountryCode
            // 
            this.lblCountryCode.AutoSize = true;
            this.lblCountryCode.Font = new System.Drawing.Font("Tahoma", 7F);
            this.lblCountryCode.Location = new System.Drawing.Point(83, 212);
            this.lblCountryCode.Name = "lblCountryCode";
            this.lblCountryCode.Size = new System.Drawing.Size(23, 12);
            this.lblCountryCode.TabIndex = 21;
            this.lblCountryCode.Text = "N/A";
            // 
            // grpAdvanced
            // 
            this.grpAdvanced.Controls.Add(this.pbox_Map);
            this.grpAdvanced.Controls.Add(this.label13);
            this.grpAdvanced.Controls.Add(this.lblAssignmentDate);
            this.grpAdvanced.Controls.Add(this.label4);
            this.grpAdvanced.Controls.Add(this.lblSubRegion);
            this.grpAdvanced.Controls.Add(this.label5);
            this.grpAdvanced.Controls.Add(this.lblCountryCode);
            this.grpAdvanced.Controls.Add(this.label6);
            this.grpAdvanced.Controls.Add(this.lblRegion);
            this.grpAdvanced.Location = new System.Drawing.Point(338, 33);
            this.grpAdvanced.Name = "grpAdvanced";
            this.grpAdvanced.Size = new System.Drawing.Size(320, 232);
            this.grpAdvanced.TabIndex = 22;
            this.grpAdvanced.TabStop = false;
            this.grpAdvanced.Text = "Details";
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
            this.ClientSize = new System.Drawing.Size(665, 296);
            this.Controls.Add(this.grpAdvanced);
            this.Controls.Add(this.groupBox1);
            this.Controls.Add(this.menuStrip1);
            this.Controls.Add(this.panel1);
            this.DoubleBuffered = true;
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.MainMenuStrip = this.menuStrip1;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.Name = "Form1";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "QSoft - Website Investigator ";
            this.Load += new System.EventHandler(this.Form1_Load);
            this.Activated += new System.EventHandler(this.Form1_Activated);
            this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
            this.contextMenuStrip1.ResumeLayout(false);
            this.panel1.ResumeLayout(false);
            this.panel1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pb_Minimize)).EndInit();
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.pbox_Map)).EndInit();
            this.grpAdvanced.ResumeLayout(false);
            this.grpAdvanced.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button btn_Match;
        private System.Windows.Forms.TextBox txtIP;
        private System.Windows.Forms.Label lbl_CountryName;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.NotifyIcon notifyIcon1;
        private System.Windows.Forms.PictureBox pb_Minimize;
        private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.ToolStripMenuItem restoreToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
        private System.Windows.Forms.Timer tmrSearch;
        private System.Windows.Forms.ProgressBar progressBar1;
        private Label label3;
        private TextBox txtWebsite;
        private PictureBox pbox_Map;
        private Label label4;
        private Label label5;
        private Label label6;
        private Label lblLastUpdate;
        private MenuStrip menuStrip1;
        private ToolStripMenuItem databaseToolStripMenuItem;
        private ToolStripMenuItem viewToolStripMenuItem;
        private ToolStripMenuItem basicToolStripMenuItem;
        private ToolStripMenuItem advancedToolStripMenuItem;
        private ToolStripMenuItem helpToolStripMenuItem;
        private ToolStripMenuItem websiteToolStripMenuItem;
        private ToolStripMenuItem aboutToolStripMenuItem1;
        private GroupBox groupBox1;
        private Label label11;
        private ListBox lstAliases;
        private Label label12;
        private ListBox lstIPs;
        private Label label13;
        DataTable dt;
        StreamReader sr;
        string[] tokens;
        private Label lblRegion;
        private Label lblSubRegion;
        private Label lblAssignmentDate;
        private Label lblCountryCode;
        string strDatabasePath;
        #endregion
        private GroupBox grpAdvanced;

        string[] arSubs;
        int ScreenH, ScreenW;
        public Form1()
        {
            InitializeComponent();
            //Control.CheckForIllegalCrossThreadCalls = false;
            ScreenH = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
            ScreenW = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;            

            String.Format("[0-9]", txtIP.Text);

            arSubs = @"AFGHANISTAN,South-central Asia,ALBANIA,Southern Europe,ALGERIA,Northern Africa,AMERICAN SAMOA,Polynesia,ANDORRA,Southern Europe,ANGOLA,Middle Africa,ANGUILLA,Caribbean,ANTARCTICA,Antarctic,ANTIGUA & BARBUDA,Caribbean,ARGENTINA,South America,ARMENIA,Western Asia,ARUBA,Caribbean,AUSTRALIA,Australia and New Zealand,AUSTRIA,Western Europe,AZERBAIJAN,Western,BAHAMAS,Caribbean,BAHRAIN,Western Asia,BANGLADESH,South-central Asia,BARBADOS,Caribbean,BELARUS,Eastern Europe,BELGIUM,Western Europe,BELIZE,Central America,BENIN,Western Africa,BERMUDA,Northern America,BHUTAN,South-central Asia,BOLIVIA,South America,BOSNIA & HERZEGOWINA,Southern Europe,BOTSWANA,Southern Africa,BOUVET ISLAND,Antarctic,BRAZIL,South America,BRITISH INDIAN OCEAN TERRITORY,South-central Asia,BRUNEI DARUSSALAM,South-eastern Asia,BULGARIA,Eastern Europe,BURKINA FASO,Western Africa,BURUNDI,Eastern Africa,CAMBODIA,South-eastern Asia,CAMEROON,Middle Africa,CANADA,Northern America,CAPE VERDE,Western Africa,CAYMAN ISLANDS,Caribbean,CENTRAL AFRICAN REPUBLIC,Middle Africa,CHAD,Middle Africa,CHILE,South America,CHINA,Eastern Asia,CHRISTMAS ISLAND,South-eastern Asia,COCOS (KEELING) ISLANDS,South-eastern Asia,COLOMBIA,South America,COMOROS,Eastern Africa,CONGO,Middle Africa,CONGO,DEMOCRATIC REPUBLIC OF THE,Middle Africa,COOK ISLANDS,Polynesia,COSTA RICA,Central America,COTE D'IVOIRE,Western Africa,CROATIA (Hrvatska),Southern Europe,CUBA,Caribbean,CYPRUS,Western Asia,CZECH REPUBLIC,Eastern Europe,DENMARK,Northern Europe,DJIBOUTI,Eastern Africa,DOMINICA,Caribbean,DOMINICAN REPUBLIC,Caribbean,EAST TIMOR,South-eastern Asia,ECUADOR,South America,EGYPT,Northern Africa,EL SALVADOR,Central America,EQUATORIAL GUINEA,Middle Africa,ERITREA,Eastern Africa,ESTONIA,Northern Europe,ETHIOPIA,Eastern Africa,FALKLAND ISLANDS (MALVINAS),South America,FAROE ISLANDS,Northern Europe,FIJI,Melanesia,FINLAND,Northern Europe,FRANCE,Western Europe,FRENCH GUIANA,South America,FRENCH POLYNESIA,Polynesia,FRENCH SOUTHERN TERRITORIES,Antarctic,GABON,Middle Africa,GAMBIA,Western Africa,GEORGIA,Western Asia,GERMANY,Western Europe,GHANA,Western Africa,GIBRALTAR,Southern Europe,GREECE,Southern Europe,GREENLAND,Northern America,GRENADA,Caribbean,GUADELOUPE,Caribbean,GUAM,Micronesia,GUATEMALA,Central America,GUINEA,Western Africa,GUINEA-BISSAU,Western Africa,GUYANA,South America,HAITI,Caribbean,HEARD & MC DONALD ISLANDS,Antarctic,HOLY SEE (VATICAN CITY STATE),Southern Europe,HONDURAS,Central America,HONG KONG,Eastern Asia,HUNGARY,Eastern Europe,ICELAND,Northern Europe,INDIA,South-central Asia,INDONESIA,South-eastern Asia,IRAN (ISLAMIC REPUBLIC OF),South-central Asia,IRAQ,Western Asia,IRELAND,Northern Europe,ISRAEL,Western Asia,ITALY,Southern Europe,JAMAICA,Caribbean,JAPAN,Eastern Asia,JORDAN,Western Asia,KAZAKHSTAN,South-central Asia,KENYA,Eastern Africa,KIRIBATI,Micronesia,KOREA,DEMOCRATIC PEOPLE'S REPUBLIC OF,Eastern Asia,KOREA,REPUBLIC OF,Eastern Asia,KUWAIT,Western Asia,KYRGYZSTAN,South-central Asia,LAO PEOPLE'S DEMOCRATIC REPUBLIC,South-eastern Asia,LATVIA,Northern Europe,LEBANON,Western Asia,LESOTHO,Southern Africa,LIBERIA,Western Africa,LIBYAN ARAB JAMAHIRIYA,Northern Africa,LIECHTENSTEIN,Western Europe,LITHUANIA,Northern Europe,LUXEMBOURG,Western Europe,MACAU,Eastern Asia,MACEDONIA,THE FORMER YUGOSLAV REPUBLIC OF,Southern Europe,MADAGASCAR,Eastern Africa,MALAWI,Eastern Africa,MALAYSIA,South-eastern Asia,MALDIVES,South-central Asia,MALI,Western Africa,MALTA,Southern Europe,MARSHALL ISLANDS,Micronesia,MARTINIQUE,Caribbean,MAURITANIA,Western Africa,MAURITIUS,Eastern Africa,MAYOTTE,Southern Africa,MEXICO,Central America,MICRONESIA,FEDERATED STATES OF,Micronesia,MOLDOVA,REPUBLIC OF,Eastern Europe,MONACO,Western Europe,MONGOLIA,Eastern Asia,MONTENEGRO,Southern Europe,MONTSERRAT,Caribbean,MOROCCO,Northern Africa,MOZAMBIQUE,Eastern Africa,MYANMAR,South-eastern Asia,NAMIBIA,Southern Africa,NAURU,Micronesia,NEPAL,South-central Asia,NETHERLANDS,Western Europe,NETHERLANDS ANTILLES,Caribbean,NEW CALEDONIA,Australia and New Zealand,NEW ZEALAND,Australia and New Zealand,NICARAGUA,Central America,NIGER,Western Africa,NIGERIA,Western Africa,NIUE,Polynesia,NORFOLK ISLAND,Australia and New Zealand,NORTHERN MARIANA ISLANDS,Micronesia,NORWAY,Northern Europe,OMAN,Western Asia,PAKISTAN,South-central Asia,PALAU,Micronesia,PANAMA,Central America,PALESTINIAN TERRITORY,Western Asia,PAPUA NEW GUINEA,Australia and New Zealand,PARAGUAY,South America,PERU,South America,PHILIPPINES,South-eastern Asia,PITCAIRN,Polynesia,POLAND,Eastern Europe,PORTUGAL,Southern Europe,PUERTO RICO,Caribbean,QATAR,Western Asia,REUNION,Eastern Africa,ROMANIA,Eastern Europe,RUSSIAN FEDERATION,Eastern Europe,RWANDA,Eastern Africa,SAINT KITTS & NEVIS,Caribbean,SAINT LUCIA,Caribbean,SAINT VINCENT & THE GRENADINES,Caribbean,SAMOA,Polynesia,SAN MARINO,Southern Europe,SAO TOME & PRINCIPE,Middle Africa,SAUDI ARABIA,Western Asia,SENEGAL,Western Africa,SERBIA,Southern Europe,SEYCHELLES,Eastern Africa,SIERRA LEONE,Western Africa,SINGAPORE,South-eastern Asia,SLOVAKIA (Slovak Republic),Eastern Europe,SLOVENIA,Southern Europe,SOLOMON ISLANDS,Melanesia,SOMALIA,Eastern Africa,SOUTH AFRICA,Southern Africa,SOUTH GEORGIA & THE SOUTH SANDWICH ISLANDS,Antarctic,SPAIN,Southern Europe,SRI LANKA,South-central Asia,ST. HELENA,Western Africa,ST. PIERRE & MIQUELON,Northern America,SUDAN,Northern Africa,SURINAME,South America,SVALBARD & JAN MAYEN ISLANDS,Northern Europe,SWAZILAND,Southern Africa,SWEDEN,Northern Europe,SWITZERLAND,Western Europe,SYRIAN ARAB REPUBLIC,Western Asia,TAIWAN,Eastern Asia,TAJIKISTAN,South-central Asia,TANZANIA,UNITED REPUBLIC OF,Eastern Africa,THAILAND,South-eastern Asia,TOGO,Western Africa,TOKELAU,Polynesia,TONGA,Polynesia,TRINIDAD & TOBAGO,Caribbean,TUNISIA,Northern Africa,TURKEY,Western Asia,TURKMENISTAN,South-central Asia,TURKS & CAICOS ISLANDS,Caribbean,TUVALU,Polynesia,UGANDA,Eastern Africa,UKRAINE,Eastern Europe,UNITED ARAB EMIRATES,Western Asia,UNITED KINGDOM,Northern Europe,UNITED STATES,Northern America,UNITED STATES MINOR OUTLYING ISLANDS,Micronesia,URUGUAY,South America,UZBEKISTAN,South-central Asia,VANUATU,Melanesia,VENEZUELA,South America,VIET NAM,South-eastern Asia,VIRGIN ISLANDS (BRITISH),Caribbean,VIRGIN ISLANDS (U.S.),Caribbean,WALLIS & FUTUNA ISLANDS,Polynesia,WESTERN SAHARA,Northern Africa,YEMEN,Western Asia,ZAMBIA,Eastern Africa,ZIMBABWE,Eastern Africa".Split(',');

            
            strDatabasePath = Environment.GetEnvironmentVariable("TEMP") + "\\IpToCountry.csv";


        }

        private void LoadDatabase()
        {
            if (!File.Exists(strDatabasePath))
            {
                DialogResult DR = MessageBox.Show("No database found, you must update now,\nDo you want to proceed and update your database now?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (DR == DialogResult.Yes)
                {
                    this.Enabled = false;
                    this.Show();
                    try
                    {
                        _frmUpdateDatabase.Show();
                        _frmUpdateDatabase.BringToFront();
                        _frmUpdateDatabase.Activate();
                    }
                    catch (Exception)
                    {
                        _frmUpdateDatabase = new frmUpdateDatabase();
                        _frmUpdateDatabase.Show();
                        _frmUpdateDatabase.BringToFront();
                        _frmUpdateDatabase.Activate();
                    }
                }
                else
                    Application.Exit();
            }
            else
            {
            OpenFile:
                try
                {
                    sr = new StreamReader(strDatabasePath);
                }
                catch (IOException)
                {
                    DialogResult dr = MessageBox.Show("File in use!","Error",MessageBoxButtons.AbortRetryIgnore,MessageBoxIcon.Error);
                    if (dr == DialogResult.Retry)
                        goto OpenFile;
                    else
                        Application.Exit();

                }
                dt = new DataTable("IP_TO_COUNTRY");

                dt.Columns.Add("IP_From", typeof(string));
                dt.Columns.Add("IP_To", typeof(string));
                dt.Columns.Add("Region", typeof(string));
                dt.Columns.Add("Assignment_Date", typeof(string));
                dt.Columns.Add("Two_Letter_Code", typeof(string));
                dt.Columns.Add("Three_Letter_Code", typeof(string));
                dt.Columns.Add("Country_Name", typeof(string));

                while (!sr.EndOfStream)
                {
                    try
                    {
                        tokens = sr.ReadLine().Split(',');

                        #region Update last update lable
                        if (tokens.Length > 0)
                            if (tokens[0].ToString().StartsWith(@"# File Time Stamp   : "))
                                lblLastUpdate.Text = "Database Last update: "+tokens[0].Replace(@"# File Time Stamp   : ", "");
                        #endregion

                        if (tokens.Length == 7)
                            dt.Rows.Add(tokens);
                    }
                    catch (Exception ex) { MessageBox.Show(ex.Message); }
                }
                sr.Close();
            }
        }

        private double Convert_IP(string _dottedIP)
        {
            try
            {
                double convertedIP = 0;
                string[] temp = _dottedIP.Split('.');
                int ipFactor = 3;

                foreach (string ip_part in temp)
                    convertedIP += (Convert.ToDouble(ip_part)) * (Math.Pow(256, ipFactor--));
                return convertedIP;
            }
            catch (Exception)
            {
                return -1;
            }
        }

        private DataRow GetIPInfo(double ip)
        {
            /*
            foreach (DataRow dr in dt.Rows)
            {
                if ((ip > (double)dr[0]) && (ip < (double)dr[1]))
                    return dr;
            }            

               //dr = dt.Select("'"+ip.ToString() + "' > IP_FROM AND " + ip + " < IP_TO")[0];
            */
            DataRow[] dr = dt.Select("IP_From = 0");
            return dr[0];
        }

        private void load_Region_Map(string strRegion)
        {
            switch (strRegion)
            {
                case "ARIN":
                    pbox_Map.Image = QIP_Country_Match.Properties.Resources.arin_countries;
                    break;
                case "APNIC":
                    pbox_Map.Image = QIP_Country_Match.Properties.Resources.apnic_countries;
                    break;
                case "AFRINIC":
                    pbox_Map.Image = QIP_Country_Match.Properties.Resources.afrinic_countries;
                    break;
                case "LACNIC":
                    pbox_Map.Image = QIP_Country_Match.Properties.Resources.lacnic_countries;
                    break;
                case "RIPE":
                    pbox_Map.Image = QIP_Country_Match.Properties.Resources.ripe_countries;
                    break;
            }
        }


        private string GetSubRegion(string strCountry)
        {
            int xx = 0;
            for (int x = 0; x < arSubs.Length; x++)
            {
                if (arSubs[x].ToLower() == strCountry.ToLower())
                    xx = x;
            }
            return arSubs[xx + 1];
        }

        private void load_info(double _ip)
        {
            try
            {
                double d_IP_From, d_IP_To;
                foreach (DataRow dr in dt.Rows)
                {
                    d_IP_From = Convert.ToDouble(dr["IP_From"].ToString().Trim().Replace("#", "").Replace(@"""", ""));
                    d_IP_To = Convert.ToDouble(dr["IP_To"].ToString().Trim().Replace("#", "").Replace(@"""", ""));

                    if ((Convert_IP(txtIP.Text) > d_IP_From) && (Convert_IP(txtIP.Text) < d_IP_To))
                    {
                        lbl_CountryName.Text = dr["Country_Name"].ToString().Trim().Replace("#", "").Replace("\"", "");
                        lblRegion.Text = dr["Region"].ToString().Trim().Replace("#", "").Replace("\"", "");

                        lblCountryCode.Text = dr["Two_Letter_Code"].ToString().Trim().Replace("#", "").Replace("\"", "") + ", " + dr["Three_Letter_Code"].ToString().Trim().Replace("#", "").Replace("\"", "");

                        lblAssignmentDate.Text = Epoch_To_Date(dr["Assignment_Date"].ToString().Trim().Replace("#", "").Replace("\"", ""));

                        lblSubRegion.Text = GetSubRegion(lbl_CountryName.Text);


                    }
                }
            }

            catch (Exception ex)
            {
                //MessageBox.Show("Please update your database!","Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }

        }

        private string GetWebsiteIP(string website)
        {
            IPHostEntry host;
            string strIP = String.Empty;
            host = Dns.GetHostEntry(website);
            return host.AddressList[0].ToString();
        }

        private void GetIPsAndAliases()
        {
            IPAddress hostIPAddress = IPAddress.Parse(txtIP.Text);
            IPHostEntry hostInfo = Dns.GetHostEntry(hostIPAddress);
            // Get the IP address list that resolves to the host names contained in 
            // the Alias property.
            IPAddress[] address = hostInfo.AddressList;
            // Get the alias names of the addresses in the IP address list.
            String[] alias = hostInfo.Aliases;

            //Aliases
            lstAliases.Items.Clear();
            lstAliases.Items.Add(hostInfo.HostName);
            for (int index = 0; index < alias.Length; index++)
                lstAliases.Items.Add(alias[index]);

            //IPs
            lstIPs.Items.Clear();
            for (int index = 0; index < address.Length; index++)
                lstIPs.Items.Add(address[index]);
        }

        private void Match()
        {
            try
            {
                if (txtWebsite.Text.Length > 0)
                    txtIP.Text = GetWebsiteIP(txtWebsite.Text);

                else
                    if (txtIP.Text.Length > 0)
                        txtWebsite.Text = Dns.GetHostEntry(txtIP.Text).HostName;

                lbl_CountryName.Text = "Processing...";
                search();


                
                    load_info(Convert_IP(txtIP.Text));

                GetIPsAndAliases();
                txtWebsite.SelectAll();

            }
            catch (Exception)
            {
                lbl_CountryName.Text = @"N/A";
                txtIP.Text = String.Empty;

                MessageBox.Show("Website not found!\nPlease make sure you are connected to the internet.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void btn_Match_Click(object sender, EventArgs e)
        {
            Match();
        }

        private void txtIP_TextChanged(object sender, EventArgs e)
        {
            
            try
            {

                if (txtIP.Text.Length == 3)
                {
                    if (Convert.ToInt32(txtIP.Text.Substring(0, 3)) > 255)
                        txtIP.Text = "255";
                    if(!txtIP.Text.EndsWith("."))
                    txtIP.Text += ".";

                    

                }
                if (txtIP.Text.Length == 7)
                {
                    if (Convert.ToInt32(txtIP.Text.Substring(4, 3)) > 255)
                        txtIP.Text = txtIP.Text.Substring(0, 4) + "255";
                    if (!txtIP.Text.EndsWith("."))
                    txtIP.Text += ".";
                }
                if (txtIP.Text.Length == 11)
                {
                    if (Convert.ToInt32(txtIP.Text.Substring(8, 3)) > 255)
                        txtIP.Text = txtIP.Text.Substring(0, 8) + "255";
                    if (!txtIP.Text.EndsWith("."))
                    txtIP.Text += ".";
                }
                string wholeIP;
                if (txtIP.Text.Length == 15)
                {
                    
                    wholeIP = String.Empty;
                                      

                    if (Convert.ToInt32(txtIP.Text.Substring(12, 3)) > 255)
                        wholeIP += txtIP.Text.Substring(0, 12) + "255";

                    if (wholeIP != String.Empty)
                    txtIP.Text = wholeIP;

                    
                }

                if (txtIP.Text.Length > 15)
                {
                    txtIP.Text = txtIP.Text.Substring(0, 15);
                }

            }
                catch (FormatException)
                { }

                txtIP.SelectionStart = txtIP.Text.Length;
                txtIP.SelectionLength = 1;

            if(txtIP.Text.Contains(".") && txtIP.Text.Length>3)
                txtIP.Text = validateIP(txtIP.Text);
            
        }

        private string validateIP(string _ip)
        {
            string[] ar_validated_ip = _ip.Split('.');
            string str_validated_ip = String.Empty;
            try
            {



                for (int x = 0; x < ar_validated_ip.Length; x++)
                {
                    if (Convert.ToInt32(ar_validated_ip[x]) > 255)
                        str_validated_ip += "255.";
                    else
                        str_validated_ip += ar_validated_ip[x].ToString()+".";
                }

                str_validated_ip = str_validated_ip.Substring(0, str_validated_ip.Length - 1);


                return str_validated_ip;
            }
            catch (FormatException)
            {
                return str_validated_ip;

            }
            
        }

        private void txtIP_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
                Match();
        }


        private void pb_Minimize_MouseEnter(object sender, EventArgs e)
        {
            //pb_Minimize.SizeMode = PictureBoxSizeMode.StretchImage;
            pb_Minimize.Top = pb_Minimize.Top + 2;
        }

        private void pb_Minimize_MouseLeave(object sender, EventArgs e)
        {
            //pb_Minimize.SizeMode = PictureBoxSizeMode.CenterImage;
            pb_Minimize.Top = pb_Minimize.Top - 2;
        }

        private void pb_Minimize_Click(object sender, EventArgs e)
        {
                try
                {
                    
                    this.WindowState = FormWindowState.Minimized;
                    
                    this.Hide();
                    this.WindowState = FormWindowState.Normal;
                    this.ShowInTaskbar = false;
                    this.notifyIcon1.ShowBalloonTip(2000);
                }
                catch (Exception)
                { }
        }

        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            try
            {
                this.Show();
                this.ShowInTaskbar = true;
            }
            catch (Exception)
            { }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                _About.Show();
                _About.Activate();
            }
            catch (Exception)
            {
                _About = new About();
                _About.Show();
                _About.Activate();
            }
        }

        private void restoreToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                
                this.Show();
                this.ShowInTaskbar = true;
            }
            catch (Exception)
            { }
        }

        int x;
        private void tmrSearch_Tick(object sender, EventArgs e)
        {
            if (x < 100)
            {
                x += 5;
                progressBar1.Value = x;
            }
            else
                kill_tmrSearch();
        }

        private void kill_tmrSearch()
        {
            tmrSearch.Stop();
            progressBar1.Value = 100;
            progressBar1.Visible = false;
            progressBar1.Value = 0;
            load_info(Convert_IP(txtIP.Text));
            load_Region_Map(lblRegion.Text);

        }

        double cip;
        private void search()
        {
                cip = Convert_IP(txtIP.Text);
                if (cip > 0)
                {
                    if (txtIP.Text.Length < 7)
                        lbl_CountryName.Text = "IP Address is too short!";
                    else
                    {
                        progressBar1.Visible = true;
                        tmrSearch.Start();
                    }
                }
                else
                    lbl_CountryName.Text = "Please enter a valid IP Address!";
            
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            notifyIcon1.Dispose();
            Application.Exit();
        }

        private void Form1_Activated(object sender, EventArgs e)
        {
            txtIP.SelectAll();
        }

        private void txtWebsite_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
                Match();
        }

        private string Epoch_To_Date(string strEpoch)
        {
            DateTime _dt = new DateTime(1970, 1, 1, 0, 0, 0);
            _dt = _dt.AddSeconds(Convert.ToDouble(strEpoch));
            return _dt.ToString("dd-MMMM-yyyy");
        }



        private string[] getCurrentConnections(TcpConnectionInformation[] _tcpInfoList)
        {
            string strActiveConnections = String.Empty;
            foreach (TcpConnectionInformation tcpInfo in _tcpInfoList)
            {
                try
                {
                    if (!tcpInfo.RemoteEndPoint.Address.ToString().Contains("127.0.0.1"))
                        strActiveConnections +=
                            "State: " + tcpInfo.State.ToString() +
                            "Host: " + Dns.GetHostEntry(tcpInfo.RemoteEndPoint.Address).Aliases[0] +
                            "IP Address: " + tcpInfo.RemoteEndPoint.Address.ToString() + ":" +
                            "Remote Port: " + tcpInfo.RemoteEndPoint.Port.ToString("d") +
                            "Local Port: " + tcpInfo.LocalEndPoint.Port.ToString() + ":" + ";";
                }
                catch (Exception) { }

            }
            if(strActiveConnections.Length > 0)
            strActiveConnections = strActiveConnections.Substring(0, strActiveConnections.Length - 1);
            return(strActiveConnections.Split(';'));
        }

        IPGlobalProperties properties;
        TcpConnectionInformation[] tcpInfoList;
        private void Form1_Load(object sender, EventArgs e)
        {
            LoadDatabase();

            txtWebsite.Select();
            txtWebsite.SelectAll();

            /*
            properties = IPGlobalProperties.GetIPGlobalProperties();
            tcpInfoList = properties.GetActiveTcpConnections();

            lstActiveConnections.Items.AddRange(getCurrentConnections(tcpInfoList));
            */
        }



        private void txtWebsite_Enter(object sender, EventArgs e)
        {
            txtWebsite.Select();
            txtWebsite.SelectAll();
        }

        private void txtWebsite_MouseEnter(object sender, EventArgs e)
        {
            txtWebsite.Select();
            txtWebsite.SelectAll();

        }

        private void txtWebsite_MouseHover(object sender, EventArgs e)
        {
            txtWebsite.Select();
            txtWebsite.SelectAll();

        }

        private void txtIP_MouseHover(object sender, EventArgs e)
        {
            txtIP.Select();
            txtIP.SelectAll();

        }

        frmUpdateDatabase _frmUpdateDatabase;
        private void databaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Are you sure you want to update your database?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.Yes)
            {
                try
                {
                    _frmUpdateDatabase.Show();
                    _frmUpdateDatabase.Activate();
                }
                catch (Exception)
                {
                    _frmUpdateDatabase = new frmUpdateDatabase();
                    _frmUpdateDatabase.Show();
                    _frmUpdateDatabase.Activate();
                }
            }
        }

        private void advancedToolStripMenuItem_Click(object sender, EventArgs e)
        {

                this.Width = 671;
                this.Height = 321;

                basicToolStripMenuItem.Checked = false;
                advancedToolStripMenuItem.Checked = true;

                this.Left = (ScreenW / 2) - (this.Width / 2);
                this.Top = (ScreenH / 2) - (this.Height / 2);

        }

        private void basicToolStripMenuItem_Click(object sender, EventArgs e)
        {
                this.Width = 340;
                this.Height = 321;

                basicToolStripMenuItem.Checked = true;
                advancedToolStripMenuItem.Checked = false;

                this.Left = (ScreenW / 2) - (this.Width / 2);
                this.Top = (ScreenH / 2) - (this.Height / 2);
                
        }

        About _About;
        private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                _About.Show();
                _About.Activate();
            }
            catch (Exception)
            {
                _About = new About();
                _About.Show();
                _About.Activate();
            }

        }

        private void websiteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start(@"http://www.qsoft-online.com/");
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Retired QSoft
Yemen Yemen
Biography?! I'm not dead yet!
www.QSoftOnline.com

Comments and Discussions