/// <summary> /// Called, when selected top filter changed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TopSearch_onItemSelected(object sender, EventArgs e) { if (!topSearch.selectedValue.Equals("no filter")) { currentFilter = new DatabaseFilter(topSearch.selectedValue); connector.insertPattern(currentFilter.ToString()); } else { currentFilter = null; } ApplyFilter(); }
public void RefreshFilterList() { topFilterList = connector.getTopPattern(10); if (currentFilter == null) { topSearch.Clear(); topSearch.AddItem("no filter"); foreach (string filter in topFilterList) { topSearch.AddItem(filter); } topSearch.selectedIndex = 0; } else { int indexSearch = topFilterList.IndexOf(currentFilter.ToString()); if (indexSearch == -1) { topSearch.Clear(); topSearch.AddItem(currentFilter.ToString()); topSearch.AddItem("no filter"); foreach (string filter in topFilterList) { topSearch.AddItem(filter); } topSearch.selectedIndex = 0; } else { topSearch.Clear(); topSearch.AddItem("no filter"); foreach (string filter in topFilterList) { topSearch.AddItem(filter); } topSearch.selectedIndex = indexSearch + 1; } } }
/// <summary> /// Send filter to main form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FilterButton_Click(object sender, EventArgs e) { int?ram = null; if (filterRam.Value != filterRam.MaximumValue) { ram = filterRam.Value; } int?weightLower = null; if (filterWeight.RangeMin != 0) { weightLower = filterWeight.RangeMin; } int?weightUpper = null; if (filterWeight.RangeMax != filterWeight.MaximumRange) { weightUpper = filterWeight.RangeMax; } int?width = null; if (filterWidth.Value != filterWidth.MaximumValue) { width = filterWidth.Value; } int?height = null; if (filterHeight.Value != filterHeight.MaximumValue) { height = filterHeight.Value; } int?depth = null; if (filterDepth.Value != filterDepth.MaximumValue) { depth = filterDepth.Value; } int?resolutionWidth = null; if (filterResolutionWidth.Value != filterResolutionWidth.MaximumValue) { resolutionWidth = filterResolutionWidth.Value; } int?resolutionHeight = null; if (filterResolutionHeight.Value != filterResolutionHeight.MaximumValue) { resolutionHeight = filterResolutionHeight.Value; } String cpu = null; if (!filterComboBoxCpu.SelectedItem.ToString().Equals("any")) { cpu = filterComboBoxCpu.SelectedItem.ToString(); } bool inconsistent = filterCheckBox.Checked; DatabaseFilter df = new DatabaseFilter(ram, weightLower, weightUpper, width, height, depth, resolutionWidth, resolutionHeight, cpu, inconsistent); formMain.currentFilter = df; formMain.connector.insertPattern(df.ToString()); formMain.RefreshFilterList(); formMain.ApplyFilter(); this.Hide(); }