Пример #1
0
 public ChatMessage(ChatMessage msg)
 {
     this.text      = msg.text;
     this.type      = msg.type;
     this.message   = msg.message;
     this.timestamp = msg.timestamp;
     this.state     = msg.state;
     this.orig      = msg.orig;
     this.b         = msg.b;
 }
Пример #2
0
 public void UpdateStatus(ChatMessageState state)
 {
     if (state == ChatMessageState.InProgress)
     {
         Status.Glyph = "\uE72A";
     }
     else if (state == ChatMessageState.NotDelivered)
     {
         Status.Glyph = "\uE711";
     }
     else
     {
         Status.Visibility = Visibility.Collapsed;
     }
 }
Пример #3
0
 public ChatMessage(ChatMessage msg)
 {
     this.text = msg.text;
       this.type = msg.type;
       this.message = msg.message;
       this.timestamp = msg.timestamp;
       this.state = msg.state;
       this.orig = msg.orig;
       this.b = msg.b;
 }
Пример #4
0
 public void MessageStateChanged(ChatMessage message, ChatMessageState state)
 {
 }
Пример #5
0
 public void OnMessageStateChanged(ChatMessage msg, ChatMessageState state)
 {
     Debug.WriteLine("Chat message state changed: " + state);
 }
Пример #6
0
        /*  private void cm_ContactFound(object sender, ContactFoundEventArgs e)
         * {
         *    if (e.ContactFound != null)
         *    {
         *        ContactName.Text = e.ContactFound.DisplayName;
         *        ContactManager.Instance.TempContact = e.ContactFound;
         *        ContactName.Tap += ContactName_Tap;
         *
         *        ContactName.Visibility = Visibility.Visible;
         *        NewChat.Visibility = Visibility.Collapsed;
         *    }
         * }*/

        /* private void ContactName_Tap(object sender, System.Windows.Input.GestureEventArgs e)
         * {
         *   NavigationService.Navigate(new Uri("/Views/Contact.xaml", UriKind.RelativeOrAbsolute));
         * }*/


        public void MessageStateChanged(ChatMessage message, ChatMessageState state)
        {
            if (LinphoneManager.Instance.CoreDispatcher == null)
            {
                return;
            }
#pragma warning disable CS4014 // Dans la mesure où cet appel n'est pas attendu, l'exécution de la méthode actuelle continue avant la fin de l'appel
            LinphoneManager.Instance.CoreDispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => {
                if (ProgressPopup.Visibility == Visibility.Visible)
                {
                    ProgressPopup.Visibility = Visibility.Collapsed;
                    MessageBox.Visibility    = Visibility.Visible;
                }

                if (state == ChatMessageState.Delivered)
                {
                    if (messageUploading != null && messageUploading.Equals(message))
                    {
                        messageUploading = null;
                    }
                }

                if (state == ChatMessageState.InProgress && message.IsOutgoing && messageUploading == null)
                {
                    // Create the chat bubble for both text or image messages
                    if (message.Appdata != null && messageUploading == null)
                    {
                        messageUploading = message;
                    }
                    OutgoingChatBubble bubble = new OutgoingChatBubble(message);
                    bubble.MessageDeleted    += bubble_MessageDeleted;
                    MessagesList.Children.Add(bubble);
                    scrollToBottom();
                }
                else if (state == ChatMessageState.FileTransferDone && !message.IsOutgoing)
                {
                    try {
                        IncomingChatBubble bubble = (IncomingChatBubble)MessagesList.Children.OfType <IncomingChatBubble>().Where(b => message.Equals(((IncomingChatBubble)b).ChatMessage)).Last();
                        if (bubble != null)
                        {
                            ((IncomingChatBubble)bubble).ChatMessage.FileTransferFilepath = message.FileTransferFilepath;
                            ((IncomingChatBubble)bubble).RefreshImage();
                        }
                        EnableDownloadButtons(true);
                    } catch {
                        Debug.WriteLine("Cannot create load download image");
                    }
                }
                else if (state == ChatMessageState.FileTransferDone && message.IsOutgoing)
                {
                    try {
                        OutgoingChatBubble bubble = (OutgoingChatBubble)MessagesList.Children.OfType <OutgoingChatBubble>().Where(b => message.Equals(((OutgoingChatBubble)b).ChatMessage)).Last();
                        if (bubble != null)
                        {
                            ((OutgoingChatBubble)bubble).ChatMessage.FileTransferFilepath = message.FileTransferFilepath;
                            ((OutgoingChatBubble)bubble).RefreshImage();
                        }
                    } catch {
                        Debug.WriteLine("Cannot load uploaded image");
                    }
                }
                else
                {
                    try {
                        foreach (OutgoingChatBubble bubble in MessagesList.Children.OfType <OutgoingChatBubble>())
                        {
                            if (bubble.ChatMessage.Equals(message))
                            {
                                bubble.UpdateStatus(state);
                            }
                        }
                    } catch {
                        Debug.WriteLine("Cannot update message state");
                    }
                }

                if (chatRoom != null)
                {
                    chatRoom.MarkAsRead();
                }
            });
        }