예제 #1
0
        /// <summary>
        /// 显示默认聊天信息(15条)
        /// </summary>
        public Messageobject ShowDefaultMessage()
        {
            var main = ServiceLocator.Current.GetInstance <MainViewModel>();

            ChatMessageList.Clear();
            var tmpMsg = new Messageobject()
            {
                FromId = Applicate.MyAccount.userId,
                ToId   = main.Sess.Jid
            };
            List <Messageobject> msgList = tmpMsg.GetPageList(0);

            ShowChatMessage(msgList);  //显示消息气泡
            SendReadMsgAsync(msgList); //发送已读
            return(msgList.LastOrDefault());
        }
예제 #2
0
 /// <summary>
 /// 显示消息气泡
 /// </summary>
 /// <param name="messageList"></param>
 public void ShowChatMessage(List <Messageobject> messageList)
 {
     App.Current.Dispatcher.Invoke(() =>
     {
         //First Clean the entire ChatMessageList
         ChatMessageList.Clear();
         //Add to the ChatMessageList
         ChatMessageList.AddRange(messageList.MsgListToObservableMsgList());
         Task.Run(() =>
         {
             App.Current.Dispatcher.Invoke(() =>
             {
                 Messenger.Default.Send(true, ChatBubbleListControl.ScrollChatBubbleMessageToBottom);//自动滚动
             });
         });
     });
 }
예제 #3
0
        /// <summary>
        /// 显示默认消息
        /// </summary>
        /// <param name="jid"></param>
        /// <returns></returns>
        public void ShowDefaultMessage(string jid)
        {
            App.Current.Dispatcher.Invoke(() =>
            {
                ChatMessageList.Clear();//
            });
            var tmpMsg = new Messageobject()
            {
                FromId = Applicate.MyAccount.userId,
                ToId   = jid
            };
            List <Messageobject> msgList = tmpMsg.GetPageList(0);

            ShowChatMessage(msgList);  //显示消息气泡
            SendReadMsgAsync(msgList); //发送已读
            if (msgList.Count < 15)    //如果消息数量不足15条则拉取100条存入数据库并显示15条
            {
                GetMoreMessage();
            }
        }