示例#1
0
 //用户状态改变通知<5>
 private void IncomingUserStateNotify(PacketHeader header, Connection connection, UserStateContract userStateContract)
 {
     lock (syncLocker)
     {
         IMUserInfo u = Common.GetFriend(userStateContract.UserID);
         if (u != null)
         {
             ChatListSubItem item = userItem[userStateContract.UserID];
             if (item != null)
             {
                 IMUserInfo user = item.Tag as IMUserInfo;
                 if (user != null)
                 {
                     if (userStateContract.OnLine == OnlineState.Online)
                     {
                         u.UserState   = (int)OnlineState.Online;
                         item.Status   = ChatListSubItem.UserStatus.Online;
                         user.IsOnline = true;
                     }
                     else
                     {
                         u.UserState   = (int)OnlineState.Offline;
                         item.Status   = ChatListSubItem.UserStatus.OffLine;
                         user.IsOnline = false;
                         //当某用户下线后,删除此用户相关的p2p 通道
                         Common.RemoveUserConn(userStateContract.UserID);
                     }
                 }
             }
         }
     }
 }
示例#2
0
        //ChatListSubItem cm
        public CreateMeetingForm()
        {
            InitializeComponent();
            ChatListItem cli = new ChatListItem("主持人");

            height = this.Height;
            this.Height = this.cbxVote.Location.Y + 20;
            meetGrouplist.Location = new Point(meetGrouplist.Location.X, label1.Location.Y);

            btnAdd.Location = new Point(btnAdd.Location.X, this.Height - btnAdd.Height-5);
            MenuColorTable mct = new MenuColorTable();
            ToolStripRendererEx t = new ToolStripRendererEx(mct);
            cmsiAdd.Renderer = t;

            ChatListSubItem clsl = new ChatListSubItem(SysParams.LoginUser.UID.ToString(), SysParams.LoginUser.Name, (SysParams.LoginUser.Company));
            clsl.ID = SysParams.LoginUser.UID.ToString();//给初始化网络会议室的默认主持人ID复制

            clsl.HeadImage = SysParams.loginUserImage != SysParams.defaultHead ? (Image)SysParams.loginUserImage.Clone() : SysParams.loginUserImage;
            cli.SubItems.Add(clsl);
            cli.IsOpen = true;

            meetGrouplist.ChatListBox_group.Items.Insert(0, cli);
            meetGrouplist.SkinContextMenuStrip_Group.Items.Clear();
            meetGrouplist.SkinContextMenuStrip_Group.Items.Add("删除成员");
            meetGrouplist.SkinContextMenuStrip_Group.Items[0].Click += CreateMeetingForm_Click;
        }
示例#3
0
        /// <summary>
        /// 加载好友信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainForm_Load(object sender, EventArgs e)
        {
            notifyIcon1.Text        = string.Format("QQ:{0}({1})\r\n声音:{2}\r\n消息提示:{3}\r\n会话消息:{4}", user.userNickName, user.userId, "未开启", "开启", "头像闪烁");
            this.Location           = frmLogin.Location;
            user                    = this.Tag as GGUserInfo;
            userImg.BackgroundImage = Image.FromFile(tools.substringFromLast(Application.StartupPath, @"\", 2, @"\Images\userImg\") + user.userImg);
            nickName.Text           = user.userNickName;
            QQSign.Text             = user.qqSign;

            //得到分组
            string    sql = string.Format("select groupName, members from GGGroup where createId='{0}'", user.userId);
            DataTable dt  = DBHelper.Select(sql);

            friendsList.Items.Clear();
            foreach (DataRow group in dt.Rows)
            {
                ChatListItem cItem = new ChatListItem(group["groupName"].ToString());
                if (!string.IsNullOrEmpty(group["members"].ToString()))
                {
                    sql = string.Format("select userId,userNickName,qqSign,userImg from GGUser where userAutoid in({0})", group["members"]);
                    dt  = DBHelper.Select(sql);
                    foreach (DataRow friend in dt.Rows)
                    {
                        ChatListSubItem.UserStatus state = ChatListSubItem.UserStatus.DontDisturb;
                        Image           img    = Image.FromFile(tools.substringFromLast(Application.StartupPath, @"\", 2, @"\Images\userImg\") + friend["userImg"]);
                        ChatListSubItem csItem = new ChatListSubItem(friend["userId"].ToString(), "00", friend["userNickName"].ToString(), friend["qqSign"].ToString(), state, img);
                        cItem.SubItems.Add(csItem);
                        friendsList.Items.Add(cItem);
                    }
                }
            }
        }
示例#4
0
        public void addPengyou(int gid, Friend friend)
        {
            User            fModel     = userBll.getUser(friend.FriendId);
            ChatListSubItem friendItem = new ChatListSubItem();

            friendItem.DisplayName = friend.FriendName;
            friendItem.ID          = friend.FriendId;
            if (friend.Photo == null)
            {
                Image errorIm = Image.FromFile("Head/error.jpg");
                Size  size    = new Size(60, 60);
                friendItem.HeadImage = new Bitmap(errorIm, size);
            }
            else
            {
                MemoryStream stream = new MemoryStream(friend.Photo);
                friendItem.HeadImage = new Bitmap(stream);
            }

            friendItem.NicName     = friend.NickName;
            friendItem.PersonalMsg = fModel.Sign;
            friendItem.IpAddress   = fModel.LastLoginIp;

            Object obj = openWith[gid];

            if (obj != null)
            {
                System.Console.WriteLine("sdasdasddasdasdasscdasdasdasd");
                ChatListItem groupItem = (ChatListItem)obj;
                groupItem.SubItems.Add(friendItem);
            }
        }
        private void addOnlineClient(Object mes)
        {
            DeviceInfo deviceInfo = (DeviceInfo)mes;

            //String port = mes.Split(':')[1];
            foreach (ChatListSubItem remote in listbox_clients.Items[1].SubItems)
            {
                if (remote.DisplayName.Equals(deviceInfo.deviceId))
                {
                    remote.NicName     = deviceInfo.deviceName;
                    remote.Tag         = deviceInfo.deviceMode;
                    remote.IpAddress   = deviceInfo.remoteIp;
                    remote.PersonalMsg = deviceInfo.remoteIp;
                    remote.Status      = ChatListSubItem.UserStatus.Online;
                    return;
                }
            }
            ChatListSubItem newClient = new ChatListSubItem();

            newClient.HeadImage     = global::ywcai.core.veiw.Properties.Resources.remote;
            newClient.DisplayName   = deviceInfo.deviceId;
            newClient.NicName       = deviceInfo.deviceName;
            newClient.Tag           = deviceInfo.deviceMode;
            newClient.IpAddress     = deviceInfo.remoteIp;
            newClient.PersonalMsg   = deviceInfo.remoteIp;
            newClient.Status        = ChatListSubItem.UserStatus.Online;
            newClient.IsVip         = false;
            newClient.PlatformTypes = PlatformType.Iphone;
            newClient.OwnerListItem = listbox_clients.Items[1];
            listbox_clients.Items[1].SubItems.Add(newClient);
        }
示例#6
0
        private void Send_Click(object sender, EventArgs e)
        {
            emojiGroup.Visible = false;
            if (scanner.Text != "")
            {
                if (UserData.isClient)
                {
                    SendClient();
                }
                else
                {
                    sendServer(scanner.Text);
                }
                ChatListSubItem recentSub = TurnChatToSubItem(scanner.Text);
                if (IsDistinct(scanner.Text))
                {
                    InfoList.CreateOrReadInstance().chatListBox_Message.Items[0].SubItems.Remove(recentSub);
                }
                else
                {
                    InfoList.CreateOrReadInstance().chatListBox_Message.Items[0].SubItems.Add(recentSub);
                }

                scanner.Text = "";
            }
            else
            {
                MessageBox.Show("消息不能为空!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
 public Form_Search(IRapidPassiveEngine rapidPassiveEngine, ChatListSubItem myInfo)
 {
     this.myInfo = myInfo;
     this.rapidPassiveEngine = rapidPassiveEngine;
     this.ReceiveUserList = new CallbackHandler(diaplayUser);//实例化收到消息时回调方法的委托
     InitializeComponent();
 }
示例#8
0
        private void Init()
        {
            chatListBox1.Items.Clear();
            Random rnd = new Random();

            for (int i = 0; i < 10; i++)
            {
                ChatListItem item = new ChatListItem("Group " + i);
                for (int j = 0; j < 10; j++)
                {
                    ChatListSubItem subItem = new ChatListSubItem("NicName" + j, "DisplayName" + j, "Personal Message...!");
                    subItem.ID        = i * 10 + j;
                    subItem.HeadImage = null;
                    subItem.Status    = (ChatListSubItem.UserStatus)(j % 6);
                    item.SubItems.Add(subItem);
                }
                item.SubItems.Sort();
                chatListBox1.Items.Add(item);
            }
            ChatListItem itema = new ChatListItem("TEST");

            for (int i = 0; i < 5; i++)
            {
                chatListBox1.Items.Add(itema);
            }
            chatListBox1.Items.Remove(itema);
        }
示例#9
0
        private void AppendUserToList(User user)
        {
            if (user == null || String.IsNullOrEmpty(user.UserID))
            {
                return;
            }

            ChatListSubItem sub = new ChatListSubItem();

            sub.Tag         = user.UserID;
            sub.NicName     = user.NickName;
            sub.DisplayName = user.NickName;
            sub.PersonalMsg = user.Signature;
            sub.Status      = (UserStatus)user.Status;

            String headFile = Path.Combine(GlobalResourceManager.AppPath, GlobalResourceManager.CurrentUser.UserID, "res", "head.jpg");

            Utils.DownFile(GlobalResourceManager.CurrentUser.HeadImageUrl, headFile);
            if (File.Exists(headFile))
            {
                skinButton_headImage.Image = Image.FromFile(headFile);
            }

            chatListBox1.Items[0].SubItems.Add(sub);
        }
示例#10
0
        private void AddUserItem(GGUser friend)
        {
            ChatListSubItem subItem = new ChatListSubItem(friend.UserID, friend.UserID, friend.Name, friend.Signature, GlobalResourceManager.ConvertUserStatus(friend.UserStatus), GlobalResourceManager.GetHeadImage(friend));

            subItem.Tag = friend;
            this.chatListBox1.Items[0].SubItems.AddAccordingToStatus(subItem);
        }
示例#11
0
 /// <summary>
 /// 朋友列表 右键菜单
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void FriendList_ContextSubItem(object sender, ChatListEventArgs e)
 {
     _IsFriendOpen           = true;
     _MouseRightClickSubItem = e.SelectSubItem;
     contextFriendList.Show(Cursor.Position);
     _IsFriendOpen = false;
 }
示例#12
0
        private void chatListBox_DoubleClickSubItem(object sender, ChatListEventArgs e, MouseEventArgs es)
        {
            if (es.Button == MouseButtons.Right)
            {
                return;
            }
            ChatListSubItem item = e.SelectSubItem;

            item.IsTwinkle = false;

            //bool isFormexist;
            string windowsName = "与 " + item.NicName + " 对话中";
            IntPtr handle      = NativeMethods.FindWindow(null, windowsName);

            if (handle != IntPtr.Zero)
            {
                Form frm = (Form)Form.FromHandle(handle);
                frm.Activate();
            }
            else
            {
                //ipSend为从列表中取出,要发送的对象的IP
                FrmQQChat fChat = new FrmQQChat(item);
                fChat.Text = "与 " + item.NicName + " 对话中";
                fChat.Show();
            }
        }
示例#13
0
        private void main_Load(object sender, EventArgs e)
        {
            UserBLL udb = new UserBLL();
            //用户信息表
            DataTable dt = new DataTable();
            //好友表
            DataTable dt1 = new DataTable();
            //分组信息表
            DataTable dt2 = new DataTable();
            //好友详细信息表
            DataTable dt3 = new DataTable();

            dt = udb.Userinfo(udb.user.UserID);
            Name_skinLable.Text  = udb.user.UserNickName;
            PersonalMessage.Text = udb.user.UserPersonalMessage;
            chatListBox1.Items.Clear();
            dt2 = udb.DB.GetData(string.Format("select * from friendgroup where userID={0}", udb.user.UserID));
            if (string.IsNullOrEmpty(dt.Rows[0]["HeadPicture"].ToString()))
            {
                headpicture.ImageLocation = s + "\\search_teacher.jpg";
            }
            else
            {
                headpicture.ImageLocation = dt.Rows[0]["HeadPicture"].ToString();
            }
            for (int i = 0; i < dt2.Rows.Count; i++)
            {
                ChatListItem chatlist1 = new ChatListItem();
                chatlist1.Bounds               = new System.Drawing.Rectangle(0, 53, 363, 25);
                chatlist1.IsTwinkleHide        = false;
                chatlist1.OwnerChatListBox     = this.chatListBox1;
                chatlist1.Text                 = dt2.Rows[i]["GrouName"].ToString();
                chatlist1.TwinkleSubItemNumber = 0;
                chatListBox1.Items.AddRange(new ChatListItem[] { chatlist1 });
                dt1 = udb.GetFriendList(udb.user.UserName, dt2.Rows[i]["GrouID"].ToString());
                for (int l = 0; l < dt1.Rows.Count; l++)
                {
                    dt3 = udb.DB.GetData(string.Format("select * from user where UserID={0}", dt1.Rows[l]["Use_UserID"]));
                    ChatListSubItem chatListSubItem1 = new ChatListSubItem();
                    chatListSubItem1.Bounds        = new System.Drawing.Rectangle(0, 0, 0, 0);
                    chatListSubItem1.DisplayName   = dt1.Rows[l]["Alternatename"].ToString();
                    chatListSubItem1.HeadImage     = null;
                    chatListSubItem1.HeadRect      = new System.Drawing.Rectangle(0, 0, 0, 0);
                    chatListSubItem1.ID            = Convert.ToInt32(dt1.Rows[l]["Use_UserID"]);
                    chatListSubItem1.IpAddress     = null;
                    chatListSubItem1.IsTwinkle     = false;
                    chatListSubItem1.IsTwinkleHide = false;
                    chatListSubItem1.NicName       = dt3.Rows[0]["UserNickName"].ToString();
                    chatListSubItem1.OwnerListItem = chatlist1;
                    chatListSubItem1.PersonalMsg   = dt3.Rows[0]["UserPersonalMessage"].ToString();
                    chatListSubItem1.Status        = ChatListSubItem.UserStatus.Online;
                    chatListSubItem1.Tag           = null;
                    chatListSubItem1.TcpPort       = 0;
                    chatListSubItem1.UpdPort       = 0;
                    chatlist1.SubItems.AddRange(new ChatListSubItem[] {
                        chatListSubItem1
                    });
                }
            }
        }
示例#14
0
        public void drawList()  //绘制成员列表
        {
            List <user> memberList = new List <user>();

            foreach (group i in publicClass.groupList)
            {
                if (i.id == groupID)
                {
                    memberList = i.groupUserList;
                }
            }
            groupMember.SubItems.Clear();
            foreach (user i in memberList)  //绘制在线列表
            {
                ChatListSubItem sub = new ChatListSubItem();
                if (i.isOnline)
                {
                    sub.NicName = "在线";
                    sub.Status  = ChatListSubItem.UserStatus.Online;
                }
                else
                {
                    sub.NicName = "下线";
                    sub.Status  = ChatListSubItem.UserStatus.OffLine;
                }
                sub.DisplayName = i.userName;
                sub.PersonalMsg = i.IPAddress;
                sub.HeadImage   = System.Drawing.Image.FromFile("../..//src/img/avatar" + i.avatar + ".png");
                groupMember.SubItems.Add(sub);
            }
            this.groupMemberListBox.Items.Add(groupMember);
        }
示例#15
0
        //private void C_OnMessage(object sender, MessageEventArgs e)
        //{

        //}

        /// <summary>
        /// 根据当前所聊天的好友状态更改聊天chat的头像状态
        /// </summary>
        public void chatHeadState(ChatListSubItem friend)
        {
            switch (friend.Status)
            {
            case ChatListSubItem.UserStatus.QMe:
                break;

            case ChatListSubItem.UserStatus.Online:
                pbxFriend.Image = friend.HeadImage;
                break;

            case ChatListSubItem.UserStatus.Away:
                break;

            case ChatListSubItem.UserStatus.Busy:
                break;

            case ChatListSubItem.UserStatus.DontDisturb:
                break;

            case ChatListSubItem.UserStatus.OffLine:
                pbxFriend.Image = ESBasic.Helpers.ImageHelper.ConvertToGrey(friend.HeadImage);
                break;

            default:
                break;
            }
        }
示例#16
0
        public ChatForm(ChatListSubItem friend, string mineID, ChatBoxContent content)
        {
            InitializeComponent();

            lblName.Text    = friend.DisplayName;
            lblCompany.Text = friend.PersonalMsg;

            FriendIDAndStaue = ((GGUser)(friend.Tag)).JID.ToString();
            Friend           = friend;

            chatHeadState(friend);


            MineID  = mineID;
            FrendID = friend.ID;

            //if (FrendID.Equals("yujunming192.168.1.95"))
            //{
            //    client = new XmppClient("chengle", "192.168.1.95", "111111");

            //}
            //else
            //{
            //    client = new XmppClient("yujunming", "192.168.1.95", "111111");
            //}
            //client.OnMessage += C_OnMessage;

            //client.Open();

            //Console.WriteLine("{0}", client);
        }
 private void initRemoteLists(String mes)
 {
     String[] list = mes.Split('|');
     for (Int32 i = 0; i < list.Length; i++)
     {
         if (!list[i].Equals(""))
         {
             String[]        str         = list[i].Split(',');
             String          displayname = str[0];
             String          ip          = str[1].Remove(0, 1);
             Int32           dreviceType = Int32.Parse(str[4]);
             String          tag         = str[5];
             Boolean         isOnline    = str[2].Equals("true") ? true : false;
             Boolean         isVip       = str[3].Equals("true") ? true : false;
             ChatListSubItem newClient   = new ChatListSubItem();
             newClient.HeadImage     = global::ywcai.core.veiw.Properties.Resources.remote;
             newClient.DisplayName   = displayname;
             newClient.NicName       = tag;
             newClient.Tag           = tag;
             newClient.IpAddress     = ip;
             newClient.PersonalMsg   = ip;
             newClient.Status        = (isOnline ? ChatListSubItem.UserStatus.Online : ChatListSubItem.UserStatus.OffLine);
             newClient.IsVip         = isVip;
             newClient.PlatformTypes = (dreviceType == MyConfig.INT_CLIENT_TYPE_PC ? PlatformType.PC : PlatformType.Iphone);
             newClient.OwnerListItem = listbox_clients.Items[1];
             listbox_clients.Items[1].SubItems.Add(newClient);
         }
     }
 }
示例#18
0
        /// <summary>
        /// 绘制列表子项
        /// </summary>
        /// <param name="g">绘图表面</param>
        /// <param name="subItem">要绘制的子项</param>
        /// <param name="rectSubItem">该子项的区域</param>
        /// <param name="sb">画刷</param>
        protected virtual void DrawSubItem(Graphics g, ChatListSubItem subItem, ref Rectangle rectSubItem, SolidBrush sb)
        {
            if (subItem.Equals(selectSubItem))
            {                                                     //判断改子项是否被选中
                rectSubItem.Height = (int)ChatListItemIcon.Large; //如果选中则绘制成大图标
                sb.Color           = this.subItemSelectColor;
                g.FillRectangle(sb, rectSubItem);
                DrawHeadImage(g, subItem, rectSubItem);         //绘制头像
                DrawLargeSubItem(g, subItem, rectSubItem);      //绘制大图标 显示的个人信息
                subItem.Bounds = new Rectangle(rectSubItem.Location, rectSubItem.Size);
                return;
            }
            else if (subItem.Equals(m_mouseOnSubItem))
            {
                sb.Color = this.subItemMouseOnColor;
            }
            else
            {
                sb.Color = this.subItemColor;
            }
            g.FillRectangle(sb, rectSubItem);
            DrawHeadImage(g, subItem, rectSubItem);

            if (iconSizeMode == ChatListItemIcon.Large)         //没有选中则根据 图标模式绘制
            {
                DrawLargeSubItem(g, subItem, rectSubItem);
            }
            else
            {
                DrawSmallSubItem(g, subItem, rectSubItem);
            }

            subItem.Bounds = new Rectangle(rectSubItem.Location, rectSubItem.Size);
        }
示例#19
0
 /// <summary>
 /// 添加一个
 /// </summary>
 /// <param name="obj"></param>
 private void AddMajorFriend(Friend obj)
 {
     try
     {
         foreach (ChatListItem item in MajorFriendList.Items)
         {
             if (item.Value == obj.FatherNumber)
             {
                 ChatListSubItem sitem = new ChatListSubItem(obj.NikeName);
                 sitem.ID   = int.Parse(obj.QQNumber);
                 sitem.Info = obj;
                 item.SubItems.Add(sitem);
                 return;
             }
         }
         //没有找到FatherQQ帐号,意味着没有该项,先添加FatherQQ.再添加一个朋友.
         ChatListItem citem = new ChatListItem(obj.FatherNumber);
         citem.Text  = obj.FatherNumber;
         citem.Value = obj.FatherNumber;
         ChatListSubItem subitem = new ChatListSubItem(obj.NikeName);
         subitem.Info = obj;
         citem.SubItems.Add(subitem);
         MajorFriendList.Items.Add(citem);
     }
     catch (Exception ex)
     {
         Loger.WriteLog(ex);
     }
 }
示例#20
0
 public Form_Chat(IRapidPassiveEngine rapidPassiveEngine, ChatListSubItem item, ChatListSubItem userItem, Form_main main)
 {
     main.Receive += new Form_main.ReceiveEventHandler(ChatHandleReceive);//注册收到信息时的事件处理程序ChatHandleReceive
     this.userItem = userItem;
     this.item = item;
     this.rapidPassiveEngine = rapidPassiveEngine;
     InitializeComponent();
 }
示例#21
0
 public Form_Chat(IRapidPassiveEngine rapidPassiveEngine, ChatListSubItem item, ChatListSubItem userItem, Form_main main)
 {
     main.Receive           += new Form_main.ReceiveEventHandler(ChatHandleReceive);//注册收到信息时的事件处理程序ChatHandleReceive
     this.userItem           = userItem;
     this.item               = item;
     this.rapidPassiveEngine = rapidPassiveEngine;
     InitializeComponent();
 }
示例#22
0
 public static void SetImageAsync(ChatListSubItem sitem, string imageUrl)
 {
     Task.Factory.StartNew(() =>
     {
         var image       = InitHelper.GetImage(imageUrl);
         sitem.HeadImage = image;
     });
 }
示例#23
0
 public FrmQQChat(ChatListSubItem QQUser)
 {
     InitializeComponent();
     this.QQUser = QQUser;
     //加载表情到文本框
     this.chatBoxSend.Initialize(GlobalResourceManager.EmotionDictionary);
     this.chatBox_history.Initialize(GlobalResourceManager.EmotionDictionary);
 }
示例#24
0
        void Box2_SelectedIndexChanged(object sender, EventArgs e)
        {
            ChatListSubItem item = searchBox2.Box.SelectedItem as ChatListSubItem;

            if (item != null)
            {
                FriendList.SelectSubItem = item;
            }
        }
示例#25
0
 private void ClearSubItemMouseOn()
 {
     if (m_mouseOnSubItem != null)
     {
         this.Invalidate(new Rectangle(
                             m_mouseOnSubItem.Bounds.X, m_mouseOnSubItem.Bounds.Y - chatVScroll.Value,
                             m_mouseOnSubItem.Bounds.Width, m_mouseOnSubItem.Bounds.Height));
         m_mouseOnSubItem = null;
     }
 }
示例#26
0
 public P2pChatForm(ChatListSubItem guestItem)
 {
     InitializeComponent();
     session        = SessionBll.GetInstance();
     hostId         = session.User.UId;
     this.guestItem = guestItem;
     this.guestId   = guestItem.ID;
     initData();
     initSocket();
 }
示例#27
0
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            ChatListSubItem          item = this.chatListBox.SelectSubItem;
            Parameter <string, bool> para = RecentListBox.ParseIDFromRecentID(item.ID);

            if (this.ChatRecordClicked != null)
            {
                this.ChatRecordClicked(para.Arg1, para.Arg2);
            }
        }
示例#28
0
 public GroupChatForm(ChatListSubItem guestItem)
 {
     InitializeComponent();
     session           = SessionBll.GetInstance();
     user              = session.User;
     this.guestItem    = guestItem;
     this.chatRoomId   = guestItem.ID;
     this.chatRoomPort = guestItem.ChatRoomPort;
     initData();
 }
示例#29
0
        private void FriendListForm_Load(object sender, EventArgs e)
        {
            friendListBox.IconSizeMode = ChatListItemIcon.Large;
            Random        rnd       = new Random();
            IList <Group> groupList = groupBll.getGroupList(user.UId);

            Console.WriteLine("user.UId----------------------->>>>>>>>" + user.UId + "count----->" + groupList.Count);

            foreach (Group group in groupList)
            {
                Console.WriteLine("group" + group.Name + "groupid" + group.GId);



                ChatListItem   groupItem  = new ChatListItem(group.Name);
                IList <Friend> friendList = friendBll.getFriendByGroup(user.UId, group.GId);
                Console.WriteLine("user.UId" + user.UId + "group.GId" + group.GId);
                Console.WriteLine("friendList" + friendList.Count);
                foreach (Friend friend in friendList)
                {
                    Console.WriteLine("friendList" + friend.NickName);
                    User            fModel     = userBll.getUser(friend.FriendId);
                    ChatListSubItem friendItem = new ChatListSubItem();
                    friendItem.DisplayName = friend.FriendName;
                    friendItem.ID          = friend.FriendId;
                    //设置好友头像
                    if (friend.Photo == null)
                    {
                        Image errorIm = Image.FromFile("Head/error.jpg");
                        Size  size    = new Size(60, 60);
                        friendItem.HeadImage = new Bitmap(errorIm, size);
                    }
                    else
                    {
                        MemoryStream stream = new MemoryStream(friend.Photo);
                        friendItem.HeadImage = new Bitmap(stream);
                    }

                    friendItem.NicName     = friend.NickName;
                    friendItem.PersonalMsg = fModel.Sign;
                    friendItem.IpAddress   = fModel.LastLoginIp;
                    groupItem.SubItems.Add(friendItem);
                }

                try
                {
                    openWith.Add(group.GId, groupItem);
                }
                catch
                {
                    Console.WriteLine("An element with Key = \"txt\" already exists.");
                }
                friendListBox.Items.Add(groupItem);
            }
        }
示例#30
0
        public void GroupInfoChanged(IGroup group, GroupChangedType type, string userID)
        {
            ChatListSubItem[] subItems = this.chatListBox_group.GetSubItemsById(group.ID);
            if (type == GroupChangedType.GroupDeleted)
            {
                if (subItems == null || subItems.Length == 0)
                {
                    return;
                }

                this.chatListBox_group.Items[0].SubItems.Remove(subItems[0]);
                return;
            }


            if (type == GroupChangedType.GroupInfoChanged)
            {
                if (subItems == null || subItems.Length == 0)
                {
                    return;
                }
                this.chatListBox_group.GetSubItemsById(group.ID)[0].DisplayName = group.Name;


                return;
            }



            if (subItems == null || subItems.Length == 0)
            {
                ChatListSubItem subItem = new ChatListSubItem(group.ID, "", group.Name, string.Format("{0}人", group.MemberList.Count), ChatListSubItem.UserStatus.Online, this.imageList1.Images[0]);
                subItem.Tag = group;
#if !Org
                this.chatListBox_group.Items[0].SubItems.Add(subItem);
#else
                if (group.ID == this.companyGroupID)
                {
                    this.chatListBox_group.Items[0].SubItems.Insert(0, subItem);
                }
                else
                {
                    this.chatListBox_group.Items[0].SubItems.Add(subItem);
                }
#endif

                return;
            }
            else
            {
                subItems[0].Tag         = group;
                subItems[0].PersonalMsg = string.Format("{0}人", group.MemberList.Count);
            }
        }
示例#31
0
 public void AddRecentUnit(IUnit unit, int insertIndex)
 {
     string recentID = RecentListBox.ConstructRecentID(unit);
     UserStatus status = unit.IsGroup ? UserStatus.Online : ((IUser)unit).UserStatus;
     Image img = unit.IsGroup ? this.imageList1.Images[0] : this.resourceGetter.GetHeadImage((IUser)unit);
     ChatListSubItem subItem = new ChatListSubItem(recentID, "", unit.Name, "", this.ConvertUserStatus(status), img);
     subItem.Tag = unit;
     subItem.LastWords = unit.LastWords;
     this.chatListBox.Items[0].SubItems.Insert(insertIndex, subItem);
     this.chatListBox.Invalidate();
 }
示例#32
0
        public void ChangeImFo()
        {
            //个人信息
            Qian();
            Console.WriteLine(QQuser.userId);
            String        sql = String.Format("select NickName,FaceId,MySign from Users where Id={0}", userId);
            SqlCommand    cmd = new SqlCommand(sql, c);
            SqlDataReader r   = cmd.ExecuteReader();

            if (r.Read())
            {
                NickName = r[0].ToString();
                FaceId   = int.Parse(r[1].ToString());
                MySign   = r[2].ToString();
            }
            label_NickName.Text = NickName;
            String img = "QQ头像/" + FaceId + ".bmp";

            pictureBox_face.Image = Image.FromFile(img);
            if (MySign == null)
            {
                textBox_Mysign.Text = "";
            }
            else
            {
                textBox_Mysign.Text = MySign;
                label_sign.Text     = MySign;
            }
            r.Close();
            //c.Close();

            chatListBox_fridents.Items.Clear();
            //好友列表
            item = new ChatListItem("好友");

            sql = String.Format("select FriendId,Remark,NickName,FaceId,MySign from Friends inner join Users on Friends.FriendId=Users.Id where HostId={0}", userId);
            cmd = new SqlCommand(sql, c);
            r   = cmd.ExecuteReader();
            while (r.Read())
            {
                ChatListSubItem list = new ChatListSubItem();
                list.ID          = int.Parse(r[0].ToString());
                list.DisplayName = r[1].ToString();
                list.NicName     = r[2].ToString();
                img              = "QQ头像/" + r[3].ToString() + ".bmp";
                list.HeadImage   = Image.FromFile(img);
                list.PersonalMsg = r[4].ToString();

                item.SubItems.Add(list);
            }


            chatListBox_fridents.Items.Add(item);
        }
示例#33
0
        public Form_Chat(IRapidPassiveEngine rapidPassiveEngine, ChatListSubItem contactInfo, ChatListSubItem myInfo, Form_main main)
        {
            //注册收到信息时的事件处理程序ChatHandleReceive
            main.Receive += new Form_main.ReceiveEventHandler(ChatHandleReceive);

            //传入变量
            this.contactInfo = contactInfo;
            this.myInfo = myInfo;
            this.rapidPassiveEngine = rapidPassiveEngine;

            InitializeComponent();
        }
示例#34
0
        private void chatListBox_group_DoubleClickSubItem(object sender, ChatListEventArgs e)
        {
            ChatListSubItem item  = e.SelectSubItem;
            IGroup          group = (IGroup)item.Tag;

            item.IsTwinkle = false;

            if (this.GroupDoubleClicked != null)
            {
                this.GroupDoubleClicked(group);
            }
        }
示例#35
0
 public void AddGroup(IGroup group)
 {
     ChatListSubItem subItem = new ChatListSubItem(group.ID, "", group.Name, string.Format("{0}人", group.MemberList.Count), ChatListSubItem.UserStatus.Online, this.imageList1.Images[0]);
     subItem.Tag = group;
     #if !Org
     this.chatListBox_group.Items[0].SubItems.Add(subItem);
     #else
     if (group.ID == this.companyGroupID)
     {
         this.chatListBox_group.Items[0].SubItems.Insert(0, subItem);
     }
     else
     {
         this.chatListBox_group.Items[0].SubItems.Add(subItem);
     }
     #endif
 }
示例#36
0
文件: FrmMain.cs 项目: sllt/eTalk
        public FrmMain(User user)
        {
            InitializeComponent();
            lblName.Text = user.userNickName;

            foreach (User u in user.friends)
            {
                ChatListSubItem clst = new ChatListSubItem();

                clst.DisplayName = u.userNickName.ToString().Trim();
                clst.NicName = u.userNumber.ToString().Trim();
                this.friendList.Items[0].SubItems.Add(clst);

            }
            //this.friendList.Items[0].IsTwinkleHide = false;
            //this.friendList.Items[0].SubItems[1].IsTwinkle = true;
        }
示例#37
0
 public FrmMain(string id, Image title, SkinButtom BtnState)
 {
     FrmMain.CheckForIllegalCrossThreadCalls = false;
     InitializeComponent();
     //New一个当前用户的对象
     UserItem = new ChatListSubItem(id, (ChatListSubItem.UserStatus)Convert.ToInt32(BtnState.Tag));
     UserItem.HeadImage = title;
     UserItem.PersonalMsg = lblQm.Text;
     UserLogin.UserItem = UserItem;
     //获取当前状态
     btnState.Image = BtnState.Image;
     btnState.Tag = BtnState.Tag;
     //获取当前登录帐号与头像
     this.Id = lblName.Text = id;
     this.Title = title;
     //获取屏幕宽高
     SW = Screen.PrimaryScreen.Bounds.Width;
     SH = Screen.PrimaryScreen.Bounds.Height;
 }
示例#38
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     this.chatListBox.Items.Clear();
     List<GGUser> users = GlobalResourceManager.RemotingService.SearchUser(this.skinTextBox_id.SkinTxt.Text.Trim());
     bool hasResult = users.Count > 0;
     this.skinLabel_noResult.Visible = !hasResult;
     if (hasResult)
     {
         this.chatListBox.Items.Add(new ChatListItem("查找结果"));
         this.chatListBox.Items[0].IsOpen = true;
         foreach (GGUser user in users)
         {
             Image headImage = this.mainForm.GetHeadImage(user);
             ChatListSubItem subItem = new ChatListSubItem(user.ID, user.ID, user.Name, user.Signature, ChatListSubItem.UserStatus.Online, headImage);
             subItem.Tag = user;
             this.chatListBox.Items[0].SubItems.Add(subItem);
         }
     }
 }
示例#39
0
        public void GroupInfoChanged(IGroup group, GroupChangedType type, string userID)
        {
            ChatListSubItem[] subItems = this.chatListBox_group.GetSubItemsById(group.ID);
            if (type == GroupChangedType.GroupDeleted)
            {
                if (subItems == null || subItems.Length == 0)
                {
                    return;
                }

                this.chatListBox_group.Items[0].SubItems.Remove(subItems[0]);
                return;
            }

            if (subItems == null || subItems.Length == 0)
            {
                ChatListSubItem subItem = new ChatListSubItem(group.ID, "", group.Name, string.Format("{0}人", group.MemberList.Count), ChatListSubItem.UserStatus.Online, this.imageList1.Images[0]);
                subItem.Tag = group;
            #if !Org
                this.chatListBox_group.Items[0].SubItems.Add(subItem);
            #else
                if (group.ID == this.companyGroupID)
                {
                    this.chatListBox_group.Items[0].SubItems.Insert(0, subItem);
                }
                else
                {
                    this.chatListBox_group.Items[0].SubItems.Add(subItem);
                }
            #endif

                return;
            }
            else
            {
                subItems[0].Tag = group;
                subItems[0].PersonalMsg = string.Format("{0}人", group.MemberList.Count);
            }
        }
示例#40
0
 private void initRemoteLists(String mes)
 {
     String[] list = mes.Split('|');
     for(Int32 i=0; i<list.Length; i++)
     {
         if(!list[i].Equals(""))
         {
         String[] str = list[i].Split(',');
         String displayname = str[0];
         String ip = str[1].Remove(0, 1);
         Int32 dreviceType = Int32.Parse(str[4]);
         String tag = str[5];
         Boolean isOnline = str[2].Equals("true") ? true : false;
         Boolean isVip = str[3].Equals("true") ? true : false;
         ChatListSubItem newClient = new ChatListSubItem();
         newClient.HeadImage = global::ywcai.core.veiw.Properties.Resources.remote;
         newClient.DisplayName = displayname;
         newClient.NicName = tag;
         newClient.Tag = tag;
         newClient.IpAddress = ip;
         newClient.PersonalMsg = ip;
         newClient.Status = (isOnline ? ChatListSubItem.UserStatus.Online : ChatListSubItem.UserStatus.OffLine);
         newClient.IsVip = isVip;
         newClient.PlatformTypes = (dreviceType == MyConfig.INT_CLIENT_TYPE_PC ? PlatformType.PC : PlatformType.Iphone);
         newClient.OwnerListItem = listbox_clients.Items[1];
         listbox_clients.Items[1].SubItems.Add(newClient);
         }
     }
 }
示例#41
0
        //, Image headImage, string nickName, ChatListSubItem.UserStatus userStatus, Image stateImage)
        /// <summary>
        /// 初始化流程:
        /// (1)Initialize时,从服务器加载自己的全部信息,从本地缓存文件加载好友列表。
        /// (2)MainForm_Load,填充ChatListBox
        /// (3)MainForm_Shown,调用globalUserCache在后台刷新:若是第一次登录,则分批从服务器加载好友资料。否则,从服务器获取好友最新状态和版本,并刷新本地缓存。
        /// (4)globalUserCache.FriendRTDataRefreshCompleted 事件,请求离线消息、离线文件、正式通知好友自己上线
        /// </summary>
        public void Initialize(IRapidPassiveEngine engine, ChatListSubItem.UserStatus userStatus, Image stateImage)
        {
            GlobalResourceManager.PostInitialize(engine.CurrentUserID);
            this.Cursor = Cursors.WaitCursor;

            this.toolTip1.SetToolTip(this.skinButton_headImage,"帐号:" + engine.CurrentUserID);
            this.rapidPassiveEngine = engine;

            this.globalUserCache = new GlobalUserCache(this.rapidPassiveEngine);
            this.globalUserCache.FriendInfoChanged += new CbGeneric<GGUser>(globalUserCache_FriendInfoChanged);
            this.globalUserCache.FriendStatusChanged += new CbGeneric<GGUser>(globalUserCache_FriendStatusChanged);
            this.globalUserCache.GroupChanged += new CbGeneric<GGGroup ,GroupChangedType, string>(globalUserCache_GroupInfoChanged);
            this.globalUserCache.FriendRTDataRefreshCompleted += new CbGeneric(globalUserCache_FriendRTDataRefreshCompleted);
            this.globalUserCache.FriendRemoved += new CbGeneric<string>(globalUserCache_FriendRemoved);
            this.globalUserCache.FriendAdded += new CbGeneric<GGUser>(globalUserCache_FriendAdded);

            this.globalUserCache.CurrentUser.UserStatus = (UserStatus)((int)userStatus);
            this.myStatus = this.globalUserCache.CurrentUser.UserStatus;
            this.labelSignature.Text = this.globalUserCache.CurrentUser.Signature;
            this.skinButton_headImage.Image = GlobalResourceManager.GetHeadImage(this.globalUserCache.CurrentUser);
            this.labelName.Text = this.globalUserCache.CurrentUser.Name;

            skinButton_State.Image = stateImage;
            skinButton_State.Tag = userStatus;
            this.skinLabel_softName.Text = GlobalResourceManager.SoftwareName;
            this.notifyIcon.ChangeText(String.Format("{0}:{1}({2})\n状态:{3}", GlobalResourceManager.SoftwareName, this.globalUserCache.CurrentUser.Name, this.globalUserCache.CurrentUser.UserID, GlobalResourceManager.GetUserStatusName(this.globalUserCache.CurrentUser.UserStatus)));

            this.MaximumSize = new Size(543, Screen.GetWorkingArea(this).Height);
            this.Size = SystemSettings.Singleton.MainFormSize;
            this.Location = SystemSettings.Singleton.MainFormLocation;//new Point(Screen.PrimaryScreen.Bounds.Width - this.Width - 20, 40);

            this.friendListBox1.Initialize(this.globalUserCache.CurrentUser, this, new UserInformationForm(new Point(this.Location.X-284 ,this.friendListBox1.Location.Y)));
            this.groupListBox.Initialize(this.globalUserCache.CurrentUser ,GlobalConsts.CompanyGroupID);
            this.recentListBox1.Initialize(this);

            if (!SystemSettings.Singleton.ShowLargeIcon)
            {
                this.friendListBox1.IconSizeMode = ChatListItemIcon.Small;
                this.大头像ToolStripMenuItem.Checked = false;
                this.小头像ToolStripMenuItem.Checked = true;
            }

            //文件传送
            this.rapidPassiveEngine.FileOutter.FileRequestReceived += new CbFileRequestReceived(fileOutter_FileRequestReceived);
            this.rapidPassiveEngine.FileOutter.FileResponseReceived += new CbGeneric<TransferingProject, bool>(fileOutter_FileResponseReceived);

            this.rapidPassiveEngine.ConnectionInterrupted += new CbGeneric(rapidPassiveEngine_ConnectionInterrupted);//预订断线事件
            this.rapidPassiveEngine.BasicOutter.BeingPushedOut += new CbGeneric(BasicOutter_BeingPushedOut);
            this.rapidPassiveEngine.RelogonCompleted += new CbGeneric<LogonResponse>(rapidPassiveEngine_RelogonCompleted);//预订重连成功事件
            this.rapidPassiveEngine.MessageReceived += new CbGeneric<string, int, byte[], string>(rapidPassiveEngine_MessageReceived);

            //群、组
            this.rapidPassiveEngine.ContactsOutter.BroadcastReceived += new CbGeneric<string, string, int, byte[]>(ContactsOutter_BroadcastReceived);
            this.rapidPassiveEngine.ContactsOutter.ContactsOffline += new CbGeneric<string>(ContactsOutter_ContactsOffline); //所有联系人的下线事件

            //网盘访问器 V2.0
            this.nDiskOutter = new NDiskOutter(this.rapidPassiveEngine.FileOutter, this.rapidPassiveEngine.CustomizeOutter);

            this.notifyIcon.UnhandleMessageOccured += new CbGeneric<UnhandleMessageType ,string>(notifyIcon_UnhandleMessageOccured);
            this.notifyIcon.UnhandleMessageGone += new CbGeneric<UnhandleMessageType ,string>(notifyIcon_UnhandleMessageGone);
            this.notifyIcon.Initialize(this ,this);
        }
示例#42
0
        void displayFriend()
        {
            //清空
            this.chatListBox_contacts.Items[0].SubItems.Clear();
            List<string> OnlineFriends = this.rapidPassiveEngine.FriendsOutter.GetAllOnlineFriends();

            //从数据库读取
            List<Friend> frList = FriendDB.uniqueInstance.queryFriends();
            foreach (Friend fr in frList)
            {
                ChatListSubItem people = new ChatListSubItem();
                people.ID = Convert.ToUInt32(fr.UserId);
                people.NicName = fr.UserName;
                people.DisplayName = fr.UserName;
                people.Status = ChatListSubItem.UserStatus.OffLine;
                this.chatListBox_contacts.Items[0].SubItems.Add(people);
            }
            foreach (string friendId in OnlineFriends)
            {
                ChatListSubItem[] list = chatListBox_contacts.GetSubItemsById(Convert.ToUInt32(friendId));
                if (list.Length > 0)
                {
                    list[0].Status = ChatListSubItem.UserStatus.Online;
                }
            }
        }
示例#43
0
 /// <summary>
 /// 用户信息及位置赋值
 /// </summary>
 /// <param name="Item"></param>
 /// <param name="point"></param>
 public void SetUserData(ChatListSubItem Item, Point point)
 {
     this.Item = Item;
     this.Location = this.point = point;
 }
示例#44
0
文件: main.cs 项目: sccdcwc/IMtest
 private void ShowFriendList(ClassMsg msg)
 {
     LoginMsg loginmsg = (LoginMsg)new ClassSerializers().DeSerializeBinary(new MemoryStream(msg.Data));
     int i=0;
     foreach (var item in loginmsg.FriendList.Group)
     {
         ChatListItem chatlist1 = new ChatListItem();
         chatlist1.Bounds = new System.Drawing.Rectangle(0, 53, 363, 25);
         chatlist1.IsTwinkleHide = false;
         chatlist1.OwnerChatListBox = this.chatListBox1;
         chatlist1.Text = item.GroupName;
         chatlist1.TwinkleSubItemNumber = 0;
         chatListBox1.Items.AddRange(new ChatListItem[] { chatlist1 });
         foreach(var item1 in loginmsg.FriendList.Group[i].Friend)
         {
              ChatListSubItem chatListSubItem1 = new ChatListSubItem();
         chatListSubItem1.Bounds = new System.Drawing.Rectangle(0, 0, 0, 0);
         chatListSubItem1.DisplayName = item1.AlternateName;
         chatListSubItem1.HeadImage = null;
         chatListSubItem1.HeadRect = new System.Drawing.Rectangle(0, 0, 0, 0);
         chatListSubItem1.ID = Convert.ToInt32(item1.UserID);
         chatListSubItem1.IpAddress = null;
         chatListSubItem1.IsTwinkle = false;
         chatListSubItem1.IsTwinkleHide = false;
         chatListSubItem1.NicName = item1.NickName;
         chatListSubItem1.OwnerListItem = chatlist1;
         chatListSubItem1.PersonalMsg = item1.UserPersonalMessage;
         chatListSubItem1.Status = ChatListSubItem.UserStatus.Online;
         chatListSubItem1.Tag = null;
         chatListSubItem1.TcpPort = 0;
         chatListSubItem1.UpdPort = 0;
         chatlist1.SubItems.AddRange(new ChatListSubItem[] { chatListSubItem1 });
         }
         i++;
     }
 }
        //在程序运行后保持监听2425端口,负责处理各种类型消息
        public void StartUdpThread()
        {
            UdpClient udpClient = new UdpClient(2425);
            IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Any, 0);

            while (true)
            {
                byte[] buff = udpClient.Receive(ref ipEndPoint);
                string userInfo = Encoding.Default.GetString(buff);
                string msgHead = userInfo.Substring(0, 6);//消息前6位为消息类型标识符
                string msgBody = userInfo.Substring(6);//第7位开始为消息实体内容

                switch(msgHead)
                {
                    /*用户第一次登录时发送USER消息到广播地址,收到此类消息会将对方
                     * 加入到自己的在线好友列表中,并回复对方消息,告诉对方自己在线 */
                    case ":USER:"******"head/4.png");
                            subItem.IpAddress = sBody[2];
                            //在集合中查找用户,没有则加,有则更新信息
                            if (Chat.GetSubItemsByIp(sBody[2]).Length > 0)
                            {
                                Chat.GetSubItemsByIp(sBody[2])[0] = subItem;
                            }
                            else
                            {
                                if (UserLogin.UserItem.NicName == sBody[0])
                                {
                                    MyNameItem.SubItems.Add(subItem);
                                }
                                else
                                {
                                    ListItem.SubItems.Add(subItem);
                                }
                            }

                            //回复消息
                            ClassBoardCast CReply = new ClassBoardCast();
                            CReply.BCReply(subItem.IpAddress);
                        }
                        catch(Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        break;

                    //聊天消息MESG
                    case ":MESG:":
                        try
                        {
                            string[] mBody = msgBody.Split('|');
                            string msgName = mBody[0];
                            string msgID = mBody[1];
                            string msgIP = mBody[2];
                            string msgDetail = mBody[3];

                            //创建一条新线程接收消息
                            ClassReceiveMsg cRecMsg = new ClassReceiveMsg(msgIP, msgName,msgID, msgDetail);
                            Thread tRecMsg = new Thread(new ThreadStart(cRecMsg.StartRecMsg));
                            tRecMsg.Start();
                        }
                        catch
                        {
                        }
                        break;

                    //用户退出时发送QUIT开头的消息
                    case ":QUIT:":
                        try
                        {
                            //在集合中查找用户,没有则加,有则更新信息
                            if (Chat.GetSubItemsByNicName(msgBody).Length > 0)
                            {
                                Chat.GetSubItemsByIp(msgBody)[0].OwnerListItem.SubItems.Remove(Chat.GetSubItemsByIp(msgBody)[0]);
                            }
                        }
                        catch
                        {
                        }
                        break;

                    /*自己上线时会向广播发送消息,在接到别人以REPY开头的回复消息时,
                    将对方加入自己的在线好友列表中*/
                    case ":REPY:":
                        try
                        {
                            string[] sBody = msgBody.Split(':');
                            //New一个用户
                            ChatListSubItem subItem = new ChatListSubItem(sBody[0], sBody[1], sBody[3]);
                            subItem.HeadImage = Image.FromFile("head/4.png");
                            subItem.IpAddress = sBody[2];
                            //在集合中查找用户,没有则加,有则更新信息
                            if (Chat.GetSubItemsByIp(sBody[2]).Length > 0)
                            {
                                Chat.GetSubItemsByIp(sBody[2])[0] = subItem;
                            }
                            else
                            {
                                if (UserLogin.UserItem.NicName == sBody[0])
                                {
                                    MyNameItem.SubItems.Add(subItem);
                                }
                                else
                                {
                                    ListItem.SubItems.Add(subItem);
                                }
                            }

                        }
                        catch(Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        break;

                    //以DATA开头的消息,表示有人发送文件
                    case ":DATA:":
                        try
                        {
                            string[] mBody = msgBody.Split('|');
                            string msgName = mBody[0];
                            string msgID = mBody[1];
                            string msgIP = mBody[2];
                            string msgFileName = mBody[3];
                            string msgFileLen = mBody[4];

                            string msgDetail = "【发送文件】" + msgFileName;
                            //创建一条新线程接收消息
                            ClassReceiveMsg cRecMsg = new ClassReceiveMsg(msgIP, msgName, msgID, msgDetail);
                            Thread tRecMsg = new Thread(new ThreadStart(cRecMsg.StartRecMsg));
                            tRecMsg.Start();
                        }
                        catch
                        {
                        }
                        break;

                    //接到以ACEP开头的消息,表示对方同意接收文件
                    case ":ACEP:":
                        try
                        {
                            string[] mFileBody = msgBody.Split('|');
                            string mFilePath = mFileBody[3];
                            string mIP = mFileBody[2];

                            ClassSendFile cSendFile = new ClassSendFile(mFilePath, mIP);
                            Thread tSendFile = new Thread(new ThreadStart(cSendFile.SendFile));
                            tSendFile.IsBackground = true;
                            tSendFile.Start();
                        }
                        catch
                        {
                        }
                        break;
                }
            }
        }
示例#46
0
 private void updateUserList(String mes)
 {
     String[] str = mes.Split(',');
     String displayname = str[0];
     String ip = str[1].Remove(0, 1);
     Int32 dreviceType = Int32.Parse(str[4]);
     String tag = str[5];
     Boolean isOnline = str[2].Equals("true") ? true : false;
     Boolean isVip = str[3].Equals("true") ? true : false;
     if (listbox_clients.Items[0].SubItems[0].DisplayName.Equals(displayname))
     {
         listbox_clients.Items[0].SubItems[0].NicName = tag;
         listbox_clients.Items[0].SubItems[0].Tag = tag;
         listbox_clients.Items[0].SubItems[0].IpAddress = ip;
         listbox_clients.Items[0].SubItems[0].PersonalMsg = ip;
         listbox_clients.Items[0].SubItems[0].Status =( isOnline? ChatListSubItem.UserStatus.Online: ChatListSubItem.UserStatus.OffLine) ;
         listbox_clients.Items[0].SubItems[0].IsVip = isVip;
         listbox_clients.Items[0].SubItems[0].PlatformTypes = (dreviceType == MyConfig.INT_CLIENT_TYPE_PC ? PlatformType.PC : PlatformType.Iphone);
         return;
     }
     foreach (ChatListSubItem remote in listbox_clients.Items[1].SubItems)
     {
         if (remote.DisplayName.Equals(displayname))
         {
             remote.NicName = tag;
             remote.Tag = tag;
             remote.IpAddress = ip;
             remote.PersonalMsg = ip;
             remote.Status = (isOnline ? ChatListSubItem.UserStatus.Online : ChatListSubItem.UserStatus.OffLine);
             remote.IsVip = isVip;
             remote.PlatformTypes = (dreviceType == MyConfig.INT_CLIENT_TYPE_PC ? PlatformType.PC : PlatformType.Iphone);
             return;
         }
     }
     ChatListSubItem  newClient= new ChatListSubItem();
     newClient.HeadImage=global::ywcai.core.veiw.Properties.Resources.remote;
     newClient.DisplayName = displayname;
     newClient.NicName = tag;
     newClient.Tag = tag;
     newClient.IpAddress = ip;
     newClient.PersonalMsg = ip;
     newClient.Status = (isOnline ? ChatListSubItem.UserStatus.Online : ChatListSubItem.UserStatus.OffLine);
     newClient.IsVip = isVip;
     newClient.PlatformTypes = (dreviceType == MyConfig.INT_CLIENT_TYPE_PC ? PlatformType.PC : PlatformType.Iphone);
     newClient.OwnerListItem = listbox_clients.Items[1];
     listbox_clients.Items[1].SubItems.Add(newClient);
 }
示例#47
0
        public void InitMain(IRapidPassiveEngine rapidPassiveEngine)
        {
            if (this.myInfo == null)
            {
                this.myInfo = new ChatListSubItem();
            }
            this.rapidPassiveEngine = rapidPassiveEngine;
            this.myInfo.ID = Convert.ToUInt32(rapidPassiveEngine.CurrentUserID);

            //加载分组
            ChatListItem gp = new ChatListItem();//new一个分组
            gp.Text = "TestList";
            ChatListSubItem people = new ChatListSubItem();

            if (myInfo.ID == 10010)
            {
                lbl_userName.Text = "联通";
                people.ID = 10086;//ID
                people.NicName = "移动";//昵称
                people.DisplayName = "X";//备注名
                people.PersonalMsg = "买买买买买";
            }
            else if (myInfo.ID == 10086)
            {
                lbl_userName.Text = "移动";
                people.ID = 10010;//ID
                people.NicName = "联通";//昵称
                people.DisplayName = "X";//备注名
                people.PersonalMsg = "买买买买买";
            }
            gp.SubItems.Add(people);
            //chatListBox_contacts.GetSubItemsById();//按照ID查找listbox中的用户

            chatListBox_contacts.Items.Add(gp);//添加到listBox中

            //预订接收到广播消息的处理事件
            this.rapidPassiveEngine.GroupOutter.BroadcastReceived += new CbGeneric<string, string, int, byte[]>(GroupOutter_BroadcastReceived);
            //预订断线事件
            this.rapidPassiveEngine.ConnectionInterrupted += new CbGeneric(rapidPassiveEngine_ConnectionInterrupted);
        }
 public FrmUserInformation(ChatListSubItem Item,Point point)
 {
     InitializeComponent();
     this.Item = Item;
     this.point = point;
 }
 public Form_SystemMsg(IRapidPassiveEngine rapidPassiveEngine, ChatListSubItem myInfo)
 {
     this.myInfo = myInfo;
     this.rapidPassiveEngine = rapidPassiveEngine;
     InitializeComponent();
 }