예제 #1
0
        /// <summary>
        /// Handles the event when the <see cref="Population"/> property changes.
        /// </summary>
        /// <param name="obj">The <see cref="DependencyObject"/> that owns the property.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> associated with the event.</param>
        private static void OnPopulationChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            FitnessChart fitnessChart = (FitnessChart)obj;

            if (e.OldValue is Population oldPopulation && oldPopulation.Algorithm != null)
            {
                oldPopulation.Algorithm.FitnessEvaluated   -= fitnessChart.Algorithm_FitnessEvaluated;
                oldPopulation.Algorithm.AlgorithmCompleted -= fitnessChart.Algorithm_AlgorithmCompleted;
            }

            if (e.NewValue != null && fitnessChart.Population.Algorithm != null)
            {
                fitnessChart.Population.Algorithm.FitnessEvaluated   += fitnessChart.Algorithm_FitnessEvaluated;
                fitnessChart.Population.Algorithm.AlgorithmCompleted += fitnessChart.Algorithm_AlgorithmCompleted;

                // Whenever the user switches populations, refresh the chart to show the selected population.
                // The population will also be changed when the algorithm is being initialized.  In that case,
                // it may not yet be fully populated so only refresh the chart if its reached the min. pop. size.
                if (fitnessChart.Population.Entities.Count >= fitnessChart.Population.MinimumPopulationSize)
                {
                    fitnessChart.TryInitializeStopwatch();
                    fitnessChart.RefreshChart(true);
                }
            }
            else
            {
                fitnessChart.columnSeries.ItemsSource = null;
                fitnessChart.stopwatch = null;
            }
        }
예제 #2
0
        /// <summary>
        /// Handles the event when the <see cref="FitnessSortOption"/> property changes.
        /// </summary>
        /// <param name="obj">The <see cref="DependencyObject"/> that owns the property.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> associated with the event.</param>
        private static void OnFitnessSortOptionChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            FitnessChart fitnessChart = (FitnessChart)obj;

            fitnessChart.RefreshChart(true);
        }