Exemplo n.º 1
0
        private void ChangedAddress(object sender, TextChangedEventArgs e)
        {
            string tag = ((TextBox)sender).Tag.ToString();

            if (oac.IsFree(tag))
            {
                string content = ((TextBox)sender).Text;
                string result  = "";
                addressStatus = false;
                //
                if (tag == "A1")
                {
                    if (Validators.IsValidAddress(content, AddressType.NetworkAddress, AddressStructure.IntegerAddress))
                    {
                        result        = Converters.AddressIntToBin(content);
                        addressStatus = true;
                    }
                    else
                    {
                        result = "";
                    }
                    if (txtIndirizzoBinario.Text != result)
                    {
                        oac.Block("A2");
                        txtIndirizzoBinario.Text = result;
                    }
                }
                else
                {
                    if (Validators.IsValidAddress(content, AddressType.NetworkAddress, AddressStructure.BinaryAddress))
                    {
                        result        = Converters.AddressBinToInt(content);
                        addressStatus = true;
                    }
                    else
                    {
                        result = "";
                    }
                    if (txtIndirizzoStandard.Text != result)
                    {
                        oac.Block("A1");
                        txtIndirizzoStandard.Text = result;
                    }
                }
                SetErrorMessage();
            }
        }
Exemplo n.º 2
0
        private void ChangedSubnet(object sender, TextChangedEventArgs e)
        {
            string tag = ((TextBox)sender).Tag.ToString();

            if (oac.IsFree(tag))
            {
                string content = ((TextBox)sender).Text;
                string result  = "";
                subnetStatus = false;
                //
                if (tag == "B1")
                {
                    if (Validators.IsValidAddress(content, AddressType.SubnetmaskAddress, AddressStructure.IntegerAddress))
                    {
                        result = Converters.AddressIntToBin(content);
                        SetSlash(Converters.SubnetmaskToSlash(content));
                        subnetStatus = true;
                    }
                    else
                    {
                        result = "";
                        SetSlashEmpty();
                    }
                    if (txtSubnetmaskBinario.Text != result)
                    {
                        oac.Block("B2");
                        txtSubnetmaskBinario.Text = result;
                    }
                }
                else
                {
                    if (Validators.IsValidAddress(content, AddressType.SubnetmaskAddress, AddressStructure.BinaryAddress))
                    {
                        result = Converters.AddressBinToInt(content);
                        SetSlash(Converters.SubnetmaskToSlash(content));
                        subnetStatus = true;
                    }
                    else
                    {
                        result = "";
                        SetSlashEmpty();
                    }
                    if (txtSubnetmaskStandard.Text != result)
                    {
                        oac.Block("B1");
                        txtSubnetmaskStandard.Text = result;
                    }
                }
                SetErrorMessage();
            }

            // F
            void SetSlash(int slash)
            {
                if (comboBoxSlash.SelectedIndex != slash)
                {
                    oac.Block("B3"); comboBoxSlash.SelectedIndex = slash;
                }
            }

            void SetSlashEmpty()
            {
                SetSlash(0);
            }
        }