Esempio n. 1
0
        private void treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            TreeViewItem tvi = (TreeViewItem)e.NewValue;

            if (tvi != null)
            {
                tvi.IsExpanded = !tvi.IsExpanded;

                // This should be the label of the course ID
                //
                StackPanel itemHeader = (StackPanel)((TreeViewItem)((TreeView)sender).SelectedItem).Header;

                // Refresh the course path canvas
                //
                coursePathCanvas.Children.Clear();
                coursePathCanvas.Children.Add(dashLine1);
                coursePathCanvas.Children.Add(dashLine2);
                coursePathCanvas.Children.Add(dashLine3);
                listOfTopCourses.Clear();
                clearListOfY();

                // And the course id take from the label name
                //
                var courseButton = itemHeader.Children.OfType <Button>().FirstOrDefault();

                if (!departmentWindow.isSetProgramme)
                {
                    Course targetCourse = DatabaseConnection.getCourse(courseButton.Content.ToString());
                    if (targetCourse != null)
                    {
                        Utilities.fillCourseInfoDataGrid(courseInfoDataGrid, targetCourse);

                        // Draw the course path
                        //
                        List <Course> relatedPreReq = DatabaseConnection.generateAllRelatedPreRequisites(targetCourse);
                        relatedPreReq.Insert(0, targetCourse);
                        foreach (Course course in relatedPreReq)
                        {
                            setCoursePath(course.id);
                        }
                    }
                    else
                    {
                        Logger.Error("ProgrammeWindow::treeView_SelectedItemChanged() Target Course could not be found in the database.");
                    }
                }
            }
        }
Esempio n. 2
0
        private void courseItemAction(object sender, System.Windows.RoutedEventArgs e)
        {
            Button button = (Button)e.Source;

            // Refresh the course path canvas
            //
            coursePathCanvas.Children.Clear();
            coursePathCanvas.Children.Add(dashLine1);
            coursePathCanvas.Children.Add(dashLine2);
            coursePathCanvas.Children.Add(dashLine3);
            listOfTopCourses.Clear();
            clearListOfY();

            // Draw the course path
            //
            try
            {
                Course targetCourse = DatabaseConnection.getCourse(button.Content.ToString());
                if (targetCourse != null)
                {
                    Utilities.fillCourseInfoDataGrid(courseInfoDataGrid, targetCourse);

                    List <Course> relatedPreReq = DatabaseConnection.generateAllRelatedPreRequisites(targetCourse);
                    relatedPreReq.Insert(0, targetCourse);
                    foreach (Course course in relatedPreReq)
                    {
                        setCoursePath(course.id);
                    }
                }
                else
                {
                    Logger.Error("ProgrammeWindow::courseItemAction() Target Course could not be found in the database.");
                }
            }
            catch (Exception ex)
            {
                Logger.Error("ProgrammeWindow::courseItemAction() " + ex.Message);
            }
        }