Exemplo n.º 1
0
 public void AddFriend(Friend item)
 {
     lock (AddFriendLock)
     {
         int panel_index = Controls.IndexOfKey(StringFinal.UserPanelName + item.GroupID);
         Group group_item = Groups[item.GroupName];
         int group_index = Controls.IndexOfKey(StringFinal.GroupName + item.GroupID);
         friendIndex += 1;
         item.Uin = friendIndex;
         Panel panel_user = Controls[panel_index] as Panel;
         GroupControl gruop_user = Controls[group_index] as GroupControl;
         if (!Rosters.ContainsKey(item.Ritem.Jid.Bare))
         {
             group_item.Count += 1;
         }
         if (item.IsOnline)
         {
             group_item.OnlineCount += 1;
         }
         gruop_user.GroupInfo = group_item;//好友总数
         Rosters.Add(item.Ritem.Jid.Bare, item);
         FriendControl friend = new FriendControl(XmppConn, item.Ritem.Jid);
         friend.FCType = FriendContainerType.Small;
         friend.Location = new Point(1, ItemHeight + 1 * panel_user.Controls.Count);
         friend.Name = StringFinal.FriendName + item.Uin;
         friend.Size = new Size(panel_user.Width - 2, ItemHeight);
         friend.FriendInfo = item;
         friend.Selecting += new FriendControl.SelectedEventHandler(friend_Selecting);
         friend.ShowContextMenu += new FriendControl.ShowContextMenuEventHandler(friend_ShowContextMenu);
         friend.OpenChat += new FriendControl.OpenChatEventHandler(friend_OpenChat);
         friend.UpdateImage();//更新头像信息
         panel_user.Controls.Add(friend);
         panel_user.Height += (ItemHeight + 1);
         UpdateLayout(3, 0);
         //UpdateLayout(1, group_item.Id);
     }
 }
        public void AddFriend(Friend firend)
        {
            if (!Rosters.ContainsKey(firend.Ritem.Jid.Bare))
            {
                FriendControl friend = new FriendControl(XmppConn,firend.Ritem.Jid);
                friend.FCType = FCType;;
                friend.Location = new Point(1, (ItemHeight + 1) * this.Controls.Count);
                friend.Name = firend.Ritem.Jid.Bare;
                friend.Size = new Size(this.Width - 2, ItemHeight);
                friend.FriendInfo = firend;
                friend.OpenChat += new CSS.IM.UI.Control.FriendControl.OpenChatEventHandler(friend_OpenChat);
                friend.Selecting += new FriendControl.SelectedEventHandler(friend_Selecting);
                friend.UpdateImage();//更新头像信息
                Controls.Add(friend);
                Rosters.Add(firend.Ritem.Jid.Bare, firend);
                this.Height += (ItemHeight + 1);
            }

            System.GC.Collect();
        }
        public void AddFriend(Friend firend)
        {
            if (FriendKey==null)
            {
                FriendKey = new Dictionary<string, Friend>();
            }

            if (!FriendKey.ContainsKey(firend.Ritem.Jid.ToString()))
            {
                FriendControl friend = new FriendControl();
                friend.XmppConnection = XmppConn;

                friend.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right)));
                friend.BackColor = this.BackColor;
                friend.Location = new Point(1, ItemHeight + 1 * this.Controls.Count);
                friend.Name = firend.Ritem.Jid.Bare;
                friend.Size = new Size(this.Width - 2, ItemHeight);
                friend.MJID = firend.Ritem.Jid;
                friend.FriendInfo = firend;
                friend.OpenChat += new CSS.IM.UI.Control.FriendControl.OpenChatEventHandler(friend_OpenChat);
                friend.UpdateImage();//更新头像信息
                Controls.Add(friend);
                FriendKey.Add(firend.Ritem.Jid.ToString(), firend);
                this.Height += (ItemHeight + 1);
            }

            System.GC.Collect();
        }