Beispiel #1
0
        private void connectButton_Click(object sender, EventArgs e)
        {
            if (listBox2.SelectedIndex == -1)
            {
                return;
            }

            if (from.GetConnectionCount() >= from.GetMaxConnections())
            {
                MessageBox.Show("All of our ports on the device " + from.GetName() + " are filled! Please remove a connection first.");
                return;
            }

            NetworkObject obj = potentialCons[listBox2.SelectedIndex];

            if (obj.GetConnectionCount() >= obj.GetMaxConnections())
            {
                MessageBox.Show("All of our ports on the device " + obj.GetName() + " are filled! Please remove a connection on " + obj.GetName() + " first.");
                return;
            }
            potentialCons.RemoveAt(listBox2.SelectedIndex);
            NetworkCable cable = new NetworkCable(Settings.GetSingleton().AllocateCableId(), from.GetObjectId(), obj.GetObjectId());

            Settings.GetSingleton().AddNetworkCable(cable);
            Settings.SaveSettings();
            listBox2.Items.RemoveAt(listBox2.SelectedIndex);
            MessageBox.Show("Wow! Successfully connected to the " + obj.GetObjectTypeName() + " " + obj.GetName() + " on floor " + (obj.GetFloor() + 1) + "!");
            Close();
        }
 public void RemoveNetworkCable(NetworkCable cable)
 {
     if (cables.Contains(cable))
     {
         cables.Remove(cable);
     }
 }
 public void AddNetworkCable(NetworkCable cable)
 {
     if (!cables.Contains(cable))
     {
         cables.Add(cable);
     }
 }
Beispiel #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex == -1)
            {
                return;
            }

            if (MessageBox.Show("Are you sure you want to remove this connection?", "Are you sure?", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            NetworkCable connectedCable = connectedCables[listBox1.SelectedIndex];

            connectedCables.RemoveAt(listBox1.SelectedIndex);
            connectedCable.RemoveCable();
            Settings.SaveSettings();
            listBox1.Items.RemoveAt(listBox1.SelectedIndex);
            MessageBox.Show("Successfully removed connection!");
            Close();
        }