示例#1
0
        //Mouse Clicked
        private void tab_MouseClicked(object sender, EventArgs e)
        {
            Panel pan = (Panel)sender;

            if (contactIndex != contacts.Controls.IndexOf(pan))
            {
                if (contactIndex >= 0)
                {
                    Panel controller = (Panel)contacts.Controls[contactIndex];
                    controller.BackColor = Color.FromArgb(240, 244, 248);
                }

                convoPanel.Visible = false;
                msgBox.Enabled     = false;
                msgBox.Enabled     = true;
                contactIndex       = contacts.Controls.IndexOf(pan);
                Contact contact = contactList[contactIndex];

                List <UnreadMessage> unreadMessages = contact.getUnreadMessageList();
                List <Control>       conversationUI = contact.getConversationUI();
                //Check and update all unread messages && Recreate new conversation
                for (int a = 0; a < contact.getUnreadMessageCount(); a++)
                {
                    string message = unreadMessages[a].getMessage();
                    string date    = unreadMessages[a].getDate();
                    if (conversationUI.Count > 0 && conversationUI[conversationUI.Count - 1].Controls[1].Text == date)//Merger
                    {
                        //Convert any emoji codes that might be inside the message
                        MyFixedRichTextBox.AppendText((MyFixedRichTextBox)conversationUI[conversationUI.Count - 1].Controls[0].Controls[0], "\r\n" + message, emoji);
                        contact.updateConversation(conversationUI.Count - 1, conversationUI[conversationUI.Count - 1]);
                    }
                    else
                    {
                        //New Message, so create the buffer first
                        //contact.updateConversation(ChatUI.getPanelBuffer(4));
                        Panel newMessage = new ChatUI("", date, contact.getContactPicture().Image, 4, emoji).getMessageTab();
                        MyFixedRichTextBox.AppendText((MyFixedRichTextBox)newMessage.Controls[0].Controls[0], message, emoji);
                        contact.updateConversation(newMessage);
                    }
                }
                contact.clearUnreadMessages();

                convoPanel.Controls.Clear();
                conversationUI = contact.getConversationUI();
                for (int a = 0; a < conversationUI.Count; a++)
                {
                    convoPanel.Controls.Add(conversationUI[a]);
                    convoPanel.Controls.SetChildIndex(conversationUI[a], 0);
                }
                convoPanel.AutoScrollPosition = new Point(0, convoPanel.VerticalScroll.Maximum);

                //convoBox.Text = contactList[contactIndex].getConversation();
                //convoBox.SelectionStart = convoBox.TextLength;
                //convoBox.ScrollToCaret();
                string name = contact.getPacket().getUsername();
                if (contact.getContactName().Text != name)
                {
                    contact.getContactName().Text = name;
                }

                //Add the new contact to the current contact panel
                if (currentContact.Controls.Count == 0)
                {
                    currentContactUI = new ContactUI(contact.getPacket().getUsername(), contact.getPacket().getContactPicture(), false);
                    currentContact.Controls.Add(currentContactUI.getContactUITab());
                    currentContact.Controls.SetChildIndex(currentContactUI.getContactUITab(), 0);
                    //Might add user controls below for when you click the current contact tab
                }
                else
                {
                    //Update the picture and name for the current contact tab
                    currentContactUI.getContactUIName().Text     = contact.getPacket().getUsername();
                    currentContactUI.getContactUIPicture().Image = contact.getContactPicture().Image;
                }

                //Handle msgBox text -- might have a message previously typed but not sent?
                if (contact.getCurrentMessage() == "")
                {
                    msgBox.ForeColor = Color.FromArgb(102, 116, 134);
                    msgBox.Font      = new Font("Segoe UI", 9.5F);
                    msgBox.Text      = "Type a message here";
                }
                else
                {
                    msgBox.ForeColor = Color.FromArgb(43, 43, 48);
                    msgBox.Font      = new Font("Segoe UI", 10.15F);
                    msgBox.Text      = contact.getCurrentMessage();
                    emoji.insertEmoji(msgBox);
                }
                convoPanel.Visible = true;
            }
        }
示例#2
0
 public void updateContactPicture(Image picture)
 {
     contactUI.getContactUIPicture().Image = picture;
 }