private void ActionByIndex(int index, Action <Factory> action) { if (index >= 0 && index < Factories.Length) { action?.Invoke(Factories.GetFactoryByIndex(index)); UpdateListBox(); } }
private void PotentialProfitClicked(object sender, EventArgs e) { int profitIndex = listBox1.SelectedIndex; if (profitIndex >= 0 && profitIndex < Factories.Length) { new PotentialProfitForm(Factories.GetFactoryByIndex(profitIndex)).ShowDialog(); } }
private void UpdateListBox() { var selectedIndices = listBox1.SelectedIndices.Cast <int>().ToList(); listBox1.Items.Clear(); for (int i = 0; i < Factories.Length; i++) { listBox1.Items.Add(Factories.GetFactoryByIndex(i)); } listBox1.Update(); foreach (var item in selectedIndices) { listBox1.SetSelected(item, true); } }