Пример #1
0
 public Link(Device[] devices, int bandwidth, LineConnect line)
 {
     Line      = line;
     Bandwidth = bandwidth;
     Devices   = devices;
     Controller.getInstance().Links.Add(this);
     line.Owner = this;
 }
Пример #2
0
        public void ConnectDevices(Device A, Device B, int linkBandwidth, LineConnect linkFigure) //for creating links
        {
            Device[] devices = { A, B };
            Link     NewLink = new Link(devices, linkBandwidth, linkFigure);

            Links.Add(NewLink);
            A.Ports.Add(NewLink);
            B.Ports.Add(NewLink);
        }
        private void buttonOK_Click(object sender, EventArgs e)
        {
            try
            {
                int capacity = (int)Convert.ToUInt32(textBoxСapacity.Text);

                if (!((Form1)this.Tag).edit)
                {
                    LineConnect line = new LineConnect(((Form1)this.Tag).X1, ((Form1)this.Tag).Y1, ((Form1)this.Tag).X2, ((Form1)this.Tag).Y2);
                    ((Form1)this.Tag).graphics.DrawLine(((Form1)this.Tag).pen, ((Form1)this.Tag).X1, ((Form1)this.Tag).Y1, ((Form1)this.Tag).X2, ((Form1)this.Tag).Y2);
                    ((Form1)this.Tag).lines.Add(line);
                    ((Form1)this.Tag).groundBox.Image = ((Form1)this.Tag).bmp;

                    Controller.getInstance().ConnectDevices(((Form1)this.Tag).figReturn1.Owner, ((Form1)this.Tag).figReturn2.Owner, capacity, line);
                }
                this.Close();
            }
            catch (Exception)
            {
                MessageBox.Show("Некоректний ввід", "ERROR :(");
            }
        }