예제 #1
0
        internal void ActivateOrCreateFormSend(string userid, IMUserInfo chatuser)
        {
            lock (locker)
            {
                IManagedForm form = GetForm(userid);

                if (form == null)
                {
                    chatMain f = new chatMain(chatuser);
                    form = f;
                    Add(f);
                    f.Show();
                }
                (form as chatMain).Activate();
                if (Common.ContainsMsg(userid))
                {
                    (form as chatMain).ShowOtherTextChat(userid, Common.GetMsgContractList(userid));
                    Common.RemoveMsg(userid);
                }
            }
        }
예제 #2
0
 public void HandleTextChat(MsgEntity contract)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action <MsgEntity>(this.HandleTextChat), contract);
     }
     else
     {
         //notifyIcon1.PushFriendMessage(contract.SenderID, null);
         if (contract.MsgSendType == (int)MsgSendType.提示信息)
         {
             InformationForm f = new InformationForm(contract);
             f.Show();
             return;
         }
         if (contract.MsgSendType == (int)MsgSendType.网服消息)
         {
             chatMain form = FormManager.Instance.GetForm(contract.SenderID) as chatMain;
             if (form == null)
             {
                 if (Common.AllUserDic.ContainsKey(contract.SenderID))
                 {
                     Common.AddUserMsg(contract);
                 }
                 //如果chatUserId中没有此用户ID,那么添加相应的id和消息。并触发FormNotOpen事件
                 else
                 {
                     ChatListSubItem subItem = new ChatListSubItem("网页用户", "网页用户", "网页用户", ChatListSubItem.UserStatus.Online);
                     subItem.Tag = contract.SenderID;
                     // Image.FromFile("Resources/q1.jpg");
                     userItem.Add(contract.SenderID, subItem);
                     chatListBox.Items[0].SubItems.Add(subItem);
                     List <MsgEntity> list = new List <MsgEntity>();
                     list.Add(contract);
                     Common.AddFriend(contract.SenderID, null);
                     Common.AddNewUserMsg(contract.SenderID, list);
                 }
                 userItem[contract.SenderID].IsTwinkle = true;
                 //让托盘图标开始跳动
                 StartTwinkle();
             }
             else
             {
                 List <MsgEntity> list = new List <MsgEntity>();
                 list.Add(contract);
                 form.ShowOtherTextChat(contract.SenderID, list);
                 form.Activate();
             }
         }
         else
         {
             frmchatMain form = FormManager.Instance.GetForm(contract.SenderID) as frmchatMain;
             if (form == null)
             {
                 if (Common.AllUserDic.ContainsKey(contract.SenderID))
                 {
                     Common.AddUserMsg(contract);
                 }
                 //如果chatUserId中没有此用户ID,那么添加相应的id和消息。并触发FormNotOpen事件
                 else
                 {
                 }
                 userItem[contract.SenderID].IsTwinkle = true;
                 //让托盘图标开始跳动
                 StartTwinkle();
             }
             else
             {
                 List <MsgEntity> list = new List <MsgEntity>();
                 list.Add(contract);
                 form.ShowOtherTextChat(contract.SenderID, list);
                 form.Activate();
             }
         }
     }
 }