Exemplo n.º 1
0
        /// <summary>
        /// 添加/移除监控
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvWeChatList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (ListenWeChatData == null)
            {
                ListenWeChatData = new List <WXUser>();
            }
            CurrentSelectedWeChat = string.Empty;
            DataGridViewCellCollection cells = this.dgvWeChatList.CurrentRow.Cells;

            if (cells != null && cells["editListen"].ColumnIndex == e.ColumnIndex)
            {
                string userName = cells["UserName"].Value.ToString();
                if (!IsListenView)
                {
                    if (!ListenWeChatData.Exists(item => { return(item.UserName == userName); }))
                    {
                        //将群添加到监控列表
                        ListenWeChatData.Add(new WXUser()
                        {
                            UserName = userName,
                            NickName = cells["ShowName"].Value.ToString()
                        });

                        NotListenWeChatData.RemoveAll(item => { return(item.UserName == userName); });
                    }
                }
                else
                {
                    //从监控列表中移除
                    if (ListenWeChatData.Exists(item => { return(item.UserName == userName); }))
                    {
                        ListenWeChatData.RemoveAll(item => { return(item.UserName == userName); });
                        //将群添加到监控列表
                        NotListenWeChatData.Add(new WXUser()
                        {
                            UserName = userName,
                            NickName = cells["ShowName"].Value.ToString()
                        });
                    }
                }
                dgvWeChatList.Rows.RemoveAt(cells["editListen"].RowIndex);
            }
            else
            {
                if (IsListenView)
                {
                    string showname = cells["ShowName"].Value.ToString();
                    CurrentSelectedWeChat = cells["UserName"].Value.ToString();
                    var data = wxMessageData.FindAll(item =>
                    {
                        return(item.MsgUserName == CurrentSelectedWeChat);
                    });
                    SetDataContentView(data);
                    lbMsgTitle.Text = "群 " + showname + " 消息列表";
                }
            }
        }
Exemplo 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 toolsAllListen_Click(object sender, EventArgs e)
 {
     NotListenWeChatData.ForEach(data =>
     {
         if (!ListenWeChatData.Exists(item => { return(item.UserName == data.UserName); }))
         {
             //将群添加到监控列表
             ListenWeChatData.Add(new WXUser()
             {
                 UserName = data.UserName,
                 NickName = data.NickName
             });
         }
     });
     NotListenWeChatData.Clear();
     dgvWeChatList.Rows.Clear();
     lbTabWeChatListen_Click(null, null);
 }
Exemplo n.º 3
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;
                }
            });
        }