Exemplo n.º 1
0
        private async void btnRunAlgorithm_Click(object sender, RoutedEventArgs e)
        {

            btnRunAlgorithm.IsEnabled = false;
            if (!allowUserInteraction) return;
            allowUserInteraction = false;

            try
            {


                AnimateStatusObjectModel model = new AnimateStatusObjectModel();

                Infrastructures.Algorithm.MainAlgorithm mainAlgorithm = new Infrastructures.Algorithm.MainAlgorithm(maxCntSuggestion);

                Task.Run(() => { mainAlgorithm.Run(offeredCourses, mainCurriculum, minUnits, maxUnits, exampCollideChecking, Properties.Settings.Default.AlgorithmMaxProcessingTimeMS, model); });


                await AlgorithmAnimation.Animate(this, canvasAlgorithmMsg, Properties.Settings.Default.AlgorithmAnimationEffectStatus, model);

                Directory.EnumerateFiles(DirectoryManager.LastAlgorithmExeOutputs).ToList().ForEach(c =>
                {
                    File.Delete(c);
                });

                mainAlgorithm.ChoosedWeeklyProgram.Sort();
                for (int i = 0; i < mainAlgorithm.ChoosedWeeklyProgram.Count; i++)
                {
                    var p = mainAlgorithm.ChoosedWeeklyProgram[i];

                    OfferedWeeklyProgram newProgram = new OfferedWeeklyProgram();
                    newProgram.DataSource = new List<GoalVersionOfferedCoursesRow>();
                    int units = 0;
                    DfsTopologicalSortAlgorithm.DfsTopologicalSort(p.WeeklyProgram.Columns).ForEach(c =>
                    {
                        newProgram.DataSource.Add(c.GoalVersionOfferedCourseRow);
                        units += c.OfferedCourse.Course.Units;
                    });
                    newProgram.Description = "";
                    newProgram.NumberOfUnits = units;
                    newProgram.UserScore = 0;
                    newProgram.TermNumber = termNumber;
                    newProgram.Score = p.WeeklyProgramScore;

                    string name = Guid.NewGuid().ToString();
                    FileServiceProvider.SerializeToXmlFile(DirectoryManager.LastAlgorithmExeOutputs + name + ".xml", newProgram);
                    Thread.Sleep(10);
                }
            }
            catch { }

            allowUserInteraction = true;
            btnRunAlgorithm.IsEnabled = true;
        }
Exemplo n.º 2
0
        private void AnimationFramework_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this) == false)
            {
                index     = 0;
                ide       = 0;
                Animation = new AlgorithmAnimation(this.ActualWidth, this.ActualHeight);

                holVan         = Allapotok.Helyen;
                timer          = new DispatcherTimer();
                timer.Interval = new TimeSpan(0, 0, 0, 0, 1);
                timer.Tick    += Timer_Tick;
                count          = 0;
                ThreadStart bubblethreadStart = new ThreadStart(Bubblesort);
                Thread      bubblethread      = new Thread(bubblethreadStart);

                bubblethread.Start();
                this.InvalidateVisual();
            }
        }