PickMultipleContactsAsync() public méthode

public PickMultipleContactsAsync ( ) : IAsyncOperation>
Résultat IAsyncOperation>
        /// <summary>
        /// The click Event. This event will decide wheather to allow Single contact pick or allow used to select multiple
        /// contacts.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void btnCallContact_Click(object sender, RoutedEventArgs e)
        {
            SingleContactDetails = new List<Store_CS_WorkingwithContacts.ContactDetails>(); 
            var contactSelector = new Windows.ApplicationModel.Contacts.ContactPicker();
            //Set the text for the commit button of the ContactPicker UI
            contactSelector.CommitButtonText = "Pick Contact";


            if (selectionType == "Single")
            {
                //Select Single Contact
                var selectedContact = await contactSelector.PickSingleContactAsync();
               SingleContactDetails.Add(new ContactDetails(selectedContact));
            }
            else
            {
                if (selectionType == "Multiple")
                {
                    //Select Multiple Contacts
                    var selectedContact = await contactSelector.PickMultipleContactsAsync();

                    foreach (var item in selectedContact)
                    {
                        SingleContactDetails.Add(new ContactDetails(item));
                    }
                }
                else
                {
                    txtmessage.Text = "Please Select the option";
                }
               
            }
            lstcontactsdetails.ItemsSource = SingleContactDetails;

        }
        async void _shakeDecetor_ShakeEvent(object sender, EventArgs e)
        {
            var res = new List<string>();

            var cp = new ContactPicker();
            var contacts = await cp.PickMultipleContactsAsync();
            if (contacts != null && contacts.Count > 0)
            {
                res.AddRange(contacts.Select(contactInformation => contactInformation.Name));
            }

            if (res.Count < 2)
            {
                Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => new MessageDialog("Not enough contacts.").ShowAsync());
            }
            else
            {
                var ran = new Random();
                var r1 = ran.Next(0, res.Count);
                var r2 = r1;
                while (r1 == r2)
                {
                    r2 = ran.Next(0, res.Count);
                }

                // App.Current.Resources.Remove("N1");
                // App.Current.Resources.Add("N1",res[r1].DisplayName);
                Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    sn = new SearchNames { N1 = res[r1], N2 = res[r2] };
                    ContentPanel.DataContext = sn;
                });
            }
        }
        private async void PickContactsButton_Click(object sender, RoutedEventArgs e)
        {
            if (rootPage.EnsureUnsnapped())
            {
                var contactPicker = new Windows.ApplicationModel.Contacts.ContactPicker();
                contactPicker.CommitButtonText = "Select";
                contacts = await contactPicker.PickMultipleContactsAsync();

                OutputContacts.Items.Clear();

                if (contacts.Count > 0)
                {
                    OutputEmpty.Visibility = Visibility.Collapsed;

                    foreach (ContactInformation contact in contacts)
                    {
                        OutputContacts.Items.Add(new ContactItemAdapter(contact));
                    }
                }
                else
                {
                    OutputEmpty.Visibility = Visibility.Visible;
                }
            }
        }
Exemple #4
0
        public async void search(string searchCriteria)
        {
            string[] args = JSON.JsonHelper.Deserialize <string[]>(searchCriteria);

            ContactSearchParams searchParams = new ContactSearchParams();

            try
            {
                searchParams.fields  = JSON.JsonHelper.Deserialize <string[]>(args[0]);
                searchParams.options = JSON.JsonHelper.Deserialize <SearchOptions>(args[1]);
            }
            catch (Exception)
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, INVALID_ARGUMENT_ERROR));
                return;
            }

            if (searchParams.options == null)
            {
                searchParams.options          = new SearchOptions();
                searchParams.options.filter   = "";
                searchParams.options.multiple = true;
            }

            if (searchParams.options.multiple == true)
            {
                var contactPicker = new Windows.ApplicationModel.Contacts.ContactPicker();
                contactPicker.CommitButtonText = "Select";
                contactPicker.SelectionMode    = Windows.ApplicationModel.Contacts.ContactSelectionMode.Contacts;


                IReadOnlyList <ContactInformation> contacts = await contactPicker.PickMultipleContactsAsync();

                string strResult = "";
                foreach (ContactInformation contact in contacts)
                {
                    strResult += FormatJSONContact(contact, null) + ",";
                }
                PluginResult result = new PluginResult(PluginResult.Status.OK);
                result.Message = "[" + strResult.TrimEnd(',') + "]";
                DispatchCommandResult(result);
            }
            else
            {
                var contactPicker = new Windows.ApplicationModel.Contacts.ContactPicker();
                contactPicker.CommitButtonText = "Select";
                contactPicker.SelectionMode    = Windows.ApplicationModel.Contacts.ContactSelectionMode.Contacts;


                ContactInformation contact = await contactPicker.PickSingleContactAsync();

                string strResult = "";

                if (contact != null)
                {
                    strResult += FormatJSONContact(contact, null) + ",";
                }

                PluginResult result = new PluginResult(PluginResult.Status.OK);
                result.Message = "[" + strResult.TrimEnd(',') + "]";
                DispatchCommandResult(result);
            }
        }