Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/12/13 13:15:52 (11 years ago)
Author:
mkommend
Message:

#1971: Adapted ItemCollectionView and RunCollectionView to use batch events if the content supports them.

File:
1 edited

Legend:

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

    r9456 r9613  
    255255      if (e.KeyCode == Keys.Delete) {
    256256        if ((itemsListView.SelectedItems.Count > 0) && !Content.IsReadOnly && !ReadOnly) {
    257           foreach (ListViewItem item in itemsListView.SelectedItems)
    258             Content.Remove((IRun)item.Tag);
     257          if (RunCollection != null) {
     258            RunCollection.RemoveRange(itemsListView.SelectedItems.Cast<ListViewItem>().Select(i => (IRun)i.Tag));
     259          } else {
     260            foreach (ListViewItem item in itemsListView.SelectedItems)
     261              Content.Remove((IRun)item.Tag);
     262          }
    259263        }
    260264      }
     
    350354    private void removeButton_Click(object sender, EventArgs e) {
    351355      if (itemsListView.SelectedItems.Count > 0) {
    352         foreach (ListViewItem item in itemsListView.SelectedItems)
    353           Content.Remove((IRun)item.Tag);
     356        if (RunCollection != null) {
     357          RunCollection.RemoveRange(itemsListView.SelectedItems.Cast<ListViewItem>().Select(i => (IRun)i.Tag));
     358        } else {
     359          foreach (ListViewItem item in itemsListView.SelectedItems)
     360            Content.Remove((IRun)item.Tag);
     361        }
    354362        itemsListView.SelectedItems.Clear();
    355363      }
     
    377385      try {
    378386        RunCollection.Modify();
    379       } finally {
     387      }
     388      finally {
    380389        ReadOnly = false;
    381390      }
Note: See TracChangeset for help on using the changeset viewer.