private void cGroup_ExpandChanged(Group sender, bool Currentstate)
 {
     if (Currentstate)
         ShowFriendsList(sender.Id);
     else
         HideFriendsList(sender.Id);
     System.GC.Collect();
 }
        public int AddGroup(string groupName,int groupId)
        {
            Group group = new Group();
            group.OnlineCount = 0;
            group.Count = 0;
            group.Title = groupName;
            group.Id = groupId;

            groupList.Add(group);
            m_Group.Add(group.Title, group);

            GroupControl cGroup = new GroupControl();
            this.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right)));
            this.BackColor = this.BackColor;
            cGroup.Location = new Point(2, 1);
            cGroup.Name = StringFinal.GroupName + group.Id;
            cGroup.Size = new Size(Width, 24);
            cGroup.GroupInfo = group;
            cGroup.ExpandChanged += new GroupControl.ExpandChangeEventHandler(cGroup_ExpandChanged);
            cGroup.ShowContextMenu += new GroupControl.ShowContextMenuEventHandler(cGroup_ShowContextMenu);
            this.Controls.Add(cGroup);

            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 = StringFinal.UserPanelName + group.Id;
            panel.Size = new Size(Width, group.Count * 56);
            panel.Visible = false;
            this.Controls.Add(panel);
            //UpdateLayout(2, 0);
            return groupId;
        }
        public void AddGroup(String groupName)
        {
            if (Groups.ContainsKey(groupName))
                throw new Exception("group is exits");

            groupIndex += 1;

            Group group = new Group();
            group.OnlineCount = 0;
            group.Count = 0;
            group.Title = groupName;
            group.Id = groupIndex;
            Groups.Add(groupName, group);

            GroupControl cGroup = new GroupControl();
            this.Anchor = ((AnchorStyles)(((AnchorStyles.Top | AnchorStyles.Left) | AnchorStyles.Right)));
            this.BackColor = this.BackColor;
            cGroup.Location = new Point(2, 1);
            cGroup.Name = StringFinal.GroupName + group.Id;
            cGroup.Size = new Size(Width, 24);
            cGroup.GroupInfo = group;
            cGroup.ExpandChanged += new GroupControl.ExpandChangeEventHandler(cGroup_ExpandChanged);
            cGroup.ShowContextMenu += new GroupControl.ShowContextMenuEventHandler(cGroup_ShowContextMenu);
            this.Controls.Add(cGroup);

            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 = StringFinal.UserPanelName + group.Id;
            panel.Size = new Size(this.Width, group.Count * 56);
            panel.Visible = false;
            this.Controls.Add(panel);

            UpdateLayout(3,group.Id);
            System.GC.Collect();
        }
        protected override void Dispose(bool disposing)
        {
            if (bgImg != null)
            {
                bgImg.Dispose();
                bgImg = null;
            }

            if (_groupInfo != null)
            {
                _groupInfo = null;
            }

            if (f != null)
            {
                f.Dispose();
                f = null;
            }

            if (bgImg != null)
            {
                bgImg.Dispose();
                bgImg = null;
            }

            if (f != null)
            {
                f.Dispose();
                f = null;
            }

            if (g != null)
            {
                g.Dispose();
                g = null;
            }

            try
            {
                base.Dispose(disposing);
            }
            catch (System.Exception)
            {

            }
            System.GC.Collect();
        }