Example #1
0
        /// <summary>
        /// 获取我的好友
        /// </summary>
        public void GetAllMyFriend()
        {
            //获取之前先清空用户字典
            Common.AllUserDic.Clear();
            if (Common.AllUserDic.Count == 0)
            {
                //向服务器端发送信息并获取结果
                UserListContract userListContract = Common.TcpConn.SendReceiveObject <UserListContract>("GetFriends", "ResGetFriends", 5000, Common.UserID);

                //遍历加载好友
                foreach (IMUserInfo user in userListContract.UserList)
                {
                    //把用户添加到字典中
                    //根据性别 分别使用不同的图标
                    //if (user.IsMale)
                    //{
                    //    Common.AddDicUser(user.UserID, new User(user.UserID, user.Name, user.Declaring, user.IsMale == true ? UserSex.Male : UserSex.Female, Properties.Resources.q1, "电话", "电子邮件", user.OnLine == true ? OnlineState.Online : OnlineState.Offline));
                    //}
                    //else
                    //{
                    //    Common.AddDicUser(user.UserID, new User(user.UserID, user.Name, user.Declaring, user.IsMale == true ? UserSex.Male : UserSex.Female, Properties.Resources.q2, "电话", "电子邮件", user.OnLine == true ? OnlineState.Online : OnlineState.Offline));

                    //}
                }
            }
        }
Example #2
0
 /// <summary>
 /// 客户端获取某用户的好友列表
 /// </summary>
 /// <param name="header"></param>
 /// <param name="Connection"></param>
 /// <param name="userID"></param>
 private void IncomingGetFriends(PacketHeader header, Connection Connection, string userID)
 {
     try
     {
         List <IMUserInfo> myfriends = GetMyFriends(userID);
         UserListContract  ulc       = new UserListContract(myfriends);
         Connection.SendObject("ResGetFriends", ulc);
     }
     catch (Exception ex)
     {
         LogTools.LogException(ex, "IncomingGetFriends");
     }
 }
Example #3
0
        /// <summary>
        /// 获取我的好友
        /// </summary>
        public void GetAllMyFriend()
        {
            //获取之前先清空用户字典
            Common.AllUserDic.Clear();
            if (Common.AllUserDic.Count == 0)
            {
                //向服务器端发送信息并获取结果
                UserListContract userListContract = Common.TcpConn
                                                    .SendReceiveObject <UserListContract>("GetFriends", "ResGetFriends", 50000, Common.CurrentUser.ID);

                //遍历加载好友
                IEnumerable <IGrouping <string, IMUserInfo> > groupUserList = userListContract.UserList.GroupBy(p => p.IMGroupName);

                foreach (var group in groupUserList)
                {
                    ChatListItem chatListItem = new ChatListItem();
                    chatListItem.Text = group.Key;
                    chatListBox.Items.Add(chatListItem);
                    foreach (var user in group)
                    {
                        ChatListSubItem subItem = new ChatListSubItem(user.DisplayName, user.Name, user.DisplaySignature, ChatListSubItem.UserStatus.Online);
                        subItem.Tag = user;
                        if (user.IsOnline)
                        {
                            subItem.Status = ChatListSubItem.UserStatus.Online;
                        }
                        else
                        {
                            subItem.Status = ChatListSubItem.UserStatus.OffLine;
                        }
                        if (user.Sex == "女")
                        {
                            subItem.HeadImage = Resource1.big45;
                        }
                        else
                        {
                            subItem.HeadImage = Resource1.big28;
                        }

                        Common.AddFriend(user.ID, user);
                        // Image.FromFile("Resources/q1.jpg");
                        userItem.Add(user.ID, subItem);
                        chatListItem.SubItems.Add(subItem);
                    }
                }
            }
        }