Ejemplo n.º 1
0
        private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Titlelable.Content = Title;
            mainPanel.Children.Clear();
            Message[] listmess = e.Result as Message[];
            if (listmess != null)
            {
                foreach (Message mess in listmess)
                {
                    MessageBox.Side side;
                    if (mess.SenderId == AppInstance.getInstance().GetUser().Id)
                    {
                        side = MessageBox.Side.User;
                    }
                    else
                    {
                        side = MessageBox.Side.Other;
                    }
                    string title = AppInstance.getInstance().GetFullname(mess.SenderId);

                    if (mess.Type == 1)
                    {
                        MessageBox messBos = new MessageBox(title, mess.Content, mess.ArrivalTime.ToString("hh:mm:ss dd-MM-yyyy"), mess.SenderId, side);
                        mainPanel.Children.Add(messBos);
                    }
                    if (mess.Type == 2)
                    {
                        MessageImageBox messBox = new MessageImageBox(title, mess.Content, mess.ArrivalTime.ToString("hh:mm:ss dd-MM-yyyy"), mess.SenderId, (MessageImageBox.Side)side);
                        mainPanel.Children.Add(messBox);
                    }
                }
            }
            mainScroll.ScrollToBottom();
            //worker.RunWorkerAsync(3000);
        }
Ejemplo n.º 2
0
        private void ReceiveMessage(string message)
        {
            Message mess = JsonConvert.DeserializeObject <Message>(message);

            if (mess.ConversationId != ConversationId)
            {
                return;
            }
            MessageBox.Side side;
            if (mess.SenderId == AppInstance.getInstance().GetUser().Id)
            {
                side = MessageBox.Side.User;
            }
            else
            {
                side = MessageBox.Side.Other;
            }
            string title = AppInstance.getInstance().GetFullname(mess.SenderId);

            if (mess.Type == 1)
            {
                MessageBox messBos = new MessageBox(title, mess.Content, mess.ArrivalTime.ToString("hh:mm:ss dd-MM-yyyy"), mess.SenderId, side);
                mainPanel.Children.Add(messBos);
            }
            if (mess.Type == 2)
            {
                MessageImageBox messBox = new MessageImageBox(title, mess.Content, mess.ArrivalTime.ToString("hh:mm:ss dd-MM-yyyy"), mess.SenderId, (MessageImageBox.Side)side);
                mainPanel.Children.Add(messBox);
            }

            mainScroll.ScrollToBottom();
        }