Changeset 10852


Ignore:
Timestamp:
05/14/14 15:32:47 (6 years ago)
Author:
rstoll
Message:
  • Search improved

take into account the selected cell when starting a search
updating data during search
updating data when dialog is closed and opened
changed selection during search from highlighting to actual selection (benefit, line chart will be selected according the search)

Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3
Files:
3 edited

Legend:

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

    r10844 r10852  
    8888      if (Content != null) {
    8989        Content.DataGridLogic.SetSelection(GetSelectedCells());
     90        if (AreMultipleCellsSelected()) {
     91          ResetHighlightedCellsBackground();
     92          HightlightedCellsBackground = GetSelectedCells();
     93          searchIterator = null;
     94        }
    9095      }
    9196    }
     
    120125        }
    121126      }
     127      searchIterator = null;
    122128    }
    123129
     
    164170      findAndReplaceDialog = new SearchAndReplaceDialog();
    165171      findAndReplaceDialog.Show(this);
    166       HightlightedCellsBackground = GetSelectedCells();
    167       dataGridView.ClearSelection();
     172      if (AreMultipleCellsSelected()) {
     173        HightlightedCellsBackground = GetSelectedCells();
     174        dataGridView.ClearSelection();
     175      }
    168176      findAndReplaceDialog.FindAllEvent += findAndReplaceDialog_FindAllEvent;
    169177      findAndReplaceDialog.FindNextEvent += findAndReplaceDialog_FindNextEvent;
     
    171179      findAndReplaceDialog.ReplaceNextEvent += findAndReplaceDialog_ReplaceEvent;
    172180      findAndReplaceDialog.FormClosing += findAndReplaceDialog_FormClosing;
     181      searchIterator = null;
    173182    }
    174183
     
    176185      ResetHighlightedCells();
    177186      ResetHighlightedCellsBackground();
     187      searchIterator = null;
    178188    }
    179189
     
    193203        currentSearchText = findAndReplaceDialog.GetSearchText();
    194204      }
     205      if (IsOneCellSelected()) {
     206        var first = GetSelectedCells().First();
     207        searchIterator.SetStartCell(first.Key, first.Value[0]);
     208      }
     209
    195210
    196211      bool moreOccurences = false;
     
    198213        currentCell = searchIterator.GetCurrent();
    199214        moreOccurences = searchIterator.MoveNext();
     215        if (IsOneCellSelected()) {
     216          var first = GetSelectedCells().First();
     217          if (currentCell.Item1 == first.Key && currentCell.Item2 == first.Value[0]) {
     218            if (!moreOccurences) {
     219              searchIterator.Reset();
     220            }
     221            currentCell = searchIterator.GetCurrent();
     222            moreOccurences = searchIterator.MoveNext();
     223
     224          }
     225        }
    200226      } while (moreOccurences && (currentCell == null || !Content.GetValue(currentCell.Item2, currentCell.Item1).Equals(currentSearchText)));
    201227
    202228      if (currentCell != null) {
    203         HightlightedCells = TransformToDictionary(currentCell);
    204         dataGridView.FirstDisplayedCell = dataGridView[currentCell.Item1, currentCell.Item2];
     229        dataGridView.ClearSelection();
     230        dataGridView[currentCell.Item1, currentCell.Item2].Selected = true;
    205231      } else {
    206232        ResetHighlightedCells();
    207233      }
    208234
    209       if (!moreOccurences) {
    210         searchIterator.Reset();
    211       }
     235      //if (!moreOccurences) {
     236      //  searchIterator.Reset();
     237      //  dataGridView.ClearSelection();
     238      //  currentCell = searchIterator.GetCurrent();
     239      //  dataGridView[currentCell.Item1, currentCell.Item2].Selected = true;
     240      //}
     241    }
     242
     243    private bool AreMultipleCellsSelected() {
     244      return GetSelectedCellCount() > 1;
     245    }
     246
     247    private bool IsOneCellSelected() {
     248      return GetSelectedCellCount() == 1;
     249    }
     250
     251    private int GetSelectedCellCount() {
     252      int count = 0;
     253      foreach (var column in GetSelectedCells()) {
     254        count += column.Value.Count();
     255      }
     256      return count;
    212257    }
    213258
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/Utils/FindPreprocessingItemsIterator.cs

    r10719 r10852  
    2323using System.Collections.Generic;
    2424using System.Linq;
    25 using System.Text;
    2625
    2726namespace HeuristicLab.DataPreprocessing.Views {
     
    3332      this.items = items;
    3433      Reset();
     34    }
     35
     36
     37    public void SetStartCell(int columnIndex, int rowIndex) {
     38      Tuple<int, int> startCell = GetNextFoundCell(columnIndex, rowIndex);
     39      int tmpColumnIndex = columnIndex + 1;
     40      while (startCell == null && tmpColumnIndex != columnIndex) {
     41        if (!items.ContainsKey(tmpColumnIndex)) {
     42          tmpColumnIndex = 0;
     43        }
     44        startCell = GetNextFoundCell(tmpColumnIndex, 0);
     45        ++tmpColumnIndex;
     46      }
     47      currentCell = startCell;
     48    }
     49
     50    private Tuple<int, int> GetNextFoundCell(int columnIndex, int rowIndex) {
     51      Tuple<int, int> next = null;
     52      for (int i = 0; i < items[columnIndex].Count; ++i) {
     53        if (items[columnIndex][i] >= rowIndex) {
     54          next = new Tuple<int, int>(columnIndex, i);
     55          break;
     56        }
     57      }
     58      return next;
    3559    }
    3660
     
    5478
    5579    public Tuple<int, int> GetCurrent() {
    56       Tuple<int, int> resultCells = null;
     80      Tuple<int, int> resultCell = null;
    5781      if (items != null && CurrentCellExists()) {
    5882        int cellRow = items[currentCell.Item1].ElementAt(currentCell.Item2);
    59         resultCells = new Tuple<int, int>(currentCell.Item1, cellRow);
     83        resultCell = new Tuple<int, int>(currentCell.Item1, cellRow);
    6084      }
    61       return resultCells;
     85      return resultCell;
    6286    }
    6387
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/Utils/IFindPreprocessingItemsIterator.cs

    r10698 r10852  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423
    2524namespace HeuristicLab.DataPreprocessing.Views {
     
    2827    bool MoveNext();
    2928    void Reset();
     29    void SetStartCell(int columnIndex, int rowIndex);
    3030  }
    3131}
Note: See TracChangeset for help on using the changeset viewer.