//checks history eligibility and prerequisites for courses
        public void AddCourseHistory(CourseHistory history)
        {
            History = history;

            var majors = CheckEligible(MajorHandler.Majors.ToArray(), 3);

            majors = CheckEligible(majors, 2);
            majors = CheckEligible(majors, 1);

            foreach (var major in majors)
            {
                cbxMajors.Items.Add(major.Name);
            }

            var matrix = History.GetPrerequisitesAsMatrix();

            for (var i = 0; i < history.Courses.Count; i++)
            {
                var currentYear = history.Courses[i];
                for (var j = 0; j < currentYear.Count; j++)
                {
                    var currentCourse = currentYear[j];

                    var newControl = new CourseControl(currentCourse, true)
                    {
                        VerticalAlignment   = VerticalAlignment.Top,
                        HorizontalAlignment = HorizontalAlignment.Left,
                        Width   = 150,
                        Height  = 60,
                        ToolTip = currentCourse.Id
                    };

                    newControl.Margin = new Thickness
                    {
                        Left   = j * (newControl.Width + 5),
                        Top    = i * (newControl.Height + 150),
                        Bottom = 0,
                        Right  = 0
                    };

                    MainGrid.Children.Add(newControl);

                    maoa[i].Add(newControl);
                }
            }

            for (var i = 0; i < matrix.Count; i++)
            {
                var currentYear = matrix[i];
                for (var j = 0; j < currentYear.Count; j++)
                {
                    var currentMatrix = currentYear[j];

                    var x1 = maoa[i][currentMatrix[0]].Margin.Left + maoa[i][currentMatrix[0]].Width / 2;
                    var x2 = maoa[currentMatrix[2]][currentMatrix[1]].Margin.Left + maoa[currentMatrix[2]][currentMatrix[1]].Width / 2;
                    var y1 = maoa[i][currentMatrix[0]].Margin.Top + maoa[i][currentMatrix[0]].Height;
                    var y2 = maoa[currentMatrix[2]][currentMatrix[1]].Margin.Top;

                    var newLine = new Line
                    {
                        X1              = x1,
                        X2              = x2,
                        Y1              = y1,
                        Y2              = y2,
                        Stroke          = Brushes.LightSteelBlue,
                        StrokeThickness = 2
                    };

                    MainGrid.Children.Add(newLine);
                }
            }
        }
Beispiel #2
0
        //sends user to next window
        private void BtnSubmit_Click(object sender, RoutedEventArgs e)
        {
            var history = new CourseHistory();

            foreach (var current in Year1Controls)
            {
                if (!current.Clicked)
                {
                    continue;
                }

                foreach (var course in CourseHandler.Courses)
                {
                    if (course.Id != current.Id)
                    {
                        continue;
                    }

                    history.Add(course, 1);
                }
            }

            foreach (var current in Year2Controls)
            {
                if (!current.Clicked)
                {
                    continue;
                }

                foreach (var course in CourseHandler.Courses)
                {
                    if (course.Id != current.Id)
                    {
                        continue;
                    }

                    history.Add(course, 2);
                }
            }

            foreach (var current in Year3Controls)
            {
                if (!current.Clicked)
                {
                    continue;
                }

                foreach (var course in CourseHandler.Courses)
                {
                    if (course.Id != current.Id)
                    {
                        continue;
                    }

                    history.Add(course, 3);
                }
            }

            MainWindow.Instance.MajorsControl.AddCourseHistory(history);

            MainWindow.Instance.UpdateWindow((int)UiControls.MajorSelection);
        }