Changeset 16308 for branches/2845_EnhancedProgress/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs
- Timestamp:
- 11/20/18 13:52:40 (5 years ago)
- Location:
- branches/2845_EnhancedProgress
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2845_EnhancedProgress
- Property svn:mergeinfo changed
/stable reverse-merged: 15587-15588 /trunk/sources removed
- Property svn:mergeinfo changed
-
branches/2845_EnhancedProgress/HeuristicLab.DataPreprocessing.Views
- Property svn:mergeinfo changed
-
branches/2845_EnhancedProgress/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs
r16307 r16308 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 8Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 85 85 base.RegisterContentEvents(); 86 86 Content.Changed += Content_Changed; 87 Content. PreprocessingData.FilterChanged += FilterLogic_FilterChanged;87 Content.FilterLogic.FilterChanged += FilterLogic_FilterChanged; 88 88 } 89 89 … … 91 91 base.DeregisterContentEvents(); 92 92 Content.Changed -= Content_Changed; 93 Content. PreprocessingData.FilterChanged -= FilterLogic_FilterChanged;93 Content.FilterLogic.FilterChanged -= FilterLogic_FilterChanged; 94 94 } 95 95 … … 98 98 searchIterator = null; 99 99 if (findAndReplaceDialog != null && !findAndReplaceDialog.IsDisposed) { 100 if (Content. PreprocessingData.IsFiltered) {100 if (Content.FilterLogic.IsFiltered) { 101 101 findAndReplaceDialog.DisableReplace(); 102 102 } else { … … 104 104 } 105 105 } 106 btnReplace.Enabled = !Content. PreprocessingData.IsFiltered;106 btnReplace.Enabled = !Content.FilterLogic.IsFiltered; 107 107 } 108 108 … … 126 126 string errorMessage; 127 127 if (!String.IsNullOrEmpty(e.FormattedValue.ToString())) { 128 if (dataGridView.IsCurrentCellInEditMode && Content. PreprocessingData.IsFiltered) {128 if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered) { 129 129 errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode."; 130 130 } else { … … 167 167 168 168 ReplaceTransaction(() => { 169 Content.Pre processingData.InTransaction(() => {169 Content.PreProcessingData.InTransaction(() => { 170 170 for (int row = containsHeader ? 1 : 0; row < values.GetLength(1); row++) { 171 171 for (int col = 0; col < values.GetLength(0); col++) { … … 177 177 if (string.IsNullOrWhiteSpace(firstRow[i])) 178 178 firstRow[i] = string.Format("<{0}>", i); 179 Content.Pre processingData.RenameColumns(firstRow);179 Content.PreProcessingData.RenameColumns(firstRow); 180 180 } 181 181 }); … … 224 224 if (e.Button == MouseButtons.Middle) { 225 225 int newIndex = e.ColumnIndex >= 0 ? e.ColumnIndex : 0; 226 Content.Pre processingData.InsertColumn<double>(newIndex.ToString(), newIndex);226 Content.PreProcessingData.InsertColumn<double>(newIndex.ToString(), newIndex); 227 227 } else if (e.Button == MouseButtons.Right && Content.SortableView) { 228 228 SortColumn(e.ColumnIndex); … … 235 235 if (e.Button == MouseButtons.Middle) { 236 236 int newIndex = e.RowIndex >= 0 ? e.RowIndex : 0; 237 Content.Pre processingData.InsertRow(newIndex);237 Content.PreProcessingData.InsertRow(newIndex); 238 238 } 239 239 } … … 248 248 } 249 249 250 private void btnApplySort_Click(object sender, EventArgs e) {251 Content. ReOrderToIndices(virtualRowIndices);250 private void btnApplySort_Click(object sender, System.EventArgs e) { 251 Content.ManipulationLogic.ReOrderToIndices(virtualRowIndices); 252 252 OnContentChanged(); 253 253 } … … 271 271 searchIterator = null; 272 272 DataGridView.SelectionChanged += DataGridView_SelectionChanged_FindAndReplace; 273 if (Content. PreprocessingData.IsFiltered) {273 if (Content.FilterLogic.IsFiltered) { 274 274 findAndReplaceDialog.DisableReplace(); 275 275 } … … 405 405 ComparisonOperation comparisonOperation = findAndReplaceDialog.GetComparisonOperation(); 406 406 var foundCells = new Dictionary<int, IList<int>>(); 407 for (int i = 0; i < Content. PreprocessingData.Columns; i++) {407 for (int i = 0; i < Content.FilterLogic.PreprocessingData.Columns; i++) { 408 408 var filters = CreateFilters(match, comparisonOperation, i); 409 409 410 bool[] filteredRows = GetFilterResult(filters, true);410 bool[] filteredRows = Content.FilterLogic.GetFilterResult(filters, true); 411 411 var foundIndices = new List<int>(); 412 412 for (int idx = 0; idx < filteredRows.Length; ++idx) { … … 427 427 } 428 428 429 private bool[] GetFilterResult(IList<IFilter> filters, bool isAndCombination) {430 IList<IFilter> activeFilters = filters.Where(f => f.Active && f.ConstraintData != null).ToList();431 432 if (activeFilters.Count == 0) {433 return Enumerable.Repeat(false, Content.PreprocessingData.Rows).ToArray(); ;434 }435 436 var result = Enumerable.Repeat(!isAndCombination, Content.PreprocessingData.Rows).ToArray();437 foreach (IFilter filter in activeFilters) {438 bool[] filterResult = filter.Check();439 for (int row = 0; row < result.Length; ++row) {440 result[row] = isAndCombination ? result[row] || filterResult[row] : result[row] && filterResult[row];441 }442 }443 return result;444 }445 446 429 private List<IFilter> CreateFilters(string match, ComparisonOperation comparisonOperation, int columnIndex) { 447 IPreprocessingData preprocessingData = Content. PreprocessingData;430 IPreprocessingData preprocessingData = Content.FilterLogic.PreprocessingData; 448 431 IStringConvertibleValue value; 449 432 if (preprocessingData.VariableHasType<double>(columnIndex)) { … … 490 473 switch (findAndReplaceDialog.GetReplaceAction()) { 491 474 case ReplaceAction.Value: 492 Content. ReplaceIndicesByString(cells, findAndReplaceDialog.GetReplaceText());475 Content.ManipulationLogic.ReplaceIndicesByValue(cells, findAndReplaceDialog.GetReplaceText()); 493 476 break; 494 477 case ReplaceAction.Average: 495 Content. ReplaceIndicesByMean(cells, false);478 Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells, false); 496 479 break; 497 480 case ReplaceAction.Median: 498 Content. ReplaceIndicesByMedianValue(cells, false);481 Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells, false); 499 482 break; 500 483 case ReplaceAction.Random: 501 Content. ReplaceIndicesByRandomValue(cells, false);484 Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells, false); 502 485 break; 503 486 case ReplaceAction.MostCommon: 504 Content. ReplaceIndicesByMode(cells, false);487 Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells, false); 505 488 break; 506 489 case ReplaceAction.Interpolation: 507 Content. ReplaceIndicesByLinearInterpolationOfNeighbours(cells);490 Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(cells); 508 491 break; 509 492 } … … 523 506 524 507 #endregion FindAndReplaceDialog 508 525 509 private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { 526 510 if (Content == null) return; … … 547 531 medianToolStripMenuItem_Selection.Enabled = 548 532 randomToolStripMenuItem_Column.Enabled = 549 randomToolStripMenuItem_Selection.Enabled = !Content.PreprocessingData.AreAllStringColumns(columnIndices); 533 randomToolStripMenuItem_Selection.Enabled = !Content.PreProcessingData.AreAllStringColumns(columnIndices); 534 535 smoothingToolStripMenuItem_Column.Enabled = 536 interpolationToolStripMenuItem_Column.Enabled = !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, 0]) 537 && !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, Content.Rows - 1]) 538 && !Content.PreProcessingData.AreAllStringColumns(columnIndices); 550 539 551 540 replaceValueOverColumnToolStripMenuItem.Visible = true; … … 558 547 base.dataGridView_KeyDown(sender, e); 559 548 //data is in read only mode.... 560 if (Content. PreprocessingData.IsFiltered) return;549 if (Content.FilterLogic.IsFiltered) return; 561 550 562 551 if (e.KeyCode == Keys.Delete) { … … 592 581 } 593 582 594 foreach (DataGridViewCell cell in dataGridView.SelectedCells) { 583 foreach (var selectedCell in dataGridView.SelectedCells) { 584 var cell = (DataGridViewCell)selectedCell; 595 585 if (!selectedCells.ContainsKey(cell.ColumnIndex)) 596 selectedCells.Add(cell.ColumnIndex, new List<int>( ));586 selectedCells.Add(cell.ColumnIndex, new List<int>(1024)); 597 587 selectedCells[cell.ColumnIndex].Add(cell.RowIndex); 598 588 } … … 601 591 } 602 592 593 private void StartReplacing() { 594 SuspendRepaint(); 595 } 596 597 private void StopReplacing() { 598 ResumeRepaint(true); 599 } 600 603 601 private void ReplaceTransaction(Action action) { 604 S uspendRepaint();602 StartReplacing(); 605 603 action(); 606 ResumeRepaint(true);604 StopReplacing(); 607 605 } 608 606 … … 618 616 619 617 #region ContextMenu Events 618 620 619 private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) { 621 620 ReplaceTransaction(() => { 622 Content. ReplaceIndicesByMean(GetSelectedCells(), false);621 Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), false); 623 622 }); 624 623 } 625 624 private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) { 626 625 ReplaceTransaction(() => { 627 Content. ReplaceIndicesByMean(GetSelectedCells(), true);626 Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true); 628 627 }); 629 628 } … … 631 630 private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) { 632 631 ReplaceTransaction(() => { 633 Content. ReplaceIndicesByMedianValue(GetSelectedCells(), false);632 Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false); 634 633 }); 635 634 } 636 635 private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) { 637 636 ReplaceTransaction(() => { 638 Content. ReplaceIndicesByMedianValue(GetSelectedCells(), true);637 Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true); 639 638 }); 640 639 } … … 642 641 private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) { 643 642 ReplaceTransaction(() => { 644 Content. ReplaceIndicesByRandomValue(GetSelectedCells(), false);643 Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false); 645 644 }); 646 645 } 647 646 private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) { 648 647 ReplaceTransaction(() => { 649 Content. ReplaceIndicesByRandomValue(GetSelectedCells(), true);648 Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true); 650 649 }); 651 650 } … … 653 652 private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) { 654 653 ReplaceTransaction(() => { 655 Content. ReplaceIndicesByMode(GetSelectedCells(), false);654 Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false); 656 655 }); 657 656 } 658 657 private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) { 659 658 ReplaceTransaction(() => { 660 Content. ReplaceIndicesByMode(GetSelectedCells(), true);659 Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true); 661 660 }); 662 661 } … … 664 663 private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) { 665 664 ReplaceTransaction(() => { 666 Content.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells()); 665 Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells()); 666 }); 667 } 668 669 private void ReplaceWithSmoothing_Selection_Click(object sender, EventArgs e) { 670 ReplaceTransaction(() => { 671 Content.ManipulationLogic.ReplaceIndicesBySmoothing(GetSelectedCells()); 667 672 }); 668 673 } … … 670 675 671 676 private void addRowButton_Click(object sender, EventArgs e) { 672 Content.Pre processingData.InsertRow(Content.Rows);677 Content.PreProcessingData.InsertRow(Content.Rows); 673 678 } 674 679 675 680 private void addColumnButton_Click(object sender, EventArgs e) { 676 Content.Pre processingData.InsertColumn<double>(Content.Columns.ToString(), Content.Columns);681 Content.PreProcessingData.InsertColumn<double>(Content.Columns.ToString(), Content.Columns); 677 682 } 678 683 … … 681 686 682 687 if (renameDialog.ShowDialog(this) == DialogResult.OK) { 683 Content.Pre processingData.RenameColumns(renameDialog.ColumnNames);688 Content.PreProcessingData.RenameColumns(renameDialog.ColumnNames); 684 689 } 685 690 } … … 688 693 foreach (DataGridViewColumn column in DataGridView.Columns) { 689 694 var variable = column.HeaderText; 690 bool isInputTarget = Content.Pre processingData.InputVariables.Contains(variable)691 || Content.Pre processingData.TargetVariable == variable;695 bool isInputTarget = Content.PreProcessingData.InputVariables.Contains(variable) 696 || Content.PreProcessingData.TargetVariable == variable; 692 697 column.Visible = isInputTarget; 693 698 } … … 705 710 } 706 711 } 707 708 private void shuffleAllButton_Click(object sender, EventArgs e) {709 Content.Shuffle(shuffleWithinPartitionsCheckBox.Checked);710 }711 712 } 712 713 }
Note: See TracChangeset
for help on using the changeset viewer.