Example #1
0
        private void LoadvCard(string p)
        {
            ClearForm();

            try
            {
                vCard vcard = vCard.LoadFromFile(p);

                this.firstNameTextbox.Text = vcard.Name.GivenName;
                this.lastNameTextbox.Text  = vcard.Name.FamilyName;
                if (vcard.Organization.Count > 0)
                {
                    this.companyTextbox.Text = vcard.Organization[0].ToString();
                }
                foreach (TelephoneNumber telephoneNumber in vcard.TelephoneNumbers)
                {
                    if (telephoneNumber.IsWork)
                    {
                        this.officePhoneTextbox.Text = telephoneNumber.Number;
                    }
                    else if (telephoneNumber.IsHome)
                    {
                        this.homePhoneTextbox.Text = telephoneNumber.Number;
                    }
                    else if (telephoneNumber.IsCellular)
                    {
                        this.mobilePhoneTextbox.Text = telephoneNumber.Number;
                    }
                }
                if (vcard.EmailAddresses.Count > 0)
                {
                    this.emailTextbox.Text = vcard.EmailAddresses[0].Address;
                }
                this.birthdayDatePicker.Value = vcard.Birthday;

                if (vcard.Photo != null)
                {
                    MemoryStream stream = new MemoryStream(vcard.Photo);
                    this.photoPictureBox.Image = Image.FromStream(stream);
                }

                this.rawDataTextbox.Text = vcard.GetData();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while loading the vCard. Please ensure this is a compatible format.");
            }
            finally
            {
                ClearForm();
            }
        }