Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5206


Ignore:
Timestamp:
01/04/11 02:09:55 (14 years ago)
Author:
cneumuel
Message:

#1361 fixed deregistration of events on parameter values

Location:
trunk/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs

    r4722 r5206  
    249249      base.Problem_OperatorsChanged(sender, e);
    250250    }
     251    void ElitesParameter_ValueChanging(object sender, EventArgs e) {
     252      Elites.ValueChanged -= new EventHandler(Elites_ValueChanged);
     253    }
    251254    private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
    252255      Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
     
    256259      ParameterizeSelectors();
    257260    }
     261
     262    void PopulationSizeParameter_ValueChanging(object sender, EventArgs e) {
     263      PopulationSize.ValueChanged -= new EventHandler(PopulationSize_ValueChanged);
     264    }
    258265    private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
    259266      PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
     
    272279    #region Helpers
    273280    private void Initialize() {
     281      PopulationSizeParameter.ValueChanging += new EventHandler(PopulationSizeParameter_ValueChanging);
    274282      PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged);
    275283      PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
     284      ElitesParameter.ValueChanging += new EventHandler(ElitesParameter_ValueChanging);
    276285      ElitesParameter.ValueChanged += new EventHandler(ElitesParameter_ValueChanged);
    277286      Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IValueParameter.cs

    r4332 r5206  
    2626    IItem Value { get; set; }
    2727    bool GetsCollected { get; set; }
     28    event EventHandler ValueChanging;
    2829    event EventHandler ValueChanged;
    2930    event EventHandler GetsCollectedChanged;
  • trunk/sources/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs

    r4722 r5206  
    5454        if (value != this.value) {
    5555          if ((value != null) && !validValues.Contains(value)) throw new ArgumentException("Invalid value.");
     56          OnValueChanging();
    5657          DeregisterValueEvents();
    5758          this.value = value;
     
    205206    }
    206207
     208    public event EventHandler ValueChanging;
     209    protected virtual void OnValueChanging() {
     210      EventHandler handler = ValueChanging;
     211      if (handler != null) handler(this, EventArgs.Empty);
     212    }
    207213    public event EventHandler ValueChanged;
    208214    protected virtual void OnValueChanged() {
  • trunk/sources/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs

    r4825 r5206  
    4646      set {
    4747        if (value != this.value) {
     48          OnValueChanging();
    4849          DeregisterValueEvents();
    4950          this.value = value;
     
    187188      ((IValueParameter)this).Value = value;
    188189    }
    189 
     190   
     191    public event EventHandler ValueChanging;
     192    protected virtual void OnValueChanging() {
     193      EventHandler handler = ValueChanging;
     194      if (handler != null) handler(this, EventArgs.Empty);
     195    }
    190196    public event EventHandler ValueChanged;
    191197    protected virtual void OnValueChanged() {
  • trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs

    r4722 r5206  
    4646      set {
    4747        if (value != this.value) {
     48          OnValueChanging();
    4849          DeregisterValueEvents();
    4950          this.value = value;
     
    159160    }
    160161
     162    public event EventHandler ValueChanging;
     163    protected virtual void OnValueChanging() {
     164      EventHandler handler = ValueChanging;
     165      if (handler != null) handler(this, EventArgs.Empty);
     166    }
    161167    public event EventHandler ValueChanged;
    162168    protected virtual void OnValueChanged() {
Note: See TracChangeset for help on using the changeset viewer.