Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10622


Ignore:
Timestamp:
03/19/14 13:28:28 (11 years ago)
Author:
rstoll
Message:

Delete rows implemented

Location:
branches/DataPreprocessing
Files:
3 edited

Legend:

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

    r10621 r10622  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Drawing;
    2425using System.Linq;
    2526using System.Windows.Forms;
    26 using HeuristicLab.Data.Views;
    2727using HeuristicLab.MainForm;
    28 using System.Drawing;
    2928
    3029namespace HeuristicLab.DataPreprocessing.Views {
     
    5352      dataGridView.CellMouseClick += dataGridView_CellMouseClick;
    5453      dataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(dataGridView_CellPainting);
     54      dataGridView.KeyUp += dataGridView_KeyUp;
    5555      contextMenuCell.Items.Add(ShowHideColumns);
     56    }
     57
     58    void dataGridView_KeyUp(object sender, KeyEventArgs e) {
     59      var selectedRows = dataGridView.SelectedRows;
     60      if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) {
     61        List<int> rows = new List<int>();
     62        for (int i = 0; i < selectedRows.Count; ++i) {
     63          rows.Add(selectedRows[i].Index);
     64        }
     65        triggersOwnEvent(() => {
     66          Content.DataGridLogic.DeleteRow(rows);
     67          OnContentChanged();
     68        });
     69      }
    5670    }
    5771
     
    7387    void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) {
    7488      if (notOwnEvent) {
    75         dataGridView.Refresh();
     89        switch (e.Type) {
     90          case DataPreprocessingChangedEventType.AddColumn:
     91          case DataPreprocessingChangedEventType.AddRow:
     92          case DataPreprocessingChangedEventType.DeleteColumn:
     93          case DataPreprocessingChangedEventType.DeleteRow:
     94          case DataPreprocessingChangedEventType.Any:
     95            OnContentChanged();
     96            break;
     97          case DataPreprocessingChangedEventType.ChangeColumn:
     98          case DataPreprocessingChangedEventType.ChangeItem:
     99            dataGridView.Refresh();
     100            break;
     101        }
     102
    76103      }
    77104    }
     
    183210      var selectedCells = new Dictionary<int, List<int>>();
    184211      for (int i = 0; i < dataGridView.SelectedCells.Count; i++) {
    185         var columnIndex=dataGridView.SelectedCells[i].ColumnIndex;
    186         if(!selectedCells.ContainsKey(columnIndex)){
    187           selectedCells.Add(columnIndex,new List<int>());
     212        var columnIndex = dataGridView.SelectedCells[i].ColumnIndex;
     213        if (!selectedCells.ContainsKey(columnIndex)) {
     214          selectedCells.Add(columnIndex, new List<int>());
    188215        }
    189216        selectedCells[columnIndex].Add(dataGridView.SelectedCells[i].RowIndex);
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridLogic.cs

    r10621 r10622  
    120120    }
    121121
     122    public void DeleteRow(List<int> rows) {
     123      preprocessingData.InTransaction(() => {
     124        foreach (int rowIndex in rows) {
     125          preprocessingData.DeleteRow(rowIndex);
     126        }
     127      });
     128    }
     129
    122130    public event DataPreprocessingChangedEventHandler Changed {
    123131      add { preprocessingData.Changed += value; }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IDataGridLogic.cs

    r10621 r10622  
    3636
    3737    event DataPreprocessingChangedEventHandler Changed;
     38
     39    void DeleteRow(List<int> rows);
    3840  }
    3941}
Note: See TracChangeset for help on using the changeset viewer.