Esempio n. 1
0
 public Link(int width, NetworkNode start, NetworkNode end, Color mainColour) : base(new Point(), width, mainColour)
 {
     this.start      = start;
     this.end        = end;
     incomingPackets = new List <Packet>();
     outgoingPackets = new List <Packet>();
 }
Esempio n. 2
0
        public Point GetExitPoint(NetworkNode node)
        {
            Point center  = node.GetDrawLocation();
            int   centerX = center.X;
            int   centerY = center.Y;

            Point otherCenter;

            if (node.Equals(start))
            {
                otherCenter = end.GetDrawLocation();
            }
            else
            {
                otherCenter = start.GetDrawLocation();
            }

            double absAngle = Program.GetAbsAngle(center, otherCenter);

            int    radius = (int)Math.Round(node.size / metersPerPixel, 0);
            double distanceFromCenterToExitPoint = Math.Sqrt(Math.Pow(radius, 2) - 0.25 * Math.Pow(size / metersPerPixel, 2));

            double deltaXFromCenterToExitPoint = distanceFromCenterToExitPoint * Program.Sin(absAngle);
            double deltaYFromCenterToExitPoint = distanceFromCenterToExitPoint * Program.Cos(absAngle);

            int exitPointX = centerX + (int)Math.Round(deltaXFromCenterToExitPoint, 0);
            int exitPointY = centerY + (int)Math.Round(deltaYFromCenterToExitPoint, 0);

            Point exitPoint = new Point(exitPointX, exitPointY);

            return(exitPoint);
        }
 public NetworkNodeWindow(int n)
 {
     InitializeComponent();
     logBox.Document.Blocks.Remove(logBox.Document.Blocks.FirstBlock);
     NodeNumber  = n;
     Title       = "Router " + NodeNumber.ToString();
     networknode = new NetworkNode(this);
     Task.Run(() => MyStart(NodeNumber));
 }
Esempio n. 4
0
        protected void GenerateWorld()
        {
            Program.allEntities = new List <Entity>();

            NetworkNode nodeA = new NetworkNode("A", 50 * 5, 80 * 5, 80 * 5, Color.Red);

            Program.allEntities.Add(nodeA);

            NetworkNode nodeB = new NetworkNode("B", 50 * 5, 150 * 5, 150 * 5, Color.Blue);

            Program.allEntities.Add(nodeB);

            Link link = new Link(20 * 5, nodeA, nodeB, Color.Green);

            Program.allEntities.Add(link);

            nodeA.SpawnData();
        }