Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/05/14 10:38:42 (10 years ago)
Author:
abeham
Message:

#2120: fixed event handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs

    r11344 r11345  
    237237      IObservableDictionary<string, IItem> dict = run.Parameters;
    238238      dict.ItemsAdded += RunOnParameterChanged;
    239       dict.ItemsRemoved += RunOnParameterChanged;
     239      dict.ItemsRemoved += RunOnParameterRemoved;
    240240      dict.ItemsReplaced += RunOnParameterChanged;
    241241      dict.CollectionReset += RunOnParameterChanged;
     
    245245      IObservableDictionary<string, IItem> dict = run.Results;
    246246      dict.ItemsAdded += RunOnResultChanged;
    247       dict.ItemsRemoved += RunOnResultChanged;
     247      dict.ItemsRemoved += RunOnResultRemoved;
    248248      dict.ItemsReplaced += RunOnResultChanged;
    249249      dict.CollectionReset += RunOnResultChanged;
     
    253253      IObservableDictionary<string, IItem> dict = run.Parameters;
    254254      dict.ItemsAdded -= RunOnParameterChanged;
    255       dict.ItemsRemoved -= RunOnParameterChanged;
     255      dict.ItemsRemoved -= RunOnParameterRemoved;
    256256      dict.ItemsReplaced -= RunOnParameterChanged;
    257257      dict.CollectionReset -= RunOnParameterChanged;
     
    261261      IObservableDictionary<string, IItem> dict = run.Results;
    262262      dict.ItemsAdded -= RunOnResultChanged;
    263       dict.ItemsRemoved -= RunOnResultChanged;
     263      dict.ItemsRemoved -= RunOnResultRemoved;
    264264      dict.ItemsReplaced -= RunOnResultChanged;
    265265      dict.CollectionReset -= RunOnResultChanged;
     
    280280    }
    281281
     282    private void RunOnParameterRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) {
     283      bool columnsChanged = false;
     284      foreach (var param in e.Items)
     285        columnsChanged |= RemoveParameterName(param.Key);
     286      if (columnsChanged) columnNameCache = null;
     287      OnReset();
     288      if (columnsChanged) {
     289        OnColumnsChanged();
     290        OnColumnNamesChanged();
     291      }
     292    }
     293
    282294    private void RunOnResultChanged(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) {
    283295      bool columnsChanged = false;
     
    285297        columnsChanged |= AddResult(result.Key, result.Value);
    286298      foreach (var result in e.OldItems)
     299        columnsChanged |= RemoveResultName(result.Key);
     300      if (columnsChanged) columnNameCache = null;
     301      OnReset();
     302      if (columnsChanged) {
     303        OnColumnsChanged();
     304        OnColumnNamesChanged();
     305      }
     306    }
     307
     308    private void RunOnResultRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) {
     309      bool columnsChanged = false;
     310      foreach (var result in e.Items)
    287311        columnsChanged |= RemoveResultName(result.Key);
    288312      if (columnsChanged) columnNameCache = null;
Note: See TracChangeset for help on using the changeset viewer.