void notifyIcon1_MouseClick(object sender, MouseEventArgs e) { try { if (e.Button != MouseButtons.Left) { return; } lock (this.locker) { if (this.friendQueue.Count > 0) { UnhandleFriendMessageBox cache = this.friendQueue[0]; this.friendQueue.RemoveAt(0); IChatForm form = this.twinkleNotifySupporter.GetChatForm(cache.User); if (form != null) //如果为null,表示刚删除好友 { form.HandleReceivedMessage(cache.MessageList); } this.DetectUnhandleMessage(); if (this.UnhandleMessageGone != null) { this.UnhandleMessageGone(UnhandleMessageType.Friend, cache.User); } return; } if (this.groupQueue.Count > 0) { UnhandleGroupMessageBox cache = this.groupQueue[0]; this.groupQueue.RemoveAt(0); IGroupChatForm form = this.twinkleNotifySupporter.GetGroupChatForm(cache.Group); form.HandleReceivedMessage(cache.MessageList); this.DetectUnhandleMessage(); if (this.UnhandleMessageGone != null) { this.UnhandleMessageGone(UnhandleMessageType.Group, cache.Group); } return; } } if (this.MouseClick != null) { this.MouseClick(sender, e); } } catch (Exception ee) { MessageBox.Show(ee.Message + " - " + ee.StackTrace); } }
public void PushGroupMessage(string broadcasterID, string groupID, int broadcastType, byte[] content) { lock (this.locker) { this.twinkleNotifySupporter.PlayAudioAsyn(); IGroupChatForm form = this.twinkleNotifySupporter.GetExistedGroupChatForm(groupID); if (form != null) { form.HandleReceivedMessage(broadcasterID, broadcastType, content); return; } UnhandleGroupMessageBox cache = null; lock (this.locker) { for (int i = 0; i < this.groupQueue.Count; i++) { if (this.groupQueue[i].Group == groupID) { cache = this.groupQueue[i]; break; } } if (cache == null) { cache = new UnhandleGroupMessageBox(groupID); this.groupQueue.Add(cache); if (this.UnhandleMessageOccured != null) { this.UnhandleMessageOccured(UnhandleMessageType.Group, groupID); } } cache.MessageList.Add(new Parameter <string, int, byte[]>(broadcasterID, broadcastType, content)); } string groupName = this.twinkleNotifySupporter.GetGroupName(groupID); this.notifyIcon1.Text = string.Format("{0}({1}) {2}条消息", groupName, groupID, cache.MessageList.Count); this.twinkleIcon = this.twinkleNotifySupporter.GroupIcon; this.ControlTimer(true); } }