Changeset 14723
- Timestamp:
- 03/07/17 11:02:19 (8 years ago)
- Location:
- branches/DataPreprocessing Enhancements
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing
-
Property
svn:mergeinfo
set to
/trunk/sources/HeuristicLab.DataPreprocessing merged eligible
-
Property
svn:mergeinfo
set to
-
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.DataPreprocessing.Views (added) merged: 14443,14548
- Property svn:mergeinfo changed
-
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs
r14583 r14723 58 58 public DataGridContentView() { 59 59 InitializeComponent(); 60 dataGridView.MouseDown += dataGridView_MouseDown; 60 61 dataGridView.CellMouseClick += dataGridView_CellMouseClick; 61 62 dataGridView.RowHeaderMouseClick += dataGridView_RowHeaderMouseClick; 62 dataGridView.KeyDown += dataGridView_KeyDown;63 63 dataGridView.MouseUp += dataGridView_MouseUp; 64 64 contextMenuCell.Items.Add(ShowHideColumns); … … 204 204 } 205 205 206 //Necessary so that dataGridView.SelectedRows and SelectedColumns are populated correctly 207 //further information: https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.selectedcolumns.aspx 208 private void dataGridView_MouseDown(object sender, MouseEventArgs e) { 209 var hitTestInfo = dataGridView.HitTest(e.X, e.Y); 210 // row header click 211 if (hitTestInfo.ColumnIndex == -1 && hitTestInfo.RowIndex >= 0) { 212 if (dataGridView.SelectionMode != DataGridViewSelectionMode.RowHeaderSelect) { 213 dataGridView.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect; 214 } 215 } 216 // column header click 217 if (hitTestInfo.RowIndex == -1 && hitTestInfo.ColumnIndex >= 0) { 218 if (dataGridView.SelectionMode != DataGridViewSelectionMode.ColumnHeaderSelect) { 219 dataGridView.SelectionMode = DataGridViewSelectionMode.ColumnHeaderSelect; 220 } 221 } 222 } 223 206 224 protected override void dataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { 207 if (Content != null) { 208 if (e.Button == MouseButtons.Left) { 209 dataGridView.Focus(); 210 dataGridView.ClearSelection(); 211 dataGridView.SelectionChanged -= dataGridView_SelectionChanged; 212 for (int i = 0; i < dataGridView.RowCount; i++) { 213 if (i + 1 == dataGridView.RowCount) 214 dataGridView.SelectionChanged += dataGridView_SelectionChanged; 215 dataGridView[e.ColumnIndex, i].Selected = true; 216 } 217 } else if (e.Button == MouseButtons.Middle) { 218 int newIndex = e.ColumnIndex >= 0 ? e.ColumnIndex : 0; 219 Content.PreProcessingData.InsertColumn<double>(newIndex.ToString(), newIndex); 220 } else if (e.Button == MouseButtons.Right && Content.SortableView) { 221 SortColumn(e.ColumnIndex); 222 } 223 } 225 if (Content == null) return; 226 227 if (e.Button == MouseButtons.Middle) { 228 int newIndex = e.ColumnIndex >= 0 ? e.ColumnIndex : 0; 229 Content.PreProcessingData.InsertColumn<double>(newIndex.ToString(), newIndex); 230 } else if (e.Button == MouseButtons.Right && Content.SortableView) { 231 SortColumn(e.ColumnIndex); 232 } 233 224 234 searchIterator = null; 225 235 } … … 538 548 539 549 protected override void dataGridView_KeyDown(object sender, KeyEventArgs e) { 540 var selectedRows = dataGridView.SelectedRows; 541 var selectedCells = dataGridView.SelectedCells; 542 if (!Content.FilterLogic.IsFiltered) { //data is in read only mode.... 543 if (e.KeyCode == Keys.Delete && selectedCells.Count == Content.Rows && selectedCells.Count > 0) { 544 Content.DeleteColumn(selectedCells[0].ColumnIndex); 545 } else if (e.KeyCode == Keys.Delete && selectedRows.Count > 0) { 546 List<int> rows = new List<int>(); 547 for (int i = 0; i < selectedRows.Count; ++i) { 548 int index = (sortedColumnIndices.Count != 0) ? (Convert.ToInt32(selectedRows[i].HeaderCell.Value) - 1) : 549 selectedRows[i].Index; 550 rows.Add(index); 551 } 552 Content.DeleteRows(rows); 553 } else if (e.Control && e.KeyCode == Keys.F) { 554 CreateFindAndReplaceDialog(); 555 findAndReplaceDialog.ActivateSearch(); 556 } else if (e.Control && e.KeyCode == Keys.R) { 557 CreateFindAndReplaceDialog(); 558 findAndReplaceDialog.ActivateReplace(); 559 } 550 base.dataGridView_KeyDown(sender, e); 551 //data is in read only mode.... 552 if (Content.FilterLogic.IsFiltered) return; 553 554 if (e.KeyCode == Keys.Delete) { 555 //Delete column 556 if (dataGridView.SelectedColumns.Count > 0) { 557 var columnsToDelete = dataGridView.SelectedColumns.Cast<DataGridViewColumn>().OrderByDescending(col => col.Index).ToList(); 558 foreach (var col in columnsToDelete) 559 Content.DeleteColumn(col.Index); 560 } 561 //Delete row 562 if (dataGridView.SelectedRows.Count > 0) { 563 //necessary if columns are sorted to translate the selected row index 564 var rowIndexes = dataGridView.SelectedRows.Cast<DataGridViewRow>().Select(row => GetRowIndex(row.Index)).ToList(); 565 Content.DeleteRows(rowIndexes); 566 } 567 } else if (e.Control && e.KeyCode == Keys.F) { 568 CreateFindAndReplaceDialog(); 569 findAndReplaceDialog.ActivateSearch(); 570 } else if (e.Control && e.KeyCode == Keys.R) { 571 CreateFindAndReplaceDialog(); 572 findAndReplaceDialog.ActivateReplace(); 560 573 } 561 574 }
Note: See TracChangeset
for help on using the changeset viewer.