Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/20/18 13:52:40 (5 years ago)
Author:
pfleck
Message:

#2845 reverted the last merge (r16307) because some revisions were missing

Location:
branches/2845_EnhancedProgress
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2845_EnhancedProgress

  • branches/2845_EnhancedProgress/HeuristicLab.DataPreprocessing.Views

  • branches/2845_EnhancedProgress/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs

    r16307 r16308  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    8585      base.RegisterContentEvents();
    8686      Content.Changed += Content_Changed;
    87       Content.PreprocessingData.FilterChanged += FilterLogic_FilterChanged;
     87      Content.FilterLogic.FilterChanged += FilterLogic_FilterChanged;
    8888    }
    8989
     
    9191      base.DeregisterContentEvents();
    9292      Content.Changed -= Content_Changed;
    93       Content.PreprocessingData.FilterChanged -= FilterLogic_FilterChanged;
     93      Content.FilterLogic.FilterChanged -= FilterLogic_FilterChanged;
    9494    }
    9595
     
    9898      searchIterator = null;
    9999      if (findAndReplaceDialog != null && !findAndReplaceDialog.IsDisposed) {
    100         if (Content.PreprocessingData.IsFiltered) {
     100        if (Content.FilterLogic.IsFiltered) {
    101101          findAndReplaceDialog.DisableReplace();
    102102        } else {
     
    104104        }
    105105      }
    106       btnReplace.Enabled = !Content.PreprocessingData.IsFiltered;
     106      btnReplace.Enabled = !Content.FilterLogic.IsFiltered;
    107107    }
    108108
     
    126126      string errorMessage;
    127127      if (!String.IsNullOrEmpty(e.FormattedValue.ToString())) {
    128         if (dataGridView.IsCurrentCellInEditMode && Content.PreprocessingData.IsFiltered) {
     128        if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered) {
    129129          errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode.";
    130130        } else {
     
    167167
    168168      ReplaceTransaction(() => {
    169         Content.PreprocessingData.InTransaction(() => {
     169        Content.PreProcessingData.InTransaction(() => {
    170170          for (int row = containsHeader ? 1 : 0; row < values.GetLength(1); row++) {
    171171            for (int col = 0; col < values.GetLength(0); col++) {
     
    177177              if (string.IsNullOrWhiteSpace(firstRow[i]))
    178178                firstRow[i] = string.Format("<{0}>", i);
    179             Content.PreprocessingData.RenameColumns(firstRow);
     179            Content.PreProcessingData.RenameColumns(firstRow);
    180180          }
    181181        });
     
    224224      if (e.Button == MouseButtons.Middle) {
    225225        int newIndex = e.ColumnIndex >= 0 ? e.ColumnIndex : 0;
    226         Content.PreprocessingData.InsertColumn<double>(newIndex.ToString(), newIndex);
     226        Content.PreProcessingData.InsertColumn<double>(newIndex.ToString(), newIndex);
    227227      } else if (e.Button == MouseButtons.Right && Content.SortableView) {
    228228        SortColumn(e.ColumnIndex);
     
    235235        if (e.Button == MouseButtons.Middle) {
    236236          int newIndex = e.RowIndex >= 0 ? e.RowIndex : 0;
    237           Content.PreprocessingData.InsertRow(newIndex);
     237          Content.PreProcessingData.InsertRow(newIndex);
    238238        }
    239239      }
     
    248248    }
    249249
    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);
    252252      OnContentChanged();
    253253    }
     
    271271        searchIterator = null;
    272272        DataGridView.SelectionChanged += DataGridView_SelectionChanged_FindAndReplace;
    273         if (Content.PreprocessingData.IsFiltered) {
     273        if (Content.FilterLogic.IsFiltered) {
    274274          findAndReplaceDialog.DisableReplace();
    275275        }
     
    405405      ComparisonOperation comparisonOperation = findAndReplaceDialog.GetComparisonOperation();
    406406      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++) {
    408408        var filters = CreateFilters(match, comparisonOperation, i);
    409409
    410         bool[] filteredRows = GetFilterResult(filters, true);
     410        bool[] filteredRows = Content.FilterLogic.GetFilterResult(filters, true);
    411411        var foundIndices = new List<int>();
    412412        for (int idx = 0; idx < filteredRows.Length; ++idx) {
     
    427427    }
    428428
    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 
    446429    private List<IFilter> CreateFilters(string match, ComparisonOperation comparisonOperation, int columnIndex) {
    447       IPreprocessingData preprocessingData = Content.PreprocessingData;
     430      IPreprocessingData preprocessingData = Content.FilterLogic.PreprocessingData;
    448431      IStringConvertibleValue value;
    449432      if (preprocessingData.VariableHasType<double>(columnIndex)) {
     
    490473          switch (findAndReplaceDialog.GetReplaceAction()) {
    491474            case ReplaceAction.Value:
    492               Content.ReplaceIndicesByString(cells, findAndReplaceDialog.GetReplaceText());
     475              Content.ManipulationLogic.ReplaceIndicesByValue(cells, findAndReplaceDialog.GetReplaceText());
    493476              break;
    494477            case ReplaceAction.Average:
    495               Content.ReplaceIndicesByMean(cells, false);
     478              Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells, false);
    496479              break;
    497480            case ReplaceAction.Median:
    498               Content.ReplaceIndicesByMedianValue(cells, false);
     481              Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells, false);
    499482              break;
    500483            case ReplaceAction.Random:
    501               Content.ReplaceIndicesByRandomValue(cells, false);
     484              Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells, false);
    502485              break;
    503486            case ReplaceAction.MostCommon:
    504               Content.ReplaceIndicesByMode(cells, false);
     487              Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells, false);
    505488              break;
    506489            case ReplaceAction.Interpolation:
    507               Content.ReplaceIndicesByLinearInterpolationOfNeighbours(cells);
     490              Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(cells);
    508491              break;
    509492          }
     
    523506
    524507    #endregion FindAndReplaceDialog
     508
    525509    private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
    526510      if (Content == null) return;
     
    547531            medianToolStripMenuItem_Selection.Enabled =
    548532            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);
    550539
    551540          replaceValueOverColumnToolStripMenuItem.Visible = true;
     
    558547      base.dataGridView_KeyDown(sender, e);
    559548      //data is in read only mode....
    560       if (Content.PreprocessingData.IsFiltered) return;
     549      if (Content.FilterLogic.IsFiltered) return;
    561550
    562551      if (e.KeyCode == Keys.Delete) {
     
    592581      }
    593582
    594       foreach (DataGridViewCell cell in dataGridView.SelectedCells) {
     583      foreach (var selectedCell in dataGridView.SelectedCells) {
     584        var cell = (DataGridViewCell)selectedCell;
    595585        if (!selectedCells.ContainsKey(cell.ColumnIndex))
    596           selectedCells.Add(cell.ColumnIndex, new List<int>());
     586          selectedCells.Add(cell.ColumnIndex, new List<int>(1024));
    597587        selectedCells[cell.ColumnIndex].Add(cell.RowIndex);
    598588      }
     
    601591    }
    602592
     593    private void StartReplacing() {
     594      SuspendRepaint();
     595    }
     596
     597    private void StopReplacing() {
     598      ResumeRepaint(true);
     599    }
     600
    603601    private void ReplaceTransaction(Action action) {
    604       SuspendRepaint();
     602      StartReplacing();
    605603      action();
    606       ResumeRepaint(true);
     604      StopReplacing();
    607605    }
    608606
     
    618616
    619617    #region ContextMenu Events
     618
    620619    private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) {
    621620      ReplaceTransaction(() => {
    622         Content.ReplaceIndicesByMean(GetSelectedCells(), false);
     621        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), false);
    623622      });
    624623    }
    625624    private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) {
    626625      ReplaceTransaction(() => {
    627         Content.ReplaceIndicesByMean(GetSelectedCells(), true);
     626        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true);
    628627      });
    629628    }
     
    631630    private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) {
    632631      ReplaceTransaction(() => {
    633         Content.ReplaceIndicesByMedianValue(GetSelectedCells(), false);
     632        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false);
    634633      });
    635634    }
    636635    private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) {
    637636      ReplaceTransaction(() => {
    638         Content.ReplaceIndicesByMedianValue(GetSelectedCells(), true);
     637        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true);
    639638      });
    640639    }
     
    642641    private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) {
    643642      ReplaceTransaction(() => {
    644         Content.ReplaceIndicesByRandomValue(GetSelectedCells(), false);
     643        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false);
    645644      });
    646645    }
    647646    private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) {
    648647      ReplaceTransaction(() => {
    649         Content.ReplaceIndicesByRandomValue(GetSelectedCells(), true);
     648        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true);
    650649      });
    651650    }
     
    653652    private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) {
    654653      ReplaceTransaction(() => {
    655         Content.ReplaceIndicesByMode(GetSelectedCells(), false);
     654        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false);
    656655      });
    657656    }
    658657    private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) {
    659658      ReplaceTransaction(() => {
    660         Content.ReplaceIndicesByMode(GetSelectedCells(), true);
     659        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true);
    661660      });
    662661    }
     
    664663    private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) {
    665664      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());
    667672      });
    668673    }
     
    670675
    671676    private void addRowButton_Click(object sender, EventArgs e) {
    672       Content.PreprocessingData.InsertRow(Content.Rows);
     677      Content.PreProcessingData.InsertRow(Content.Rows);
    673678    }
    674679
    675680    private void addColumnButton_Click(object sender, EventArgs e) {
    676       Content.PreprocessingData.InsertColumn<double>(Content.Columns.ToString(), Content.Columns);
     681      Content.PreProcessingData.InsertColumn<double>(Content.Columns.ToString(), Content.Columns);
    677682    }
    678683
     
    681686
    682687      if (renameDialog.ShowDialog(this) == DialogResult.OK) {
    683         Content.PreprocessingData.RenameColumns(renameDialog.ColumnNames);
     688        Content.PreProcessingData.RenameColumns(renameDialog.ColumnNames);
    684689      }
    685690    }
     
    688693      foreach (DataGridViewColumn column in DataGridView.Columns) {
    689694        var variable = column.HeaderText;
    690         bool isInputTarget = Content.PreprocessingData.InputVariables.Contains(variable)
    691           || Content.PreprocessingData.TargetVariable == variable;
     695        bool isInputTarget = Content.PreProcessingData.InputVariables.Contains(variable)
     696          || Content.PreProcessingData.TargetVariable == variable;
    692697        column.Visible = isInputTarget;
    693698      }
     
    705710      }
    706711    }
    707 
    708     private void shuffleAllButton_Click(object sender, EventArgs e) {
    709       Content.Shuffle(shuffleWithinPartitionsCheckBox.Checked);
    710     }
    711712  }
    712713}
Note: See TracChangeset for help on using the changeset viewer.