Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        private void unseatRandomStudent()
        {
            if (occupiedDesks.Count <= 0)
            {
                return;
            }
            ClassroomSpotControl desk = occupiedDesks.First();

            StudentListbox.appendStudentList(new List <Student> {
                desk.Occupant
            });
            desk.Occupant = null;
        }
Beispiel #4
0
 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();
 }
Beispiel #5
0
        private Point getClassroomSpotLocation(int x, int y)
        {
            Size classroomSpotSize = new ClassroomSpotControl().Size;

            return(new Point(x * classroomSpotSize.Width, y * classroomSpotSize.Height));
        }