Extending on what Daniel said, you should rewrite your OnPaint to paint the entire surface (nodes and lines) but in a modular manner that you can pass a Graphics object (and perhaps the clip bounds) to paint on, but don't paint directly in OnPaint. This allows you to pass the Graphics for a PrintDocument (or even an HDC for some other device using Graphics.FromHdc) and use the same drawing routines. The common solution follows:
private void Paint(Graphics g, Rectangle bounds)
{
// Your drawing routines go here...
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Paint(e.Graphics, Bounds);
}
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
Paint(e.Graphics, e.PageBounds);
}
Handling your mouse events isn't too hard if you design a nice abstract system of nodes where the Panel may translate mouse events to the nodes, but the nodes actually contain the code to move themselves. Polymorphism is a very powerful tool. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]