Example #1
0
        private void Sqlchat_MessageEvent(List <Message> msg)
        {
            Task.Run(() =>
            {
                var offset = msg.Count - Messages.Count;
                if (offset != 0)
                {
                    var buffers = msg.ToList();
                    buffers.RemoveRange(0, Messages.Count);


                    foreach (var buffer in buffers)
                    {
                        Dispatcher.Invoke(() =>
                        {
                            IC.Items.Add(new ChatItemViewModel {
                                AvatarUrl = cts.GetServerData(buffer.userid).FirstOrDefault().Account.Split('|')[1], message = buffer.message, Date = buffer.Date.Split(':')[0] + "/" + buffer.Date.Split(':')[1] + "/" + buffer.Date.Split(':')[2] + " " + buffer.Date.Split(':')[3] + ":" + buffer.Date.Split(':')[4] + ":" + buffer.Date.Split(':')[5], Modify = buffer.Modify, user = buffer.user, Name = buffer.user
                            });
                            SVroller.ScrollToEnd();
                        });
                    }
                    Messages = msg;
                }
            });
        }
Example #2
0
 private void Sqlchat_UpdateEvent(Endless_Development_Project_Studio.ChatsC msg)
 {
     SocketStatus.UpdateNewMessage();
     Dispatcher.Invoke(() =>
     {
         IC.Items.Add(new ChatItemViewModel {
             AvatarUrl = cts.GetServerData(msg.userid).FirstOrDefault().Account.Split('|')[1], message = msg.message, Date = msg.Date.Split(':')[0] + "/" + msg.Date.Split(':')[1] + "/" + msg.Date.Split(':')[2] + " " + msg.Date.Split(':')[3] + ":" + msg.Date.Split(':')[4] + ":" + msg.Date.Split(':')[5], Modify = msg.Modify, user = msg.user, Name = msg.user
         });
         SVroller.ScrollToEnd();
     });
 }