Problemer med Graphics
Hej er der nogen der lige kan tage et kig på noget kode skrivet til Pocket PC 2003.Mit problem er at der ikke bliver tegnet noget. se nedn stående kode
public partial class Form1 : Form
{
Graphics onscreen;
Graphics offscreen;
Bitmap backbuffer;
DateTime last;
int fps = 0;
Font font;
SolidBrush fontbrush;
public Form1()
{
InitializeComponent();
this.Visible = true;
Application.DoEvents();
Thread.Sleep(0);
backbuffer = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
offscreen = Graphics.FromImage(backbuffer);
font = new Font("Arial", 10, FontStyle.Regular);
fontbrush = new SolidBrush(Color.Black);
gameloop();
}
private void gameloop()
{
last = DateTime.Now;
onscreen = this.CreateGraphics();
while (true)
{
offscreen.Clear(Color.White);
if (DateTime.Now - last >= new TimeSpan(0, 0, 0, 1))
{
fps = 0;
last = DateTime.Now;
}
fps++;
rendergame();
}
}
private void rendergame()
{
offscreen.DrawString("fps: " + fps.ToString(), font, fontbrush, 10, 10);
onscreen.DrawImage(backbuffer, 0, 0);
Thread.Sleep(0);
Application.DoEvents();
}
private void Form1_Resize(object sender, EventArgs e)
{
if (backbuffer != null)
backbuffer.Dispose();
backbuffer = new Bitmap(ClientRectangle.Width, ClientRectangle.Height);
offscreen = Graphics.FromImage(backbuffer);
}
protected override void OnPaintBackground(PaintEventArgs e)
{
//Do nothing
}
protected override void OnPaint(PaintEventArgs e)
{
//Do nothing
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
Håber at der er nogen som kan hjælpe.
På forhånd tak.
Xiol