Example #1
0
        private void RefreshProps()
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new RefreshHandler(RefreshProps));
                return;
            }

            nicName.Text        = m_nic.Name;
            nicDescription.Text = m_nic.Description;
            nicSpeed.Text       = m_nic.Speed.ToString();
            nicStatus.Text      = m_nic.OperationalStatus.ToString();
            nicMAC.Text         = m_nic.GetPhysicalAddress().ToString();
            currentIP.Text      = m_nic.CurrentIpAddress.ToString();
            currentNetMask.Text = m_nic.CurrentSubnetMask.ToString();
            IPInterfaceProperties ipprops = m_nic.GetIPProperties();

            if (ipprops.GatewayAddresses.Count > 0)
            {
                currentGateway.Text = ipprops.GatewayAddresses[0].Address.ToString();
            }
            else
            {
                currentGateway.Text = string.Empty;
            }

            dhcpEnabled.Checked = m_nic.GetIPProperties().GetIPv4Properties().IsDhcpEnabled;

            if (dhcpEnabled.Checked)
            {
                dhcpRenew.Enabled        = true;
                currentIP.ReadOnly       = true;
                currentNetMask.ReadOnly  = true;
                currentGateway.ReadOnly  = true;
                currentIP.BackColor      = SystemColors.ControlLight;
                currentNetMask.BackColor = SystemColors.ControlLight;
                currentGateway.BackColor = SystemColors.ControlLight;
            }
            else
            {
                dhcpRenew.Enabled        = false;
                currentIP.ReadOnly       = false;
                currentNetMask.ReadOnly  = false;
                currentGateway.ReadOnly  = false;
                currentIP.BackColor      = SystemColors.Window;
                currentNetMask.BackColor = SystemColors.Window;
                currentGateway.BackColor = SystemColors.Window;
            }
        }