示例#1
0
        public void SetMessageResult(string fromUserId, string toUserId, long id, bool success)
        {
            string userItemId = fromUserId;

            if (fromUserId == this.OwnerUser.ID)
            {
                //如果是我自己,那么则是发送消息
                if (success)
                {
                    //发送时就按照默认成功的,发送成功的消息可以忽略了
                    return;
                }
                userItemId = toUserId;
            }

            UserListItem    userItem = this[userItemId];
            UserChatControl chatCtrl = userItem.ChatControl;

            MessageListItem item = null;

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

            Store.Models.Message m = item.Message;
            m.Flag = success;
            item.Update();

            if (chatCtrl != null && userItemId == this.SelectedUser.ID)
            {
                //当前表示着,更新
                chatCtrl.Invalidate();
            }
        }
示例#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);
            }
        }