示例#1
0
        private void LogoutYesBtn_OnClick(object sender, RoutedEventArgs e)
        {
            TheTeacher = null;
            AttendingStudents.Clear();
            CurrentClassCourse = null;

            new LoginWindow().Show();

            Close();
        }
        private void CalculateSizes()
        {
            NumberOfStudents = AttendingStudents.Count(theStudent => theStudent.IsAttending);
            StudentsLeft     = AttendingStudents.Count(theStudent => !theStudent.AlreadyPicked && theStudent.IsAttending);

            mIsSettingSizes = true;
            GroupSize       = 0;
            NumberOfGroups  = 0;
            mIsSettingSizes = false;

            if (NumberOfStudents > 2)
            {
                GroupSize = 2;
            }
            else
            {
                GroupSize = NumberOfStudents;
            }
        }
        private void GetGroups()
        {
            var theSortedStudents = AttendingStudents.Where(theStudent => theStudent.IsAttending)
                                    .OrderBy(theStudent => Guid.NewGuid());

            int theCurrentGroup = 1;

            foreach (var theStudent in theSortedStudents)
            {
                theStudent.Group = theCurrentGroup;

                ++theCurrentGroup;
                if (theCurrentGroup > NumberOfGroups)
                {
                    theCurrentGroup = 1;
                }
            }

            RefreshStudents();
        }
示例#4
0
        private void SetAttendance(IEnumerable <Guid> aStudentIds)
        {
            if (mAppService.AppState.SelectedSection.AttendingStudents != null)
            {
                return;
            }

            mAppService.AppState.SelectedSection.AttendingStudents = new ObservableCollection <AttendingStudent>();

            foreach (Guid theGuid in aStudentIds)
            {
                var theStudent = mDataService.GetStudent(theGuid);
                if (theStudent != null)
                {
                    AttendingStudents.Add(new AttendingStudent()
                    {
                        Id = theGuid, Name = theStudent.ToString(), IsAttending = true
                    });
                }
            }
        }
示例#5
0
        private void StudentIds_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.OldItems != null)
            {
                var theStudentsToRemove = new List <AttendingStudent>();
                foreach (Guid theGuid in e.OldItems)
                {
                    foreach (var theStudent in AttendingStudents)
                    {
                        if (theStudent.Id == theGuid)
                        {
                            theStudentsToRemove.Add(theStudent);
                        }
                    }
                }

                foreach (var theStudent in theStudentsToRemove)
                {
                    AttendingStudents.Remove(theStudent);
                }
            }

            if (e.NewItems != null)
            {
                foreach (Guid theGuid in e.NewItems)
                {
                    var theStudent = mDataService.GetStudent(theGuid);
                    if (theStudent != null)
                    {
                        AttendingStudents.Add(new AttendingStudent()
                        {
                            Id = theGuid, Name = theStudent.ToString(), IsAttending = true
                        });
                    }
                }
            }
        }
        void HandleTimer_Tick(object sender, EventArgs e)
        {
            LuckyStudent = AttendingStudents.Where(theStudent => !theStudent.AlreadyPicked && theStudent.IsAttending)
                           .OrderBy(theStudent => Guid.NewGuid())
                           .FirstOrDefault();


            if (mCounter > 25 || StudentsLeft == 1)
            {
                if (LuckyStudent != null)
                {
                    LuckyStudent.AlreadyPicked = true;
                }

                CalculateSizes();
                mCounter = 0;
                mTimer.Stop();
                IsBusy = false;
            }
            else
            {
                mCounter++;
            }
        }