Quantcast
Channel: CSharp Forum Latest Questions
Viewing all articles
Browse latest Browse all 32747

Using event to switch between photos

$
0
0
Hello,

I have 2 forms with 2 pictureBoxs, showing photos.

In the forms there is timer set to 10Sec.

In those 10Sec, the viewer can Key press for an answer.

Right after key press, I would like to switch between the forms (no regarding to the remaining time), and restart the timer..

How can I do that?

I've created timer1, timer2 in Form1, Here is the code in Form1:

    private void timer1_Tick(object sender, EventArgs e)
            {
                if (!stopSlideshow)
                {
                    timer1.Stop();
                    timer2.Start();
                    form2.Show();
                    form2.startTimer();
                    this.Hide();
                }
            }
   
            private void timer2_Tick_1(object sender, EventArgs e)
            {
                if (!stopSlideshow)
                {
                        pictureBox1.Image = getPicture();
                        timer2.Stop();
                        timer1.Start();
                }
            }


And timer1 in form 2, Here is the code in Form2:

     public void startTimer()
            {
                timer1.Start();           
            }
   
            private void timer1_Tick_1(object sender, EventArgs e)
            {
                timer1.Stop();
                this.Hide();
                Form1.F1.Show(); 
            }

Tick Event is timer1_Tick_1.

I already used the "Keydown" event to save the viewer's answer.

Thanks!

Viewing all articles
Browse latest Browse all 32747

Trending Articles