I have a problem here. Something I don't understand.
Well isn't OnPaint only called when there is something to paint? But how can you paint something when you don't have the PaintEventArgs. Well this is my OnPint right now. And I need it to be called every time I have moved the ojects on the screen:
But as you see in the last line, I have to call my draw function and pass it the g (the Graphics object to be able to use FillElipse and DrawString.Code:protected override void OnPaint(PaintEventArgs e) { // Set the atributes for the graphics object g = e.Graphics; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; // Draw a circle g.FillRectangle( new SolidBrush(Color.Black), ClientRectangle); g.DrawString("Solsystem", new Font("Courier",32), new SolidBrush(Color.DarkRed), 10,10); foreach (Himmellegeme spaceObject in skyObjects) spaceObject.draw(g);
Code:public override void draw(Graphics g) { g.FillEllipse(new SolidBrush(farge),(float)xpos,(float)ypos,radius*2,radius*2); g.DrawString(name, new Font("Courier",8), new SolidBrush(Color.White),origox+avstand,origoy+radius); }
How am I supposed to think here?




Reply With Quote