Exemplo n.º 1
0
        private void tbMaskNumber_TextChanged(object sender, EventArgs e)
        {
            if (tbMaskNumber.Text == string.Empty || Handle_reset || !Handle_allowCalculate)
            {
                return;
            }
            int iMaskNumber;

            int.TryParse(tbMaskNumber.Text, out iMaskNumber);
            if (iMaskNumber > 30)
            {
                tbMaskNumber.Text = "30";
            }
            else if (iMaskNumber < 1)
            {
                tbMaskNumber.Text = "1";
            }
            Check_validate(enum_global.kindOfCheckValidate.Empty);
            if (!Handle_Empty && !Handle_wrongWrite)
            {
                Package pg_send, pg_receive;
                pg_receive = new Package();
                pg_send    = new Package(Package.PackageType.CTS_SubnetOne, tbIPAddress.Text, int.Parse(tbMaskNumber.Text), -1);

                pg_send.SerializeSurrealists(client, client.GetStream());
                pg_receive = IpHelpers.getPackageDeserialized(client.GetStream());

                reset_Value(pg_receive);
            }
        }
Exemplo n.º 2
0
        private void combobox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Handle_needHost = true;
            //tbNeededHost.Text = cbHostsPerSubnet.Text;
            //Handle_needHost = false;
            if (!Handle_combobox || Handle_reset)
            {
                return;
            }

            System.Windows.Forms.ComboBox comboBox = sender as System.Windows.Forms.ComboBox;

            int index = comboBox.SelectedIndex;


            cbHostsPerSubnet.SelectedIndex = cbMaskBits.SelectedIndex = cbSubnetBits.SelectedIndex = cbSubnetMasks.SelectedIndex = cbMaximumSubnets.SelectedIndex = index;

            Package pg_send, pg_receive;

            pg_receive = new Package();
            pg_send    = new Package(Package.PackageType.CTS_PackageToCalculate, tbIPAddress.Text, int.Parse(tbMaskNumber.Text), cbSubnetMasks.Text);

            pg_send.SerializeSurrealists(client, client.GetStream());
            pg_receive = IpHelpers.getPackageDeserialized(client.GetStream());

            showSTC_calculatePackage(pg_receive);
            Handle_combobox = false;
        }
Exemplo n.º 3
0
        private void tbIPAddress_TextChanged_1(object sender, EventArgs e)
        {
            if ((!Handle_Empty && !Handle_wrongWrite) || Handle_reset || !Handle_allowCalculate)
            {
                Package pg_send, pg_receive;
                pg_receive = new Package();
                pg_send    = new Package(Package.PackageType.CTS_SubnetOne, tbIPAddress.Text, int.Parse(tbMaskNumber.Text), -1);

                pg_send.SerializeSurrealists(client, client.GetStream());
                pg_receive = IpHelpers.getPackageDeserialized(client.GetStream());

                reset_Value(pg_receive);
            }
        }
Exemplo n.º 4
0
        private void tbIPAddress_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                Package pg_send, pg_receive;
                pg_receive = new Package();

                pg_send = new Package(Package.PackageType.CTS_PackageToCalculate, tbIPAddress.Text, int.Parse(tbMaskNumber.Text), cbSubnetMasks.Text);

                pg_send.SerializeSurrealists(client, client.GetStream());
                pg_receive = IpHelpers.getPackageDeserialized(client.GetStream());

                showSTC_calculatePackage(pg_receive);
            }
        }
Exemplo n.º 5
0
        private void tbIPAddress_TextChanged(object sender, EventArgs e)
        {
            if (!Handle_allowCalculate || Handle_reset)
            {
                return;
            }
            Check_validate(enum_global.kindOfCheckValidate.wrongWrite);
            if (!Handle_Empty && !Handle_wrongWrite)
            {
                // send
                Package pg_send, pg_receive;
                pg_receive = new Package();
                pg_send    = new Package(Package.PackageType.CTS_SubnetOne, tbIPAddress.Text, int.Parse(tbMaskNumber.Text), -1);

                pg_send.SerializeSurrealists(client, client.GetStream());
                pg_receive = IpHelpers.getPackageDeserialized(client.GetStream());

                reset_Value(pg_receive);
            }
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (lbMessage.Text == string.Empty && tbSubnetName.Text == string.Empty)
            {
                lbMessage.Text          = "Mời bạn nhập SubnetName";
                gbSubnetName.BackColor  = Color.Coral;
                Handle_Empty_subnetName = false;
                return;
            }
            Handle_allowCalculate = false;
            string strNeededHost = "";

            if (tbNeededHost.Text == string.Empty)
            {
                strNeededHost = cbHostsPerSubnet.Text;
            }
            SubnetClass subnetItem = new SubnetClass(intSubnetOder.ToString(), tbIPAddress.Text, tbMaskNumber.Text, tbSubnetName.Text, tbNeededHost.Text, cbHostsPerSubnet.Text, tbSubnetID.Text, cbMaskBits.Text, cbSubnetMasks.Text, tbHostRange.Text, tbBroadCast.Text);

            liSubnet.Add(subnetItem);
            //liSubnet.Add(subnetItem);
            //DataGridViewRow dtRow = new DataGridViewRow();
            //dtRow.Cells[0].Value = tbIPAddress.Text;
            //dtRow.Cells[1].Value = intSubnetOder.ToString();
            //dtRow.Cells[2].Value = strNeededHost;
            //dtRow.Cells[0].Value = cbHostsPerSubnet.Text;
            //dtRow.Cells[0].Value = cbMaskBits.Text;
            //dtRow.Cells[0].Value = tbSubnetName.Text;
            //dtRow.Cells[0].Value = tbSubnetID.Text;
            //dtRow.Cells[0].Value = cbSubnetMasks.Text;
            //dtRow.Cells[0].Value = tbHostRange.Text;
            //dtRow.Cells[0].Value = tbBroadCast.Text;

            //table.Rows.Add(intSubnetOder.ToString(), tbIPAddress.Text, tbSubnetName.Text, tbNeededHost.Text, cbHostsPerSubnet.Text, tbSubnetID.Text, cbMaskBits.Text, cbSubnetMasks.Text, tbHostRange.Text, tbBroadCast.Text);



            tbIPAddress.Text      = IpAdressNext;
            tbMaskNumber.Text     = cbMaskBits.Text;
            Handle_allowCalculate = true;



            Package pg_send, pg_receive;

            pg_receive = new Package();

            pg_send = new Package(Package.PackageType.CTS_SubnetOne, tbIPAddress.Text, int.Parse(tbMaskNumber.Text), maxhost - int.Parse(cbHostsPerSubnet.Text) - 2);

            pg_send.SerializeSurrealists(client, client.GetStream());
            pg_receive = IpHelpers.getPackageDeserialized(client.GetStream());

            BindingSubnetToTable();
            if (pg_receive.IsEmptySubnet)
            {
                btnSubnet.Text    = "Hết";
                btnSubnet.Enabled = false;
                return;
            }

            reset_Value(pg_receive);


            //table.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.Fill);

            table.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            table.AutoSizeRowsMode    = DataGridViewAutoSizeRowsMode.None;


            intSubnetOder++;
            tbIPAddress.Enabled  = false;
            tbMaskNumber.Enabled = false;

            btnSubnet.Text = "Subnet " + (intSubnetOder + 1).ToString();
        }