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 } } }
private void Level0_Click(object sender, EventArgs e) // button 0 { if (PictureBox.Top < 300) { if ((panel4.Width >= 138) && (panel5.Width <= 150)) { LiftDown.Start(); // lift goes down lift_status = 0; FloorOneDoors.Stop(); // stop timer for floor 1 direction = "Lift went down"; } label.Text = "0"; Level0.BackColor = Color.Red; Level1.BackColor = Color.AliceBlue; SaveEvent(); // function call of a method that saves event to the database } }
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; } } } }