[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.drawing

PictureBox not reload at runtime

juklingos

11/19/2004 5:14:00 PM

Hi all,

I'm writing a graphic application (for simulation) for pocket pc. I
define a picturebox in my form and build up a special background
using my own math functions. Then I need to draw a line and move it
(based on other math function) in that picturebox, keeping of course
the
special background.

My steps are:
draw the background first and then save in memory
draw the line
clean the picturebox
restore the background from memory
draw the line in new position
etc..


Here my code but doesn't work. The background created is fine, but
it's not reload it inside the loop, I can see it only once.
It is not reloaded within the loop, picturebox shows only the line
moving!

Any idea?

Thanks
Juky

Private Sub Simulation()
Dim bitcopy As Bitmap
bitcopy = New Bitmap(Me.PictureBox.Width,
Me.PictureBox.Height)

Me.PictureBox.Image = New Bitmap(Me.PictureBox.Width,
Me.PictureBox.Height)
Dim g As Graphics = Graphics.FromImage(Me.PictureBox.Image)

g.Clear(Color.White)


'DrawBackground with math functions
....
g.DrawLine(Color.Blue, x0,x1,x1,y1)
.....

PictureBox.Refresh()

'save my background
bitcopy = Me.PictureBox.Image

For i = 0 To norm
x0=....
y0=....
x1=....
y1=....

g.DrawLine(blackPen, x0,x1,x1,y1)
PictureBox.Refresh()

g.Clear(Color.White)

'reload background
g.DrawImage(bitcopy, 0, 0)

PictureBox.Refresh()
Next
End Sub