public void ShowSimulatingScreen() { SimulatedScreen = new SimulatingScreen(mainSim); SimulatedScreen.StartPosition = FormStartPosition.Manual; SimulatedScreen.Size = pnlLayout1.Size; SimulatedScreen.Location = new Point(this.Location.X + 92, this.Location.Y + 100); //SimulatedScreen=SimulatingScreen.instance //SimulatedScreen.TopLevel = false; //pnlLayout1.Controls.Add(SimulatedScreen); //SimulatedScreen.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; //SimulatedScreen.Dock = DockStyle.Fill; SimulatedScreen.Show(this); }
public void StartSim(SimulatingScreen FormScreen) { this.FormScreen = FormScreen; hall1.HallConfiguration(); listSeats = hall1.Seats(); doors = hall1.Doors(); shops = hall1.Shops(); GenratedCustomers(amount); AssignCustomerSeats(); for (int i = 0; i < hall1.GetRow(); i++) { for (int j = 0; j < hall1.GetColumn(); j++) { System.Windows.Forms.Panel p = new System.Windows.Forms.Panel(); p.Location = new System.Drawing.Point(listSeats[i, j].seatPositionX, listSeats[i, j].seatPositionY); p.Size = new System.Drawing.Size(listSeats[i, j].SHeight, listSeats[i, j].SWidth); p.BackColor = listSeats[i, j].seatColour; FormScreen.Controls.Add(p); } } for (int i = 0; i < hall1.GetDoorAmount(); i++) { System.Windows.Forms.Panel p = new System.Windows.Forms.Panel(); p.Location = new System.Drawing.Point(doors[i].DoorPositionX, doors[i].DoorPositionY); p.Size = new System.Drawing.Size(doors[i].DoorWidth, doors[i].DoorHeight); p.BackColor = System.Drawing.Color.Tomato; FormScreen.Controls.Add(p); } for (int i = 0; i < hall1.GetShopsAmount(); i++) { System.Windows.Forms.Panel p = new System.Windows.Forms.Panel(); p.Location = new System.Drawing.Point(shops[i].shopsPositionX, shops[i].shopsPositionY); p.Size = new System.Drawing.Size(shops[i].shopsWidth, shops[i].shopsHeight); p.BackColor = System.Drawing.Color.BlueViolet; FormScreen.Controls.Add(p); } generateCustomer(); }
//public static bool StopTimer = false; public void goToShop(int amount, List <System.Windows.Forms.Panel> users, Shops[] shops, Seat[,] listSeats, List <Customer> customers, SimulatingScreen FormScreen) { for (int i = 0; i < amount; i++) { if (customers[i].hungry == true) { if (users[i].Top < shops[customers[i].Shopss].shopsPositionY - shops[customers[i].Shopss].shopsHeight) { if (i != 0 && users[i].Bottom >= users[i - 1].Top && users[i].Left >= users[i - 1].Left) { users[i].Top += 0; } else { //users[i].Top +=customers[i].speed; users[i].Top += spd; } } else { if (users[i].Left > shops[customers[i].Shopss].shopsPositionX) { users[i].Left -= 1; } else if (users[i].Left == shops[customers[i].Shopss].shopsPositionX) { while (users[i].Top < shops[customers[i].Shopss].shopsPositionY && boolStopShop == true) { users[i].Top += 1; //shoppp users[i].BringToFront(); } } } if (users[i].Top < listSeats[customers[i].SeatRow, customers[i].seatColumn].seatPositionY - listSeats[customers[i].SeatRow, customers[i].seatColumn].SHeight) { if (i != 0 && users[i].Bottom >= users[i - 1].Top && users[i].Left >= users[i - 1].Left) { users[i].Top += 0; } else { //users[i].Top += customers[i].speed; users[i].Top += spd; } } else { if (users[i].Left < listSeats[customers[i].SeatRow, customers[i].seatColumn].seatPositionX) { users[i].Left += 2; } else if (users[i].Left == listSeats[customers[i].SeatRow, customers[i].seatColumn].seatPositionX) { while (users[i].Top < listSeats[customers[i].SeatRow, customers[i].seatColumn].seatPositionY) { users[i].Top += 1; if (users[i].Top == listSeats[customers[i].SeatRow, customers[i].seatColumn].seatPositionY) { users[i].BringToFront(); visitorCounter++; System.Windows.Forms.Label lbl = ((Form1)FormScreen.Owner).NrShopVistor; lbl.Text = Convert.ToString(visitorCounter + " person(s) visted Shop"); //StopTimer = true; // seatCounter++; } } } } } else { if (users[i].Top < listSeats[customers[i].SeatRow, customers[i].seatColumn].seatPositionY - listSeats[customers[i].SeatRow, customers[i].seatColumn].SHeight) { if (i != 0 && users[i].Bottom >= users[i - 1].Top && users[i].Left >= users[i - 1].Left) { users[i].Top += 0; } else { // users[i].Top +=customers[i].speed; users[i].Top += spd; //IncreaseSimulationSpeed(); } } else { if (users[i].Left < listSeats[customers[i].SeatRow, customers[i].seatColumn].seatPositionX) { users[i].Left += 1; } else if (users[i].Left == listSeats[customers[i].SeatRow, customers[i].seatColumn].seatPositionX) { while (users[i].Top < listSeats[customers[i].SeatRow, customers[i].seatColumn].seatPositionY) { users[i].Top += 1; //IncreaseSimulationSpeed(); if (users[i].Top == listSeats[customers[i].SeatRow, customers[i].seatColumn].seatPositionY) { users[i].BringToFront(); } } } } } SeatCounter = i + 1; } System.Windows.Forms.Label lblSeat = ((Form1)FormScreen.Owner).seatsFilled; lblSeat.Text = Convert.ToString(SeatCounter); }