/// <summary>
        /// 设置在线/离线
        /// </summary>
        /// <param name="account"></param>
        /// <param name="status"></param>
        public static void SetOnlineStatus(string account, bool status)
        {
            GroupShowForm.GroupShowForm friendForm  = GetFriendObject(account) as GroupShowForm.GroupShowForm;
            GroupShowForm.GroupShowForm groupForm   = GetGroupObject(account) as GroupShowForm.GroupShowForm;
            GroupShowForm.GroupShowForm messageForm = GetMessageObejct(account) as GroupShowForm.GroupShowForm;

            //好友栏中设置
            if (friendForm != null)
            {
                friendForm.IsOnlineUnsafe = status;  //修改内部记录
                friendForm.ShowOnlineStatus(status); //设置显示
            }

            //群组栏中设置
            if (groupForm != null)
            {
                groupForm.IsOnlineUnsafe = status;  //修改内部记录
                groupForm.ShowOnlineStatus(status); //设置显示
            }

            //消息栏中设置
            if (messageForm != null)
            {
                messageForm.IsOnlineUnsafe = status;  //修改内部记录
                messageForm.ShowOnlineStatus(status); //设置显示
            }
        }
 /// <summary>
 /// 好友置顶
 /// </summary>
 /// <param name="o"></param>
 private void GroupShowForm_FriendToUpEvent(object o)
 {
     GroupShowForm.GroupShowForm groupShowForm = o as GroupShowForm.GroupShowForm;
     this.FriendTab.Controls.Remove(groupShowForm);
     this.FriendTab.Controls.Add(groupShowForm);
     groupShowForm.Dock = DockStyle.Top;
 }
        /// <summary>
        /// 增加显示好友/群组
        /// kind默认值为0, kind=1表示好友,kind=2表示群组
        /// </summary>
        /// <param name="kind"></param>
        /// <param name="Name"></param>
        /// <param name="Number"></param>
        /// <param name="ImagePath"></param>
        public void AddControl(int kind, string name, string account, Bitmap userImage, bool isOnline)
        {
            TabPage tabForm = null;

            GroupShowForm.GroupShowForm groupShowForm = new GroupShowForm.GroupShowForm();
            groupShowForm.SetInformation(kind, name, account, userImage, isOnline);
            groupShowForm.RequestChatEvent += GroupShowForm_RequestChatEvent;
            //判断父控件
            if (kind == 1)
            {
                tabForm = this.FriendTab;
                groupShowForm.ToUpEvent   += new Action <object>(GroupShowForm_FriendToUpEvent);
                groupShowForm.DeleteEvent += new Action <object>(GroupShowForm_FriendDeleteEvent);
                UserInformation.FriendsInformation.Add(groupShowForm);
            }
            else if (kind == 2)
            {
                tabForm = this.GroupTab;
                groupShowForm.ToUpEvent   += new Action <object>(GroupShowForm_GroupToUpEvent);
                groupShowForm.DeleteEvent += new Action <object>(GroupShowForm_GroupDeleteEvent);
                UserInformation.GroupsInformation.Add(groupShowForm);
            }
            else
            {
                MessageBox.Show("群组错误");
                return;
            }
            //添加控件
            tabForm.Controls.Add(groupShowForm);
            groupShowForm.Dock = DockStyle.Top;
        }
 /// <summary>
 /// 退群
 /// </summary>
 /// <param name="o"></param>
 private void GroupShowForm_GroupDeleteEvent(object o)
 {
     GroupShowForm.GroupShowForm groupShowForm = o as GroupShowForm.GroupShowForm;
     this.GroupTab.Controls.Remove(groupShowForm);
     //删除全局记录
     MessageBirdCommon.UserInformation.RemoveGroupsInformation(groupShowForm.Account);
 }
        /// <summary>
        /// 执行删除
        /// </summary>
        /// <param name="o"></param>
        private void GroupShowForm_DeleteEvent(object o)
        {
            GroupShowForm.GroupShowForm groupShowForm = o as GroupShowForm.GroupShowForm;
            this.Controls.Remove(groupShowForm);

            UserInformation.RemoveMessageInformation(groupShowForm.Account);
        }
        /// <summary>
        /// 获取主界中好友的对象
        /// 返回值为null表示对象不存在
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public static Object GetFriendObject(string account)
        {
            if (FriendsInformation.Count <= 0)
            {
                return(null);
            }

            GroupShowForm.GroupShowForm obj = null;
            for (int i = 0; i < FriendsInformation.Count; i++)
            {
                obj = FriendsInformation[i] as GroupShowForm.GroupShowForm;
                if (obj.Account == account)
                {
                    return(obj);
                }
            }
            return(null);
        }
        /// <summary>
        /// 获取主界面中消息对象
        /// 返回值为null表示对象不存在
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public static Object GetMessageObejct(string account)
        {
            if (MessageInformation.Count <= 0)
            {
                return(null);
            }

            GroupShowForm.GroupShowForm obj = null;
            //倒序查询,消息列表中一个账户可以有多个对象,界面只显示了最后一个
            for (int i = MessageInformation.Count - 1; i >= 0; i--)
            {
                obj = MessageInformation[i] as GroupShowForm.GroupShowForm;
                if (obj.Account == account)
                {
                    return(obj);
                }
            }
            return(null);
        }
        /// <summary>
        /// 返回含有关键字的群组引用列表
        /// </summary>
        /// <param name="keyWords"></param>
        /// <returns></returns>
        public static List <GroupShowForm.GroupShowForm> GetGroupsObjectHasKeyWords(string keyWords)
        {
            if (GroupsInformation.Count <= 0)
            {
                return(null);
            }

            List <GroupShowForm.GroupShowForm> GroupsObjectHasKeyWords = new List <GroupShowForm.GroupShowForm>();

            GroupShowForm.GroupShowForm groupShowForm = null;
            for (int i = 0; i < GroupsInformation.Count; i++)
            {
                groupShowForm = GroupsInformation[i] as GroupShowForm.GroupShowForm;
                if (groupShowForm.HasKeywords(keyWords))
                {
                    GroupsObjectHasKeyWords.Add(groupShowForm);
                }
            }
            return(GroupsObjectHasKeyWords);
        }
        /// <summary>
        /// 删除消息
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public static void RemoveMessageInformation(string account)
        {
            if (MessageInformation.Count <= 0)
            {
                return;
            }

            List <Object> infoList = new List <Object>();//结果列表

            GroupShowForm.GroupShowForm groupShowForm = null;
            for (int i = 0; i < MessageInformation.Count; i++)
            {
                groupShowForm = MessageInformation[i] as GroupShowForm.GroupShowForm;
                if (groupShowForm.Account != account)
                {
                    infoList.Add(groupShowForm);
                }
            }
            MessageInformation = infoList;
        }
        /// <summary>
        /// 返回含有关键字的群组列表
        /// </summary>
        /// <param name="keyWords"></param>
        /// <returns></returns>
        public static List <BaseInformation> GetGroupsHasKeyWords(string keyWords)
        {
            if (GroupsInformation.Count <= 0)
            {
                return(null);
            }

            List <BaseInformation> GroupsHasKeyWords = new List <BaseInformation>();

            GroupShowForm.GroupShowForm groupShowForm   = null;
            BaseInformation             baseInformation = null;

            for (int i = 0; i < GroupsInformation.Count; i++)
            {
                groupShowForm = GroupsInformation[i] as GroupShowForm.GroupShowForm;
                if (groupShowForm.HasKeywords(keyWords))
                {
                    baseInformation = new BaseInformation();
                    baseInformation.SetInformation(groupShowForm.Kind, groupShowForm.Account, groupShowForm.UserName, groupShowForm.UserImage, groupShowForm.IsOnline);
                    GroupsHasKeyWords.Add(baseInformation);
                }
            }
            return(GroupsHasKeyWords);
        }
        /// <summary>
        /// 添加消息控件,并且绑定相关事件
        /// </summary>
        /// <param name="kind"></param>
        /// <param name="name"></param>
        /// <param name="account"></param>
        /// <param name="message"></param>
        /// <param name="time"></param>
        /// <param name="imagePath"></param>
        public void AddControl(int kind, string name, string account, string message, string time, Bitmap userImage, bool isOnline)
        {
            GroupShowForm.GroupShowForm groupShowForm = null;
            if (kind != 3)
            {
                MessageBox.Show("消息分组错误");
                return;
            }
            for (int i = 0; i < this.Controls.Count; i++)
            {
                groupShowForm = this.Controls[i] as GroupShowForm.GroupShowForm;
                if (groupShowForm.Account == account)
                {
                    this.Controls.Remove(groupShowForm);
                    break;
                }
                groupShowForm = null;
            }
            if (groupShowForm == null)
            {
                groupShowForm                   = new GroupShowForm.GroupShowForm();
                groupShowForm.ToUpEvent        += GroupShowForm_ToUpEvent;
                groupShowForm.DeleteEvent      += GroupShowForm_DeleteEvent;
                groupShowForm.Dock              = DockStyle.Top;
                groupShowForm.RequestChatEvent += GroupShowForm_RequestChatEvent;
            }

            //全局注册
            UserInformation.MessageInformation.Add(groupShowForm);

            //更新显示内容
            groupShowForm.SetInformation(3, name, account, message, time, userImage, isOnline);
            //此账户消息数目加一
            groupShowForm.Number++;
            this.Controls.Add(groupShowForm);
        }