Esempio n. 1
0
        private void TestContactFunctions()
        {
            // Test contacts functions..
            // Add a John iCloudSeed contact, edit all existing John iCloudSeeds, then delete them all.

            // Add a contact.
            iCloud.iCloudContactsContact newContact = new iCloud.iCloudContactsContact();
            newContact.FirstName = "John";
            newContact.LastName  = "iCloudSeed";
            Client.SetContact(newContact);

            // Edit contacts
            iCloud.iCloudContactsContact[] edittedContacts = Client.Contacts.Where(x => x.FirstName == "John" && x.LastName == "iCloudSeed").ToArray();
            foreach (iCloud.iCloudContactsContact editContact in edittedContacts)
            {
                editContact.MiddleName = "TestEdit";
            }
            Client.SetContacts(edittedContacts);

            // Remove contacts
            if (edittedContacts.Length > 0)
            {
                Client.DeleteContacts(edittedContacts);
            }
        }
Esempio n. 2
0
        private void listContacts_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Make sure we have a contact selected
            if (listContacts.SelectedItems.Count == 0)
            {
                return;
            }

            // Obtain our contact
            iCloud.iCloudContactsContact contact = (iCloud.iCloudContactsContact)listContacts.SelectedItems[0].Tag;

            // Format our dates section text
            string strDates = "";

            if (contact.Dates != null)
            {
                foreach (iCloud.iCloudContactsStringEntry entry in contact.Dates)
                {
                    strDates += string.Format("{0}: {1}\r\n", entry.Label.ToUpper(), entry.Field);
                }
            }
            strDates = strDates.Trim();

            // Format our phones section text
            string strPhones = "";

            if (contact.Phones != null)
            {
                foreach (iCloud.iCloudContactsStringEntry entry in contact.Phones)
                {
                    strPhones += string.Format("{0}: {1}\r\n", entry.Label.ToUpper(), entry.Field);
                }
            }
            strPhones = strPhones.Trim();

            // Format our addresses section text
            string strAddresses = "";

            if (contact.StreetAddresses != null)
            {
                foreach (iCloud.iCloudContactsContact.iCloudContactsContactAddress address in contact.StreetAddresses)
                {
                    strAddresses += string.Format(
                        @"Label: {0}
Street: {1}
City: {2}
Province/State: {3}
Country: {4}
Postal Code: {5}

",
                        address.Label.ToUpper(),
                        address.Field.Street,
                        address.Field.City,
                        address.Field.State,
                        address.Field.Country,
                        address.Field.PostalCode
                        );
                }
            }
            strAddresses = strAddresses.Trim();

            // Format our related names section text
            string strRelated = "";

            if (contact.RelatedNames != null)
            {
                foreach (iCloud.iCloudContactsStringEntry entry in contact.RelatedNames)
                {
                    strRelated += string.Format("{0}: {1}\r\n", entry.Label.ToUpper(), entry.Field);
                }
            }
            strRelated = strRelated.Trim();

            txtContactInfo.Text = string.Format(@"ALIASES
========
First Name: {0}
Middle Name: {1}
Last Name: {2}
Nick Name: {3}
Phonetix First Name: {4}
Phonetic Last Name: {5}

PHONES
======
{6}

WORK
=====
Company: {7}
Department: {8}
Job Title: {9}

ADDRESSES
=========
{10}

DATES
=====
Birthday: {11}
{12}

RELATED
=======
{13}

NOTES
=====
{14}
",
                                                contact.FirstName,
                                                contact.MiddleName,
                                                contact.LastName,
                                                contact.NickName,
                                                contact.PhoneticFirstName,
                                                contact.PhoneticLastName,
                                                strPhones,
                                                contact.CompanyName,
                                                contact.Department,
                                                contact.JobTitle,
                                                strAddresses,
                                                contact.Birthday,
                                                strDates,
                                                strRelated,
                                                contact.Notes
                                                );
        }