FrmNetworkInfo: Network information on realtime.
This commit is contained in:
283
VAR.Toolbox/UI/FrmNetworkInfo.Designer.cs
generated
Normal file
283
VAR.Toolbox/UI/FrmNetworkInfo.Designer.cs
generated
Normal file
@@ -0,0 +1,283 @@
|
|||||||
|
namespace VAR.Toolbox.UI
|
||||||
|
{
|
||||||
|
partial class FrmNetworkInfo
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
this.ddlNetworkInterfaces = new System.Windows.Forms.ComboBox();
|
||||||
|
this.lblID = new System.Windows.Forms.Label();
|
||||||
|
this.txtID = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblName = new System.Windows.Forms.Label();
|
||||||
|
this.txtName = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtStatus = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtSpeed = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtDescription = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtInterface = new System.Windows.Forms.TextBox();
|
||||||
|
this.txtMAC = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblStatus = new System.Windows.Forms.Label();
|
||||||
|
this.lblSpeed = new System.Windows.Forms.Label();
|
||||||
|
this.lblDescription = new System.Windows.Forms.Label();
|
||||||
|
this.lblInterface = new System.Windows.Forms.Label();
|
||||||
|
this.lblMAC = new System.Windows.Forms.Label();
|
||||||
|
this.txtIPs = new System.Windows.Forms.TextBox();
|
||||||
|
this.lblIPs = new System.Windows.Forms.Label();
|
||||||
|
this.timRefresh = new System.Windows.Forms.Timer(this.components);
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// ddlNetworkInterfaces
|
||||||
|
//
|
||||||
|
this.ddlNetworkInterfaces.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.ddlNetworkInterfaces.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
|
this.ddlNetworkInterfaces.FormattingEnabled = true;
|
||||||
|
this.ddlNetworkInterfaces.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.ddlNetworkInterfaces.Name = "ddlNetworkInterfaces";
|
||||||
|
this.ddlNetworkInterfaces.Size = new System.Drawing.Size(510, 21);
|
||||||
|
this.ddlNetworkInterfaces.TabIndex = 0;
|
||||||
|
this.ddlNetworkInterfaces.SelectedIndexChanged += new System.EventHandler(this.ddlNetworkInterfaces_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// lblID
|
||||||
|
//
|
||||||
|
this.lblID.AutoSize = true;
|
||||||
|
this.lblID.Location = new System.Drawing.Point(12, 41);
|
||||||
|
this.lblID.Name = "lblID";
|
||||||
|
this.lblID.Size = new System.Drawing.Size(18, 13);
|
||||||
|
this.lblID.TabIndex = 2;
|
||||||
|
this.lblID.Text = "ID";
|
||||||
|
//
|
||||||
|
// txtID
|
||||||
|
//
|
||||||
|
this.txtID.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.txtID.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.txtID.Location = new System.Drawing.Point(98, 39);
|
||||||
|
this.txtID.Name = "txtID";
|
||||||
|
this.txtID.ReadOnly = true;
|
||||||
|
this.txtID.Size = new System.Drawing.Size(424, 20);
|
||||||
|
this.txtID.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// lblName
|
||||||
|
//
|
||||||
|
this.lblName.AutoSize = true;
|
||||||
|
this.lblName.Location = new System.Drawing.Point(12, 69);
|
||||||
|
this.lblName.Name = "lblName";
|
||||||
|
this.lblName.Size = new System.Drawing.Size(35, 13);
|
||||||
|
this.lblName.TabIndex = 4;
|
||||||
|
this.lblName.Text = "Name";
|
||||||
|
//
|
||||||
|
// txtName
|
||||||
|
//
|
||||||
|
this.txtName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.txtName.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.txtName.Location = new System.Drawing.Point(98, 66);
|
||||||
|
this.txtName.Name = "txtName";
|
||||||
|
this.txtName.ReadOnly = true;
|
||||||
|
this.txtName.Size = new System.Drawing.Size(424, 20);
|
||||||
|
this.txtName.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// txtStatus
|
||||||
|
//
|
||||||
|
this.txtStatus.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.txtStatus.Font = new System.Drawing.Font("Consolas", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.txtStatus.Location = new System.Drawing.Point(98, 93);
|
||||||
|
this.txtStatus.Name = "txtStatus";
|
||||||
|
this.txtStatus.ReadOnly = true;
|
||||||
|
this.txtStatus.Size = new System.Drawing.Size(424, 26);
|
||||||
|
this.txtStatus.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// txtSpeed
|
||||||
|
//
|
||||||
|
this.txtSpeed.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.txtSpeed.Font = new System.Drawing.Font("Consolas", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.txtSpeed.Location = new System.Drawing.Point(98, 125);
|
||||||
|
this.txtSpeed.Name = "txtSpeed";
|
||||||
|
this.txtSpeed.ReadOnly = true;
|
||||||
|
this.txtSpeed.Size = new System.Drawing.Size(424, 32);
|
||||||
|
this.txtSpeed.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// txtDescription
|
||||||
|
//
|
||||||
|
this.txtDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.txtDescription.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.txtDescription.Location = new System.Drawing.Point(98, 163);
|
||||||
|
this.txtDescription.Name = "txtDescription";
|
||||||
|
this.txtDescription.ReadOnly = true;
|
||||||
|
this.txtDescription.Size = new System.Drawing.Size(424, 20);
|
||||||
|
this.txtDescription.TabIndex = 8;
|
||||||
|
//
|
||||||
|
// txtInterface
|
||||||
|
//
|
||||||
|
this.txtInterface.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.txtInterface.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.txtInterface.Location = new System.Drawing.Point(98, 189);
|
||||||
|
this.txtInterface.Name = "txtInterface";
|
||||||
|
this.txtInterface.ReadOnly = true;
|
||||||
|
this.txtInterface.Size = new System.Drawing.Size(424, 20);
|
||||||
|
this.txtInterface.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// txtMAC
|
||||||
|
//
|
||||||
|
this.txtMAC.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.txtMAC.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.txtMAC.Location = new System.Drawing.Point(98, 215);
|
||||||
|
this.txtMAC.Name = "txtMAC";
|
||||||
|
this.txtMAC.ReadOnly = true;
|
||||||
|
this.txtMAC.Size = new System.Drawing.Size(424, 20);
|
||||||
|
this.txtMAC.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// lblStatus
|
||||||
|
//
|
||||||
|
this.lblStatus.AutoSize = true;
|
||||||
|
this.lblStatus.Location = new System.Drawing.Point(12, 100);
|
||||||
|
this.lblStatus.Name = "lblStatus";
|
||||||
|
this.lblStatus.Size = new System.Drawing.Size(37, 13);
|
||||||
|
this.lblStatus.TabIndex = 11;
|
||||||
|
this.lblStatus.Text = "Status";
|
||||||
|
//
|
||||||
|
// lblSpeed
|
||||||
|
//
|
||||||
|
this.lblSpeed.AutoSize = true;
|
||||||
|
this.lblSpeed.Location = new System.Drawing.Point(12, 136);
|
||||||
|
this.lblSpeed.Name = "lblSpeed";
|
||||||
|
this.lblSpeed.Size = new System.Drawing.Size(38, 13);
|
||||||
|
this.lblSpeed.TabIndex = 12;
|
||||||
|
this.lblSpeed.Text = "Speed";
|
||||||
|
//
|
||||||
|
// lblDescription
|
||||||
|
//
|
||||||
|
this.lblDescription.AutoSize = true;
|
||||||
|
this.lblDescription.Location = new System.Drawing.Point(12, 165);
|
||||||
|
this.lblDescription.Name = "lblDescription";
|
||||||
|
this.lblDescription.Size = new System.Drawing.Size(60, 13);
|
||||||
|
this.lblDescription.TabIndex = 13;
|
||||||
|
this.lblDescription.Text = "Description";
|
||||||
|
//
|
||||||
|
// lblInterface
|
||||||
|
//
|
||||||
|
this.lblInterface.AutoSize = true;
|
||||||
|
this.lblInterface.Location = new System.Drawing.Point(12, 191);
|
||||||
|
this.lblInterface.Name = "lblInterface";
|
||||||
|
this.lblInterface.Size = new System.Drawing.Size(49, 13);
|
||||||
|
this.lblInterface.TabIndex = 14;
|
||||||
|
this.lblInterface.Text = "Interface";
|
||||||
|
//
|
||||||
|
// lblMAC
|
||||||
|
//
|
||||||
|
this.lblMAC.AutoSize = true;
|
||||||
|
this.lblMAC.Location = new System.Drawing.Point(12, 217);
|
||||||
|
this.lblMAC.Name = "lblMAC";
|
||||||
|
this.lblMAC.Size = new System.Drawing.Size(30, 13);
|
||||||
|
this.lblMAC.TabIndex = 15;
|
||||||
|
this.lblMAC.Text = "MAC";
|
||||||
|
//
|
||||||
|
// txtIPs
|
||||||
|
//
|
||||||
|
this.txtIPs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.txtIPs.Font = new System.Drawing.Font("Consolas", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.txtIPs.Location = new System.Drawing.Point(12, 260);
|
||||||
|
this.txtIPs.Multiline = true;
|
||||||
|
this.txtIPs.Name = "txtIPs";
|
||||||
|
this.txtIPs.ReadOnly = true;
|
||||||
|
this.txtIPs.Size = new System.Drawing.Size(510, 204);
|
||||||
|
this.txtIPs.TabIndex = 16;
|
||||||
|
//
|
||||||
|
// lblIPs
|
||||||
|
//
|
||||||
|
this.lblIPs.AutoSize = true;
|
||||||
|
this.lblIPs.Location = new System.Drawing.Point(12, 244);
|
||||||
|
this.lblIPs.Name = "lblIPs";
|
||||||
|
this.lblIPs.Size = new System.Drawing.Size(22, 13);
|
||||||
|
this.lblIPs.TabIndex = 17;
|
||||||
|
this.lblIPs.Text = "IPs";
|
||||||
|
//
|
||||||
|
// timRefresh
|
||||||
|
//
|
||||||
|
this.timRefresh.Interval = 500;
|
||||||
|
this.timRefresh.Tick += new System.EventHandler(this.timRefresh_Tick);
|
||||||
|
//
|
||||||
|
// FrmNetworkInfo
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(534, 476);
|
||||||
|
this.Controls.Add(this.lblIPs);
|
||||||
|
this.Controls.Add(this.txtIPs);
|
||||||
|
this.Controls.Add(this.lblMAC);
|
||||||
|
this.Controls.Add(this.lblInterface);
|
||||||
|
this.Controls.Add(this.lblDescription);
|
||||||
|
this.Controls.Add(this.lblSpeed);
|
||||||
|
this.Controls.Add(this.lblStatus);
|
||||||
|
this.Controls.Add(this.txtMAC);
|
||||||
|
this.Controls.Add(this.txtInterface);
|
||||||
|
this.Controls.Add(this.txtDescription);
|
||||||
|
this.Controls.Add(this.txtSpeed);
|
||||||
|
this.Controls.Add(this.txtStatus);
|
||||||
|
this.Controls.Add(this.txtName);
|
||||||
|
this.Controls.Add(this.lblName);
|
||||||
|
this.Controls.Add(this.txtID);
|
||||||
|
this.Controls.Add(this.lblID);
|
||||||
|
this.Controls.Add(this.ddlNetworkInterfaces);
|
||||||
|
this.Name = "FrmNetworkInfo";
|
||||||
|
this.Text = "NetworkInfo";
|
||||||
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmNetworkInfo_FormClosing);
|
||||||
|
this.Load += new System.EventHandler(this.FrmNetworkInfo_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.ComboBox ddlNetworkInterfaces;
|
||||||
|
private System.Windows.Forms.Label lblID;
|
||||||
|
private System.Windows.Forms.TextBox txtID;
|
||||||
|
private System.Windows.Forms.Label lblName;
|
||||||
|
private System.Windows.Forms.TextBox txtName;
|
||||||
|
private System.Windows.Forms.TextBox txtStatus;
|
||||||
|
private System.Windows.Forms.TextBox txtSpeed;
|
||||||
|
private System.Windows.Forms.TextBox txtDescription;
|
||||||
|
private System.Windows.Forms.TextBox txtInterface;
|
||||||
|
private System.Windows.Forms.TextBox txtMAC;
|
||||||
|
private System.Windows.Forms.Label lblStatus;
|
||||||
|
private System.Windows.Forms.Label lblSpeed;
|
||||||
|
private System.Windows.Forms.Label lblDescription;
|
||||||
|
private System.Windows.Forms.Label lblInterface;
|
||||||
|
private System.Windows.Forms.Label lblMAC;
|
||||||
|
private System.Windows.Forms.TextBox txtIPs;
|
||||||
|
private System.Windows.Forms.Label lblIPs;
|
||||||
|
private System.Windows.Forms.Timer timRefresh;
|
||||||
|
}
|
||||||
|
}
|
||||||
169
VAR.Toolbox/UI/FrmNetworkInfo.cs
Normal file
169
VAR.Toolbox/UI/FrmNetworkInfo.cs
Normal file
@@ -0,0 +1,169 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace VAR.Toolbox.UI
|
||||||
|
{
|
||||||
|
public partial class FrmNetworkInfo : Form
|
||||||
|
{
|
||||||
|
public FrmNetworkInfo()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
RefreshInterfaces();
|
||||||
|
ddlNetworkInterfaces.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FrmNetworkInfo_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
timRefresh.Enabled = true;
|
||||||
|
timRefresh.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FrmNetworkInfo_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
timRefresh.Enabled = false;
|
||||||
|
timRefresh.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ddlNetworkInterfaces_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ListItem listItem = ddlNetworkInterfaces.SelectedItem as ListItem;
|
||||||
|
if (listItem == null) { return; }
|
||||||
|
RefreshInterface(listItem.ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void timRefresh_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
RefreshInterfaces();
|
||||||
|
RefreshInterface();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshInterfaces()
|
||||||
|
{
|
||||||
|
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
foreach (ListItem it in ddlNetworkInterfaces.Items)
|
||||||
|
{
|
||||||
|
if (it.ID == nic.Id)
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
if (it.Text != nic.Description) { it.Text = nic.Description; }
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found == false)
|
||||||
|
{
|
||||||
|
ddlNetworkInterfaces.Items.Add(new ListItem { ID = nic.Id, Text = nic.Description });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _networkInterfaceId = null;
|
||||||
|
|
||||||
|
private void RefreshInterface()
|
||||||
|
{
|
||||||
|
RefreshInterface(_networkInterfaceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshInterface(string id)
|
||||||
|
{
|
||||||
|
_networkInterfaceId = id;
|
||||||
|
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
|
||||||
|
{
|
||||||
|
if (nic.Id == id)
|
||||||
|
{
|
||||||
|
RefreshInterface(nic);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshInterface(NetworkInterface nic)
|
||||||
|
{
|
||||||
|
if (txtID.Text != nic.Id) { txtID.Text = nic.Id; }
|
||||||
|
if (txtName.Text != nic.Name) { txtName.Text = nic.Name; }
|
||||||
|
string status = nic.OperationalStatus.ToString();
|
||||||
|
if (txtStatus.Text != status) { txtStatus.Text = status; }
|
||||||
|
string speed = FormatNetworkSpeedUnits(nic.Speed);
|
||||||
|
if (txtSpeed.Text != speed) { txtSpeed.Text = speed; }
|
||||||
|
if (txtDescription.Text != nic.Description) { txtDescription.Text = nic.Description; }
|
||||||
|
string strInterface = nic.NetworkInterfaceType.ToString();
|
||||||
|
if (txtInterface.Text != strInterface) { txtInterface.Text = strInterface; }
|
||||||
|
string strMac = FormatPhysicalAddress(nic.GetPhysicalAddress().GetAddressBytes());
|
||||||
|
if (txtMAC.Text != strMac) { txtMAC.Text = strMac; }
|
||||||
|
StringBuilder sbIPs = new StringBuilder();
|
||||||
|
IPInterfaceProperties ipInterfaceProperties = nic.GetIPProperties();
|
||||||
|
sbIPs.AppendLine("****** IPs *****");
|
||||||
|
foreach (UnicastIPAddressInformation uniAddress in ipInterfaceProperties.UnicastAddresses)
|
||||||
|
{
|
||||||
|
sbIPs.AppendLine(uniAddress.Address.ToString());
|
||||||
|
}
|
||||||
|
sbIPs.AppendLine();
|
||||||
|
sbIPs.AppendLine("****** Gateways *****");
|
||||||
|
foreach (GatewayIPAddressInformation gwAddress in ipInterfaceProperties.GatewayAddresses)
|
||||||
|
{
|
||||||
|
sbIPs.AppendLine(gwAddress.Address.ToString());
|
||||||
|
}
|
||||||
|
sbIPs.AppendLine();
|
||||||
|
sbIPs.AppendLine("****** DNSs *****");
|
||||||
|
foreach (IPAddress dnsAddress in ipInterfaceProperties.DnsAddresses)
|
||||||
|
{
|
||||||
|
sbIPs.AppendLine(dnsAddress.ToString());
|
||||||
|
}
|
||||||
|
string strIPs = sbIPs.ToString();
|
||||||
|
if (txtIPs.Text != strIPs) { txtIPs.Text = strIPs; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static string FormatNetworkSpeedUnits(long speed)
|
||||||
|
{
|
||||||
|
decimal dSpeed;
|
||||||
|
if (speed < 1000)
|
||||||
|
{
|
||||||
|
return string.Format("{0}bps", speed);
|
||||||
|
}
|
||||||
|
dSpeed = speed / (decimal)1000;
|
||||||
|
if (dSpeed < 1000)
|
||||||
|
{
|
||||||
|
return string.Format("{0}kbps", Math.Round(dSpeed, 2));
|
||||||
|
}
|
||||||
|
dSpeed = dSpeed / 1000;
|
||||||
|
if (dSpeed < 1000)
|
||||||
|
{
|
||||||
|
return string.Format("{0}mbps", Math.Round(dSpeed, 2));
|
||||||
|
}
|
||||||
|
dSpeed = dSpeed / 1000;
|
||||||
|
if (dSpeed < 1000)
|
||||||
|
{
|
||||||
|
return string.Format("{0}gbps", Math.Round(dSpeed, 2));
|
||||||
|
}
|
||||||
|
dSpeed = dSpeed / 1000;
|
||||||
|
return string.Format("{0}tbps", Math.Round(dSpeed, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string FormatPhysicalAddress(byte[] address)
|
||||||
|
{
|
||||||
|
StringBuilder sbAddres = new StringBuilder();
|
||||||
|
foreach (byte b in address)
|
||||||
|
{
|
||||||
|
if (sbAddres.Length > 0) { sbAddres.Append(":"); }
|
||||||
|
sbAddres.AppendFormat("{0:X2}", b);
|
||||||
|
}
|
||||||
|
return sbAddres.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ListItem
|
||||||
|
{
|
||||||
|
public string Text { get; set; }
|
||||||
|
public string ID { get; set; }
|
||||||
|
|
||||||
|
public override string ToString() { return Text; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
14
VAR.Toolbox/UI/FrmToolbox.Designer.cs
generated
14
VAR.Toolbox/UI/FrmToolbox.Designer.cs
generated
@@ -39,6 +39,7 @@
|
|||||||
this.btnTestWebService = new System.Windows.Forms.Button();
|
this.btnTestWebService = new System.Windows.Forms.Button();
|
||||||
this.btnScreenshooter = new System.Windows.Forms.Button();
|
this.btnScreenshooter = new System.Windows.Forms.Button();
|
||||||
this.btnIPScan = new System.Windows.Forms.Button();
|
this.btnIPScan = new System.Windows.Forms.Button();
|
||||||
|
this.btnNetworkInfo = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// btnCoder
|
// btnCoder
|
||||||
@@ -158,11 +159,23 @@
|
|||||||
this.btnIPScan.UseVisualStyleBackColor = true;
|
this.btnIPScan.UseVisualStyleBackColor = true;
|
||||||
this.btnIPScan.Click += new System.EventHandler(this.btnIPScan_Click);
|
this.btnIPScan.Click += new System.EventHandler(this.btnIPScan_Click);
|
||||||
//
|
//
|
||||||
|
// btnNetworkInfo
|
||||||
|
//
|
||||||
|
this.btnNetworkInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.btnNetworkInfo.Location = new System.Drawing.Point(180, 92);
|
||||||
|
this.btnNetworkInfo.Name = "btnNetworkInfo";
|
||||||
|
this.btnNetworkInfo.Size = new System.Drawing.Size(165, 34);
|
||||||
|
this.btnNetworkInfo.TabIndex = 12;
|
||||||
|
this.btnNetworkInfo.Text = "NetworkInfo";
|
||||||
|
this.btnNetworkInfo.UseVisualStyleBackColor = true;
|
||||||
|
this.btnNetworkInfo.MouseClick += new System.Windows.Forms.MouseEventHandler(this.btnNetworkInfo_MouseClick);
|
||||||
|
//
|
||||||
// FrmToolbox
|
// FrmToolbox
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(352, 400);
|
this.ClientSize = new System.Drawing.Size(352, 400);
|
||||||
|
this.Controls.Add(this.btnNetworkInfo);
|
||||||
this.Controls.Add(this.btnIPScan);
|
this.Controls.Add(this.btnIPScan);
|
||||||
this.Controls.Add(this.btnScreenshooter);
|
this.Controls.Add(this.btnScreenshooter);
|
||||||
this.Controls.Add(this.btnTestWebService);
|
this.Controls.Add(this.btnTestWebService);
|
||||||
@@ -198,6 +211,7 @@
|
|||||||
private System.Windows.Forms.Button btnTestWebService;
|
private System.Windows.Forms.Button btnTestWebService;
|
||||||
private System.Windows.Forms.Button btnScreenshooter;
|
private System.Windows.Forms.Button btnScreenshooter;
|
||||||
private System.Windows.Forms.Button btnIPScan;
|
private System.Windows.Forms.Button btnIPScan;
|
||||||
|
private System.Windows.Forms.Button btnNetworkInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,11 @@ namespace VAR.Toolbox.UI
|
|||||||
CreateWindow(typeof(FrmIPScan));
|
CreateWindow(typeof(FrmIPScan));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnNetworkInfo_MouseClick(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
CreateWindow(typeof(FrmNetworkInfo));
|
||||||
|
}
|
||||||
|
|
||||||
#endregion UI events
|
#endregion UI events
|
||||||
|
|
||||||
#region Window handling
|
#region Window handling
|
||||||
|
|||||||
@@ -119,6 +119,12 @@
|
|||||||
<Compile Include="UI\FrmIPScan.Designer.cs">
|
<Compile Include="UI\FrmIPScan.Designer.cs">
|
||||||
<DependentUpon>FrmIPScan.cs</DependentUpon>
|
<DependentUpon>FrmIPScan.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="UI\FrmNetworkInfo.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="UI\FrmNetworkInfo.Designer.cs">
|
||||||
|
<DependentUpon>FrmNetworkInfo.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="UI\FrmProxyCmd.cs">
|
<Compile Include="UI\FrmProxyCmd.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
Reference in New Issue
Block a user