Пример #1
0
        private void PopulateInemsUser()
        {
            this.PanelListUsers.Controls.Clear();

            _userListItems.Clear();

            for (int i = 0; i < _allChatUsers.Count; ++i)
            {
                UserListItem item = new UserListItem(this);
                item.UserName = _allChatUsers[i].userName;

                if (_allChatUsers[i].isConnected)
                {
                    item.ConnectedImage = Resources.Circle_Green;
                }
                else
                {
                    item.ConnectedImage = Resources.Circle_Red;
                }


                if (_allChatUsers[i].haveMsg)
                {
                    item.HaveMsgImage = Resources.haveMsg;
                }
                else
                {
                    item.HaveMsgImage = Resources.Tick;
                }

                _userListItems.Add(item);
                this.PanelListUsers.Controls.Add(item);
            }
        }
Пример #2
0
        public void СhangeCurrentUserItem(UserListItem item)
        {
            if (_idCurrentUserItem != -1)
            {
                _userListItems[_idCurrentUserItem].SetBackColor(Color.White);
                _userListItems[_idCurrentUserItem].clickAtThis = false;
            }

            _idCurrentUserItem = _userListItems.IndexOf(item);
            item.SetBackColor(Color.FromArgb(132, 133, 235));
            item.HaveMsgImage = Resources.Tick;
        }
Пример #3
0
        public void ConnectUserCallback(string userName)
        {
            if (userName == _userName)
            {
                return;
            }

            bool isNewUser = true;

            for (int i = 0; i < _allChatUsers.Count; ++i)
            {
                if (_allChatUsers.ToArray()[i].userName == userName)
                {
                    ChatUser newCU = new ChatUser();
                    newCU             = _allChatUsers.ToArray()[i];
                    newCU.isConnected = true;
                    _allChatUsers.Remove(_allChatUsers[i]);
                    _allChatUsers.Insert(i, newCU);

                    isNewUser = false;
                }
            }

            if (isNewUser)
            {
                ChatUser cu = new ChatUser
                {
                    userName    = userName,
                    isConnected = true,
                    haveMsg     = false,
                    msgItems    = new List <MessageItem>()
                };
                _allChatUsers.Add(cu);
                UserListItem item = new UserListItem(this);

                item.UserName       = userName;
                item.ConnectedImage = Resources.Circle_Green;
                item.HaveMsgImage   = Resources.Tick;
                _userListItems.Add(item);
                this.PanelListUsers.Controls.Add(item);
            }
            else
            {
                for (int i = 0; i < _userListItems.Count; ++i)
                {
                    if (_userListItems[i].UserName == userName)
                    {
                        _userListItems[i].ConnectedImage = Resources.Circle_Green;
                    }
                }
            }
        }
Пример #4
0
        public void ClickUserItem(UserListItem item)
        {
            СhangeCurrentUserItem(item);

            for (int i = 0; i < _allChatUsers.Count; ++i)
            {
                if (_allChatUsers[i].userName == item.UserName)
                {
                    string[] msgs = _client.GetUnsentMsg(item.UserName, _userName);
                    for (int h = 0; h < msgs.Length; ++h)
                    {
                        MsgCallback(item.UserName, _userName, msgs[h]);
                    }

                    this.msgFlowPanel.Controls.Clear();

                    for (int k = 0; k < _allChatUsers[i].msgItems.Count; ++k)
                    {
                        this.msgFlowPanel.Controls.Add(_allChatUsers[i].msgItems[k]);
                    }
                    break;
                }
            }
        }