/// <summary>
        /// Adds contacts found through a search to a ContactSubscription
        /// and raises the ContactAddedEvent.
        /// </summary>
        /// <param name="sContact">List[Contact]. The list of contacts found in a search.</param>
        public void SubscribeToSearchResults(List <Contact> sContactList)
        {
            try
            {
                if (searchResultSubscription == null)
                {
                    // Create subscription for the contact manager
                    // if the contact manager is not subscribed.
                    searchResultSubscription = contactMgr.CreateSubscription();
                }
                else
                {
                    // Remove all existing search results.
                    searchResultSubscription.Unsubscribe();
                    foreach (Contact c in searchResultSubscription.Contacts)
                    {
                        searchResultSubscription.RemoveContact(c);
                    }
                }

                // Add the Contact to a ContactSubscription.
                searchResultSubscription.AddContacts(sContactList);

                // Specify the Contact Information Types to be
                // returned in ContactInformationChanged events.
                ContactInformationType[] ContactInformationTypes = { ContactInformationType.Availability, ContactInformationType.ActivityId };

                // Activate the subscription.
                searchResultSubscription.Subscribe(ContactSubscriptionRefreshRate.High, ContactInformationTypes);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error:    " + ex.Message);
            }
        }
Exemplo n.º 2
0
        public void FreeContact()
        {
            _ContactName         = string.Empty;
            _ContactAvailability = -1;
            try
            {
                _ContactSubscription.Unsubscribe();

                IList <Contact> _Contacts = _ContactSubscription.Contacts;
                foreach (Contact C in _Contacts)
                {
                    _ContactSubscription.RemoveContact(C);
                }

                //if (_Contact != null)
                //{
                //    _ContactSubscription.RemoveContact(_Contact);
                //}
            }
            catch
            {
            }
            _Contact = null;
        }