private void OnLocalContactChanged(object sender, VATRP.Core.Events.ContactEventArgs e)
 {
     if (ServiceManager.Instance.Dispatcher.Thread != System.Threading.Thread.CurrentThread)
     {
         ServiceManager.Instance.Dispatcher.BeginInvoke((Action)(() => this.OnLocalContactChanged(sender, e)));
         return;
     }
     Contact = this._contactService.FindContact(e.Contact);
 }
        private void OnLoggedContactUpdated(object sender, ContactEventArgs e)
        {
            if (ServiceManager.Instance.Dispatcher.Thread != Thread.CurrentThread)
            {
                ServiceManager.Instance.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
                    new EventHandler<ContactEventArgs>(OnChatContactAdded), sender, new object[] { e });
                return;
            }

            if (_loggedInContactViewModel == null || _loggedInContactViewModel.Contact != e.Contact)
            {
                var loggedInContact = _contactsManager.FindContact(e.Contact);
                if (loggedInContact != null)
                {
                    _loggedInContactViewModel = new ContactViewModel(loggedInContact);
                }
            }
        }
 private void OnChatContactAdded(object sender, ContactEventArgs e)
 {
     if (ServiceManager.Instance.Dispatcher.Thread != Thread.CurrentThread)
     {
         ServiceManager.Instance.Dispatcher.BeginInvoke(DispatcherPriority.Normal,
             new EventHandler<ContactEventArgs>(OnChatContactAdded), sender, new object[] { e });
         return;
     }
     var contactVM = FindContactViewModel(e.Contact);
     if (contactVM == null)
     {
         var contact = this._contactsManager.FindContact(e.Contact);
         if (contact != null)
         {
             this.Contacts.Add(new ContactViewModel(contact));
             OnPropertyChanged("Contacts");
         }
     }
 }
 private void OnContactAdded(object sender, ContactEventArgs e)
 {
     VATRPContact contact = this._contactSvc.FindContact(e.Contact);
     if (contact != null)
     {
         if (contact.IsLoggedIn)
             return;
         VATRPChat chat = AddChat(contact, string.Empty);
         Contacts.Add(contact);
         if (ContactAdded != null)
             ContactAdded(this, new ContactEventArgs(new ContactID(e.Contact)));
     }
 }
        private void ContactChanged(object sender, ContactEventArgs e)
        {
            if (ServiceManager.Instance.Dispatcher.Thread != System.Threading.Thread.CurrentThread)
            {
                ServiceManager.Instance.Dispatcher.BeginInvoke((Action)(() => this.ContactChanged(sender, e)));
                return;
            }

            if (ContactsListView != null)
                ContactsListView.Refresh();
        }
        private void ContactAdded(object sender, ContactEventArgs e)
        {
            if (ServiceManager.Instance.Dispatcher.Thread != System.Threading.Thread.CurrentThread)
            {
                ServiceManager.Instance.Dispatcher.BeginInvoke((Action)(() => this.ContactAdded(sender, e)));
                return;
            }

            var contact = _contactsService.FindContact(e.Contact);
            if (contact != null)
            {
                AddContact(contact, true);
            }
        }
        private void OnNewContactAdded(object sender, ContactEventArgs e)
        {
            if (ServiceManager.Instance.Dispatcher.Thread != System.Threading.Thread.CurrentThread)
            {
                ServiceManager.Instance.Dispatcher.BeginInvoke((Action)(() => this.OnNewContactAdded(sender, e)));
                return;
            }

            // search and update all items
            var contact = _contactService.FindContact(new ContactID(e.Contact));
            if (contact != null && contact.IsLinphoneContact)
            {
                lock (this.Calls)
                {
                    foreach (var call in Calls)
                    {
                        if (call.CallEvent.RemoteParty.TrimSipPrefix() == contact.ID)
                        {
                            call.UpdateContact(contact);
                            call.AllowAddContact = false;
                        }
                    }
                }
                CallsListView.Refresh();
            }
        }