0
votes

My application is basically a graph type arrangement, there is a panel containing verticies (let's call them nodes from herein) and those nodes need to be dragged around.

These nodes are rectangles drawn on a graphics object.

To accomplish this I store each node as an object, the class contains variables to store their bounding rectangles and x,y positions amongst other things, each new instance of the object is stored in a list that can be iterated through when required.

The actual logic of the dragging/redrawing mechanism seems to work fine, my problem is with the background image of the panel.

Once the mouseup event is fired I update the position of the node that has been moved/dragged via it's object variables, clear the graphics object and then redraw every node so the graphical representation can be updated based on the new position.

The problem is that when I reload the background image of the panel, it doesn't display and I'm just left with the background colour and the redrawn nodes.

I thought it might be because I was loading it from the file, so I loaded it as an image at runtime and still no joy.

Any ideas gratefully received, some sort of trickery with Invalidate() perhaps?

1
Don't talk about it, post code. - Hans Passant

1 Answers

0
votes

Figured it out, for anyone else having the same problem;

panel1.Invalidate();
panel1.Refresh();

//set the background image at the end of this method.
redrawScene(nodes);