private void friend_ShowContextMenu(FriendControl sender, MouseEventArgs e) { if (friend_qcm == null) { InitFriendMenu(); } friend_qcm.Show(sender, e.Location); System.GC.Collect(); }
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 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); } }
private void friend_ShowContextMenu(FriendControl sender, MouseEventArgs e) { if (qcm2 == null) { InitFriendMenu(); } qcm2.Show(sender, e.Location); }
public void InitFriendList(List<Group> groups) { GroupCount = groups.Count; for (int i = 0; i < groups.Count; i++) { GroupControl cGroup = new GroupControl(); this.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right))); this.BackColor = this.BackColor; cGroup.Location = new Point(1, 24 * i + i + 1); cGroup.Name = StringFinal.GroupName + groups[i].Id; cGroup.Size = new Size(Width, 24); cGroup.GroupInfo = groups[i]; cGroup.ExpandChanged += new GroupControl.ExpandChangeEventHandler(cGroup_ExpandChanged); cGroup.ShowContextMenu += new GroupControl.ShowContextMenuEventHandler(cGroup_ShowContextMenu); //AddGroup(groups[i].Title); //this.Controls.Add(cGroup);//添加组便签 int index=groupList.Add(groups[i]); m_Group.Add(groups[i].Title, groups[i]); Panel panel = new Panel(); panel.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right))); panel.BackColor = this.BackColor; panel.Location = new Point(0, 0); panel.Name = "userPanel_" + groups[i].Id; panel.Size = new Size(this.Width, groups[i].Count * 56); panel.Visible = false; if (groups[i].Count > 0) { for (int j = 0; j < groups[i].List.Count; j++) { Friend friendInfo = (Friend)groups[i].List[j]; if (friendInfo.State != 0 && friendInfo.State != 5) { //cGroup.GroupInfo.OnlineCount++; } friendInfo.GroupID = groups[i].Id; FriendControl friend = new FriendControl(); friend.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right))); friend.BackColor = this.BackColor; friend.Location = new Point(1, 56 * j); friend.Name = "friend_" + friendInfo.Uin; friend.Size = new Size(panel.Width - 2, 55); friend.FriendInfo = friendInfo; friend.Selecting += new FriendControl.SelectedEventHandler(friend_Selecting); friend.ShowContextMenu += new FriendControl.ShowContextMenuEventHandler(friend_ShowContextMenu); friend.MouseDoubleClick += new MouseEventHandler(friend_MouseDoubleClick); panel.Controls.Add(friend); } } this.Controls.Add(panel);//添加联系人标签 } GC.Collect(); }
public int addFriend(Friend item) { FriendID += 1; int groupid = item.GroupID; item.Uin = FriendID; int panel_index=Controls.IndexOfKey(StringFinal.UserPanelName + groupid); int group_index = Controls.IndexOfKey(StringFinal.GroupName + groupid); Panel panel_user = Controls[panel_index] as Panel; GroupControl gruop_user = Controls[group_index] as GroupControl; gruop_user.GroupInfo.Count++;//好友总数 //gruop_user.GroupInfo.OnlineCount++;//在线好友 m_Roster.Add(item.NikeName, item); FriendControl friend = new FriendControl(); friend.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right))); friend.BackColor = this.BackColor; friend.Location = new Point(1, 56 * panel_user.Controls.Count); friend.Name = "friend_" + item.Uin; friend.Size = new Size(panel_user.Width - 2, 55); friend.FriendInfo = item; friend.Selecting += new FriendControl.SelectedEventHandler(friend_Selecting); friend.ShowContextMenu += new FriendControl.ShowContextMenuEventHandler(friend_ShowContextMenu); friend.MouseDoubleClick += new MouseEventHandler(friend_MouseDoubleClick); panel_user.Controls.Add(friend); System.Diagnostics.Debug.WriteLine("count:"+panel_user.Controls.Count); //panel_user.Controls.Add(item); panel_user.Height += 56; //if (item.State != 0 && item.State != 5) //{ // cGroup.GroupInfo.OnlineCount++; //} //friendInfo.GroupID = groups[i].Id; return 0; }
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(); }