public bool Equals(MessageViewModel other) { return other.MessageID == MessageID; }
public void getMessage(MessageViewModel msg) { Chat chat = new Chat(client) { FriendID = msg.SourceID }; int index = lstChats.IndexOf(chat); if (index != -1) { foreach (Panel chatPnl in pnlChats.Controls) { if (chatPnl.Tag.ToString() == lstChats[index].FriendID) { chatPnl.BackColor = Color.FromArgb(44, 53, 59); } else { chatPnl.BackColor = Color.FromArgb(0, 10, 20); } } for (int i = 0; i < lstChats.Count; i++) { if (i != index) { lstChats[i].pnlChat.Visible = false; } } } else { Panel pnlFriendChat = new Panel() { Font = defaultFont, Name = "pnlUserInfo", Size = new System.Drawing.Size(254, 55), TabIndex = 4, Cursor = Cursors.Hand, Tag = msg.SourceID, Margin = new Padding(0), BackColor = Color.FromArgb(44, 53, 59) }; pnlFriendChat.Click += PnlFriendChat_Click; Label lblUserID = new Label { ForeColor = Color.FromArgb(187, 188, 182), AutoSize = true, Font = defaultFont, Location = new Point(20, 10), TabIndex = 3, Text = msg.SourceID }; foreach (Panel chatPnl in pnlChats.Controls) { chatPnl.BackColor = Color.FromArgb(0, 10, 20); } index = lstChats.Count; lstChats.Add(chat); pnlFriendChat.Controls.Add(lblUserID); pnlChats.Controls.Add(pnlFriendChat); pnlChat.Controls.Add(chat.pnlChat); } lstChats[index].newMessage(msg); lstChats[index].pnlChat.Visible = true; lstChats[index].pnlChat.BringToFront(); pnlMessages.Visible = true; pnlMessages.BringToFront(); }