Пример #1
0
        /// <summary>
        /// Callback called by LinphoneCore when the state of a sent message changes.
        /// </summary>
        public void MessageStateChanged(LinphoneChatMessage message, LinphoneChatMessageState state)
        {
            Logger.Msg("[Chat] Message state changed: " + state.ToString());

            Dispatcher.BeginInvoke(() =>
            {
                if (ProgressPopup.Visibility == Visibility.Visible)
                {
                    ProgressPopup.Visibility = Visibility.Collapsed;
                    MessageBox.Visibility = Visibility.Visible;
                    AddSendButtonsToAppBar();
                }

                if (state == LinphoneChatMessageState.InProgress)
                {
                    // Create the chat bubble for both text or image messages
                    OutgoingChatBubble bubble = new OutgoingChatBubble(message);
                    bubble.MessageDeleted += bubble_MessageDeleted;
                    MessagesList.Children.Insert(MessagesList.Children.Count - 1, bubble);
                    scrollToBottom();
                }
                else if (state == LinphoneChatMessageState.FileTransferDone && !message.IsOutgoing)
                {
                    try
                    {
                        message.AppData = message.FileTransferFilePath;
                        ChatBubble bubble = (ChatBubble)MessagesList.Children.Where(b => message.Equals(((ChatBubble)b).ChatMessage)).Last();
                        if (bubble != null)
                        {
                            ((IncomingChatBubble)bubble).RefreshImage();
                        }
                        EnableDownloadButtons(true);
                    }
                    catch { }
                }
                else
                {
                    // Update the outgoing status of the message
                    try
                    {
                        ChatBubble bubble = (ChatBubble)MessagesList.Children.Where(b => message.Equals(((ChatBubble)b).ChatMessage)).Last();
                        if (bubble != null)
                        {
                            ((OutgoingChatBubble)bubble).UpdateStatus(state);
                        }
                    }
                    catch { }
                }

                if (chatRoom != null)
                {
                    chatRoom.MarkAsRead();
                }
            });
        }
Пример #2
0
 private void DisplayPastMessages(IList<Object> messages)
 {
     foreach (LinphoneChatMessage message in messages)
     {
         if (!message.IsOutgoing)
         {
             IncomingChatBubble bubble = new IncomingChatBubble(message);
             bubble.MessageDeleted += bubble_MessageDeleted;
             bubble.DownloadImage += bubble_DownloadImage;
             MessagesList.Children.Insert(MessagesList.Children.Count - 1, bubble);
         }
         else
         {
             OutgoingChatBubble bubble = new OutgoingChatBubble(message);
             bubble.MessageDeleted += bubble_MessageDeleted;
             bubble.UpdateStatus(message.State);
             MessagesList.Children.Insert(MessagesList.Children.Count - 1, bubble);
         }
     }
     scrollToBottom();
 }