private void seatRandomStudent() { ClassroomSpotControl[] unoccupiedDeskArray = unoccupiedDesks.ToArray(); int deskIndex = random.Next(0, unoccupiedDeskArray.Length); ClassroomSpotControl desk = unoccupiedDeskArray[deskIndex]; int studentIndex = random.Next(0, StudentListbox.Students.Count); desk.Occupant = StudentListbox.popStudent(studentIndex); }
private void addClassroomSpot(int x, int y, ClassroomSpot data = null) { ClassroomSpotControl newSpot = new ClassroomSpotControl(); newSpot.subscribeToDeskChange(updateDeskState); newSpot.Location = getClassroomSpotLocation(x, y); newSpot.UpdateSpot(new Point(x, y), data?.Occupant, (data != null)); StudentListbox.removeStudentList(new List <Student>() { data?.Occupant }); ClassroomSpotsPanel.Controls.Add(newSpot); }
private void unseatRandomStudent() { if (occupiedDesks.Count <= 0) { return; } ClassroomSpotControl desk = occupiedDesks.First(); StudentListbox.appendStudentList(new List <Student> { desk.Occupant }); desk.Occupant = null; }
private void updateDeskState(ClassroomSpotControl desk, bool seat, bool occupied) { if (!seat) { occupiedDesks.Remove(desk); unoccupiedDesks.Remove(desk); } else { if (occupied) { unoccupiedDesks.Remove(desk); occupiedDesks.Add(desk); } else { occupiedDesks.Remove(desk); unoccupiedDesks.Add(desk); } } refreshDeskCount(); }
private Point getClassroomSpotLocation(int x, int y) { Size classroomSpotSize = new ClassroomSpotControl().Size; return(new Point(x * classroomSpotSize.Width, y * classroomSpotSize.Height)); }