public BasicCalculationForm(List <SingleCourse> selectedCourses, int numPossib, Random random, int creditAmount,
                                    CourseSelectionForm courseForm, LoadingResultsForm ScheduleSelectForm,
                                    bool isOptimization)
        {
            //References to previous form/worker
            RefToCourseSelectForm = courseForm;
            RefToResultLoadForm   = ScheduleSelectForm;

            //Calculation variables
            this.random          = random;
            this.creditAmount    = creditAmount;
            this.selectedCourses = selectedCourses;
            this.courseAmount    = selectedCourses.Count();
            this.scheduleAmount  = numPossib;
            this.isOptimization  = isOptimization;

            schedulePopulation    = new List <SingleSchedule>(20000);
            this.sectionAmountAll = new List <int>(selectedCourses.Count());
            foreach (var course in selectedCourses)
            {
                sectionAmountAll.Add(course.getSections().Count());
            }

            //Setup Form Content
            InitializeComponent();
        }
        public OptimizationSettingsForm(SingleSchedule oldSchedule, CourseSelectionForm CourseSelectForm, LoadingResultsForm LoadResultsForm)
        {
            //Build references
            RefToCourseSelectForm = CourseSelectForm;
            RefToLoadResultsForm  = LoadResultsForm;
            this.oldSchedule      = oldSchedule;

            InitializeComponent();
            UpdateCheckBoxes(oldSchedule);
        }
        //[FUNCTION - ChooseOptimizationCourses]
        //Adds sections that can be substituted based on user defined settings (revise so courses fit better)
        public void ChooseOptimizationCourses(List <bool> canOptimize, SingleSchedule oldSchedule, LoadingResultsForm ScheduleSelectForm)
        {
            //Create copy of selected courses & set optimization state
            RefToScheduleSelectForm = ScheduleSelectForm;
            List <SingleCourse> selectedCoursesMod = new List <SingleCourse>(selectedCourses.Count());

            foreach (var course in selectedCourses)
            {
                selectedCoursesMod.Add(DeepCopySingleCourse(course));
            }
            isOptimization = true;

            //Add all similar courses to section list (revise to get more accurate substitutions)
            int optimizeCounter = 0;

            foreach (var optimizeOption in canOptimize)
            {
                if (optimizeOption == true)
                {
                    string matchCourseID     = oldSchedule.getAllSections()[optimizeCounter].getID();
                    string matchCourseIDTrim = matchCourseID.Substring(0, matchCourseID.IndexOf("-", 4));
                    string depID             = matchCourseID.Substring(0, matchCourseID.IndexOf("-", 0));
                    string levelID           = matchCourseID.Substring((matchCourseID.IndexOf("-", 0) + 1), 1) + "00";
                    bool   isLab             = matchCourseIDTrim[matchCourseIDTrim.Length - 1] == 'L' ? true : false;
                    Debug.WriteLine("Dep ID: " + depID + " | Level ID: " + levelID + " | Lab State: " + isLab);

                    bool isLabCourse = false;
                    foreach (var course in availableCourses)
                    {
                        isLabCourse = course.getAbrvCourseName()[course.getAbrvCourseName().Length - 1] == 'L' ? true : false;
                        if ((course.getCourseLevel() == levelID && course.getAbrvCourseName().Contains(depID)) &&
                            (course.getAbrvCourseName() != matchCourseID.Substring(0, matchCourseID.IndexOf("-", 4))) &&
                            (isLab == isLabCourse))
                        {
                            foreach (var section in course.getSections())
                            {
                                Debug.WriteLine("Added a suggested section: " + section.getID());
                                selectedCoursesMod[optimizeCounter].getSections().Add(new SingleSection(section, true));
                            }
                        }
                    }
                }
                optimizeCounter++;
            }
            ComputeOptimalTimes(selectedCoursesMod);
        }
        private void BackgroundWorkerSchedules_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (BackgroundWorkerSchedules.IsBusy)
            {
                return;
            }

            if (!isCancelled)
            {
                this.Hide();
                Debug.WriteLine("THERE ARE " + resultSchedules.Count() + " COURSES TO SHOW!");
                if (resultSchedules.Count() != 0)

                {
                    if (RefToResultLoadForm == null)
                    {
                        Debug.WriteLine("NEW RESULT FORM SHOWN");
                        RefToResultLoadForm = new LoadingResultsForm(selectedCourses, resultSchedules, RefToCourseSelectForm);
                    }
                    else
                    {
                        Debug.WriteLine("OLD RESULT FORM SHOWN! IT IS " + (isOptimization == true ? "OPTIMIZED" : "NOT OPTIMIZED"));
                        RefToResultLoadForm.ShowNewScheduleSet(selectedCourses, resultSchedules, isOptimization);
                    }

                    this.Hide();
                    if (!RefToResultLoadForm.Visible)
                    {
                        Debug.WriteLine("Result Form is NOW VISIBLE!");
                        RefToResultLoadForm.ShowDialog();
                    }
                }
                RefToCourseSelectForm.setIsFirstCalculationState(false);
            }

            acceptableSchedulesTemp.Clear();
            overlapSchedulesTemp.Clear();
            acceptableSchedules.Clear();
            overlapSchedules.Clear();
            isCancelled = false;
        }
 public FinalSchedule(LoadingResultsForm loadingResultsForm)
 {
     this.loadingResultsForm = loadingResultsForm;
     InitializeComponent();
 }