Esempio n. 1
0
        public void AddInMessage(ReferenceData.Entity.Message message)
        {
            currentOutMessage = null;
            UserControl bubble = null;

            if (message.messageType.ToUpper().Equals("TEXT"))
            {
                bubble = new TextBubble(message.content, TextBubble.msgType.In);
            }
            else
            {
                bubble = new FileBubble(message.content, message.file, FileBubble.msgType.In);
            }
            if (this.currentInMessage == null)
            {
                currentInMessage = new IncomingMessage(message.avatar, message.senderId, message.lastName, DateTime.Now);
            }
            else
            {
                if (currentInMessage.UserId != message.senderId)
                {
                    currentInMessage = new IncomingMessage(message.avatar, message.senderId, message.lastName, DateTime.Now);
                }
                else
                {
                    if (compareTime(currentInMessage.Time, DateTime.Now))
                    {
                        FPMessage1.Controls.Remove(currentInMessage);
                    }
                    else
                    {
                        currentInMessage = new IncomingMessage(message.avatar, message.senderId, message.lastName, DateTime.Now);
                    }
                }
            }
            currentInMessage.AddBubble(bubble);
            FPMessage1.Controls.Add(currentInMessage);
            this.messageBox.UpdateUi();
            if (this.messageBox.panelBg.Size.Height < this.messageBox.flowLayoutPanel.PreferredSize.Height)
            {
                this.messageBox.vScrollBar.Value = this.messageBox.vScrollBar.Maximum;
            }
            foreach (var c in Form.ConversationList)
            {
                if (c.Cvst.id.Equals(message.conversationId))
                {
                    Form.InitLatestMessage(c, message);
                    break;
                }
            }
        }
Esempio n. 2
0
 private void handleMessage(object data)
 {
     ReferenceData.Entity.Message message = (ReferenceData.Entity.Message)data;
     if (form.ChatBox != null && form.ChatBox.Conversation.id.Equals(message.conversationId))
     {
         form.ChatBox.Invoke(new AddInMessageDelegate(form.ChatBox.AddInMessage), new object[] { message });
     }
     else
     {
         foreach (var c in form.ConversationList)
         {
             if (c.Cvst.id.Equals(message.conversationId))
             {
                 form.Invoke(new InitLatestMessageDelegate(form.InitLatestMessage), new object[] { c, message });
                 break;
             }
         }
     }
 }
Esempio n. 3
0
        public void InitLatestMessage(Components.Conversation cvst, ReferenceData.Entity.Message message)
        {
            if (message.messageType.Equals("FILE"))
            {
                string[] arr = message.content.Split('_');
                string   fex = arr[arr.Length - 1];
                if (fex.Equals(".jpg") || fex.Equals(".png") || fex.Equals(".jpeg") || fex.Equals(".gif"))
                {
                    cvst.lbLatestMessage.Text = (message.senderId != cvst.Acc.id ? message.lastName : "Bạn") + " đã gửi một ảnh.";
                }
                else
                {
                    cvst.lbLatestMessage.Text = (message.senderId != cvst.Acc.id ? message.lastName : "Bạn") + " đã gửi một file.";
                }
            }
            else
            {
                cvst.lbLatestMessage.Text = (message.senderId != cvst.Acc.id ? message.lastName : "Bạn") + ": " + message.content;
            }
            DateTime time = (DateTime)message.createdAt;

            cvst.lbDate.Text = time.ToString("HH:mm dd/MM/yyyy");
        }