Beispiel #1
0
        private async void timer6_Tick(object sender, EventArgs e)  // floor 0 doors
        {
            if (PictureBox.Top < 300)
            {
                if (btn == true)
                {
                    if (panel2.Width <= 11)
                    {
                        btn = false;
                    }
                    else
                    {
                        await Task.Delay(1000);          // delay doors. works with the keyword "async"

                        panel2.Width = panel2.Width - 1; // open doors
                        panel3.Width = panel3.Width - 1;
                        panel3.Left  = panel3.Left + 1;
                        LiftDown.Stop();                    // stop timer of lift going down
                    }
                }
                else
                {
                    if (panel2.Width >= 138)
                    {
                        FloorZeroDoors.Stop();          // stop the timer for floor 0 doors
                        btn = true;
                    }

                    else
                    {
                        panel2.Width = panel2.Width + 1;            // close doors
                        panel3.Width = panel3.Width + 1;
                        panel3.Left  = panel3.Left - 1;
                    }
                }
            }
        }