private async void Send(object sender, RoutedEventArgs e) { ContactPicker contactPicker = new ContactPicker(); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Email); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Address); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); Contact contact = await contactPicker.PickContactAsync(); var picker = new Windows.Storage.Pickers.FileOpenPicker(); picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail; picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary; picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".jpeg"); picker.FileTypeFilter.Add(".png"); Windows.Storage.StorageFile file = await picker.PickSingleFileAsync(); if (contact != null && file != null) { await ComposeEmail(contact, "hello", file); } }
private async void PickAContactButton_Click(object sender, RoutedEventArgs e) { ContactPicker contactPicker = new ContactPicker(); contactPicker.CommitButtonText = "SelectThis"; contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Email); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Address); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); Contact contact = await contactPicker.PickContactAsync(); if (contact != null) { //OutputFields.Visibility = Visibility.Visible; //OutputEmpty.Visibility = Visibility.Collapsed; txtblock_imePriimek.Text = contact.DisplayName; AppendContactFieldValues(OutputEmails, contact.Emails); AppendContactFieldValues(OutputPhoneNumbers, contact.Phones); AppendContactFieldValues(OutputAddresses, contact.Addresses); } else { //OutputEmpty.Visibility = Visibility.Visible; //OutputFields.Visibility = Visibility.Collapsed; } }
private async void ContactPickerBox_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) { if (args.ChosenSuggestion == null) { var picker = new ContactPicker(); picker.CommitButtonText = "Select"; picker.SelectionMode = ContactSelectionMode.Fields; picker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); var result = await picker.PickContactAsync(); if (result != null) { if (string.IsNullOrEmpty(ContactPickerBox.Text)) { ContactPickerBox.Text = result.Phones.First().Number; } else { ContactPickerBox.Text += "; " + result.Phones.First().Number; } ContactPickerBox.Focus(FocusState.Pointer); } } }
private async void pickContactsBt_Click(object sender, RoutedEventArgs e) { try { cp = new ContactPicker(); cp.SelectionMode = ContactSelectionMode.Fields; cp.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); var contact = await cp.PickContactAsync(); Country selectedCountry = ((WithdrawalViewModel)DataContext).SelectedCountry; bool validationResult; if (contact == null) { validationResult = Helper.ValidateContactInfo("", "", out ((WithdrawalViewModel)DataContext).contactNumberWellFormatted, ref selectedCountry, ref ((WithdrawalViewModel)DataContext).isToResetCountry, ref ((WithdrawalViewModel)DataContext).validateContactInfoAgain); ((WithdrawalViewModel)DataContext).SelectedCountry = selectedCountry; ((WithdrawalViewModel)DataContext).updateUserInterfaceBasedOnBasedOnValidationResult("", "", validationResult); } else { validationResult = Helper.ValidateContactInfo(contact.DisplayName, contact.Phones.FirstOrDefault().Number, out ((WithdrawalViewModel)DataContext).contactNumberWellFormatted, ref selectedCountry, ref ((WithdrawalViewModel)DataContext).isToResetCountry, ref ((WithdrawalViewModel)DataContext).validateContactInfoAgain); ((WithdrawalViewModel)DataContext).SelectedCountry = selectedCountry; ((WithdrawalViewModel)DataContext).updateUserInterfaceBasedOnBasedOnValidationResult(contact.DisplayName, contact.Phones.FirstOrDefault().Number, validationResult); contactNumberBackup = contact.Phones.FirstOrDefault().Number; ButtonOk.Focus(FocusState.Programmatic); } } catch (Exception) { } HelperWindows.LoseFocus(sender); }
private async void btnPickContact_Click(object sender, RoutedEventArgs e) { ContactPicker contactPicker = new ContactPicker(); // 指定需要选取的联系人的字段 contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Email); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); // 启动联系人选取器,以选择一个联系人 Contact contact = await contactPicker.PickContactAsync(); if (contact != null) { lblMsg.Text += string.Format("name:{0}", contact.Name); lblMsg.Text += Environment.NewLine; foreach (ContactEmail email in contact.Emails) { lblMsg.Text += string.Format("email kind:{0}, email address:{1}", email.Kind, email.Address); lblMsg.Text += Environment.NewLine; } foreach (ContactPhone phone in contact.Phones) { lblMsg.Text += string.Format("phone kind:{0}, phone number:{1}, phone description:{2}", phone.Kind, phone.Number, phone.Description); lblMsg.Text += Environment.NewLine; } } else { lblMsg.Text += "取消了"; lblMsg.Text += Environment.NewLine; } }
static async Task <Contact> PlatformPickContactAsync() { var contactPicker = new ContactPicker(); var contactSelected = await contactPicker.PickContactAsync(); return(ConvertContact(contactSelected)); }
private async void BtnShareMail_Click(object sender, RoutedEventArgs e) { if (txtNom.Text != "" || txtPrenom.Text != "") { string message = "Bonjour, " + txtNom.Text + " " + txtPrenom.Text + " vous informe de sa participation à GeoDrapeau et que son score est de " + lblScore.Text + " points. \nSi vous pensez faire mieux, venez relever le défi.\n\nL'équipe de GeoDrapeau vous remercie."; ContactPicker contactPicker = new ContactPicker(); Contact contact = await contactPicker.PickContactAsync(); ContactStore contactStore = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly); if (contact != null) { Contact real = await contactStore.GetContactAsync(contact.Id); EmailMessage emailMessage = new EmailMessage(); emailMessage.To.Add(new EmailRecipient(real.Emails.FirstOrDefault <Windows.ApplicationModel.Contacts.ContactEmail>().Address)); emailMessage.Subject = "GeoDrapeau Score" + ApplicationView.GetForCurrentView().Title.ToString().Trim(); emailMessage.Body = message; await EmailManager.ShowComposeNewEmailAsync(emailMessage); } } else { message(); } }
private async void ThirdContactPanel_OnTapped(object sender, TappedRoutedEventArgs e) { var localsettings = ApplicationData.Current.LocalSettings; var romaingsettings = ApplicationData.Current.RoamingSettings; var contactPicker2 = new ContactPicker(); // Ask the user to pick contact phone numbers. contactPicker2.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); var contacts2 = await contactPicker2.PickContactAsync(); if (!localsettings.Values.ContainsKey("ThirdContactName")) { localsettings.Values.Add("ThirdContactName", contacts2.DisplayName); localsettings.Values.Add("ThirdContactNumber", contacts2.YomiDisplayName); ThirdContactTextBlock.Text = contacts2.DisplayName; } else { localsettings.Values.Remove("ThirdContactName"); localsettings.Values.Remove("ThirdContactNumber"); localsettings.Values.Add("ThirdContactName", contacts2.DisplayName); localsettings.Values.Add("ThirdContactNumber", contacts2.YomiDisplayName); ThirdContactTextBlock.Text = contacts2.DisplayName; } }
private async Task<IList<Contact>> SelectContactsAsync( SelectContactInteraction selectContact ) { Contract.Requires( selectContact != null ); Contract.Ensures( Contract.Result<Task<IList<Contact>>>() != null ); var commitButtonText = selectContact.DefaultCommand?.Name; var dialog = new ContactPicker(); dialog.DesiredFieldsWithContactFieldType.AddRange( selectContact.DesiredFields ); #if WINDOWS_PHONE_APP TryIfImplemented( () => dialog.SelectionMode = selectContact.DesiredFields.Any() ? ContactSelectionMode.Fields : ContactSelectionMode.Contacts ); TryIfImplemented( () => { if ( !string.IsNullOrEmpty( commitButtonText ) ) dialog.CommitButtonText = commitButtonText; } ); #else dialog.SelectionMode = selectContact.DesiredFields.Any() ? ContactSelectionMode.Fields : ContactSelectionMode.Contacts; if ( !string.IsNullOrEmpty( commitButtonText ) ) dialog.CommitButtonText = commitButtonText; #endif if ( selectContact.Multiselect ) return await dialog.PickContactsAsync(); var contacts = new List<Contact>(); var contact = await dialog.PickContactAsync(); if ( contact != null ) contacts.Add( contact ); return contacts; }
private async void SendContactExecute() { var picker = new ContactPicker(); picker.SelectionMode = ContactSelectionMode.Fields; picker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); var picked = await picker.PickContactAsync(); if (picked != null) { Telegram.Td.Api.Contact contact = null; var annotationStore = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite); var store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite); if (store != null && annotationStore != null) { var full = await store.GetContactAsync(picked.Id); if (full != null) { var annotations = await annotationStore.FindAnnotationsForContactAsync(full); var first = annotations.FirstOrDefault(); if (first != null) { var remote = first.RemoteId; if (int.TryParse(remote.Substring(1), out int userId)) { var user = ProtoService.GetUser(userId); if (user != null) { contact = new Telegram.Td.Api.Contact(user.PhoneNumber, user.FirstName, user.LanguageCode, user.Id); } } } //contact = full; } } if (contact == null) { var phone = picked.Phones.FirstOrDefault(); if (phone == null) { return; } contact = new Telegram.Td.Api.Contact(phone.Number, picked.FirstName, picked.LastName, 0); } if (contact != null) { await SendContactAsync(contact); } } }
async void NewPerson(NewPersonMessage newPersonMessage) { var cp = new ContactPicker(); var ci = await cp.PickSingleContactAsync(); if (ci != null) { var model = new PersonOverViewModel() { Name = ci.Name }; Items.Add(model); var stream = await ci.GetThumbnailAsync(); if (stream.Size == 0) { stream = await GetCameraStream(); } if (stream.Size != 0) { await _storeImages.StorePersonImage(stream, model.Id); model.ImageId = model.Id; } } }
private async void SendContactExecute() { var picker = new ContactPicker(); picker.SelectionMode = ContactSelectionMode.Fields; picker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); var contact = await picker.PickContactAsync(); if (contact != null) { TLUser user = null; var annotationStore = await ContactManager.RequestAnnotationStoreAsync(ContactAnnotationStoreAccessType.AppAnnotationsReadWrite); var store = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AppContactsReadWrite); if (store != null && annotationStore != null) { var full = await store.GetContactAsync(contact.Id); if (full != null) { var annotations = await annotationStore.FindAnnotationsForContactAsync(full); var first = annotations.FirstOrDefault(); if (first != null) { var remote = first.RemoteId; if (int.TryParse(remote.Substring(1), out int userId)) { user = CacheService.GetUser(userId) as TLUser; } } //contact = full; } } if (user == null) { var phone = contact.Phones.FirstOrDefault(); if (phone == null) { return; } user = new TLUser(); user.FirstName = contact.FirstName; user.LastName = contact.LastName; user.Phone = phone.Number; } if (user != null) { await SendContactAsync(user); } } }
/// <summary> /// Handles the click event for the button that allows selection of a contact to be used for procotol activation. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private async void HandleProtocolActivationContactSelection(Object sender, RoutedEventArgs e) { var contactPicker = new ContactPicker(); _selectedContact = await contactPicker.PickContactAsync(); UpdateProtocolLauncherControls(); }
private async void btnPickContact_Click(object sender, RoutedEventArgs e) { ContactPicker contactPicker = new ContactPicker(); // 指定需要选取的联系人的字段 contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Email); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); // 启动联系人选取器,以选择一个联系人 Contact contact = await contactPicker.PickContactAsync(); if (contact != null) { lblMsg.Text += string.Format("name:{0}", contact.Name); lblMsg.Text += Environment.NewLine; lblMsg.Text += string.Format("id:{0}", contact.Id); lblMsg.Text += Environment.NewLine; foreach (ContactEmail email in contact.Emails) { lblMsg.Text += string.Format("email kind:{0}, email address:{1}", email.Kind, email.Address); lblMsg.Text += Environment.NewLine; } foreach (ContactPhone phone in contact.Phones) { lblMsg.Text += string.Format("phone kind:{0}, phone number:{1}, phone description:{2}", phone.Kind, phone.Number, phone.Description); lblMsg.Text += Environment.NewLine; } ContactStore contactStore = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly); // 通过 ContactStore 和联系人 id 可以获取到联系人的完整信息(需要配置 <Capability Name = "contacts" />) Contact realContact = await contactStore.GetContactAsync(contact.Id); // 通过 ContactStore 也是可以拿到全部联系人信息的,这部分知识点以后再写 // IReadOnlyList<Contact> contacts = await contactStore.FindContactsAsync(); // 显示联系人的图片(只通过 ContactPicker 是获取不到的) IRandomAccessStreamReference imageStreamRef = realContact.SmallDisplayPicture; if (imageStreamRef != null) { IRandomAccessStream imageStream = await imageStreamRef.OpenReadAsync(); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(imageStream); imgThumbnail.Source = bitmapImage; } } else { lblMsg.Text += "取消了"; lblMsg.Text += Environment.NewLine; } }
public async Task <IEnumerable <Contact> > PickContactsPhone() { ContactPicker contactPicker = new ContactPicker(); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); var contacts = await contactPicker.PickContactsAsync(); return(contacts); }
public async Task <Contact> PickContactEmail() { ContactPicker contactPicker = new ContactPicker(); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Email); var contact = await contactPicker.PickContactAsync(); return(contact); }
private async void btnContact_Click(object sender, RoutedEventArgs e) { Details = new List <ContactDetails>(); var p = new ContactPicker(); p.CommitButtonText = "Pick Contact"; var selectedContact = await p.PickSingleContactAsync(); Details.Add(new ContactDetails(selectedContact)); lstContact.ItemsSource = Details; }
private async void PickContactsPhone() { ClearOutputs(); var contactPicker = new ContactPicker(); // Ask the user to pick contact phone numbers. contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); var contacts = await contactPicker.PickContactsAsync(); ReportContactResults(contacts); }
private async void PickContactsEmail() { ClearOutputs(); var contactPicker = new ContactPicker(); // Ask the user to pick contact email addresses. contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Email); var contacts = await contactPicker.PickContactsAsync(); ReportContactResults(contacts); }
private async void PickContactEmail() { ClearOutputs(); // Ask the user to pick a contact email address. var contactPicker = new ContactPicker(); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Email); Contact contact = await contactPicker.PickContactAsync(); ReportContactResult(contact); }
private async void selectContact_Tapped(object sender, TappedRoutedEventArgs e) { var contactPicker = new ContactPicker(); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); contact = await contactPicker.PickContactAsync(); if (contact != null) { ClientName.Text = contact.DisplayName; PhoneNumber.Text = contact.Phones[0].Number; } }
public async void Load() { IsAvailable = await ContactPicker.IsSupportedAsync(); RaisePropertyChanged(nameof(IsAvailable)); if (!IsAvailable) { Status = "ContactPicker is not supported on this platform"; } else { Status = "ContactPicker is supported"; } }
private async void Button_Click(object sender, RoutedEventArgs e) { try { var contactPicker = new ContactPicker(); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); Contact contact = await contactPicker.PickContactAsync(); string sms = string.Format("I need your help, The coordinates of my location are:- " + "Latitude:{0} Longitude:{1}", MyMap.Center.Position.Latitude, MyMap.Center.Position.Longitude); ComposeSMS(contact, sms); } catch { } }
private async void HandleAddContactClick(Object sender, RoutedEventArgs e) { var contactPicker = new ContactPicker { SelectionMode = ContactSelectionMode.Contacts, //SelectionMode = ContactSelectionMode.Fields, //DesiredFieldsWithContactFieldType = {ContactFieldType.Email} }; var contacts = await contactPicker.PickContactsAsync(); foreach (var contact in contacts) { AppSampleData.Current.SampleData.AddContact(contact); } }
private async void ComposeEmail() { var contactPicker = new ContactPicker(); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Email); Contact recipent = await contactPicker.PickContactAsync(); if (recipent != null) { this.AppendContactFieldValues(recipent.Emails); } else { } }
private async void SendSMSButton_Tapped(object sender, TappedRoutedEventArgs e) { ContactPicker contactPicker = new ContactPicker(); Contact contact = await contactPicker.PickContactAsync(); // You need to add required capabilities in your App manifest file for access contact list. ContactStore contactStore = await ContactManager.RequestStoreAsync(ContactStoreAccessType.AllContactsReadOnly); if (contact != null) { // Get Selected Contact Contact realContact = await contactStore.GetContactAsync(contact.Id); SendSMS(realContact, "This is test SMS."); } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (ContactPicker.IsShowContactPickerIntent(requestCode)) { if (ShowContactPicker != null) { var args = new ActivityResultEventArgs { data = data, requestCode = requestCode, resultCode = resultCode }; ShowContactPicker(null, args); } } }
public void openContactSelection(ContactFieldType?fieldType, IPromise promise) { try { this.RunOnDispatcher(async() => { try { var contactPicker = new ContactPicker(); if (fieldType != null) { contactPicker.SelectionMode = ContactSelectionMode.Fields; contactPicker.DesiredFieldsWithContactFieldType.Add(fieldType.Value); } Contact contact = await contactPicker.PickContactAsync(); promise.Resolve(contact == null ? null : new { recordId = contact.Id, name = contact.Name, givenName = contact.FirstName, middleName = contact.MiddleName, familyName = contact.LastName, phones = contact.Phones?.Select(x => new { number = x.Number, type = x.Kind.ToString(), }), emails = contact.Emails?.Select(x => new { address = x.Address, type = x.Kind.ToString(), }), postalAddresses = contact.Addresses?.Select(x => new { street = x.StreetAddress, city = x.Locality, state = x.Region, postalCode = x.PostalCode, isoCountryCode = CountryHelper.TryGetTwoLetterISORegionName(x.Country), }), }); } catch (Exception ex) { promise.Reject(ex); } }); } catch (Exception ex) { promise.Reject(ex); } }
private async void MultiSelectContact_Tapped(object sender, TappedRoutedEventArgs e) { ContactPicker contactPicker = new ContactPicker(); contactPicker.CommitButtonText = "Select"; contactPicker.SelectionMode = ContactSelectionMode.Fields; contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.Email); IList <Contact> contacts = await contactPicker.PickContactsAsync(); if (contacts != null && contacts.Count > 0) { foreach (Contact contact in contacts) { System.Diagnostics.Debug.WriteLine(contact?.DisplayName + contact.Emails?[0]?.Address); } } }
public async Task <Contact> PromptUserForContactAsync() { // Open the prompt var contactPicker = new ContactPicker() { SelectionMode = ContactSelectionMode.Contacts }; Contact contact = await contactPicker.PickContactAsync(); if (contact != null) { // Fetch all the details ContactStore contactStore = await PromptForPermissionsAsync(); contact = await contactStore.GetContactAsync(contact.Id); } return(contact); }
private async void Button_Click(object sender, RoutedEventArgs e) { ContactPicker contactPicker = new ContactPicker(); contactPicker.DesiredFieldsWithContactFieldType.Add(ContactFieldType.PhoneNumber); var contacts = await contactPicker.PickContactsAsync(); if (contacts != null && contacts.Count > 0) { foreach (Contact contact in contacts) { recipientbox.Text += contact.Phones[0].Number + "; "; } var wors = recipientbox.Text.Split("; "); foreach (var wor in wors) { Debug.WriteLine(wor); } } }