Пример #1
0
        private void up_Click(object sender, EventArgs e)  // floor 0 button
        {
            if (lift_status == 0)
            {
                if (PictureBox.Top > 0)
                {
                    Floor0Doors.Start();            // Open and close floor 0 doors
                }
                label.Text = "0";
            }
            else if (lift_status == 1)
            {
                if (PictureBox.Top <= 300)
                {
                    if ((panel4.Width >= 138) && (panel5.Width <= 150))
                    {
                        lift_status = 0;

                        LiftDown.Start();       // lift goes down
                        FloorOneDoors.Stop();   // stop timer1 door
                        direction = "Lift went down";
                    }

                    label.Text = "0";

                    Level1.BackColor = Color.AliceBlue;
                    Level0.BackColor = Color.AliceBlue;
                    SaveEvent();    // function call of a method that saves event to the database
                }
            }
        }
Пример #2
0
        private async void timer1_Tick(object sender, EventArgs e)   // floor 0 doors
        {
            if (panel2.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 the doors
                        panel3.Width = panel3.Width - 1;
                        panel3.Left  = panel3.Left + 1;
                    }
                }
                else
                {
                    if (panel2.Width >= 138)
                    {
                        Floor0Doors.Stop();             // stop floor 0 doors
                        btn = true;
                    }

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