How do I move a picture from top to bottom and then get it in other coordinates?
I will explain my problem more clearly: I want the image to start at the top right corner of the form and go down, then appear at the top in other coordinates, for example (370,0), and go down again.
I wrote the code, but it just goes down and I don't know how to proceed.
What I have tried:
public moving()
{
InitializeComponent();
timer = new System.Threading.Timer(Callback, null, 0, 50);
}
private void Callback(object state)
{
BeginInvoke((MethodInvoker)delegate
{
pictureBox1.Location = new Point(0, pictureBox1.Location.Y + dtY);
// when it touches the bottom of the container
if (pictureBox1.Location.Y + pictureBox1.Size.Height >
pictureBox1.Parent.Height)
{
// we already reset once, so no more going back up: stop the timer
if (resetOnce)
{
timer.Change(Timeout.Infinite, Timeout.Infinite);
}
// we did not reset yet, so go to other coordinates for example(370,0)
else
{
resetOnce = true;
pictureBox1.Location = new Point(370,0);
}
}
});