/// <summary> /// Method called when the page is displayed, fetches and display contact information and create actions. /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); while (actions.Children.Count > 0) { actions.Children.RemoveAt(0); } contact = ContactManager.Instance.TempContact; contactName.Text = contact.DisplayName; Stream imgStream = contact.GetPicture(); if (imgStream != null) { Image contactPicture = new Image(); contactPicture.Width = 150; contactPicture.Height = 150; contactPicture.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; contactPicture.Source = PictureDecoder.DecodeJpeg(imgStream); contactPicture.Margin = new Thickness(0, 0, 0, 15); actions.Children.Add(contactPicture); } foreach (ContactPhoneNumber phone in contact.PhoneNumbers) { ContactAction entry = new ContactAction(); entry.Action = "/Assets/AppBar/feature.phone.png"; entry.Action2 = "/Assets/AppBar/chat.png"; entry.Label = phone.Kind.ToString(); entry.NumberOrAddress = phone.PhoneNumber; entry.Click += action_Click_1; entry.Click2 += action_Click_2; actions.Children.Add(entry); } foreach (ContactEmailAddress email in contact.EmailAddresses) { ContactAction entry = new ContactAction(); entry.Action = "/Assets/AppBar/feature.phone.png"; entry.Action2 = "/Assets/AppBar/chat.png"; entry.Label = email.Kind.ToString(); entry.NumberOrAddress = email.EmailAddress; entry.Click += action_Click_1; entry.Click2 += action_Click_2; actions.Children.Add(entry); } }
/// <summary> /// Method called when the page is displayed, fetches and display contact information and create actions. /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); while (actions.Children.Count > 0) { actions.Children.RemoveAt(0); } contact = ContactManager.Instance.TempContact; contactName.Text = contact.DisplayName; Stream imgStream = contact.GetPicture(); if (imgStream != null) { Image contactPicture = new Image(); contactPicture.Width = 150; contactPicture.Height = 150; contactPicture.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; contactPicture.Source = PictureDecoder.DecodeJpeg(imgStream); contactPicture.Margin = new Thickness(0,0,0,15); actions.Children.Add(contactPicture); } foreach (ContactPhoneNumber phone in contact.PhoneNumbers) { ContactAction entry = new ContactAction(); entry.Action = "/Assets/AppBar/feature.phone.png"; entry.Action2 = "/Assets/AppBar/chat.png"; entry.Label = phone.Kind.ToString(); entry.NumberOrAddress = phone.PhoneNumber; entry.Click += action_Click_1; entry.Click2 += action_Click_2; actions.Children.Add(entry); } foreach (ContactEmailAddress email in contact.EmailAddresses) { ContactAction entry = new ContactAction(); entry.Action = "/Assets/AppBar/feature.phone.png"; entry.Action2 = "/Assets/AppBar/chat.png"; entry.Label = email.Kind.ToString(); entry.NumberOrAddress = email.EmailAddress; entry.Click += action_Click_1; entry.Click2 += action_Click_2; actions.Children.Add(entry); } }
private void AddressbookContactSelected(object sender, SelectionChangedEventArgs e) { if ((sender as LongListSelector).SelectedItem == null) { return; } var contactsList = sender as LongListSelector; Contact selectedContact = contactsList.SelectedItem as Contact; if (AddressbookUserSelected != null) { AddressbookUserSelected(sender, selectedContact); } (sender as LongListSelector).SelectedItem = null; }
private static Contact GetContact(Microsoft.Phone.UserData.Contact contact) { Contact c = new Contact(contact); c.DisplayName = contact.DisplayName; if (contact.CompleteName != null) { c.Prefix = contact.CompleteName.Title; c.FirstName = contact.CompleteName.FirstName; c.MiddleName = contact.CompleteName.MiddleName; c.LastName = contact.CompleteName.LastName; c.Suffix = contact.CompleteName.Suffix; } foreach (ContactAddress address in contact.Addresses) { c.addresses.Add(GetAddress(address)); } foreach (ContactEmailAddress email in contact.EmailAddresses) { c.emails.Add(GetEmail(email)); } foreach (ContactPhoneNumber phone in contact.PhoneNumbers) { c.phones.Add(GetPhone(phone)); } foreach (ContactCompanyInformation company in contact.Companies) { c.organizations.Add(GetOrganization(company)); } foreach (string name in contact.Children) { c.relationships.Add(new Relationship { Name = name, Type = RelationshipType.Child }); } foreach (string name in contact.SignificantOthers) { c.relationships.Add(new Relationship { Name = name, Type = RelationshipType.SignificantOther }); } foreach (string url in contact.Websites) { c.websites.Add(new Website { Address = url }); } foreach (string note in contact.Notes) { c.notes.Add(new Note { Contents = note }); } return(c); }