Ejemplo n.º 1
0
 private async void Events_OnRosterItemSelected(object sender, Frontend.ContactSelectedEventArgs e)
 {
     try
     {
         await Frontend.RunAsync(() =>
         {
             SelectedContact = e.Contact;
             RecreateLayout();
         });
     }
     catch (Exception uiEx) { Frontend.UIError(uiEx); }
 }
Ejemplo n.º 2
0
 private async void Events_OnSubscriptionContactSelected(object sender, Frontend.ContactSelectedEventArgs e)
 {
     try
     {
         await Frontend.RunAsync(() =>
         {
             if (CleanPaneState())
             {
                 CurrentFlyout = new Flyout.Flyout(FlyoutType.Subscription, e.Contact);
             }
         });
     }
     catch (Exception uiEx) { Frontend.UIError(uiEx); }
 }
Ejemplo n.º 3
0
 private async void Events_OnRosterItemSelected(object sender, Frontend.ContactSelectedEventArgs e)
 {
     try
     {
         await Frontend.RunAsync(() =>
         {
             if (e.Contact != null)
             {
                 this.DataContext = e.Contact;
             }
         });
     }
     catch (Exception uiEx) { Frontend.UIError(uiEx); }
 }
Ejemplo n.º 4
0
        private async void OnRosterContactSelected(object sender, Frontend.ContactSelectedEventArgs e)
        {
            try
            {
                await Frontend.RunAsync(() =>
                {
                    if (e.Contact != null && !string.IsNullOrEmpty(e.Contact.jid))
                    {
                        var account = Frontend.Accounts[new XMPP.JID(e.Contact.account).Bare];
                        if (account == null || account.OwnContact == null)
                        {
                            return;
                        }

                        if (!account.CurrentConversations.Keys.Contains(e.Contact.jid))
                        {
                            account.CurrentConversations[e.Contact.jid] = new Backend.Data.Conversation(account.OwnContact.jid, e.Contact.jid);
                        }

                        // Remove old listerners
                        if (CurrentConversation != null)
                        {
                            CurrentConversation.Items.CollectionChanged -= OnCoversationItemCollectionChanged;
                        }

                        // Change to the new Conversation
                        CurrentConversation = account.CurrentConversations[e.Contact.jid];

                        UpdateOfflineWarnings();

                        // Remove old text
                        SendText.Text = string.Empty;

                        // Add new listener
                        CurrentConversation.Items.CollectionChanged += OnCoversationItemCollectionChanged;

                        ClearMessageCount();

                        ScrollToBottom();

                        // Can be vary annoying
                        if (Frontend.Settings.focusTextInput)
                        {
                            this.SendText.Focus(FocusState.Programmatic);
                        }
                    }
                    else // No contact selected
                    {
                        if (CurrentConversation != null)
                        {
                            if (CurrentConversation.Items.Count > 0)
                            {
                                foreach (var item in CurrentConversation.Items)
                                {
                                    item.Messages.CollectionChanged -= OnConversationItemMessageCollectionChanged;
                                }
                            }

                            CurrentConversation.Items.CollectionChanged -= OnCoversationItemCollectionChanged;

                            AccountOfflineWarning.Visibility = Visibility.Collapsed;
                            ContactOfflineWarning.Visibility = Visibility.Collapsed;
                        }

                        CurrentConversation = null;
                    }
                });
            }
            catch (Exception uiEx) { Frontend.UIError(uiEx); }
        }