private void addButton_Click(object sender, EventArgs e) { try { switch (typeTab.SelectedTab.Text) { case "int": int n; if (!int.TryParse(intBox.Text, out n)) { MessageBox.Show("Warning: wrong number", "ERROR"); } else { IntList.Add(n); IntList.Display(ref listView); } break; case "string": StrList.Add(stringBox.Text); StrList.Display(ref listView); break; case "flower": try { FlowerList.Add(new Flower(typeBox.Text, colourBox.Text)); FlowerList.Display(ref listView); } catch (Exception exception) { MessageBox.Show(exception.Message, "ERROR"); } break; } } catch (Exception exception) { MessageBox.Show(exception.Message, "ERROR"); } }
private void actionFlwrButton_Click(object sender, EventArgs e) { IList <Flower> flowers = N6_ClassLib.SkipLibrary.ListUtils.FindAll <Flower>(FlowerList, delegate(Flower flw) { return(flw.colour != "white"); }, delegate { if (arrayRadio.Checked) { return(new N6_ClassLib.SkipLibrary.ArrayList <Flower>()); } return(new N6_ClassLib.SkipLibrary.LinkedList <Flower>()); }); //заменяем текущий список цветов на удовлетворяющий предикату FlowerList = (N6_ClassLib.SkipLibrary.SkipList <Flower>)flowers; if (immutableRadio.Checked) { FlowerList = new N6_ClassLib.SkipLibrary.ImmutableList <Flower>(FlowerList); } FlowerList.Display(ref listView); }