public Main() { pChat = new PrivateChat(this); InitializeComponent(); listener = new Listener(2014); listener.SocketAccepted += listener_SocketAccepted; }
private void chatWithClientToolStripMenuItem_Click(object sender, EventArgs e) { foreach (var client in from ListViewItem item in clientList.SelectedItems select(Client) item.Tag) { client.Send("Chat|"); pChat = new PrivateChat(this); pChat.Show(); } }
private void chatWithClientToolStripMenuItem_Click(object sender, EventArgs e) { foreach (var client in from ListViewItem item in clientList.SelectedItems select (Client) item.Tag) { client.Send("Chat|"); pChat = new PrivateChat(this); pChat.Show(); } }
//Gửi yêu cầu chat riêng với client private void privateChatToolStripMenuItem_Click(object sender, EventArgs e) { foreach (var client in from ListViewItem item in userlist.SelectedItems select(User) item.Tag) { string to = userlist.SelectedItems[0].SubItems[0].Text; var value = listpChat.SingleOrDefault(r => r.getTo() == to); if (value == null) //Neu chua co form { client.SendData("Chat|" + to); pChat = new PrivateChat(this); pChat.SetTo(to); pChat.Show(); listpChat.Add(pChat); } } }
//Chat riêng tư với client private void ChatPrivateWithUser(string [] cmd) { var value = listpChat.SingleOrDefault(r => r.getTo() == cmd[1]); if (value != null) //Neu trong list ton tai form { value.chatBox.Text += cmd[1] + " : " + cmd[2] + "\r\n"; } else { this.Invoke(() => { pChat = new PrivateChat(this); pChat.SetTo(cmd[1]); pChat.Show(); listpChat.Add(pChat); pChat.chatBox.Text += cmd[1] + " : " + cmd[2] + "\r\n"; }); } }
public void Remove(PrivateChat p) { listpChat.Remove(p); }