private void _appendBubble(string nick, DB.Message msg, bool self) { var bubble = new MessageBubble(nick, msg.Text, self); messageLayout.Controls.Add(bubble); bubble.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; }
private void _drawMessage(DB.Message msg) { if (msg.Self) { _appendBubble(self.Nickname, msg, msg.Self); } else { var sender = _onlineUsers.Find(usr => usr.UserID == msg.ChatId); _appendBubble(sender.Nickname, msg, msg.Self); } }
private DB.Message _sendMessage(PublicUser user, string text) { if (!_onlineUsers.Contains(user)) { return(null); } var packet = _client.Send(user.UserID, textBox1.Text); var message = new DB.Message(packet.Id, user.UserID, true, text); //TODO: save to DB if (!_chatUsers.Contains(user)) { _chats.Add(user, new List <DB.Message> { message }); chatList.Items.Add(user); } return(message); }
private void _saveMessage(Packets.Message msg) { var senderId = msg.Reciever == self.UserID ? msg.Sender : msg.Reciever; var message = new DB.Message(msg.Id, msg.Sender, senderId == self.UserID, msg.Text); var sender = _onlineUsers.First(usr => usr.UserID == senderId); if (_chats.ContainsKey(sender)) { _chats[sender].Add(message); } else { _chats.Add(sender, new List <DB.Message> { message }); chatList.Items.Add(sender); chatList.Focus(); } //TODO: add to DB _drawMessage(message); }