Ejemplo n.º 1
0
        /// <summary>
        /// 添加通讯录
        /// </summary>
        /// <param name="user">The user.</param>
        public void AddContactsView(WXUser user)
        {
            if (NotListenWeChatData == null)
            {
                NotListenWeChatData = new List <WXUser>();
            }
            if (ListenWeChatData == null)
            {
                ListenWeChatData = new List <WXUser>();
            }

            if (!NotListenWeChatData.Exists(item => { return(item.UserName == user.UserName); }) && !ListenWeChatData.Exists(item => { return(item.UserName == user.UserName); }))
            {
                NotListenWeChatData.Add(user);
                SetContactsView(user);
                //DownLoadWeChatImage(user);
            }
            ListenWeChatData.ForEach(item =>
            {
                if (item.UserName == user.UserName)
                {
                    item.NickName = user.ShowName;
                }
            });
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 一键移除监控
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 private void toolsClearListen_Click(object sender, EventArgs e)
 {
     ListenWeChatData.ForEach(data =>
     {
         if (!NotListenWeChatData.Exists(item => { return(item.UserName == data.UserName); }))
         {
             //将群添加到监控列表
             NotListenWeChatData.Add(new WXUser()
             {
                 UserName = data.UserName,
                 NickName = data.NickName
             });
         }
     });
     ListenWeChatData.Clear();
     dgvWeChatList.Rows.Clear();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 加载微信通讯录
        /// </summary>
        /// <param name="user">The user.</param>
        private void SetContactsView(WXUser user)
        {
            if (NotListenWeChatData == null)
            {
                NotListenWeChatData = new List <WXUser>();
            }

            if (dgvWeChatList.InvokeRequired)
            {
                this.dgvWeChatList.Invoke(new Action <WXUser>(SetContactsView), new object[] { user });
            }
            else
            {
                bool result = false;
                foreach (DataGridViewRow item in dgvWeChatList.Rows)
                {
                    if (item.Cells["UserName"].Value.ToString().Equals(user.UserName))
                    {
                        result = true;
                        item.Cells["ShowName"].Value = user.ShowName;
                        item.Cells["UserName"].Value = user.UserName;
                        break;
                    }
                }
                if (!IsListenView && !result)
                {
                    int i = dgvWeChatList.Rows.Count;
                    dgvWeChatList.Rows.Add();
                    ++i;
                    dgvWeChatList.Rows[i - 1].Cells["ID"].Value       = i;
                    dgvWeChatList.Rows[i - 1].Cells["ShowName"].Value = user.ShowName;
                    dgvWeChatList.Rows[i - 1].Cells["UserName"].Value = user.UserName;

                    dgvWeChatList.Rows[i - 1].Height = 50;
                    dgvWeChatList.Rows[i - 1].DefaultCellStyle.SelectionBackColor = Color.FromArgb(236, 232, 231);
                }

                if (NotListenWeChatData.Exists(item => { return(item.UserName == user.UserName); }))
                {
                    NotListenWeChatData.RemoveAll(u => { return(u.UserName == user.UserName); });
                }
                NotListenWeChatData.Add(user);
            }
        }