public MonitorViewModel(IAdminList adminList, ICourseList courseList)
 {
     this.adminList  = adminList;
     this.courseList = courseList;
     this.ConfigureDefaultCourses();
     this.SelectedCourses = new List <string>();
 }
Ejemplo n.º 2
0
        private void AllCoursesListView__ItemActivate(object sender, EventArgs e)
        {
            // this is the Event Handler for the mouse double-click on a row of the ListView

            Course   course     = null;
            ListView lv         = (ListView)sender;
            string   courseCode = null;

            // 39. get the courseCode from the currently selected row
            courseCode = lv.SelectedItems[0].Tag.ToString();

            // 40. get the course object associated with this courseCode from Globals.courses SortedList
            course = Globals.courses[courseCode];

            ICourseList iCourseList = (ICourseList)formPerson;

            if (course != null)
            {
                if (iCourseList.CourseList.Contains(course.courseCode))
                {
                    iCourseList.CourseList.Remove(course.courseCode);
                }
                else
                {
                    iCourseList.CourseList.Add(course.courseCode);
                }

                PaintListView(this.selectedCoursesListView);
            }
        }
Ejemplo n.º 3
0
 public CourseListPresenter(ICourseList view, CourseDataAccess model)
 {
     this.view  = view;
     this.model = model;
     this.view.searchHandler += Search;
     LoadAllCourses();
 }
Ejemplo n.º 4
0
        private void ScheduleWebBrowser__DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            WebBrowser  wb = (WebBrowser)sender;
            HtmlElement htmlElement;
            Course      course;

            ICourseList iCourseList = (ICourseList)formPerson;

            string htmlId = null;

            foreach (string courseCode in iCourseList.CourseList)
            {
                course = Globals.courses[courseCode];

                foreach (DayOfWeek dayOfWeek in course.schedule.daysOfWeek)
                {
                    switch (dayOfWeek)
                    {
                    case DayOfWeek.Sunday:
                    case DayOfWeek.Monday:
                    case DayOfWeek.Tuesday:
                    case DayOfWeek.Wednesday:
                    case DayOfWeek.Friday:
                        htmlId = (dayOfWeek.ToString())[0].ToString();
                        break;

                    case DayOfWeek.Thursday:
                        htmlId = "R";
                        break;

                    case DayOfWeek.Saturday:
                        htmlId = "A";
                        break;
                    }

                    htmlId += $"{course.schedule.startTime:HH}";

                    htmlElement = wb.Document.GetElementById(htmlId);

                    if (htmlElement != null)
                    {
                        htmlElement.InnerText = course.courseCode;
                        htmlElement.Style    += "background-color:red;";

                        htmlElement.MouseDown += new HtmlElementEventHandler(HtmlElement__MouseDown);
                        htmlElement.MouseOver += new HtmlElementEventHandler(HtmlElement__MouseOver);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void AllCoursesListView__KeyDown(object sender, KeyEventArgs e)
        {
            // this is the Event Handler for pressing Enter on a row of the ListView

            Course   course     = null;
            ListView lv         = (ListView)sender;
            string   courseCode = null;

            // if Enter was pressed, we will handle it
            if (e.KeyCode == Keys.Enter)
            {
                // remove the key from the keyboard buffer, we handled it
                e.SuppressKeyPress = true;

                try
                {
                    // get the courseCode from the currently selected row
                    courseCode = lv.SelectedItems[0].Tag.ToString();

                    // get the course object associated with this courseCode from Globals.courses
                    course = Globals.courses[courseCode];

                    if (course != null)
                    {
                        ICourseList iCourseList = (ICourseList)formPerson;

                        if (iCourseList.CourseList.Contains(course.courseCode))
                        {
                            iCourseList.CourseList.Remove(course.courseCode);
                        }
                        else
                        {
                            iCourseList.CourseList.Add(course.courseCode);
                        }

                        PaintListView(this.selectedCoursesListView);
                    }
                }
                catch
                {
                }
            }
        }
 public QueryViewModel(IQueryList repository, ICourseList courseListRepository)
 {
     this.repository           = repository;
     this.courseListRepository = courseListRepository;
 }
Ejemplo n.º 7
0
        private void OkButton__Click(object sender, EventArgs e)
        {
            Student student = null;
            Teacher teacher = null;
            Person  person  = null;

            Globals.people.Remove(this.formPerson.email);

            ICourseList iCourseList = (ICourseList)formPerson;

            if (this.typeComboBox.SelectedIndex == 0)
            {
                student             = new Student();
                student.courseCodes = iCourseList.CourseList;
                person = student;
            }
            else
            {
                teacher             = new Teacher();
                teacher.courseCodes = iCourseList.CourseList;
                person = teacher;
            }


            person.name        = this.nameText.Text;
            person.email       = this.emailText.Text;
            person.age         = Convert.ToInt32(this.ageText.Text);
            person.LicenseId   = Convert.ToInt32(this.licText.Text);
            person.homePageURL = this.homepageTextBox.Text;
            person.dateOfBirth = this.birthDateTimePicker.Value;
            person.photoPath   = this.photoPictureBox.ImageLocation;

            if (this.herRadioButton.Checked)
            {
                person.eGender = genderPronoun.her;
            }

            if (this.himRadioButton.Checked)
            {
                person.eGender = genderPronoun.him;
            }

            if (this.themRadioButton.Checked)
            {
                person.eGender = genderPronoun.them;
            }

            if (person.GetType() == typeof(Student))
            {
                student.gpa = Convert.ToDouble(this.gpaText.Text);

                if (this.froshRadioButton.Checked)
                {
                    student.eCollegeYear = collegeYear.freshman;
                }

                if (this.sophRadioButton.Checked)
                {
                    student.eCollegeYear = collegeYear.sophomore;
                }

                if (this.juniorRadioButton.Checked)
                {
                    student.eCollegeYear = collegeYear.junior;
                }

                if (this.seniorRadioButton.Checked)
                {
                    student.eCollegeYear = collegeYear.senior;
                }
            }
            else
            {
                teacher.specialty = this.specText.Text;
            }

            Globals.people[person.email] = person;


            if (this.Owner != null)
            {
                // enable the parent form
                this.Owner.Enabled = true;

                // and set it into focus to process mouse and keyboard events
                this.Owner.Focus();

                try
                {
                    // repaint the parent form's ListView control with the edited person at the top of the screen
                    IListView iListView = (IListView)this.Owner;
                    iListView.PaintListView(person.email);
                }
                catch
                {
                }
            }

            // set the public class formPerson variable to the updated person object
            // for access to the updated details outside of the class
            formPerson = person;

            // hide the form instead of closing it so that the form persists in memory
            this.Hide();

            // close and dispose of this instance of the PersonEdit Form
            // note that these must come at the end since they clear and release the form data
            //this.Close();
            //this.Dispose();
        }
Ejemplo n.º 8
0
        public void PaintListView(ListView lv)
        {
            // redraws the ListView based on the current contents of courses
            // and whether to start the current page of courses with firstCourseCode
            // passed in as a parameter
            ListViewItem lvi = null;

            ListViewItem.ListViewSubItem lvsi = null;


            // 12. clear the listview items
            lv.Items.Clear();

            // 13. lock the listview to begin updating it
            lv.BeginUpdate();

            int lviCntr = 0;

            // 14. loop through all courses in Globals.courses.sortedList and insert them in the ListView
            foreach (KeyValuePair <string, Course> keyValuePair in Globals.courses.sortedList)
            {
                Course thisCourse = null;

                // 15. set thisCourse to the Value in the current keyValuePair
                thisCourse = keyValuePair.Value;

                if (lv == selectedCoursesListView)
                {
                    ICourseList iCourseList = (ICourseList)formPerson;

                    if (!iCourseList.CourseList.Contains(thisCourse.courseCode))
                    {
                        continue;
                    }
                }
                else
                {
                    if (courseSearchTextBox.TextLength > 0)
                    {
                        if (!thisCourse.courseCode.Contains(courseSearchTextBox.Text) &&
                            !thisCourse.description.Contains(courseSearchTextBox.Text))
                        {
                            continue;
                        }
                    }
                }


                // 16. create a new ListViewItem named lvi
                lvi = new ListViewItem();

                // 17. set the first column of this row to show thisCourse.courseCode
                lvi.Text = thisCourse.courseCode;

                // 18. set the Tag property for this ListViewItem to the courseCode
                lvi.Tag = thisCourse.courseCode;

                // alternate row color
                if (lviCntr % 2 == 0)
                {
                    lvi.BackColor = Color.LightBlue;
                }
                else
                {
                    lvi.BackColor = Color.Beige;
                }


                // 19. create a new ListViewItem.ListViewSubItem named lvsi for the next column
                lvsi = new ListViewItem.ListViewSubItem();

                // 20. set the column to show thisCourse.description
                lvsi.Text = thisCourse.description;

                // 21. add lvsi to lvi.SubItems
                lvi.SubItems.Add(lvsi);


                // 22. create a new ListViewItem.ListViewSubItem named lvsi for the next column
                lvsi = new ListViewItem.ListViewSubItem();

                // 23. set the column to show thisCourse.teacherEmail
                lvsi.Text = thisCourse.teacherEmail;

                // 24. add lvsi to lvi.SubItems
                lvi.SubItems.Add(lvsi);


                // 25. create a new ListViewItem.ListViewSubItem named lvsi for the next column
                lvsi = new ListViewItem.ListViewSubItem();

                // 26. set the column to show thisCourse.schedule.DaysOfWeek()
                // note that thisCourse.schedule.DaysOfWeek() returns the string that we want to display
                lvsi.Text = thisCourse.schedule.DaysOfWeek();

                // 27. add lvsi to lvi.SubItems
                lvi.SubItems.Add(lvsi);


                // 28. create a new ListViewItem.ListViewSubItem named lvsi for the next column
                lvsi = new ListViewItem.ListViewSubItem();

                // 29. set the column to show thisCourse.schedule.GetTimes()
                // note that thisCourse.schedule.GetTimes() returns the string that we want to display
                lvsi.Text = thisCourse.schedule.GetTimes();

                // 30. add lvsi to lvi.SubItems
                lvi.SubItems.Add(lvsi);

                // 35. lvi is all filled in for all columns for this row so add it to courseListView.Items
                lv.Items.Add(lvi);

                // 36. increment our counter to alternate colors and check for nStartEl
                ++lviCntr;
            }


            // 37. unlock the ListView since we are done updating the contents
            lv.EndUpdate();
        }
 public AdminViewModel(ICourseList courseList, IAdminList adminList)
 {
     this.courseList = courseList;
     this.adminList  = adminList;
 }
 public AdminAddCourseWindowViewModel(ICourseList courseList)
 {
     this.courseList = courseList;
 }