src/GenFx.Wpf/Controls/FitnessChart.xaml.cs
/// <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>
Handles the event when the  property changes.
Handles the event when the property changes .
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;
                if (fitnessChart.Population.Entities.Count >= fitnessChart.Population.MinimumPopulationSize)
                {
                    fitnessChart.TryInitializeStopwatch();
                    fitnessChart.RefreshChart(true);
                }
            }
            else
            {
                fitnessChart.columnSeries.ItemsSource = null;
                fitnessChart.stopwatch = null;
            }
        }
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 ; if ( fitnessChart . Population . Entities . Count >= fitnessChart . Population . MinimumPopulationSize ) { fitnessChart . TryInitializeStopwatch ( ) ; fitnessChart . RefreshChart ( true ) ; } } else { fitnessChart . columnSeries . ItemsSource = null ; fitnessChart . stopwatch = null ; } }
Handles the event when the  property changes.
Handles the event when the property changes .
// 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.
obj
DependencyObject
The  that owns the property.
The that owns the property .
e
DependencyPropertyChangedEventArgs
The  associated with the event.
The associated with the event .