|
using System;
using System.Drawing;
using System.Windows.Forms;
namespace BlackJack
{
public class Screen
{
protected Graphics drawingSurface = null;
protected Image offScreenBitmap = null;
protected Graphics offScreenSurface = null;
protected Rectangle screenSize;
protected string backgroundImage;
public enum InvalidationType
{
none = 0,
labelOnly = 1,
latestCard = 2,
latestHand = 3,
bothHands = 4,
all = 5
}
public Screen( Form parent, string image )
{
// get a visible screen
drawingSurface = parent.CreateGraphics();
screenSize = parent.ClientRectangle;
// get offscreen buffer context
offScreenBitmap = new Bitmap( screenSize.Width, screenSize.Height );
offScreenSurface = Graphics.FromImage( offScreenBitmap );
backgroundImage = image;
}
public Graphics screenGraphics
{
get { return offScreenSurface; }
}
public void Erase()
{
// erase all content in back buffer by redrawing the background
if ( drawingSurface != null && offScreenSurface != null )
offScreenSurface.DrawImage( Image.FromFile( backgroundImage ), screenSize.X, screenSize.Y );
}
public void Flip()
{
// flip buffers for smooth animation
drawingSurface.DrawImage( offScreenBitmap, screenSize.X, screenSize.Y );
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
I'm a software engineer and consultant working in San Diego, California. I began using .NET during the early alpha releases since I worked for a Microsoft subsidiary then, and now I've focused my career on .NET technologies.
There are a lot of .NET sites out there now, but The Code Project is still top of the heap.