Exemplo n.º 1
0
        /// <summary>
        /// change the icon to match the connection
        /// </summary>
        public void adjust_Button()
        {
            if ((!String.IsNullOrEmpty(dest_PortNum.Text) && !String.IsNullOrEmpty(src_PortNum.Text)) &&
                cn_mngr.Is_Connected(src_IPAddr.Text, Convert.ToInt32(src_PortNum.Text),
                                     dest_IPAddr.Text, Convert.ToInt32(dest_PortNum.Text)))
            {
                //update button image
                take_Button.BackgroundImage = global::Simple_Switcher.Properties.Resources.stop_Z;

                //also make fields not editable
                src_IPAddr.ReadOnly   = true;
                dest_IPAddr.ReadOnly  = true;
                src_Name.ReadOnly     = true;
                dest_Name.ReadOnly    = true;
                src_PortNum.ReadOnly  = true;
                dest_PortNum.ReadOnly = true;
            }
            else
            {
                //update button image
                take_Button.BackgroundImage = global::Simple_Switcher.Properties.Resources.take;

                //make fields editable
                src_IPAddr.ReadOnly   = false;
                dest_IPAddr.ReadOnly  = false;
                src_Name.ReadOnly     = false;
                dest_Name.ReadOnly    = false;
                src_PortNum.ReadOnly  = false;
                dest_PortNum.ReadOnly = false;
            }
        }
Exemplo n.º 2
0
        private void src_Del_Click(object sender, EventArgs e)
        {
            string src_IPAddress  = ch_mngr.get_Channel_Information("Sources", src_listBox.SelectedIndex, 1);
            int    src_PortNumber = Convert.ToInt32(ch_mngr.get_Channel_Information("Sources", src_listBox.SelectedIndex, 2));

            //check if connected
            if (cn_mngr.Is_Connected(src_IPAddress, src_PortNumber, "", 0))
            {
                //if so cancel deletion, inform user
                MessageBox.Show("This connection is being used, it cannot be removed");
                return;
            }

            //else proceed
            //delete from list, combo box, and data file

            //if the currently selected is not selected then keep cuireent selection
            //else turn to a default of zero

            for (int i = 0; i < in_combobox_array.Length; i++)
            {
                if (in_combobox_array[i].SelectedIndex == src_listBox.SelectedIndex)
                {
                    //keep new selection within bounds
                    if (in_combobox_array[i].SelectedIndex + 1 < in_combobox_array[i].Items.Count)
                    {
                        in_combobox_array[i].SelectedIndex = in_combobox_array[i].SelectedIndex + 1;
                    }
                    else
                    {
                        in_combobox_array[i].SelectedIndex = 0;
                    }
                }
                in_combobox_array[i].Items.RemoveAt(src_listBox.SelectedIndex);
            }


            ch_mngr.Remove_Channel("Sources", src_listBox.SelectedIndex);

            //last to be deleted because of dependencies
            src_listBox.Items.RemoveAt(src_listBox.SelectedIndex);
        }