Inheritance: System.Windows.Forms.Form
Example #1
0
        private void AddUnicastIp()
        {
            var unicastForm = new UnicastForm();

            if (this.univDGVN.CurrentCell != null)
            {
                if (this.univDGVN.CurrentCell.IsInEditMode)
                {
                    this.univDGVN.EndEdit();
                }
            }

            if (unicastForm.ShowDialog() == DialogResult.OK)
            {
                IPAddress ipAddress;
                bool      valid = IPAddress.TryParse(unicastForm.IpAddrText, out ipAddress);

                if (valid)
                {
                    var ipBytes = ipAddress.GetAddressBytes();

                    if (ipBytes[0] == 0 && ipBytes[1] == 0 && ipBytes[2] == 0 && ipBytes[3] == 0)
                    {
                        valid = false;
                    }

                    if (ipBytes[0] == 255 && ipBytes[1] == 255 && ipBytes[2] == 255 && ipBytes[3] == 255)
                    {
                        valid = false;
                    }
                }

                if (!valid)
                {
                    MessageBox.Show(
                        "Error - Invalid IP Address",
                        "IP Address Validation",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
                else
                {
                    var ipAddressText = ipAddress.ToString();

                    if (this.unicasts.ContainsKey(ipAddressText))
                    {
                        MessageBox.Show(
                            "Error - Duplicate IP Address",
                            "IP Address Validation",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                    else
                    {
                        this.unicasts.Add(ipAddressText, 0);
                        this.SetDestinations();
                    }
                }
            }
        }
Example #2
0
        private void AddUnicastIp()
        {
            var unicastForm = new UnicastForm();

            if (this.univDGVN.CurrentCell != null)
            {
                if (this.univDGVN.CurrentCell.IsInEditMode)
                {
                    this.univDGVN.EndEdit();
                }
            }

            if (unicastForm.ShowDialog() == DialogResult.OK)
            {
                IPAddress ipAddress;
                bool valid = IPAddress.TryParse(unicastForm.IpAddrText, out ipAddress);

                if (valid)
                {
                    var ipBytes = ipAddress.GetAddressBytes();

                    if (ipBytes[0] == 0 && ipBytes[1] == 0 && ipBytes[2] == 0 && ipBytes[3] == 0)
                    {
                        valid = false;
                    }

                    if (ipBytes[0] == 255 && ipBytes[1] == 255 && ipBytes[2] == 255 && ipBytes[3] == 255)
                    {
                        valid = false;
                    }
                }

                if (!valid)
                {
                    MessageBox.Show(
                        "Error - Invalid IP Address",
                        "IP Address Validation",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
                else
                {
                    var ipAddressText = ipAddress.ToString();

                    if (this.unicasts.ContainsKey(ipAddressText))
                    {
                        MessageBox.Show(
                            "Error - Duplicate IP Address",
                            "IP Address Validation",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                    else
                    {
                        this.unicasts.Add(ipAddressText, 0);
                        this.SetDestinations();
                    }
                }
            }
        }
Example #3
0
        /*private void UnivDgvnDefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
        {
            e.Row.Cells[ACTIVE_COLUMN].Value = false;
            e.Row.Cells[START_COLUMN].Value = "1";

            int maxUniverse = 1;

            //try to supply a more useful start value
            foreach(DataGridViewRow r in univDGVN.Rows) {
                if (r.Cells[UNIVERSE_COLUMN].Value != null)
                    if (Convert.ToInt16(e.Row.Cells[UNIVERSE_COLUMN].Value.ToString()) > maxUniverse)
                        maxUniverse = Convert.ToInt16(e.Row.Cells[UNIVERSE_COLUMN].Value.ToString());
            }

            e.Row.Cells[UNIVERSE_COLUMN].Value = maxUniverse;

            e.Row.Cells[SIZE_COLUMN].Value = "1";
        }*/
        private void AddUnicastIp()
        {
            var unicastForm = new UnicastForm();

            if (this.univDGVN.CurrentCell != null)
            {
                if (this.univDGVN.CurrentCell.IsInEditMode)
                {
                    this.univDGVN.EndEdit();
                }
            }

            if (unicastForm.ShowDialog() == DialogResult.OK)
            {

                var ipAddressText = unicastForm.IpAddrText;

                if (E131OutputPlugin.unicasts.ContainsKey(ipAddressText))
                {
                    //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible)
                    MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form.
                    var messageBox = new MessageBoxForm("Error - Duplicate IP Address",
                        "IP Address Validation", false, false);
                    messageBox.ShowDialog();
                }
                else
                {
                    E131OutputPlugin.unicasts.Add(ipAddressText, 0);
                    this.SetDestinations();
                }
                comboDestination.SelectedItem = "Unicast " + ipAddressText;
            }
        }