Пример #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            Count++;
            GuiHandler gh = new GuiHandler(Count, this);

            handlers.Add(gh);
            listBox1.Items.Add(gh.ID.ToString());
        }
Пример #2
0
 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 = "";
 }
Пример #3
0
        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;
                }));
            }
        }
Пример #4
0
 public void DeleteThis(GuiHandler handler)
 {
     listBox1.Invoke(new Action(() => listBox1.Items.Remove(handler.ID.ToString())));
     handlers.Remove(handler);
 }