Exemplo n.º 1
0
        public void AddOrUpdateUser(LanUser user, UpdateState updateState)
        {
            if (this.ContainsUser(user))
            {
                UserListItem item = this[user.ID];

                if ((updateState & UpdateState.NickName) != 0)
                {
                    item.Update();
                }

                this.Invalidate(item.Bounds);

                UserChatControl chatControl = item.ChatControl;
                if (chatControl != null)
                {
                    chatControl.Contacter          = user;
                    chatControl.SendMessageEnabled = (user.Status != UserStatus.Offline);
                }

                if (this.SelectedUser != null && this.SelectedUser.ID == user.ID)
                {
                    //当前刚好表示着聊天记录则更新
                    if (chatControl != null)
                    {
                        chatControl.RefreshMessageList(null);
                    }
                }
            }
            else
            {
                UserListItem item = new UserListItem(user);
                item.Save();

                this.Items.Add(item);
            }
        }
Exemplo n.º 2
0
        public void SetFileTransportProgress(TransportFile file)
        {
            UserListItem    userItem = this[file.MAC];
            UserChatControl chatCtrl = userItem.ChatControl;

            MessageListItem item = null;

            if (chatCtrl == null)
            {
                //如果还没表示则取出来
                item = userItem.GetWaitDisplayMessageItem(file.ID);
            }
            else
            {
                item = chatCtrl.GetMessageItem(file.ID);
            }

            item.FileTransportedLength = file.TransportedLength;
            item.FileTransportedSpeed  = file.TransportedSpeed;
            item.Progress = file.Progress;

            if (file.Progress == 100)
            {
                //传输完毕
                Store.Models.Message m = item.Message;
                m.Flag = true;
                item.Update();

                item.State = MessageState.Received;
            }

            if (chatCtrl != null && file.MAC == this.SelectedUser.MAC)
            {
                //当前表示着,更新
                chatCtrl.RefreshMessageList(item);
            }
        }