// Event for when the user changes their selection in the ResearcherListView
        private void ResearcherListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ResearcherListView.Items.Count > 0 && ResearcherListView.SelectedItem != null)
            {
                Researcher selected = Researchers[ResearcherListView.SelectedIndex];
                ResearcherController.LoadResearcherDetails(selected);
                PublicationController.LoadResearcherPublications(selected);

                SelectedResearcher = selected;

                VisiblePublications   = SelectedResearcher.Publications;
                CumulativePublication = PublicationController.GetCumulativePublicationCount(SelectedResearcher);

                ShowSupervisions    = false;
                ShowCumulativeCount = false;

                // Select the first entry in the list, if there is one
                if (PublicationsListView.Items.Count > 0)
                {
                    PublicationsListView.SelectedIndex = 0;
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            string response;

            Control.ResearcherController   R_Controller = new ResearcherController();
            Control.PublicationsController P_controller = new PublicationsController();
            Researcher.Researcher          res;
            int id;

            R_Controller.LoadReseachers();
            do
            {
                R_Controller.basicConsoleDisplay().ForEach(Console.WriteLine);
                Console.WriteLine("Would you like to a) exit, b) filter by name, c) filter by level, d) reset, e) sort ascending, f) sort descending, g) more info");
                response = Console.ReadLine();
                //Should have used switch but anyway :-)
                if (response == "a")
                {
                }
                else if (response == "b")
                {
                    Console.WriteLine("Please enter name: ");
                    R_Controller.FilterByName(Console.ReadLine());
                }
                else if (response == "c")
                {
                    Console.WriteLine("Please enter Employment Level: ");
                    R_Controller.FilterBy((Researcher.EmploymentLevel)Enum.Parse(typeof(Researcher.EmploymentLevel), Console.ReadLine()));
                }
                else if (response == "d")
                {
                    R_Controller.reset();
                }
                else if (response == "e")
                {
                    R_Controller.sortAlphabetically(true);
                }
                else if (response == "f")
                {
                    R_Controller.sortAlphabetically(false);
                }
                else if (response == "g")
                {
                    Console.WriteLine("Please enter ID: ");
                    id = Int32.Parse(Console.ReadLine());
                    R_Controller.LoadResearcherDetails(id);
                    R_Controller.researcherConsoleDisplay().ForEach(Console.WriteLine);
                    Console.WriteLine("Press a) to exit or b) to display publications: ");
                    if (Console.ReadLine() == "b")
                    {
                        if (R_Controller.isStaff)
                        {
                            res = (Researcher.Researcher)R_Controller.staff;
                        }
                        else
                        {
                            res = (Researcher.Researcher)R_Controller.student;
                        }
                        P_controller.loadPublications(res);
                        P_controller.basicPublicationConsole().ForEach(Console.WriteLine);
                        Console.WriteLine("Press a) to exit or b) to view detailed publication");
                        if (Console.ReadLine() == "b")
                        {
                            Console.WriteLine("Please enter number: ");
                            id = int.Parse(Console.ReadLine());
                            P_controller.loadFullPublications(P_controller.displayList.ToArray()[id]);
                            P_controller.fullPublicationConsole().ForEach(Console.WriteLine);
                            Console.WriteLine("Press enter to continue");
                            Console.ReadLine();
                        }
                    }
                }
            } while (response != "a");
        }
예제 #3
0
        private void researchersListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count > 0)
            {
                researcher = (Researcher)e.AddedItems[0];
                researcher = rc.LoadResearcherDetails(researcher);
                ResearcherDetailsPanel.DataContext = researcher;
                //Show past positions
                positionsListView.Items.Clear();
                foreach (var p in researcher.positions)
                {
                    if (researcher.position.Level != EmploymentLevel.Student && p.End != default(DateTime))
                    {
                        positionsListView.Items.Add(p.Start + "\t" + p.End + "\t" + p.Title() + Environment.NewLine);
                    }
                }


                staff = new Staff(researcher);
                rc.GetViewableStudents();
                students = rc.VisibleStudents.ToList();
                if (researcher.position.Level != EmploymentLevel.Student)
                {
                    threeYear.Content    = staff.ThreeYearAverage;
                    performance.Content  = staff.PerformancePercentage;
                    supervisions.Content = staff.Supervisions;
                }
                else
                {
                    threeYear.Content    = null;
                    performance.Content  = null;
                    supervisions.Content = null;
                }

                if (researcher.position.Level == EmploymentLevel.Student)
                {
                    Student student = (from s in students
                                       where researcher.ID == s.ID
                                       select s).SingleOrDefault();
                    degree.Content = student.Degree;

                    researchers = rc.VisibleResearchers.ToList();

                    var supervisor = (from s in researchers
                                      where s.ID == student.SupervisorID
                                      select s).SingleOrDefault();
                    supervisors.Content = supervisor.GivenName + " " + supervisor.FamilyName;
                }
                else
                {
                    degree.Content      = null;
                    supervisors.Content = null;
                }

                //Show publications
                pc = new PublicationsController(researcher);
                pc.SortPublicationList();
                publications = pc.VisiblePublications.ToList();
                publicationsListView.ItemsSource = publications;
            }
        }