Esempio n. 1
0
 public void CreateChannel(Router r1, Port port1, Router r2, Port port2)
 {
     Channel channel = new Channel(r1, port1, r2, port2);
     Network.Channels.Add(channel);
     drawingChannels.Add(channel);
     if (mainForm.AutoWeight == false)
     {
         ChannelForm properties = new ChannelForm(channel);
         properties.ShowDialog(this);
     }
     else
     {
         Random random = new Random();
         channel.Delay = 1 + random.Next(15);
         channel.Cost = 1 + random.Next(15);
         channel.Metric = 1 + random.Next(15);
     }
     if (mainForm.AutoPortName == true)
     {
         CreateTextLabel(port1.ShortName, new Point(r1.Location.X + (r2.Location.X - r1.Location.X) / 6,
                                           r1.Location.Y + (r2.Location.Y - r1.Location.Y) / 6));
         CreateTextLabel(port2.ShortName, new Point(r2.Location.X + (r1.Location.X - r2.Location.X) / 6,
                                           r2.Location.Y + (r1.Location.Y - r2.Location.Y) / 6));
     }
     channel.ChangeCriterion(mainForm.Criterion);
     mainForm.ChannelsRefresh(Network.Channels.Count);
 }
Esempio n. 2
0
        private void EditElement()
        {
            TextLabel selectedTextLabel = FindTextLabel(mouseLocation);
            if (selectedTextLabel != null)
            {
                EditText textForm = new EditText(selectedTextLabel);
                textForm.SetLocation(ctlPicBox.PointToScreen(selectedTextLabel.Location));
                textForm.ShowDialog();
                return;
            }

            Router selectedRouter = FindRouter(mouseLocation);
            if (selectedRouter != null)
            {
                SelectedElements.Clear();
                SelectedElements.Add(selectedRouter);
                UpdateField();
                RouterForm properties = new RouterForm(selectedRouter, Network);
                if (properties.ShowDialog(this) == DialogResult.OK)
                {
                    mainForm.AreasRefresh(this.Network.Areas.Count - 1);
                    Network.RoutersRecolor();
                    UpdateField();
                }
                return;
            }

            if (SelectedChannel != null)
            {
                ChannelForm properties = new ChannelForm(SelectedChannel);
                if (properties.ShowDialog(this) == DialogResult.OK)
                {
                    SelectedChannel.ChangeCriterion(mainForm.Criterion);
                    ctlPicBox.Invalidate();
                }
                SelectedChannel = null;
            }
        }