PIBD-14_Boyko_M_S_Cursach_DFS/Cursach/VizulizatorGraph.cs
2024-05-16 00:37:58 +04:00

32 lines
1.1 KiB
C#

using Cursach.Realisations;
namespace Cursach;
public class VizulizatorGraph
{
public void Draw(Graphics g, AdjacencyList _adjacencyList)
{
Pen penLine = new(Color.Black, 5);
Pen penBid = new(Color.Red, 2);
Pen penSelectedBid = new(Color.Green, 3);
Brush brush = new SolidBrush(Color.Gray);
Brush darkBrush = new SolidBrush(Color.Black);
g.FillRectangle(new SolidBrush(Color.White), 0, 0, 500, 500);
foreach (var parentNode in _adjacencyList.Keys())
{
foreach (var childNode in _adjacencyList.Values(parentNode))
{
g.DrawLine(penLine, parentNode.GetPosition(), childNode.GetPosition());
}
g.DrawString(parentNode.ToString(), new Font("Comic Sans MS", 7), darkBrush,
parentNode.GetPosition().X - 20, parentNode.GetPosition().Y - 30);
DrawPoint(g, parentNode.GetPosition(), Color.Gray);
}
}
public static void DrawPoint(Graphics g, Point point, Color color = default)
{
g.FillEllipse(new SolidBrush(color), point.X - 10, point.Y - 10, 20, 20);
}
}