- Timestamp:
- 05/21/14 12:22:38 (10 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3
- Files:
-
- 4 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 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/SearchAndReplaceDialog.Designer.cs
r10762 r10870 37 37 this.txtValue = new System.Windows.Forms.TextBox(); 38 38 this.label1 = new System.Windows.Forms.Label(); 39 this.cmbComparisonOperator = new System.Windows.Forms.ComboBox(); 39 40 this.tabSearchReplace.SuspendLayout(); 40 41 this.tabReplace.SuspendLayout(); … … 67 68 // tabReplace 68 69 // 70 this.tabReplace.Controls.Add(this.cmbComparisonOperator); 69 71 this.tabReplace.Controls.Add(this.txtSearchString); 70 72 this.tabReplace.Controls.Add(this.lblSearch); … … 87 89 // txtSearchString 88 90 // 89 this.txtSearchString.Location = new System.Drawing.Point(1 03, 20);91 this.txtSearchString.Location = new System.Drawing.Point(154, 20); 90 92 this.txtSearchString.Name = "txtSearchString"; 91 this.txtSearchString.Size = new System.Drawing.Size(2 54, 20);93 this.txtSearchString.Size = new System.Drawing.Size(203, 20); 92 94 this.txtSearchString.TabIndex = 23; 93 95 // … … 171 173 this.label1.TabIndex = 14; 172 174 this.label1.Text = "Replace with"; 175 // 176 // cmbComparisonOperator 177 // 178 this.cmbComparisonOperator.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 179 this.cmbComparisonOperator.FormattingEnabled = true; 180 this.cmbComparisonOperator.Location = new System.Drawing.Point(103, 19); 181 this.cmbComparisonOperator.Name = "cmbComparisonOperator"; 182 this.cmbComparisonOperator.Size = new System.Drawing.Size(45, 21); 183 this.cmbComparisonOperator.TabIndex = 24; 173 184 // 174 185 // SearchAndReplaceDialog … … 206 217 private System.Windows.Forms.TextBox txtValue; 207 218 private System.Windows.Forms.Label label1; 219 private System.Windows.Forms.ComboBox cmbComparisonOperator; 208 220 } 209 221 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/SearchAndReplaceDialog.cs
r10762 r10870 13 13 } 14 14 15 public enum ComparisonOperation { 16 Equal, 17 Less, 18 LessOrEqual, 19 Greater, 20 GreaterOrEqual, 21 NotEqual 22 } 23 15 24 public partial class SearchAndReplaceDialog : Form { 16 25 private string[] cmbItemsText = { "Value", "Average", "Median", "Random", "Most Common", "Interpolation" }; 26 private string[] cmbComparisonOperatorText = { "==", "<", "<=", ">", ">=", "!=" }; 17 27 18 28 public SearchAndReplaceDialog() { … … 20 30 cmbReplaceWith.Items.AddRange(cmbItemsText); 21 31 cmbReplaceWith.SelectedIndex = (int)ReplaceAction.Value; 32 cmbComparisonOperator.Items.AddRange(cmbComparisonOperatorText); 33 cmbComparisonOperator.SelectedIndex = (int)ComparisonOperation.Equal; 22 34 } 23 35 … … 45 57 tabSearchReplace.SelectedTab.Controls.Add(lblSearch); 46 58 tabSearchReplace.SelectedTab.Controls.Add(txtSearchString); 59 tabSearchReplace.SelectedTab.Controls.Add(cmbComparisonOperator); 47 60 ActiveControl = txtSearchString; 48 61 AcceptButton = btnFindNext; … … 59 72 public ReplaceAction GetReplaceAction() { 60 73 return (ReplaceAction)cmbReplaceWith.SelectedIndex; 74 } 75 76 public ComparisonOperation GetComparisonOperation() { 77 return (ComparisonOperation)cmbComparisonOperator.SelectedIndex; 61 78 } 62 79 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/Utils/FindPreprocessingItemsIterator.cs
r10852 r10870 45 45 ++tmpColumnIndex; 46 46 } 47 if (startCell == null && tmpColumnIndex == columnIndex && rowIndex != 0) { 48 startCell = GetNextFoundCell(columnIndex, 0); 49 } 47 50 currentCell = startCell; 48 51 } … … 62 65 bool result = false; 63 66 bool endReached = false; 64 if ( items != null) {67 if (CurrentCellExists()) { 65 68 do { 66 69 if (currentCell.Item2 < items[currentCell.Item1].Count - 1) { … … 95 98 private bool CurrentCellExists() { 96 99 bool result = false; 97 if ( items != null) {100 if (currentCell != null && items != null) { 98 101 result = items.ContainsKey(currentCell.Item1) && currentCell.Item2 < items[currentCell.Item1].Count; 99 102 }
Note: See TracChangeset
for help on using the changeset viewer.