Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/14/14 15:32:47 (10 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)

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.