How to effectively .Clear() a Graphics Object?

Here's an issue I have been looking at recently, and was wondering if anyone had some input.

Basically I have a 'whiteboard' type function between two connected PCs, so that one person can 'draw' over the image on screen and the other person can see the results. Everything is working fine, I just had a few housekeeping problems that would clean up the look of the drawing.

Basically I have 2 Graphics objects overlaying the image on screen. The one on top is the 'scratch' so to speak, and the one on bottom is the 'final' copy. Basically, the 'scratch' is drawn on, then the markings are transfered to the 'final' and the 'scratch' is deleted.

The mouse is clicked and in a 'down' state and then the 'scratch' object is drawn on, marked up, etc.. When the mouse pointer is released and changed to an 'up' state, I would like the 'scratch' object to be cleared and then the points are sent to the 'final' layer and it is drawn on.

I have this all working fine, it's just that I have no way to CLEAR the scratch layer. There is a clear function...

Graphics grphx = new Graphics
grphx.Clear(Color.White)

but this simply fills the entire layer with a defined color. I've gone through all the Graphics member functions, etc, and just haven't found a way to simply erase, delete, anything, to get rid of the first 'scratch' layer.

This causes issues because you can see the 'final' layer through the 'scratch' layer, and when you grphx.clear(Color.xxx) is simply looks as if everything has been erased...simply because the 'final' layer is now covered up.

Are there any suggestions on how to get rid of this first layer? Any and all help is as always, very much appreciated.

Thanks again.copy the object from one object to the other.

gr2 = (Graphics) gr1.MemberwiseClone();The problem with simply copying layer 1 to layer 2 is that the top layer has alot of markings that I don't want copied to the bottom layer.

Basically there is the ability to draw a rectangle, and you can see the rectangle displayed dynamically as you resize it. However, in order to accomplish this, every mouse movement, I have to fill in the old displayed rectangle with the background color and re-draw the new rectangle. This results in alot of markings on the top layer. That is why I simply wanted to delete the top layer and only make one final marking on the bottom layer using the final mouse coordinates.

Thanks for the suggestion though afterburn, I appreciate it. :)
 
Back
Top