tags:

views:

1530

answers:

3

Hello,

is there a way to draw an oriented graph / tree in c#, without using external libraries?

A: 

you should be able use the System.Drawing namespace to draw and then just do the math and computational stuff yourself.

willz
A: 

Yes. You'll use the System.Drawing namespace (more info here). You'll want to create a virtual canvas large enough to handle your widest and tallest extents. These can be calculated by figuring the number of leaves in your tree (it is a bit more difficult with a graph) and then adding a spacing factor, etc.

It isn't a hard problem but it is tedious. It took me about a day several years ago. Sorry but I abandoned the interface as too clumsy and didn't keep the code.

Mark Brittingham
+1  A: 

Yes, use the System.Drawing namespace, which contains drawing functions/classes.

Basically to draw, you do this:

    Bitmap bmp = new Bitmap(width, height);
    Image img = bmp;
    Graphics g = Graphics.FromImage(img);

Then use g.FillRectangle , g.DrawLine, g.DrawString etc.

Remember that 0,0 is on top left though :)

Spikolynn