Changeset 10993


Ignore:
Timestamp:
06/11/14 15:13:24 (8 years ago)
Author:
sbreuer
Message:
  • make data grid selection faster
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs

    r10965 r10993  
    140140
    141141    protected override void dataGridView_SelectionChanged(object sender, EventArgs e) {
    142       if (Content != null) {
    143         if (!isSearching && !isReplacing) {
    144 
    145           if (Control.MouseButtons == MouseButtons.Left) {
    146             updateOnMouseUp = true;
    147             return;
    148           }
    149 
    150           base.dataGridView_SelectionChanged(sender, e);
    151 
    152           Content.DataGridLogic.SetSelection(GetSelectedCells());
    153         }
    154       }
     142      base.dataGridView_SelectionChanged(sender, e);
     143      Content.DataGridLogic.SetSelection(GetSelectedCells());
    155144    }
    156145
     
    572561    private IDictionary<int, IList<int>> GetSelectedCells() {
    573562      IDictionary<int, IList<int>> selectedCells = new Dictionary<int, IList<int>>();
    574       for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
    575         var columnIndex = dataGridView.SelectedCells[i].ColumnIndex;
    576         if (!selectedCells.ContainsKey(columnIndex)) {
    577           selectedCells.Add(columnIndex, new List<int>());
    578         }
    579         selectedCells[columnIndex].Add(dataGridView.SelectedCells[i].RowIndex);
    580       }
     563
     564      //special case if all cells are selected
     565      if (dataGridView.AreAllCellsSelected(true)) {
     566        for (int i = 0; i < Content.Columns; i++)
     567          selectedCells[i] = Enumerable.Range(0, Content.Rows).ToList();
     568        return selectedCells;
     569      }
     570
     571      foreach (var selectedCell in dataGridView.SelectedCells) {
     572        var cell = (DataGridViewCell) selectedCell;
     573        if (!selectedCells.ContainsKey(cell.ColumnIndex))
     574          selectedCells.Add(cell.ColumnIndex, new List<int>(1024));
     575        selectedCells[cell.ColumnIndex].Add(cell.RowIndex);
     576      }
     577
    581578      return selectedCells;
    582579    }
Note: See TracChangeset for help on using the changeset viewer.