private void button2_Click(object sender, EventArgs e) { Count++; GuiHandler gh = new GuiHandler(Count, this); handlers.Add(gh); listBox1.Items.Add(gh.ID.ToString()); }
private void ConsoleSend_Click(object sender, EventArgs e) { if (ConsoleText.Text != "") { foreach (var s in listBox1.SelectedItems) { GuiHandler gh = handlers.Find(new Predicate <GuiHandler>(x => x.ID == Convert.ToInt32(s.ToString()))); gh.Send(ConsoleText.Text); } } ConsoleText.Text = ""; }
public void ConsoleUpdate() { GuiHandler gh = null; if (listBox1.SelectedItem != null) { listBox1.Invoke(new Action(() => gh = handlers.Find(new Predicate <GuiHandler>(x => x.ID == Int32.Parse(listBox1.SelectedItem.ToString()))))); } if (gh != null) { listBoxConsole.Invoke(new Action(() => { listBoxConsole.Items.Clear(); listBoxConsole.Items.AddRange(gh.Answers.ToArray()); listBoxConsole.SelectedIndex = listBoxConsole.Items.Count - 1; })); } }
public void DeleteThis(GuiHandler handler) { listBox1.Invoke(new Action(() => listBox1.Items.Remove(handler.ID.ToString()))); handlers.Remove(handler); }