public void loadStudents(List <Student> students, StudentStatesQuerier studentStatesQuerier)
 {
     clearStudents();
     foreach (var student in students)
     {
         addStudent(student, studentStatesQuerier.getStudentState(student));
     }
     alterRowAndColumnCount();
 }
Ejemplo n.º 2
0
        public StudentsConsolePanel(McrFactory mcrFactory,
                                    SessionStatesQuerier sessionStatesQuerier,
                                    StudentStatesQuerier studentsQuerier,
                                    LoggerView loggerView) : this()
        {
            this.mcrFactory           = mcrFactory;
            this.sessionStatesQuerier = sessionStatesQuerier;
            this.studentStatesQuerier = studentsQuerier;
            this.loggerView           = loggerView;
            this.studentsInfoTableLayoutPanel.onStudentCellClicked = this.StudentCell_Clicked;

            presenter = new StudentsConsolePresenter(mcrFactory.createMcrRepository());
            presenter.setStudentsConsoleView(this);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// For enhancing the speed, this method does all computations in another thread.
        /// Update the student if (1) he's not in the table (2) he's state is changed.
        /// Should still be enhanced though.
        /// </summary>
        private void addOrUpdateStudents(List <Student> students, StudentStatesQuerier studentStatesQuerier)
        {
            var cellTable = studentsInfoTableLayoutPanel.cellTable;

            Task.Factory.StartNew(() =>
            {
                foreach (var student in students)
                {
                    var state = invokeOnMainThread(() => studentStatesQuerier.getStudentState(student));
                    if (!cellTable.ContainsKey(student))
                    {
                        invokeOnMainThread(() => studentsInfoTableLayoutPanel.addStudent(student, state));
                    }
                    else if (cellTable[student].state != state)  // update only if the state changed.
                    {
                        invokeOnMainThread(() => cellTable[student].state = state);
                    }
                }
            });
        }