public void writeMsg(string chatname, string msg) { MsgHistory m = getMsgHistory(chatname); m.sb.AppendLine(msg); m.unread++; refreshTextWindow(); }
MsgHistory getMsgHistory(string chatname) { if (!msgHistorys.ContainsKey(chatname)) { MsgHistory m = new MsgHistory(); m.sb = new StringBuilder(); m.unread = 0; msgHistorys.Add(chatname, m); } return(msgHistorys[chatname]); }
void refreshTextWindow() { if (listBoxFriend.SelectedIndex != -1) { string chatname = ((ChatLink)listBoxFriend.Items[listBoxFriend.SelectedIndex]).getChatname(); textBoxMsgReceive.Text = string.Empty; MsgHistory m = getMsgHistory(chatname); textBoxMsgReceive.AppendText(m.sb.ToString()); m.unread = 0; } listBoxFriend.Refresh(); }