private void down_Click(object sender, EventArgs e) // floor 1 { if (lift_status == 0) { if (PictureBox.Top > 0) { lift_status = 1; LiftUp.Start(); // lift goes up if it was in floor 0 direction = "Lift went up"; } SaveEvent(); // function call of a method that saves event to the database } else if (lift_status == 1) { if (PictureBox.Top <= 300) { if ((panel4.Width >= 138) && (panel5.Width <= 150)) { Floor1Doors.Start(); // stop the timers for floor 1 doors FloorOneDoors.Stop(); } label.Text = "1"; Level1.BackColor = Color.AliceBlue; Level0.BackColor = Color.AliceBlue; } } }
private void timer2_Tick(object sender, EventArgs e) // lift goes up { if (PictureBox.Top > 0) { lift_status = 1; PictureBox.Top = PictureBox.Top - 5; // moves up by 5 ProgressBar.Top = ProgressBar.Top - 5; } else if (PictureBox.Top < 300) { Floor1Doors.Start(); // when lift is up, open and close the floor1 doors } }
private void Level1_Click(object sender, EventArgs e) { if (PictureBox.Top > 0) { if ((panel2.Width >= 138) && (panel3.Width <= 150)) { LiftUp.Start(); // lift goes up Floor1Doors.Stop(); // stop floor 1 doors lift_status = 1; direction = "Lift went up"; SaveEvent(); // function call of a method that saves event to the database } label.Text = "1"; Level1.BackColor = Color.Red; Level0.BackColor = Color.AliceBlue; } }
private async void timer3_Tick(object sender, EventArgs e) // floor 1 doors { if (PictureBox.Top < 300) { if (btn == true) { if (panel4.Width <= 11) { btn = false; } else { await Task.Delay(1500); // delay doors. works with the keyword "async" panel4.Width = panel4.Width - 1; // open doors panel5.Width = panel5.Width - 1; panel5.Left = panel5.Left + 1; LiftUp.Stop(); // stop the timer for lift up } } else { if (panel4.Width >= 138) { Floor1Doors.Stop(); // stop the timer for floor 1 doors btn = true; } else { panel4.Width = panel4.Width + 1; // close doors panel5.Width = panel5.Width + 1; panel5.Left = panel5.Left - 1; } } } }