Ejemplo n.º 1
0
        public GroupChatForm GetGroupChatForm(string groupID)
        {
            GroupChatForm form = this.groupChatFormManager.GetForm(groupID);

            if (form == null)
            {
                form = new GroupChatForm(this.rapidPassiveEngine, groupID, this.globalUserCache, this);
                form.LastWordChanged += new CbGeneric <bool, string, LastWordsRecord>(form_LastWordChanged);
                this.groupChatFormManager.Add(form);
                form.Show();
                UnhandleGroupMessageBox cache = this.notifyIcon.PickoutGroupMessageCache(groupID);
                if (cache != null)
                {
                    form.HandleReceivedMessage(cache.MessageList);
                }
            }
            else
            {
                if (form.WindowState == FormWindowState.Minimized)
                {
                    form.WindowState = FormWindowState.Normal;
                }
                form.Focus();
            }
            return(form);
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        public void PushGroupMessage(string broadcasterID, string groupID, int broadcastType, byte[] content)
        {
            lock (this.locker)
            {
                this.twinkleNotifySupporter.PlayAudioAsyn();
                var form = this.twinkleNotifySupporter.GetExistedGroupChatForm(groupID);
                if (form != null)
                {
                    form.HandleReceivedMessage(broadcasterID, broadcastType, content);
                    return;
                }

                UnhandleGroupMessageBox cache = null;
                lock (this.locker)
                {
                    for (var 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));
                }

                var 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);
            }
        }
Ejemplo n.º 4
0
 private void DetectUnhandleMessage()
 {
     if (this.friendQueue.Count == 0 && this.groupQueue.Count == 0)
     {
         this.ControlTimer(false);
     }
     else if (this.friendQueue.Count > 0)
     {
         UnhandleFriendMessageBox cache = this.friendQueue[0];
         string userName = this.twinkleNotifySupporter.GetFriendName(cache.User);
         this.notifyIcon1.Text = string.Format("{0}({1})  {2}条消息", cache.User, userName, cache.MessageList.Count);
         this.twinkleIcon      = this.twinkleNotifySupporter.GetHeadIcon(cache.User);
     }
     else
     {
         UnhandleGroupMessageBox cache = this.groupQueue[0];
         string groupName = this.twinkleNotifySupporter.GetGroupName(cache.Group);
         this.notifyIcon1.Text = string.Format("{0}({1})  {2}条消息", groupName, cache.Group, cache.MessageList.Count);
         this.twinkleIcon      = this.twinkleNotifySupporter.GroupIcon;
     }
 }
Ejemplo n.º 5
0
        public UnhandleGroupMessageBox PickoutGroupMessageCache(string groupID)
        {
            lock (this.locker)
            {
                for (int i = 0; i < this.groupQueue.Count; i++)
                {
                    UnhandleGroupMessageBox tmp = this.groupQueue[i];
                    if (tmp.Group == groupID)
                    {
                        this.groupQueue.RemoveAt(i);
                        this.DetectUnhandleMessage();
                        if (this.UnhandleMessageGone != null)
                        {
                            this.UnhandleMessageGone(UnhandleMessageType.Group, groupID);
                        }
                        return(tmp);
                    }
                }
            }

            return(null);
        }