Ejemplo n.º 1
0
        private void maskbitcombo_SelectedValueChanged_1(object sender, EventArgs e)
        {
            int hostbit = 32 - (int)maskbitcombo.SelectedValue;
            var Index   = hostbitcombo.FindStringExact(hostbit.ToString());

            if (!(Index == -1))
            {
                hostbitcombo.SelectedItem = hostbitcombo.Items[Index];
            }
            int sub = (int)maskbitcombo.SelectedItem / 8;

            if (sub == 1)
            {
                int val = (int)maskbitcombo.SelectedItem - 8;
                making_subnets = "255." + specialSubnets[val] + ".0.0";
            }
            if (sub == 2)
            {
                int val = (int)maskbitcombo.SelectedItem - 16;
                making_subnets = "255.255." + specialSubnets[val] + ".0";
            }
            if (sub == 3)
            {
                int val = (int)maskbitcombo.SelectedItem - 24;
                making_subnets = "255.255.255." + specialSubnets[val];
            }
            var thisindex = Subnet_Mask.FindStringExact(making_subnets);

            if (thisindex != -1)
            {
                Subnet_Mask.SelectedItem = Subnet_Mask.Items[thisindex];
            }
        }
Ejemplo n.º 2
0
        private void Subnet_Mask_SelectedValueChanged_1(object sender, EventArgs e)
        {
            int maskbit = 0;

            string[] subnetbroken = Subnet_Mask.SelectedItem.ToString().Split('.');
            int[]    words        = new int[4];
            for (int i = 0; i < 4; i++)
            {
                words[i] = Convert.ToInt32(subnetbroken[i]);
            }

            foreach (var item in words)
            {
                int index = 0;
                foreach (var someitem in specialSubnets)
                {
                    if (item == someitem)
                    {
                        break;
                    }
                    index++;
                }
                maskbit += index;
            }
            //taking maskbit
            maskbitcombo.DataSource = mask_bitcombo.ToArray();
            int numbofsubnets = 0;

            var Index = maskbitcombo.FindStringExact(maskbit.ToString());

            if (Index != -1)
            {
                maskbitcombo.SelectedItem = maskbitcombo.Items[Index];
            }



            //taking Host bits
            int hostbit   = 32 - (int)maskbitcombo.SelectedValue;
            var Indexhost = hostbitcombo.FindStringExact(hostbit.ToString());

            if (!(Indexhost == -1))
            {
                hostbitcombo.SelectedItem = hostbitcombo.Items[Indexhost];
            }

            hostpersubnetcombo.DataSource = host_persubnet.ToArray();


            var subindex = noofsubnetcombo.FindStringExact(numbofsubnets.ToString());

            if (subindex != -1)
            {
                noofsubnetcombo.SelectedItem = noofsubnetcombo.Items[subindex];
            }

            double hostpersubnet = 0.0;

            hostpersubnet = Math.Pow(2, hostbit);
            int totalhosts = ((int)(hostpersubnet)) - 2;

            var hostindex = hostpersubnetcombo.FindStringExact(totalhosts.ToString());

            if (hostindex != -1)
            {
                hostpersubnetcombo.SelectedItem = hostpersubnetcombo.Items[hostindex];
            }

            double noofsubnets  = 0.0;
            int    someotherval = Convert.ToInt32(Bit.SelectedItem.ToString());
            double someval      = Convert.ToDouble(maskbit - someotherval);

            noofsubnets = Math.Pow(2.0, someval);
            int totalnoofsubnets = (int)noofsubnets;
            var totalsubnetindex = noofsubnetcombo.FindStringExact(totalnoofsubnets.ToString());

            if (totalsubnetindex != -1)
            {
                noofsubnetcombo.SelectedItem = noofsubnetcombo.Items[totalsubnetindex];
            }
            var someintindex = Subnet_Mask.FindStringExact(Subnet_Mask.SelectedItem.ToString());

            Subnet_Mask.SelectedItem = Subnet_Mask.Items[someintindex];
        }