Changeset 10870 for branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs
- Timestamp:
- 05/21/14 12:22:38 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs
r10863 r10870 35 35 36 36 private bool notOwnEvent = true; 37 private bool isSearching = false; 37 38 private SearchAndReplaceDialog findAndReplaceDialog; 38 39 private IFindPreprocessingItemsIterator searchIterator; 39 40 private string currentSearchText; 41 private ComparisonOperation currentComparisonOperation; 40 42 private Tuple<int, int> currentCell; 41 43 … … 54 56 } 55 57 56 private IDictionary<int, IList<int>> _highlightedCells;57 public IDictionary<int, IList<int>> HightlightedCells {58 get { return _highlightedCells; }59 set {60 _highlightedCells = value;61 Refresh();62 }63 }64 65 58 private IDictionary<int, IList<int>> _highlightedCellsBackground; 66 59 public IDictionary<int, IList<int>> HightlightedCellsBackground { … … 78 71 dataGridView.KeyDown += dataGridView_KeyDown; 79 72 contextMenuCell.Items.Add(ShowHideColumns); 80 _highlightedCells = new Dictionary<int, IList<int>>();81 73 _highlightedRowIndices = new List<int>(); 82 74 _highlightedCellsBackground = new Dictionary<int, IList<int>>(); … … 86 78 87 79 void DataGridView_SelectionChanged(object sender, EventArgs e) { 88 Content.DataGridLogic.SetSelection(GetSelectedCells()); 80 if (!isSearching) { 81 Content.DataGridLogic.SetSelection(GetSelectedCells()); 82 } 89 83 } 90 84 … … 179 173 void DataGridView_SelectionChanged_FindAndReplace(object sender, EventArgs e) { 180 174 if (Content != null) { 181 if ( AreMultipleCellsSelected()) {175 if (!isSearching && AreMultipleCellsSelected()) { 182 176 ResetHighlightedCellsBackground(); 183 177 HightlightedCellsBackground = GetSelectedCells(); … … 188 182 189 183 void findAndReplaceDialog_FormClosing(object sender, FormClosingEventArgs e) { 190 ResetHighlightedCells();191 184 ResetHighlightedCellsBackground(); 192 185 searchIterator = null; … … 205 198 206 199 void findAndReplaceDialog_FindNextEvent(object sender, EventArgs e) { 207 if (searchIterator == null || currentSearchText != findAndReplaceDialog.GetSearchText()) { 200 if (searchIterator == null || 201 currentSearchText != findAndReplaceDialog.GetSearchText() || 202 currentComparisonOperation != findAndReplaceDialog.GetComparisonOperation()) { 208 203 searchIterator = new FindPreprocessingItemsIterator(FindAll(findAndReplaceDialog.GetSearchText())); 209 204 currentSearchText = findAndReplaceDialog.GetSearchText(); 210 } 205 currentComparisonOperation = findAndReplaceDialog.GetComparisonOperation(); 206 } 207 211 208 if (IsOneCellSelected()) { 212 209 var first = GetSelectedCells().First(); … … 214 211 } 215 212 216 217 213 bool moreOccurences = false; 218 do { 219 currentCell = searchIterator.GetCurrent(); 220 moreOccurences = searchIterator.MoveNext(); 221 if (IsOneCellSelected()) { 222 var first = GetSelectedCells().First(); 223 if (currentCell.Item1 == first.Key && currentCell.Item2 == first.Value[0]) { 224 if (!moreOccurences) { 225 searchIterator.Reset(); 226 } 227 currentCell = searchIterator.GetCurrent(); 228 moreOccurences = searchIterator.MoveNext(); 229 214 currentCell = searchIterator.GetCurrent(); 215 moreOccurences = searchIterator.MoveNext(); 216 if (IsOneCellSelected() && currentCell != null) { 217 var first = GetSelectedCells().First(); 218 if (currentCell.Item1 == first.Key && currentCell.Item2 == first.Value[0]) { 219 if (!moreOccurences) { 220 searchIterator.Reset(); 230 221 } 231 } 232 } while (moreOccurences && (currentCell == null || !Content.GetValue(currentCell.Item2, currentCell.Item1).Equals(currentSearchText))); 222 currentCell = searchIterator.GetCurrent(); 223 moreOccurences = searchIterator.MoveNext(); 224 if (!moreOccurences) { 225 searchIterator.Reset(); 226 } 227 } 228 } 229 230 dataGridView.ClearSelection(); 233 231 234 232 if (currentCell != null) { 235 dataGridView.ClearSelection();236 233 dataGridView[currentCell.Item1, currentCell.Item2].Selected = true; 237 } else { 238 ResetHighlightedCells(); 239 } 240 241 //if (!moreOccurences) { 242 // searchIterator.Reset(); 243 // dataGridView.ClearSelection(); 244 // currentCell = searchIterator.GetCurrent(); 245 // dataGridView[currentCell.Item1, currentCell.Item2].Selected = true; 246 //} 234 } 247 235 } 248 236 … … 264 252 265 253 void findAndReplaceDialog_FindAllEvent(object sender, EventArgs e) { 266 HightlightedCells = FindAll(findAndReplaceDialog.GetSearchText()); 254 dataGridView.ClearSelection(); 255 isSearching = true; 256 foreach (var column in FindAll(findAndReplaceDialog.GetSearchText())) { 257 foreach (var cell in column.Value) { 258 dataGridView[column.Key, cell].Selected = true; 259 } 260 } 261 isSearching = false; 262 DataGridView_SelectionChanged(null, null); 263 } 264 265 private Core.ConstraintOperation GetConstraintOperation(ComparisonOperation comparisonOperation) { 266 Core.ConstraintOperation constraintOperation = Core.ConstraintOperation.Equal; 267 switch (comparisonOperation) { 268 case ComparisonOperation.Equal: 269 constraintOperation = Core.ConstraintOperation.Equal; 270 break; 271 case ComparisonOperation.Greater: 272 constraintOperation = Core.ConstraintOperation.Greater; 273 break; 274 case ComparisonOperation.GreaterOrEqual: 275 constraintOperation = Core.ConstraintOperation.GreaterOrEqual; 276 break; 277 case ComparisonOperation.Less: 278 constraintOperation = Core.ConstraintOperation.Less; 279 break; 280 case ComparisonOperation.LessOrEqual: 281 constraintOperation = Core.ConstraintOperation.LessOrEqual; 282 break; 283 case ComparisonOperation.NotEqual: 284 constraintOperation = Core.ConstraintOperation.NotEqual; 285 break; 286 } 287 return constraintOperation; 267 288 } 268 289 269 290 private IDictionary<int, IList<int>> FindAll(string match) { 270 291 bool searchInSelection = HightlightedCellsBackground.Values.Sum(list => list.Count) > 1; 271 var comparisonFilter = new ComparisonFilter(Content.FilterLogic.PreprocessingData, Core.ConstraintOperation.Equal, new StringValue(match), true); 292 ComparisonOperation comparisonOperation = findAndReplaceDialog.GetComparisonOperation(); 293 var comparisonFilter = new ComparisonFilter(Content.FilterLogic.PreprocessingData, GetConstraintOperation(comparisonOperation), new StringValue(match), true); 272 294 var filters = new List<Filter.IFilter>() { comparisonFilter }; 273 295 var foundCells = new Dictionary<int, IList<int>>(); … … 324 346 } 325 347 326 private void ResetHighlightedCells() {327 HightlightedCells = new Dictionary<int, IList<int>>();328 }329 330 348 private void ResetHighlightedCellsBackground() { 331 349 HightlightedCellsBackground = new Dictionary<int, IList<int>>(); … … 374 392 if (e.State.HasFlag(DataGridViewElementStates.Selected)) return; 375 393 if (!e.PaintParts.HasFlag(DataGridViewPaintParts.Background)) return; 376 if (HighlightedRowIndices == null && HightlightedCells == null) return;394 if (HighlightedRowIndices == null) return; 377 395 378 396 int rowIndex = virtualRowIndices[e.RowIndex]; … … 382 400 if (HightlightedCellsBackground.ContainsKey(e.ColumnIndex) && HightlightedCellsBackground[e.ColumnIndex].Contains(e.RowIndex)) { 383 401 backColor = Color.LightGray; 384 }385 if (HighlightedRowIndices.Contains(rowIndex) || HightlightedCells.ContainsKey(e.ColumnIndex) && HightlightedCells[e.ColumnIndex].Contains(e.RowIndex)) {386 backColor = Color.LightGreen;387 402 } 388 403
Note: See TracChangeset
for help on using the changeset viewer.