Exemplo n.º 1
0
 private void BtnSend_Click(object sender, EventArgs e)
 {
     ChatServices.SendMessage(TbMessage.Text, ((Users)LbUsers.SelectedItem).id);
     RtbChat.AppendText(DateTime.Now.ToString() + "  ");
     RtbChat.AppendText($"to {((Users)LbUsers.SelectedItem).username}" + "\r\n");
     RtbChat.AppendText($"{TbMessage.Text}" + "\r\n");
     TbMessage.Text = "";
     TbMessage.Focus();
 }
Exemplo n.º 2
0
        private void TimerRefreshChat_Tick(object sender, EventArgs e)
        {
            int messageId = ChatServices.ReturnUnreadMessageId();

            if (messageId > 0)
            {
                ChatMessages message = ChatServices.ReturnMessage(messageId);
                RtbChat.AppendText(DateTime.Now.ToString() + "  ");
                RtbChat.AppendText($"from {ChatServices.GetUsers(message.sender_id)}" + "\r\n");
                RtbChat.AppendText($"{message.Message}" + "\r\n");
                ChatServices.SetFlagRead(messageId);
            }
        }
Exemplo n.º 3
0
        private void LbUsers_SelectedIndexChanged(object sender, EventArgs e)
        {
            RtbChat.Text = "";
            TimerRefreshChat.Stop();
            List <ChatMessages> chatMessages = ChatServices.ReturnReadMessages(((Users)LbUsers.SelectedItem).id);

            foreach (var message in chatMessages)
            {
                RtbChat.AppendText(DateTime.Now.ToString() + "  ");
                RtbChat.AppendText($"from {ChatServices.GetUsers(message.sender_id)}" + "\r\n");
                RtbChat.AppendText($"{message.Message}" + "\r\n");
            }
            TimerRefreshChat.Start();
        }