Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10698


Ignore:
Timestamp:
04/02/14 12:27:46 (9 years ago)
Author:
sbreuer
Message:
  • refactoring - extract iterator class
  • create utils folder
Location:
branches/DataPreprocessing
Files:
4 added
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.Core/3.3/Constraints/ComparisonConstraint.cs

    r9456 r10698  
    3737    }
    3838    public ComparisonConstraint(IItem constrainedValue, ConstraintOperation comparisonOperation, object comparisonValue, bool active)
    39       : base(constrainedValue, comparisonOperation, comparisonOperation, active) {
     39      : base(constrainedValue, comparisonOperation, comparisonValue, active) {
    4040    }
    4141
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs

    r10672 r10698  
    3535    private bool notOwnEvent = true;
    3636    private FindAndReplaceDialog findAndReplaceDialog;
    37     private IDictionary<int, IList<int>> foundCells;
    38     private Tuple<int, int> currentCell;
     37    private IFindPreprocessingItemsIterator searchIterator;
    3938    private string currentSearchText;
    4039
     
    142141    }
    143142
    144 
     143    #region FindAndReplaceDialog
    145144
    146145    private void CreateFindAndReplaceDialog() {
    147146      findAndReplaceDialog = new FindAndReplaceDialog();
    148       findAndReplaceDialog.Show();
     147      findAndReplaceDialog.Show(this);
    149148      findAndReplaceDialog.FindAllEvent += findAndReplaceDialog_FindAllEvent;
    150149      findAndReplaceDialog.FindNextEvent += findAndReplaceDialog_FindNextEvent;
    151150      findAndReplaceDialog.ReplaceAllEvent += findAndReplaceDialog_ReplaceAllEvent;
    152151      findAndReplaceDialog.ReplaceNextEvent += findAndReplaceDialog_ReplaceEvent;
    153       foundCells = null;
    154       currentCell = null;
    155152    }
    156153
    157154    void findAndReplaceDialog_ReplaceEvent(object sender, EventArgs e) {
    158       if (foundCells != null)
     155      if (searchIterator != null && searchIterator.GetCurrent() != null)
    159156      {
    160         Replace(GetIndexOfCurrentSelectedCell());
     157        Replace(TransformToDictionary(searchIterator.GetCurrent()));
    161158      }
    162159    }
     
    167164
    168165    void findAndReplaceDialog_FindNextEvent(object sender, EventArgs e) {
    169       IDictionary<int, IList<int>> highlightCell;
    170       do {
    171         if (foundCells == null || currentSearchText != findAndReplaceDialog.GetSearchText()) {
    172           currentSearchText = findAndReplaceDialog.GetSearchText();
    173           foundCells = FindAll(findAndReplaceDialog.GetSearchText());
    174           currentCell = new Tuple<int, int>(0, 0);
    175         } else {
    176           if (currentCell.Item2 < foundCells[currentCell.Item1].Count - 1) {
    177             currentCell = new Tuple<int, int>(currentCell.Item1, currentCell.Item2 + 1);
    178           } else if (currentCell.Item1 < foundCells.Count - 1) {
    179             currentCell = new Tuple<int, int>(currentCell.Item1 + 1, 0);
    180           } else {
    181             currentCell = new Tuple<int, int>(0, 0);
    182           }
    183         }
    184 
    185         highlightCell = GetIndexOfCurrentSelectedCell();
    186 
    187       } while (!Content.GetValue(currentCell.Item1, highlightCell[currentCell.Item1].ElementAt(0)).Equals(currentSearchText));
    188       HightlightedCells = highlightCell;
     166      if (searchIterator == null || currentSearchText != findAndReplaceDialog.GetSearchText()) {
     167        searchIterator = new FindPreprocessingItemsIterator(FindAll(findAndReplaceDialog.GetSearchText()));
     168        currentSearchText = findAndReplaceDialog.GetSearchText();
     169      }
     170
     171      while (searchIterator.MoveNext() && (searchIterator.GetCurrent() == null || !Content.GetValue(searchIterator.GetCurrent().Item1, searchIterator.GetCurrent().Item2).Equals(currentSearchText))) {
     172       
     173      }
     174
     175      if (searchIterator.GetCurrent() != null) {
     176        HightlightedCells = TransformToDictionary(searchIterator.GetCurrent());
     177      } else {
     178        HightlightedCells.Clear();
     179      }
    189180    }
    190181
     
    233224    }
    234225
    235     private IDictionary<int, IList<int>> GetIndexOfCurrentSelectedCell() {
     226    private IDictionary<int, IList<int>> TransformToDictionary(Tuple<int, int> tuple) {
    236227      var highlightCells = new Dictionary<int, IList<int>>();
    237       int highlightCell = foundCells[currentCell.Item1].ElementAt(currentCell.Item2);
    238       highlightCells.Add(currentCell.Item1, new List<int>() { highlightCell });
     228      highlightCells.Add(tuple.Item1, new List<int>() { tuple.Item2 });
    239229      return highlightCells;
    240230    }
     231
     232    #endregion FindAndReplaceDialog
    241233
    242234    private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/HeuristicLab.DataPreprocessing.Views-3.3.csproj

    r10697 r10698  
    141141      <DependentUpon>TransformationView.cs</DependentUpon>
    142142    </Compile>
     143    <Compile Include="Utils\FindPreprocessingItemsIterator.cs" />
     144    <Compile Include="Utils\IFindPreprocessingItemsIterator.cs" />
    143145    <Compile Include="ViewShortcutCollectionView.cs">
    144146      <SubType>UserControl</SubType>
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/HeuristicLab.DataPreprocessing-3.3.csproj

    r10694 r10698  
    7575    <Compile Include="Implementations\PreprocessingData.cs" />
    7676    <Compile Include="Implementations\DataGridLogic.cs" />
    77     <Compile Include="Implementations\DataPreprocessingChangedEvent.cs" />
     77    <Compile Include="Utils\DataPreprocessingChangedEvent.cs" />
    7878    <Compile Include="Implementations\Filter\ComparisonFilter.cs" />
    7979    <Compile Include="Implementations\Filter\IFilter.cs" />
Note: See TracChangeset for help on using the changeset viewer.