private void UpdateFiltersButton_Click(object sender, EventArgs e) { //Determine if filtering by ID Range if (IDRangeMinInput.Text != "00000000" || IDRangeMaxInput.Text != "FFFFFFFF") { currentFilters.idRangeActive = true; currentFilters.idRangeMin = HexConverter.HexToInt(IDRangeMinInput.Text); currentFilters.idRangeMax = HexConverter.HexToInt(IDRangeMaxInput.Text); } else { currentFilters.idRangeActive = false; } //Determine if filtering by Category if (CategoryComboBox.SelectedIndex >= 0) { currentFilters.categoryActive = true; currentFilters.category = CategoryComboBox.Items[ CategoryComboBox.SelectedIndex] as string; } else { currentFilters.categoryActive = false; } //Determine if filtering by name string match if (NameFilterInput.Text != "") { currentFilters.nameStringMatchActive = true; currentFilters.nameString = NameFilterInput.Text.Trim(' '); } else { currentFilters.nameStringMatchActive = false; } //Determine if filtering by field name if (FieldNameInput.Text != "") { currentFilters.fieldNameActive = true; currentFilters.fieldName = FieldNameInput.Text; } else { currentFilters.fieldNameActive = false; } RefreshList(); }
//********************************************************************* //************************** Form Operations ************************** //********************************************************************* //Finds a tech in the current view and selects it. REturns true if selected public bool Select(uint id) { int rows = TechListGrid.Rows.Count; if (rows == 0) { return(false); } int a = 0; int b = rows - 1; int c = (b - a) / 2; uint current = HexConverter.HexToInt(TechListGrid.Rows[c].Cells[0].Value as string); //Check last record if (HexConverter.HexToInt(TechListGrid.Rows[b].Cells[0].Value as string) == id) { current = id; //skips the loop c = b; //postcondition is c is target row } while ((current != id) && (b - a > 1)) { current = HexConverter.HexToInt(TechListGrid.Rows[c].Cells[0].Value as string); if (id > current) { //upper range selected for further search a = c; c = a + (b - a) / 2; } else if (id < current) { //lower range selected for further search b = c; c = a + (b - a) / 2; } } if (id == current) { //Found. Select the tech found at row c TechListGrid.ClearSelection(); TechListGrid.Rows[c].Selected = true; TechListGrid.FirstDisplayedScrollingRowIndex = c; return(true); } return(false); }