/// <summary> /// Pre: n/a /// Post: n/a /// Description: Updates the filter /// </summary> private void UpdateFilter() { // Code only executes if filter is active if (filterActive) { // Creates new dictionary of filtered indexes filteredIndex = new Dictionary<int, int>(); // Filters the inventory with user's input List<int> filteredList = inventory.FilterItems((string)filterTypeComboBox.SelectedItem, filterTitleTxt.Text, (string)filterPlatformComboBox.SelectedItem); // Clears the list box itemListBox.Items.Clear(); // Loops through each filtered item for (int i = 0; i < filteredList.Count; ++i) { // Adds each filtered item to the list box itemListBox.Items.Add(inventory.items[filteredList[i]].Display()); // Adds the index to the dictionary of filtered indexes filteredIndex.Add(i, filteredList[i]); } // Resets selected index to 0, unless there are 0 items (prevents crashing) if (itemListBox.Items.Count != 0) itemListBox.SelectedIndex = 0; } }