//Draws all the links then all the nodes private void DrawPanel(Graphics graphics) { foreach (INode node in this.graph.Nodes.OrderBy(n => n.Layer)) { foreach (ILink link in node.ConnectedLinks) { ILinkDraw linkDraw = new LinkDraw(link); if (this.selectedLink != null && link == this.selectedLink.Link) { linkDraw.Draw(graphics, Color.Red); } else { linkDraw.Draw(graphics, Color.Black); } } } foreach (INode node in this.graph.Nodes.OrderBy(n => n.Layer)) { INodeDraw nodeDraw = new NodeDraw(node); if (this.selectedNode != null && node == this.selectedNode.Node) { nodeDraw.Draw(graphics, Color.Red); } else if (this.source != null && node == this.source.Node) { nodeDraw.Draw(graphics, Color.Blue); } else if (this.destination != null && node == this.destination.Node) { nodeDraw.Draw(graphics, Color.Green); } else { nodeDraw.Draw(graphics, Color.Black); } } }
//Draws all the links, then draws all the nodes, then draws tenative values if the current step is one or more. public void DrawPanel(Graphics graphics) { foreach (INode node in this.dijkstra.Graph.Nodes.OrderBy(n => n.Layer)) { foreach (ILink link in node.ConnectedLinks) { ILinkDraw linkDraw = new LinkDraw(link); linkDraw.Draw(graphics, Color.Black); } } foreach (INode node in this.dijkstra.Graph.Nodes.OrderBy(n => n.Layer)) { INodeDraw nodeDraw = new NodeDraw(node); if (this.dijkstra.DijkstraCurrentNode == node) { nodeDraw.Draw(graphics, Color.Red); } else if (node == this.dijkstra.Graph.Source) { nodeDraw.Draw(graphics, Color.Blue); } else if (node == this.dijkstra.Graph.Destination) { nodeDraw.Draw(graphics, Color.Green); } else { nodeDraw.Draw(graphics, Color.Black); } if (this.currentStep >= 1) { nodeDraw.DrawTenativeValue(graphics, Color.Magenta); } } }