public void LinkNodes(NodePictureBox node1, NodePictureBox node2)
        {
            edgeList.Add(new VisualEdge <NodePictureBox>(node1, node2));

            nodeController.LinkNodes(node1.node, node2.node);


            panelGraphics.Invalidate();
        }
 public bool IsNodeConnectedTo(NodePictureBox pb, NodePictureBox nextPb)
 {
     for (int i = 0; i < edgeList.Count; i++)
     {
         if (edgeList[i].End == pb && edgeList[i].Start == nextPb || edgeList[i].Start == pb && edgeList[i].End == nextPb)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        public void NodePictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            graphicsController.connectionCheckEnabled = true;
            NodePictureBox node = sender as NodePictureBox;

            dataGridViewTable.Rows.Clear();

            foreach (var entry in node.node.routingTable)
            {
                dataGridViewTable.Rows.Add(entry.Destination, entry.NextNode);
            }
        }
        public void SendPacket(Node from, int time)
        {
            NodePictureBox fromVisual = null;

            foreach (NodePictureBox control in panelGraphics.Controls)
            {
                if (control.node == from)
                {
                    fromVisual = control;
                }
            }

            //fromVisual.Image = Image.FromFile(Properties.Resources.MailImage);
        }
        public void AddNodeGraphics(Node node, Point location)
        {
            NodePictureBox pb = new NodePictureBox(node, new Point(location.X - nodeSize / 2, location.Y - nodeSize / 2));

            pb.SizeMode = PictureBoxSizeMode.AutoSize;
            panelGraphics.Controls.Add(pb);

            pb.MouseDown += new MouseEventHandler(NodePictureBox_MouseDown);
            pb.MouseUp   += new MouseEventHandler(NodePictureBox_MouseUp);
            pb.MouseMove += new MouseEventHandler(NodePictureBox_MouseMove);

            pb.MouseDown += new MouseEventHandler(main.NodePictureBox_MouseDown);

            panelGraphics.Refresh();
        }
        private void NodePictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            NodePictureBox node = sender as NodePictureBox;

            if (e.Button == MouseButtons.Left)
            {
                moving = true;

                if (NodePictureBox.ModifierKeys.HasFlag(Keys.Control))
                {
                    if (selectedNode1 == null)
                    {
                        selectedNode1 = node;
                    }
                    else if (selectedNode2 == null)
                    {
                        if (selectedNode1 != node)
                        {
                            selectedNode2 = node;

                            LinkNodes(selectedNode1, selectedNode2);
                            selectedNode1 = null;
                            selectedNode2 = null;
                        }
                    }
                    else
                    {
                        selectedNode1 = null;
                        selectedNode2 = null;
                    }
                }
            }
            if (e.Button == MouseButtons.Right)
            {
            }
        }