Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11345 for trunk


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

#2120: fixed event handling

Location:
trunk/sources
Files:
2 edited

Legend:

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

    r11344 r11345  
    6767    private void RegisterContentParametersEvents() {
    6868      Content.Parameters.ItemsAdded += ParametersOnItemsChanged;
    69       Content.Parameters.ItemsRemoved += ParametersOnItemsChanged;
     69      Content.Parameters.ItemsRemoved += ParametersOnItemsRemoved;
    7070      Content.Parameters.ItemsReplaced += ParametersOnItemsChanged;
    7171      Content.Parameters.CollectionReset += ParametersOnItemsChanged;
     
    7373    private void RegisterContentResultsEents() {
    7474      Content.Results.ItemsAdded += ResultsOnItemsChanged;
    75       Content.Results.ItemsRemoved += ResultsOnItemsChanged;
     75      Content.Results.ItemsRemoved += ResultsOnItemsRemoved;
    7676      Content.Results.ItemsReplaced += ResultsOnItemsChanged;
    7777      Content.Results.CollectionReset += ResultsOnItemsChanged;
     
    8585    private void DeregisterContentParametersEvents() {
    8686      Content.Parameters.ItemsAdded -= ParametersOnItemsChanged;
    87       Content.Parameters.ItemsRemoved -= ParametersOnItemsChanged;
     87      Content.Parameters.ItemsRemoved -= ParametersOnItemsRemoved;
    8888      Content.Parameters.ItemsReplaced -= ParametersOnItemsChanged;
    8989      Content.Parameters.CollectionReset -= ParametersOnItemsChanged;
     
    9191    private void DeregisterContentResultsEvents() {
    9292      Content.Results.ItemsAdded -= ResultsOnItemsChanged;
    93       Content.Results.ItemsRemoved -= ResultsOnItemsChanged;
     93      Content.Results.ItemsRemoved -= ResultsOnItemsRemoved;
    9494      Content.Results.ItemsReplaced -= ResultsOnItemsChanged;
    9595      Content.Results.CollectionReset -= ResultsOnItemsChanged;
     
    123123    }
    124124
     125    private void ParametersOnItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) {
     126      foreach (var item in e.Items) {
     127        listView.Items.Remove(parametersItemToListViewItem[item.Key]);
     128        parametersItemToListViewItem.Remove(item.Key);
     129      }
     130    }
     131
    125132    private void ResultsOnItemsChanged(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) {
    126133      foreach (var item in e.OldItems) {
     
    132139        listView.Items.Add(listViewItem);
    133140        resultsItemToListViewItem[item.Key] = listViewItem;
     141      }
     142    }
     143
     144    private void ResultsOnItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<string, IItem>> e) {
     145      foreach (var item in e.Items) {
     146        listView.Items.Remove(resultsItemToListViewItem[item.Key]);
     147        resultsItemToListViewItem.Remove(item.Key);
    134148      }
    135149    }
  • 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.