9.4. The Surface

We needed a place to paint to. In GDI+ all painting is done to a Graphics object. The user control, which is in fact a form because it inherits from it, has an associated Graphics object that can be repainted in the OnPaint event. One of the problems we had to face was that changes in the graphics object are not permanent. This means that we needed a way of tracking all the changes that were applied to the surface in every loop. The solution we followed consisted in mantaining a Bitmap object with the surface content. Then in the OnPaint event this content is dropped to the user control graphics object through the DrawImage method.


===============================================================================
Generated by the free version of GemDoc. Purchase now at www.gemdoc.net/purchase
DocBook Made Easy - A single source, Windows based, multiple format solution for your document needs.