protected static void OnOfflineMsgsChanged(OfflineMsgEventArgs e) { if (OfflineMsgChanged != null) { OfflineMsgChanged(e); } }
private void RefreshHistory(OfflineMsgEventArgs e) { if (this.tb_history.InvokeRequired) { MyIMClient.OfflineMsgChangedHandler handler = new MyIMClient.OfflineMsgChangedHandler(RefreshHistory); this.Invoke(handler, e); } else { if (e.Reason == OfflineMsgEventArgs.EnumReason.MsgAdded) { //解析数据并显示 foreach (var msg in e.NewMsgs) { ShowMsg(msg); } } } }
//private void InsertMsg(Msg msg) //{ // if (msg.From.Equals(LoginStatus.UserInfo.Name)) // { // //收到信息 // tb_history.AppendLine(string.Format("{0} {1}", msg.Time.ToLocalTime().ToString(), msg.From), // MsgRcvFont, MsgRcvColor, HorizontalAlignment.Left); // tb_history.AppendLine(msg.Content, MsgContentFont, MsgContentColor, HorizontalAlignment.Left); // } // else // { // //发送信息 // tb_history.AppendLine(string.Format("{0} {1}", msg.Time.ToLocalTime().ToString(), msg.From), // MsgSendFont, MsgSendColor, HorizontalAlignment.Left); // tb_history.AppendLine(msg.Content, MsgContentFont, MsgContentColor, HorizontalAlignment.Left); // } // tb_history.AppendLine(); //} private void MyIMClient_OfflineMsgChanged(OfflineMsgEventArgs e) { RefreshHistory(e); }