private void filterList(int list, string cats)
{
ListBox pListBox = null;
List<int> pList = null;
currentList = list;
currentCats = cats;
switch (list)
{
case 2:
pListBox = this.listBoxCommands;
pList = commandList;
break;
case 1:
pListBox = this.listBoxCreatures;
pList = creatureList;
break;
case 0:
pListBox = this.listBoxItems;
pList = itemList;
break;
}
if (pListBox != null)
{
pListBox.Items.Clear();
pList.Clear();
int i = 0;
foreach (Entity entity in entities)
{
if ((this.textBoxSearch.Text.Length == 0 || entity.name.IndexOf(this.textBoxSearch.Text, StringComparison.InvariantCultureIgnoreCase) >= 0) && entity.category.Length >= cats.Length && cats == entity.category.Substring(0, cats.Length))
{
pListBox.Items.Add(entity.name);
pList.Add(i);
}
i++;
}
}
}