private void AddButton_Click(object sender, EventArgs e) { if (int.TryParse(AddTextBox.Text, out int value)) { var item = new SortedItem(value, items.Count); items.Add(item); } RefreshItems(); AddTextBox.Text = ""; }
private void AddRandom_Click(object sender, EventArgs e) { if (int.TryParse(AddRandomTextBox.Text, out int value)) { var rnd = new Random(); for (int i = 0; i < value; i++) { var item = new SortedItem(rnd.Next(100), items.Count); items.Add(item); } } RefreshItems(); AddRandomTextBox.Text = ""; }
private void Swap(SortedItem a, SortedItem b) { a.SetColor(Color.Red); b.SetColor(Color.Green); }