Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2932 for trunk/sources


Ignore:
Timestamp:
03/05/10 03:07:12 (15 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • replaced Changed in IItem by ToStringChanged
Location:
trunk/sources
Files:
1 deleted
39 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.Designer.cs

    r2924 r2932  
    3838        foreach (ListViewItem listViewItem in itemsListView.Items) {
    3939          T item = listViewItem.Tag as T;
    40           if (item != null) item.Changed -= new ChangedEventHandler(Item_Changed);
     40          if (item != null) item.ToStringChanged -= new EventHandler(Item_ToStringChanged);
    4141        }
    4242        if (components != null) components.Dispose();
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemArrayView.cs

    r2917 r2932  
    129129      itemsListView.Items.Add(listViewItem);
    130130      if (listViewItem.Tag != null)
    131         ((T)listViewItem.Tag).Changed += new ChangedEventHandler(Item_Changed);
     131        ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged);
    132132    }
    133133    protected virtual void InsertListViewItem(int index, ListViewItem listViewItem) {
    134134      itemsListView.Items.Insert(index, listViewItem);
    135135      if (listViewItem.Tag != null)
    136         ((T)listViewItem.Tag).Changed += new ChangedEventHandler(Item_Changed);
     136        ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged);
    137137    }
    138138    protected virtual void RemoveListViewItem(ListViewItem listViewItem) {
    139139      if (listViewItem.Tag != null)
    140         ((T)listViewItem.Tag).Changed -= new ChangedEventHandler(Item_Changed);
     140        ((T)listViewItem.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged);
    141141      listViewItem.Remove();
    142142    }
     
    309309
    310310    #region Item Events
    311     protected virtual void Item_Changed(object sender, ChangedEventArgs e) {
     311    protected virtual void Item_ToStringChanged(object sender, EventArgs e) {
    312312      if (InvokeRequired)
    313         Invoke(new ChangedEventHandler(Item_Changed), sender, e);
     313        Invoke(new EventHandler(Item_ToStringChanged), sender, e);
    314314      else {
    315315        T item = (T)sender;
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.Designer.cs

    r2924 r2932  
    3838      if (disposing) {
    3939        foreach (ListViewItem item in itemsListView.Items)
    40           ((T)item.Tag).Changed -= new ChangedEventHandler(Item_Changed);
     40          ((T)item.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged);
    4141        if (components != null) components.Dispose();
    4242      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs

    r2924 r2932  
    109109    protected virtual void AddListViewItem(ListViewItem listViewItem) {
    110110      itemsListView.Items.Add(listViewItem);
    111       ((T)listViewItem.Tag).Changed += new ChangedEventHandler(Item_Changed);
     111      ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged);
    112112      sortAscendingButton.Enabled = itemsListView.Items.Count > 0;
    113113      sortDescendingButton.Enabled = itemsListView.Items.Count > 0;
    114114    }
    115115    protected virtual void RemoveListViewItem(ListViewItem listViewItem) {
    116       ((T)listViewItem.Tag).Changed -= new ChangedEventHandler(Item_Changed);
     116      ((T)listViewItem.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged);
    117117      listViewItem.Remove();
    118118      sortAscendingButton.Enabled = itemsListView.Items.Count > 0;
     
    254254
    255255    #region Item Events
    256     protected virtual void Item_Changed(object sender, ChangedEventArgs e) {
    257       if (InvokeRequired)
    258         Invoke(new ChangedEventHandler(Item_Changed), sender, e);
     256    protected virtual void Item_ToStringChanged(object sender, EventArgs e) {
     257      if (InvokeRequired)
     258        Invoke(new EventHandler(Item_ToStringChanged), sender, e);
    259259      else {
    260260        T item = (T)sender;
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.Designer.cs

    r2924 r2932  
    3737      if (disposing) {
    3838        foreach (ListViewItem item in itemsListView.Items)
    39           ((T)item.Tag).Changed -= new ChangedEventHandler(Item_Changed);
     39          ((T)item.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged);
    4040        if (components != null) components.Dispose();
    4141      }
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemListView.cs

    r2917 r2932  
    131131    protected virtual void AddListViewItem(ListViewItem listViewItem) {
    132132      itemsListView.Items.Add(listViewItem);
    133       ((T)listViewItem.Tag).Changed += new ChangedEventHandler(Item_Changed);
     133      ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged);
    134134    }
    135135    protected virtual void InsertListViewItem(int index, ListViewItem listViewItem) {
    136136      itemsListView.Items.Insert(index, listViewItem);
    137       ((T)listViewItem.Tag).Changed += new ChangedEventHandler(Item_Changed);
     137      ((T)listViewItem.Tag).ToStringChanged += new EventHandler(Item_ToStringChanged);
    138138    }
    139139    protected virtual void RemoveListViewItem(ListViewItem listViewItem) {
    140       ((T)listViewItem.Tag).Changed -= new ChangedEventHandler(Item_Changed);
     140      ((T)listViewItem.Tag).ToStringChanged -= new EventHandler(Item_ToStringChanged);
    141141      listViewItem.Remove();
    142142    }
     
    333333
    334334    #region Item Events
    335     protected virtual void Item_Changed(object sender, ChangedEventArgs e) {
    336       if (InvokeRequired)
    337         Invoke(new ChangedEventHandler(Item_Changed), sender, e);
     335    protected virtual void Item_ToStringChanged(object sender, EventArgs e) {
     336      if (InvokeRequired)
     337        Invoke(new EventHandler(Item_ToStringChanged), sender, e);
    338338      else {
    339339        T item = (T)sender;
  • trunk/sources/HeuristicLab.Core/3.3/HeuristicLab.Core-3.3.csproj

    r2900 r2932  
    102102    <Compile Include="Cloner.cs" />
    103103    <Compile Include="Attributes\CreatableAttribute.cs" />
    104     <Compile Include="ChangedEventArgs.cs" />
    105104    <None Include="HeuristicLabCorePlugin.cs.frame" />
    106105    <Compile Include="Interfaces\IParameterizedNamedItem.cs" />
  • trunk/sources/HeuristicLab.Core/3.3/Interfaces/IItem.cs

    r2852 r2932  
    2020#endregion
    2121
     22using System;
    2223using System.Drawing;
    2324
     
    3132    Image ItemImage { get; }
    3233
    33     event ChangedEventHandler Changed;
     34    event EventHandler ToStringChanged;
    3435  }
    3536}
  • trunk/sources/HeuristicLab.Core/3.3/Item.cs

    r2830 r2932  
    2020#endregion
    2121
     22using System;
    2223using System.Drawing;
    2324using HeuristicLab.Common.Resources;
     
    4950    }
    5051
    51     public event ChangedEventHandler Changed;
    52     protected void OnChanged() {
    53       OnChanged(new ChangedEventArgs());
    54     }
    55     protected virtual void OnChanged(ChangedEventArgs e) {
    56       if ((e.RegisterChangedObject(this)) && (Changed != null))
    57         Changed(this, e);
     52    public event EventHandler ToStringChanged;
     53    protected virtual void OnToStringChanged() {
     54      if (ToStringChanged != null)
     55        ToStringChanged(this, EventArgs.Empty);
    5856    }
    5957  }
  • trunk/sources/HeuristicLab.Core/3.3/ItemArray.cs

    r2833 r2932  
    3535  [Item("ItemArray<T>", "Represents an array of items.")]
    3636  public class ItemArray<T> : ObservableArray<T>, IItem where T : class, IItem {
    37     [Storable(Name = "RestoreEvents")]
    38     private object RestoreEvents {
    39       get { return null; }
    40       set {
    41         foreach (T item in this)
    42           if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    43       }
    44     }
    45 
    4637    public virtual string ItemName {
    4738      get { return ItemAttribute.GetName(this.GetType()); }
     
    5647    public ItemArray() : base() { }
    5748    public ItemArray(int length) : base(length) { }
    58     public ItemArray(T[] array) : base(array) {
    59       foreach (T item in this)
    60         if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    61     }
    62     public ItemArray(IEnumerable<T> collection) : base(collection) {
    63       foreach (T item in this)
    64         if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    65     }
     49    public ItemArray(T[] array) : base(array) { }
     50    public ItemArray(IEnumerable<T> collection) : base(collection) { }
    6651
    6752    public object Clone() {
     
    7964    }
    8065
    81     public event ChangedEventHandler Changed;
    82     protected void OnChanged() {
    83       OnChanged(new ChangedEventArgs());
    84     }
    85     protected virtual void OnChanged(ChangedEventArgs e) {
    86       if ((e.RegisterChangedObject(this)) && (Changed != null))
    87         Changed(this, e);
    88     }
    89 
    90     protected override void OnItemsReplaced(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    91       foreach (IndexedItem<T> oldItem in oldItems)
    92         if (oldItem.Value != null) oldItem.Value.Changed -= new ChangedEventHandler(Item_Changed);
    93       foreach (IndexedItem<T> item in items)
    94         if (item.Value != null) item.Value.Changed += new ChangedEventHandler(Item_Changed);
    95       base.OnItemsReplaced(items, oldItems);
    96     }
    97     protected override void OnCollectionReset(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    98       foreach (IndexedItem<T> oldItem in oldItems)
    99         if (oldItem.Value != null) oldItem.Value.Changed -= new ChangedEventHandler(Item_Changed);
    100       foreach (IndexedItem<T> item in items)
    101         if (item.Value != null) item.Value.Changed += new ChangedEventHandler(Item_Changed);
    102       base.OnCollectionReset(items, oldItems);
    103     }
    104     protected override void OnPropertyChanged(string propertyName) {
    105       base.OnPropertyChanged(propertyName);
    106       OnChanged();
    107     }
    108 
    109     private void Item_Changed(object sender, ChangedEventArgs e) {
    110       OnChanged(e);
     66    public event EventHandler ToStringChanged;
     67    protected virtual void OnToStringChanged() {
     68      if (ToStringChanged != null)
     69        ToStringChanged(this, EventArgs.Empty);
    11170    }
    11271  }
  • trunk/sources/HeuristicLab.Core/3.3/ItemCollection.cs

    r2852 r2932  
    3232  [Item("ItemCollection<T>", "Represents a collection of items.")]
    3333  public class ItemCollection<T> : ObservableCollection<T>, IItem where T : class, IItem {
    34     [Storable(Name = "RestoreEvents")]
    35     private object RestoreEvents {
    36       get { return null; }
    37       set {
    38         foreach (T item in this)
    39           if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    40       }
    41     }
    42 
    4334    public virtual string ItemName {
    4435      get { return ItemAttribute.GetName(this.GetType()); }
     
    5344    public ItemCollection() : base() { }
    5445    public ItemCollection(int capacity) : base(capacity) { }
    55     public ItemCollection(IEnumerable<T> collection) : base(collection) {
    56       foreach (T item in this)
    57         if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    58     }
     46    public ItemCollection(IEnumerable<T> collection) : base(collection) { }
    5947
    6048    public object Clone() {
     
    7260    }
    7361
    74     public event ChangedEventHandler Changed;
    75     protected void OnChanged() {
    76       OnChanged(new ChangedEventArgs());
    77     }
    78     protected virtual void OnChanged(ChangedEventArgs e) {
    79       if ((e.RegisterChangedObject(this)) && (Changed != null))
    80         Changed(this, e);
    81     }
    82 
    83     protected override void OnItemsAdded(IEnumerable<T> items) {
    84       foreach (T item in items)
    85         if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    86       base.OnItemsAdded(items);
    87     }
    88     protected override void OnItemsRemoved(IEnumerable<T> items) {
    89       foreach (T item in items)
    90         if (item != null) item.Changed -= new ChangedEventHandler(Item_Changed);
    91       base.OnItemsRemoved(items);
    92     }
    93     protected override void OnCollectionReset(IEnumerable<T> items, IEnumerable<T> oldItems) {
    94       foreach (T oldItem in oldItems)
    95         if (oldItem != null) oldItem.Changed -= new ChangedEventHandler(Item_Changed);
    96       foreach (T item in items)
    97         if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    98       base.OnCollectionReset(items, oldItems);
    99     }
    100     protected override void OnPropertyChanged(string propertyName) {
    101       base.OnPropertyChanged(propertyName);
    102       OnChanged();
    103     }
    104 
    105     private void Item_Changed(object sender, ChangedEventArgs e) {
    106       OnChanged(e);
     62    public event EventHandler ToStringChanged;
     63    protected virtual void OnToStringChanged() {
     64      if (ToStringChanged != null)
     65        ToStringChanged(this, EventArgs.Empty);
    10766    }
    10867  }
  • trunk/sources/HeuristicLab.Core/3.3/ItemList.cs

    r2833 r2932  
    3636  [Item("ItemList<T>", "Represents a list of items.")]
    3737  public class ItemList<T> : ObservableList<T>, IItem where T : class, IItem {
    38     [Storable(Name = "RestoreEvents")]
    39     private object RestoreEvents {
    40       get { return null; }
    41       set {
    42         foreach (T item in this)
    43           if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    44       }
    45     }
    46 
    4738    public virtual string ItemName {
    4839      get { return ItemAttribute.GetName(this.GetType()); }
     
    5748    public ItemList() : base() { }
    5849    public ItemList(int capacity) : base(capacity) { }
    59     public ItemList(IEnumerable<T> collection) : base(collection) {
    60       foreach (T item in this)
    61         if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    62     }
     50    public ItemList(IEnumerable<T> collection) : base(collection) { }
    6351
    6452    public object Clone() {
     
    7664    }
    7765
    78     public event ChangedEventHandler Changed;
    79     protected void OnChanged() {
    80       OnChanged(new ChangedEventArgs());
    81     }
    82     protected virtual void OnChanged(ChangedEventArgs e) {
    83       if ((e.RegisterChangedObject(this)) && (Changed != null))
    84         Changed(this, e);
    85     }
    86 
    87     protected override void OnItemsAdded(IEnumerable<IndexedItem<T>> items) {
    88       foreach (IndexedItem<T> item in items)
    89         if (item.Value != null) item.Value.Changed += new ChangedEventHandler(Item_Changed);
    90       base.OnItemsAdded(items);
    91     }
    92     protected override void OnItemsRemoved(IEnumerable<IndexedItem<T>> items) {
    93       foreach (IndexedItem<T> item in items)
    94         if (item.Value != null) item.Value.Changed -= new ChangedEventHandler(Item_Changed);
    95       base.OnItemsRemoved(items);
    96     }
    97     protected override void OnItemsReplaced(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    98       foreach (IndexedItem<T> oldItem in oldItems)
    99         if (oldItem.Value != null) oldItem.Value.Changed -= new ChangedEventHandler(Item_Changed);
    100       foreach (IndexedItem<T> item in items)
    101         if (item.Value != null) item.Value.Changed += new ChangedEventHandler(Item_Changed);
    102       base.OnItemsReplaced(items, oldItems);
    103     }
    104     protected override void OnCollectionReset(IEnumerable<IndexedItem<T>> items, IEnumerable<IndexedItem<T>> oldItems) {
    105       foreach (IndexedItem<T> oldItem in oldItems)
    106         if (oldItem.Value != null) oldItem.Value.Changed -= new ChangedEventHandler(Item_Changed);
    107       foreach (IndexedItem<T> item in items)
    108         if (item.Value != null) item.Value.Changed += new ChangedEventHandler(Item_Changed);
    109       base.OnCollectionReset(items, oldItems);
    110     }
    111     protected override void OnPropertyChanged(string propertyName) {
    112       base.OnPropertyChanged(propertyName);
    113       OnChanged();
    114     }
    115 
    116     private void Item_Changed(object sender, ChangedEventArgs e) {
    117       OnChanged(e);
     66    public event EventHandler ToStringChanged;
     67    protected virtual void OnToStringChanged() {
     68      if (ToStringChanged != null)
     69        ToStringChanged(this, EventArgs.Empty);
    11870    }
    11971  }
  • trunk/sources/HeuristicLab.Core/3.3/ItemSet.cs

    r2833 r2932  
    3636  [Item("ItemSet<T>", "Represents a set of items.")]
    3737  public class ItemSet<T> : ObservableSet<T>, IItem where T : class, IItem {
    38     [Storable(Name = "RestoreEvents")]
    39     private object RestoreEvents {
    40       get { return null; }
    41       set {
    42         foreach (T item in this)
    43           if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    44       }
    45     }
    46 
    4738    public virtual string ItemName {
    4839      get { return ItemAttribute.GetName(this.GetType()); }
     
    5647
    5748    public ItemSet() : base() { }
    58     public ItemSet(IEnumerable<T> collection) : base(collection) {
    59       foreach (T item in this)
    60         if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    61     }
     49    public ItemSet(IEnumerable<T> collection) : base(collection) { }
    6250
    6351    public object Clone() {
     
    7563    }
    7664
    77     public event ChangedEventHandler Changed;
    78     protected void OnChanged() {
    79       OnChanged(new ChangedEventArgs());
    80     }
    81     protected virtual void OnChanged(ChangedEventArgs e) {
    82       if ((e.RegisterChangedObject(this)) && (Changed != null))
    83         Changed(this, e);
    84     }
    85 
    86     protected override void OnItemsAdded(IEnumerable<T> items) {
    87       foreach (T item in items)
    88         if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    89       base.OnItemsAdded(items);
    90     }
    91     protected override void OnItemsRemoved(IEnumerable<T> items) {
    92       foreach (T item in items)
    93         if (item != null) item.Changed -= new ChangedEventHandler(Item_Changed);
    94       base.OnItemsRemoved(items);
    95     }
    96     protected override void OnCollectionReset(IEnumerable<T> items, IEnumerable<T> oldItems) {
    97       foreach (T oldItem in oldItems)
    98         if (oldItem != null) oldItem.Changed -= new ChangedEventHandler(Item_Changed);
    99       foreach (T item in items)
    100         if (item != null) item.Changed += new ChangedEventHandler(Item_Changed);
    101       base.OnCollectionReset(items, oldItems);
    102     }
    103     protected override void OnPropertyChanged(string propertyName) {
    104       base.OnPropertyChanged(propertyName);
    105       OnChanged();
    106     }
    107 
    108     private void Item_Changed(object sender, ChangedEventArgs e) {
    109       OnChanged(e);
     65    public event EventHandler ToStringChanged;
     66    protected virtual void OnToStringChanged() {
     67      if (ToStringChanged != null)
     68        ToStringChanged(this, EventArgs.Empty);
    11069    }
    11170  }
  • trunk/sources/HeuristicLab.Core/3.3/NamedItem.cs

    r2931 r2932  
    130130      if (NameChanged != null)
    131131        NameChanged(this, EventArgs.Empty);
    132       OnChanged();
     132      OnToStringChanged();
    133133    }
    134134    /// <inheritdoc/>
     
    141141      if (DescriptionChanged != null)
    142142        DescriptionChanged(this, EventArgs.Empty);
    143       OnChanged();
    144143    }
    145144  }
  • trunk/sources/HeuristicLab.Core/3.3/NamedItemCollection.cs

    r2834 r2932  
    6666    }
    6767
    68     public event ChangedEventHandler Changed;
    69     protected void OnChanged() {
    70       OnChanged(new ChangedEventArgs());
    71     }
    72     protected virtual void OnChanged(ChangedEventArgs e) {
    73       if ((e.RegisterChangedObject(this)) && (Changed != null))
    74         Changed(this, e);
     68    public event EventHandler ToStringChanged;
     69    protected virtual void OnToStringChanged() {
     70      if (ToStringChanged != null)
     71        ToStringChanged(this, EventArgs.Empty);
    7572    }
    7673
     
    9895      base.OnCollectionReset(items, oldItems);
    9996    }
    100     protected override void OnPropertyChanged(string propertyName) {
    101       base.OnPropertyChanged(propertyName);
    102       OnChanged();
    103     }
    10497
    10598    private void RegisterItemEvents(IEnumerable<T> items) {
     
    108101          item.NameChanging += new EventHandler<CancelEventArgs<string>>(Item_NameChanging);
    109102          item.NameChanged += new EventHandler(Item_NameChanged);
    110           item.Changed += new ChangedEventHandler(Item_Changed);
    111103        }
    112104      }
     
    117109          item.NameChanging -= new EventHandler<CancelEventArgs<string>>(Item_NameChanging);
    118110          item.NameChanged -= new EventHandler(Item_NameChanged);
    119           item.Changed -= new ChangedEventHandler(Item_Changed);
    120111        }
    121112      }
     
    129120      UpdateItemKey(item);
    130121    }
    131     private void Item_Changed(object sender, ChangedEventArgs e) {
    132       OnChanged(e);
    133     }
    134122  }
    135123}
  • trunk/sources/HeuristicLab.Core/3.3/OperatorGraph.cs

    r2853 r2932  
    114114      if (InitialOperatorChanged != null)
    115115        InitialOperatorChanged(this, EventArgs.Empty);
    116       OnChanged();
    117116    }
    118117
     
    153152    private void RegisterOperatorsEvents() {
    154153      if (operators != null) {
    155         operators.Changed += new ChangedEventHandler(Operators_Changed);
    156154        operators.ItemsAdded += new CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsAdded);
    157155        operators.ItemsRemoved += new CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsRemoved);
     
    175173          DeregisterOperatorEvents(op);
    176174        }
    177         operators.Changed -= new ChangedEventHandler(Operators_Changed);
    178175        operators.ItemsAdded -= new CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsAdded);
    179176        operators.ItemsRemoved -= new CollectionItemsChangedEventHandler<IOperator>(Operators_ItemsRemoved);
     
    240237      if (opParam.Value != null) Operators.Add(opParam.Value);
    241238    }
    242     private void Operators_Changed(object sender, ChangedEventArgs e) {
    243       OnChanged(e);
    244     }
    245239    #endregion
    246240  }
  • trunk/sources/HeuristicLab.Core/3.3/ParameterizedNamedItem.cs

    r2851 r2932  
    3434      get { return parameters; }
    3535      private set {
    36         if (parameters != null) parameters.Changed -= new ChangedEventHandler(Parameters_Changed);
    3736        parameters = value;
    3837        readOnlyParameters = null;
    39         if (parameters != null) parameters.Changed += new ChangedEventHandler(Parameters_Changed);
    4038      }
    4139    }
     
    8381      return clone;
    8482    }
    85 
    86     private void Parameters_Changed(object sender, ChangedEventArgs e) {
    87       OnChanged(e);
    88     }
    8983  }
    9084}
  • trunk/sources/HeuristicLab.Core/3.3/Scope.cs

    r2931 r2932  
    4141    }
    4242
     43    [Storable]
    4344    private VariableCollection variables;
    44     [Storable]
    4545    public VariableCollection Variables {
    4646      get { return variables; }
    47       private set {
    48         if (variables != null) variables.Changed -= new ChangedEventHandler(Variables_Changed);
    49         variables = value;
    50         if (variables != null) variables.Changed += new ChangedEventHandler(Variables_Changed);
    51       }
    5247    }
    5348
     
    6964      : base("Anonymous") {
    7065      parent = null;
    71       Variables = new VariableCollection();
     66      variables = new VariableCollection();
    7267      SubScopes = new ScopeList();
    7368    }
     
    7974      : base(name) {
    8075      parent = null;
    81       Variables = new VariableCollection();
     76      variables = new VariableCollection();
    8277      SubScopes = new ScopeList();
    8378    }
     
    8580      : base(name, description) {
    8681      parent = null;
    87       Variables = new VariableCollection();
     82      variables = new VariableCollection();
    8883      SubScopes = new ScopeList();
    8984    }
     
    10196      clone.Name = Name;
    10297      clone.Description = Description;
    103       if (variables.Count > 0) clone.Variables = (VariableCollection)cloner.Clone(variables);
     98      if (variables.Count > 0) clone.variables = (VariableCollection)cloner.Clone(variables);
    10499      if (subScopes.Count > 0) clone.SubScopes = (ScopeList)cloner.Clone(subScopes);
    105100      return clone;
     
    113108        subScopes.ItemsReplaced += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsReplaced);
    114109        subScopes.CollectionReset += new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_CollectionReset);
    115         subScopes.Changed += new ChangedEventHandler(SubScopes_Changed);
    116110      }
    117111    }
     
    122116        subScopes.ItemsReplaced -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_ItemsReplaced);
    123117        subScopes.CollectionReset -= new CollectionItemsChangedEventHandler<IndexedItem<IScope>>(SubScopes_CollectionReset);
    124         subScopes.Changed -= new ChangedEventHandler(SubScopes_Changed);
    125118      }
    126119    }
     
    145138        item.Value.Parent = this;
    146139    }
    147     private void SubScopes_Changed(object sender, ChangedEventArgs e) {
    148       OnChanged(e);
    149     }
    150     #endregion
    151 
    152     #region Variables Events
    153     private void Variables_Changed(object sender, ChangedEventArgs e) {
    154       OnChanged(e);
    155     }
    156140    #endregion
    157141  }
  • trunk/sources/HeuristicLab.Core/3.3/Variable.cs

    r2833 r2932  
    3939      set {
    4040        if (this.value != value) {
    41           if (this.value != null) this.value.Changed -= new ChangedEventHandler(Value_Changed);
     41          if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);
    4242          this.value = value;
    43           if (this.value != null) this.value.Changed += new ChangedEventHandler(Value_Changed);
     43          if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);
    4444          OnValueChanged();
    4545        }
     
    7272      : base(name) {
    7373      this.value = value;
    74       if (this.value != null) this.value.Changed += new ChangedEventHandler(Value_Changed);
     74      if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);
    7575    }
    7676    public Variable(string name, string description, IItem value)
    7777      : base(name, description) {
    7878      this.value = value;
    79       if (this.value != null) this.value.Changed += new ChangedEventHandler(Value_Changed);
     79      if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);
    8080    }
    8181
     
    110110      if (ValueChanged != null)
    111111        ValueChanged(this, EventArgs.Empty);
    112       OnChanged();
    113112    }
    114113
    115     private void Value_Changed(object sender, ChangedEventArgs e) {
    116       OnChanged(e);
     114    private void Value_ToStringChanged(object sender, EventArgs e) {
     115      OnToStringChanged();
    117116    }
    118117  }
  • trunk/sources/HeuristicLab.Data.Views/3.3/BoolDataView.cs

    r2917 r2932  
    5050
    5151    protected override void DeregisterContentEvents() {
    52       Content.Changed -= new ChangedEventHandler(Content_Changed);
     52      Content.ValueChanged -= new EventHandler(Content_ValueChanged);
    5353      base.DeregisterContentEvents();
    5454    }
     
    5656    protected override void RegisterContentEvents() {
    5757      base.RegisterContentEvents();
    58       Content.Changed += new ChangedEventHandler(Content_Changed);
     58      Content.ValueChanged += new EventHandler(Content_ValueChanged);
    5959    }
    6060
     
    7272    }
    7373
    74     private void Content_Changed(object sender, ChangedEventArgs e) {
     74    private void Content_ValueChanged(object sender, EventArgs e) {
    7575      if (InvokeRequired)
    76         Invoke(new ChangedEventHandler(Content_Changed), sender, e);
     76        Invoke(new EventHandler(Content_ValueChanged), sender, e);
    7777      else
    7878        valueCheckBox.Checked = Content.Value;
  • trunk/sources/HeuristicLab.Data.Views/3.3/ComparisonDataView.cs

    r2917 r2932  
    5151
    5252    protected override void DeregisterContentEvents() {
    53       Content.Changed -= new ChangedEventHandler(Content_Changed);
     53      Content.ValueChanged -= new EventHandler(Content_ValueChanged);
    5454      base.DeregisterContentEvents();
    5555    }
     
    5757    protected override void RegisterContentEvents() {
    5858      base.RegisterContentEvents();
    59       Content.Changed += new ChangedEventHandler(Content_Changed);
     59      Content.ValueChanged += new EventHandler(Content_ValueChanged);
    6060    }
    6161
     
    7272    }
    7373
    74     private void Content_Changed(object sender, ChangedEventArgs e) {
     74    private void Content_ValueChanged(object sender, EventArgs e) {
    7575      if (InvokeRequired)
    76         Invoke(new ChangedEventHandler(Content_Changed), sender, e);
     76        Invoke(new EventHandler(Content_ValueChanged), sender, e);
    7777      else
    7878        valueComboBox.SelectedItem = Content.Value;
  • trunk/sources/HeuristicLab.Data.Views/3.3/StringConvertibleDataView.cs

    r2917 r2932  
    5353
    5454    protected override void DeregisterContentEvents() {
    55       Content.Changed -= new ChangedEventHandler(Content_Changed);
     55      Content.ValueChanged -= new EventHandler(Content_ValueChanged);
    5656      base.DeregisterContentEvents();
    5757    }
     
    5959    protected override void RegisterContentEvents() {
    6060      base.RegisterContentEvents();
    61       Content.Changed += new ChangedEventHandler(Content_Changed);
     61      Content.ValueChanged += new EventHandler(Content_ValueChanged);
    6262    }
    6363
     
    7575    }
    7676
    77     private void Content_Changed(object sender, ChangedEventArgs e) {
     77    private void Content_ValueChanged(object sender, EventArgs e) {
    7878      if (InvokeRequired)
    79         Invoke(new ChangedEventHandler(Content_Changed), sender, e);
     79        Invoke(new EventHandler(Content_ValueChanged), sender, e);
    8080      else
    8181        valueTextBox.Text = Content.GetValue();
  • trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleData.cs

    r2790 r2932  
    3232    bool SetValue(string value);
    3333
    34     event ChangedEventHandler Changed;
     34    event EventHandler ValueChanged;
    3535  }
    3636}
  • trunk/sources/HeuristicLab.Data/3.3/StringArrayData.cs

    r2863 r2932  
    139139      if (ItemChanged != null)
    140140        ItemChanged(this, new EventArgs<int, int>(index, 0));
    141       OnChanged();
     141      OnToStringChanged();
    142142    }
    143143    private event EventHandler Reset;
     
    149149      if (Reset != null)
    150150        Reset(this, EventArgs.Empty);
    151       OnChanged();
     151      OnToStringChanged();
    152152    }
    153153    #endregion
  • trunk/sources/HeuristicLab.Data/3.3/StringData.cs

    r2790 r2932  
    4040          if ((value != null) || (this.value != string.Empty)) {
    4141            this.value = value != null ? value : string.Empty;
    42             OnChanged();
     42            OnValueChanged();
    4343          }
    4444        }
     
    7171    }
    7272
     73    public event EventHandler ValueChanged;
     74    private void OnValueChanged() {
     75      if (ValueChanged != null)
     76        ValueChanged(this, EventArgs.Empty);
     77      OnToStringChanged();
     78    }
     79
    7380    #region IStringConvertibleData Members
    7481    bool IStringConvertibleData.Validate(string value, out string errorMessage) {
  • trunk/sources/HeuristicLab.Data/3.3/StringMatrixData.cs

    r2790 r2932  
    160160      if (ItemChanged != null)
    161161        ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex));
    162       OnChanged();
     162      OnToStringChanged();
    163163    }
    164164    private event EventHandler Reset;
     
    170170      if (Reset != null)
    171171        Reset(this, EventArgs.Empty);
    172       OnChanged();
     172      OnToStringChanged();
    173173    }
    174174    #endregion
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeArrayData.cs

    r2790 r2932  
    9595      if (ItemChanged != null)
    9696        ItemChanged(this, new EventArgs<int, int>(index, 0));
    97       OnChanged();
     97      OnToStringChanged();
    9898    }
    9999    protected event EventHandler Reset;
     
    101101      if (Reset != null)
    102102        Reset(this, EventArgs.Empty);
    103       OnChanged();
     103      OnToStringChanged();
    104104    }
    105105  }
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeData.cs

    r2790 r2932  
    3838        if (!value.Equals(this.value)) {
    3939          this.value = value;
    40           OnChanged();
     40          OnValueChanged();
    4141        }
    4242      }
     
    5959      return value.ToString();
    6060    }
     61
     62    public event EventHandler ValueChanged;
     63    protected virtual void OnValueChanged() {
     64      if (ValueChanged != null)
     65        ValueChanged(this, EventArgs.Empty);
     66      OnToStringChanged();
     67    }
    6168  }
    6269}
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeMatrixData.cs

    r2790 r2932  
    112112      if (ItemChanged != null)
    113113        ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex));
    114       OnChanged();
     114      OnToStringChanged();
    115115    }
    116116    protected event EventHandler Reset;
     
    118118      if (Reset != null)
    119119        Reset(this, EventArgs.Empty);
    120       OnChanged();
     120      OnToStringChanged();
    121121    }
    122122  }
  • trunk/sources/HeuristicLab.Encodings.Permutation/3.3/Tests/Random.cs

    r2929 r2932  
    112112    }
    113113
    114     public event ChangedEventHandler Changed;
     114    public event EventHandler ToStringChanged;
    115115
    116116    #endregion
  • trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Tests/TestRandom.cs

    r2929 r2932  
    112112    }
    113113
    114     public event ChangedEventHandler Changed;
     114    public event EventHandler ToStringChanged;
    115115
    116116    #endregion
  • trunk/sources/HeuristicLab.Operators.Programmable/3.3/ProgrammableOperator.cs

    r2911 r2932  
    3737using HeuristicLab.PluginInfrastructure;
    3838using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     39using HeuristicLab.Collections;
    3940
    4041namespace HeuristicLab.Operators.Programmable {
     
    168169      Plugins = defaultPluginDict;
    169170      namespaces = new HashSet<string>(DiscoverNamespaces());
    170       Parameters.Changed += (s, a) => OnSignatureChanged(s, a);
    171     }
    172 
    173     protected void OnSignatureChanged(object sender, EventArgs args) {
     171      Parameters.ItemsAdded += (s, a) => OnSignatureChanged(s, a);
     172      Parameters.ItemsRemoved += (s, a) => OnSignatureChanged(s, a);
     173      Parameters.ItemsReplaced += (s, a) => OnSignatureChanged(s, a);
     174      Parameters.CollectionReset += (s, a) => OnSignatureChanged(s, a);
     175    }
     176
     177    protected void OnSignatureChanged(object sender, CollectionItemsChangedEventArgs<IParameter> args) {
    174178      if (SignatureChanged != null)
    175         SignatureChanged(sender, args);
     179        SignatureChanged(sender, EventArgs.Empty);
    176180    }
    177181
  • trunk/sources/HeuristicLab.Operators/3.3/Operator.cs

    r2845 r2932  
    163163        BreakpointChanged(this, EventArgs.Empty);
    164164      }
    165       OnChanged();
    166165    }
    167166    /// <inheritdoc/>
  • trunk/sources/HeuristicLab.Optimization/3.3/Algorithm.cs

    r2882 r2932  
    112112      if (ProblemChanged != null)
    113113        ProblemChanged(this, EventArgs.Empty);
    114       OnChanged();
    115114    }
    116115    public event EventHandler ExecutionTimeChanged;
     
    118117      if (ExecutionTimeChanged != null)
    119118        ExecutionTimeChanged(this, EventArgs.Empty);
    120       OnChanged();
    121119    }
    122120    public event EventHandler Prepared;
     
    124122      if (Prepared != null)
    125123        Prepared(this, EventArgs.Empty);
    126       OnChanged();
    127124    }
    128125    public event EventHandler Started;
     
    130127      if (Started != null)
    131128        Started(this, EventArgs.Empty);
    132       OnChanged();
    133129    }
    134130    public event EventHandler Stopped;
     
    136132      if (Stopped != null)
    137133        Stopped(this, EventArgs.Empty);
    138       OnChanged();
    139134    }
    140135    protected virtual void OnCanceledChanged() { }
     
    147142      problem.SolutionCreatorChanged -= new EventHandler(Problem_SolutionCreatorChanged);
    148143      problem.EvaluatorChanged -= new EventHandler(Problem_EvaluatorChanged);
    149       problem.Changed -= new ChangedEventHandler(Problem_Changed);
    150144    }
    151145    protected virtual void RegisterProblemEvents() {
    152146      problem.SolutionCreatorChanged += new EventHandler(Problem_SolutionCreatorChanged);
    153147      problem.EvaluatorChanged += new EventHandler(Problem_EvaluatorChanged);
    154       problem.Changed += new ChangedEventHandler(Problem_Changed);
    155148    }
    156149
    157150    protected virtual void Problem_SolutionCreatorChanged(object sender, EventArgs e) { }
    158151    protected virtual void Problem_EvaluatorChanged(object sender, EventArgs e) { }
    159     private void Problem_Changed(object sender, ChangedEventArgs e) {
    160       OnChanged(e);
    161     }
    162152    #endregion
    163153  }
  • trunk/sources/HeuristicLab.Optimization/3.3/EngineAlgorithm.cs

    r2924 r2932  
    195195      if (EngineChanged != null)
    196196        EngineChanged(this, EventArgs.Empty);
    197       OnChanged();
    198197    }
    199198
     
    202201    }
    203202    private void RegisterEngineEvents() {
    204       Engine.Changed += new ChangedEventHandler(Engine_Changed);
    205203      Engine.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred);
    206204      Engine.ExecutionTimeChanged += new EventHandler(Engine_ExecutionTimeChanged);
     
    208206    }
    209207    private void DeregisterEngineEvents() {
    210       Engine.Changed -= new ChangedEventHandler(Engine_Changed);
    211208      Engine.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Engine_ExceptionOccurred);
    212209      Engine.ExecutionTimeChanged -= new EventHandler(Engine_ExecutionTimeChanged);
     
    223220      OnStopped();
    224221    }
    225     private void Engine_Changed(object sender, ChangedEventArgs e) {
    226       OnChanged(e);
    227     }
    228222  }
    229223}
  • trunk/sources/HeuristicLab.Parameters/3.3/LookupParameter.cs

    r2852 r2932  
    156156      if (ActualNameChanged != null)
    157157        ActualNameChanged(this, EventArgs.Empty);
    158       OnChanged();
     158      OnToStringChanged();
    159159    }
    160160
  • trunk/sources/HeuristicLab.Parameters/3.3/OptionalConstrainedValueParameter.cs

    r2924 r2932  
    5050        if (value != this.value) {
    5151          if ((value != null) && !validValues.Contains(value)) throw new ArgumentException("Invalid value.");
     52          if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);
    5253          this.value = value;
     54          if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);
    5355          OnValueChanged();
    5456        }
    5557      }
    5658    }
     59
    5760    IItem IValueParameter.Value {
    5861      get { return Value; }
     
    121124      if (ValueChanged != null)
    122125        ValueChanged(this, EventArgs.Empty);
    123       OnChanged();
     126      OnToStringChanged();
    124127    }
    125128
     
    129132        validValues.ItemsRemoved += new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved);
    130133        validValues.CollectionReset += new CollectionItemsChangedEventHandler<T>(ValidValues_CollectionReset);
    131         validValues.Changed += new ChangedEventHandler(ValidValues_Changed);
    132134      }
    133135    }
     
    138140        validValues.ItemsRemoved -= new CollectionItemsChangedEventHandler<T>(ValidValues_ItemsRemoved);
    139141        validValues.CollectionReset -= new CollectionItemsChangedEventHandler<T>(ValidValues_CollectionReset);
    140         validValues.Changed -= new ChangedEventHandler(ValidValues_Changed);
    141142      }
    142143    }
     
    149150      if ((Value != null) && !validValues.Contains(Value)) Value = null;
    150151    }
    151     protected virtual void ValidValues_Changed(object sender, ChangedEventArgs e) {
    152       OnChanged(e);
     152    protected virtual void Value_ToStringChanged(object sender, EventArgs e) {
     153      OnToStringChanged();
    153154    }
    154155  }
  • trunk/sources/HeuristicLab.Parameters/3.3/OptionalValueParameter.cs

    r2924 r2932  
    3737      set {
    3838        if (value != this.value) {
    39           if (this.value != null) this.value.Changed -= new ChangedEventHandler(Value_Changed);
     39          if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);
    4040          this.value = value;
    41           if (this.value != null) this.value.Changed += new ChangedEventHandler(Value_Changed);
     41          if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);
    4242          OnValueChanged();
    4343        }
     
    9696      if (ValueChanged != null)
    9797        ValueChanged(this, EventArgs.Empty);
    98       OnChanged();
     98      OnToStringChanged();
    9999    }
    100     private void Value_Changed(object sender, ChangedEventArgs e) {
    101       OnChanged(e);
     100    private void Value_ToStringChanged(object sender, EventArgs e) {
     101      OnToStringChanged();
    102102    }
    103103  }
  • trunk/sources/HeuristicLab.Parameters/3.3/ValueLookupParameter.cs

    r2852 r2932  
    3737      set {
    3838        if (value != this.value) {
    39           if (this.value != null) this.value.Changed -= new ChangedEventHandler(Value_Changed);
     39          if (this.value != null) this.value.ToStringChanged -= new EventHandler(Value_ToStringChanged);
    4040          this.value = value;
    41           if (this.value != null) this.value.Changed += new ChangedEventHandler(Value_Changed);
     41          if (this.value != null) this.value.ToStringChanged += new EventHandler(Value_ToStringChanged);
    4242          OnValueChanged();
    4343        }
     
    8989      if (ValueChanged != null)
    9090        ValueChanged(this, EventArgs.Empty);
    91       OnChanged();
     91      OnToStringChanged();
    9292    }
    93     private void Value_Changed(object sender, ChangedEventArgs e) {
    94       OnChanged(e);
     93    private void Value_ToStringChanged(object sender, EventArgs e) {
     94      OnToStringChanged();
    9595    }
    9696  }
Note: See TracChangeset for help on using the changeset viewer.