//Send Text void Send() { if (RTBText.Text == string.Empty) { MessageBox.Show("Tin nhắn rỗng. Thử lại!"); } else { ChatMessage CM = new ChatMessage(); ChatUsers = UserClient; CM.Sender = UserClient; CM.Content = " " + txtusername.Text + " : " + RTBText.Text + "\n"; CM.CurrentTime = DateTime.Now; if (cbChatMat.Checked) { AppendText(RTBPrivate, Color.Blue, CM.Content); AppendText(RTBRoom, Color.Blue, CM.Content); RTBPrivate.SelectionStart = RTBPrivate.Text.Length; RTBPrivate.ScrollToCaret(); RTBRoom.SelectionStart = RTBRoom.Text.Length; RTBRoom.ScrollToCaret(); proxy.SendPrivateMessage(CM, _toUser); } else { AppendText(RTBRoom, Color.Black, CM.Content); RTBRoom.SelectionStart = RTBRoom.Text.Length; RTBRoom.ScrollToCaret(); proxy.SendPublicMessage(CM, CM.Sender.username); } } RTBText.Select(0, RTBText.TextLength); RTBText.SelectedText = ""; }
//Send 1 message cho 1 đối tượng người dùng cụ thể public void NewPrivateMessage(ChatMessage CM) { ChatUsers = CM.Sender; AppendText(RTBRoom, Color.Blue, CM.Content); AppendText(RTBPrivate, Color.Blue, CM.Content); RTBPrivate.SelectionStart = RTBPrivate.Text.Length; RTBPrivate.ScrollToCaret(); RTBRoom.SelectionStart = RTBRoom.Text.Length; RTBRoom.ScrollToCaret(); ChatUsers = UserClient; }