Exemplo n.º 1
0
        public void UpdatePrefix()
        {
            try
            {
                SubnetMask subnetMask = new SubnetMask((int)numPrefix.Value);
                ipAddress.SubnetMask = subnetMask;

                cmbSubnetMask.Text = subnetMask.ToString();
                UpdatePropertiesPanel();

                numSubnetBits.Maximum = 30 - numPrefix.Value;
                numNumberOfSubnets.Maximum = (decimal)Math.Pow(2, 30 - (double)numPrefix.Value);
                numHostPerSubnet.Maximum = (decimal)Math.Pow(2, 32 - (double)numPrefix.Value) - 2;
                UpdateSubnetBit();
                UpdateSubnetBitmap();

                picSubnetMask.Image = Resources.icon_ok_20;
            }
            catch { }
        }
Exemplo n.º 2
0
        public void UpdateClass()
        {
            switch (cmbClass.SelectedIndex)
            {
                case 0:
                    ipAddress = isSelectClass ? new IPv4Address(IPv4Class.A) : new IPv4Address(txtIPv4Address.Text);
                    numPrefix.Minimum = 8;
                    break;
                case 1:
                    ipAddress = isSelectClass ? new IPv4Address(IPv4Class.B) : new IPv4Address(txtIPv4Address.Text);
                    numPrefix.Minimum = 16;
                    break;
                case 2:
                    ipAddress = isSelectClass ? new IPv4Address(IPv4Class.C) : new IPv4Address(txtIPv4Address.Text);
                    numPrefix.Minimum = 24;
                    break;
                default:
                    break;
            }
            numPrefix.Value = ipAddress.SubnetMask.Prefix;
            txtIPv4Address.Text = ipAddress.Address;

            UpdatePropertiesPanel();
            UpdateSubnetBitmap();

            //Update Subnetmask combobox items
            cmbSubnetMask.Items.Clear();
            SubnetMask temp = new SubnetMask();

            for (int i = SubnetMask.ToPrefix(ipAddress.Class); i < 31; i++)
            {
                temp.Prefix = i;
                cmbSubnetMask.Items.Add(temp.ToString());
            }
        }