Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10719


Ignore:
Timestamp:
04/02/14 16:13:55 (11 years ago)
Author:
sbreuer
Message:
  • highlight selected cells when search an replace opens
Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3
Files:
2 edited

Legend:

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

    r10712 r10719  
    2626using System.Windows.Forms;
    2727using HeuristicLab.Data;
     28using HeuristicLab.DataPreprocessing.Filter;
    2829using HeuristicLab.MainForm;
    2930
     
    5859      set {
    5960        _highlightedCells = value;
     61        Refresh();
     62      }
     63    }
     64
     65    private IDictionary<int, IList<int>> _highlightedCellsBackground;
     66    public IDictionary<int, IList<int>> HightlightedCellsBackground {
     67      get { return _highlightedCellsBackground; }
     68      set {
     69        _highlightedCellsBackground = value;
    6070        Refresh();
    6171      }
     
    7080      _highlightedCells = new Dictionary<int, IList<int>>();
    7181      _highlightedRowIndices = new List<int>();
     82      _highlightedCellsBackground = new Dictionary<int, IList<int>>();
    7283      currentCell = null;
    7384    }
     
    147158      findAndReplaceDialog = new FindAndReplaceDialog();
    148159      findAndReplaceDialog.Show(this);
     160      HightlightedCellsBackground = GetSelectedCells();
     161      dataGridView.ClearSelection();
    149162      findAndReplaceDialog.FindAllEvent += findAndReplaceDialog_FindAllEvent;
    150163      findAndReplaceDialog.FindNextEvent += findAndReplaceDialog_FindNextEvent;
     
    156169    void findAndReplaceDialog_FormClosing(object sender, FormClosingEventArgs e) {
    157170      ResetHighlightedCells();
     171      ResetHighlightedCellsBackground();
    158172    }
    159173
     
    188202      if (!moreOccurences) {
    189203        searchIterator.Reset();
    190         ResetHighlightedCells();
    191204      }
    192205    }
     
    194207    void findAndReplaceDialog_FindAllEvent(object sender, EventArgs e) {
    195208      HightlightedCells = FindAll(findAndReplaceDialog.GetSearchText());
     209      searchIterator.Reset();
    196210    }
    197211
    198212    private IDictionary<int, IList<int>> FindAll(string match) {
    199       var comparisonFilter = new Filter.ComparisonFilter(Content.FilterLogic.PreprocessingData, Core.ConstraintOperation.Equal, new StringValue(match), true);
     213      bool searchInSelection = HightlightedCellsBackground.Values.Sum(list => list.Count) > 1;
     214      var comparisonFilter = new ComparisonFilter(Content.FilterLogic.PreprocessingData, Core.ConstraintOperation.Equal, new StringValue(match), true);
    200215      var filters = new List<Filter.IFilter>() { comparisonFilter };
    201216      var foundCells = new Dictionary<int, IList<int>>();
     
    207222          .Select(pair => pair.Index)
    208223          .ToList();
     224        IList<int> selectedList;
     225        if (searchInSelection && HightlightedCellsBackground.TryGetValue(i, out selectedList)) {
     226          foundCells[i].Intersect(selectedList);
     227        } else {
     228          foundCells[i].Clear();
     229        }
    209230      }
    210231      return foundCells;
     
    244265    private void ResetHighlightedCells() {
    245266      HightlightedCells = new Dictionary<int, IList<int>>();
     267    }
     268
     269    private void ResetHighlightedCellsBackground() {
     270      HightlightedCellsBackground = new Dictionary<int, IList<int>>();
    246271    }
    247272
     
    284309      Color backColor = e.CellStyle.BackColor;
    285310
     311      if (HightlightedCellsBackground.ContainsKey(e.ColumnIndex) && HightlightedCellsBackground[e.ColumnIndex].Contains(e.RowIndex)) {
     312        backColor = Color.LightGray;
     313      }
    286314      if (HighlightedRowIndices.Contains(rowIndex) || HightlightedCells.ContainsKey(e.ColumnIndex) && HightlightedCells[e.ColumnIndex].Contains(e.RowIndex)) {
    287         backColor = Color.Pink;
     315        backColor = Color.LightGreen;
    288316      }
    289317
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/Utils/FindPreprocessingItemsIterator.cs

    r10705 r10719  
    7676      return result;
    7777    }
    78 
    79     //private bool EndReached() {
    80     //  bool result = true;
    81     //  if (items != null && CurrentCellExists()) {
    82     //    result = currentCell.Item1 >= items.Count - 1 && currentCell.Item2 >= items[currentCell.Item1].Count - 1;
    83     //  }
    84     //  return result;
    85     //}
    8678  }
    8779}
Note: See TracChangeset for help on using the changeset viewer.