private void buttonDelFriend_Click(object sender, EventArgs e) { if (listBoxFriend.SelectedIndex > -1) { ChatLink cl = (ChatLink)listBoxFriend.Items[listBoxFriend.SelectedIndex]; ls.unregister(cl.getChatname()); writeInstantMsg("已删除聊天:" + cl.Nickname); } }
private void listBoxFriend_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); if (e.Index >= 0) { ChatLink cl = (ChatLink)listBoxFriend.Items[e.Index]; string chatname = cl.getChatname(); var m = getMsgHistory(chatname); if (m.unread > 0) { string showText = string.Format("【{0}未读】{1}", m.unread, cl.Nickname); e.Graphics.DrawString(showText, new Font("Arial", 8, FontStyle.Bold), Brushes.Black, e.Bounds); } else { e.Graphics.DrawString(cl.Nickname, new Font("Arial", 8, FontStyle.Regular), Brushes.Black, e.Bounds); } } e.DrawFocusRectangle(); }