public static StreetAddress Duplicate(this StreetAddress address)
 {
     return(new StreetAddress
     {
         City = address.City.Duplicate(),
         Line1 = address.Line1.Duplicate(),
         Line2 = address.Line2.Duplicate(),
         State = address.State,
         Type = address.Type,
         ZipCode = address.ZipCode,
     });
 }
        public EditStreetAddressDialog(StreetAddress address)
        {
            InitializeComponent();
            cboStates.Properties.FillWithEnum <USState>();
            cboTypes.Properties.FillWithEnum <AddressType>();

            txtLine1.DataBindings.Add("Text", address, "Line1");
            txtLine2.DataBindings.Add("Text", address, "Line2");
            txtCity.DataBindings.Add("Text", address, "City");
            cboStates.DataBindings.Add("EditValue", address, "State");
            numZip.DataBindings.Add("Value", address, "ZipCode");
            cboTypes.DataBindings.Add("EditValue", address, "Type");
        }
Exemple #3
0
        public static void Import(List <Contact> data)
        {
            string    filepath = @"C:\Users\mallen\Dropbox\Paige\Programs\ContactManager\addressBook.xml";
            XDocument doc      = XDocument.Load(filepath);

            foreach (var entry in doc.Descendants("Entry"))
            {
                var contact = new Contact
                {
                    Addresses = new List <StreetAddress>(),
                    Dates     = new List <SpecialDate>(),
                    Emails    = new List <EmailAddress>(),
                    ID        = Arbiter.ID,
                    Name      = null,
                    Notes     = string.Empty,
                    Phones    = new List <PhoneNumber>(),
                };

                contact.Name = new ContactName {
                    First = entry.Element("FirstName").Value, Last = entry.Element("LastName").Value
                };
                contact.ID = Arbiter.ID;

                var addr    = entry.Element("Address");
                var address = new StreetAddress();
                address.City    = addr.Element("City").Value;
                address.Line1   = addr.Element("Line1").Value;
                address.Line2   = addr.Element("Line2").Value;
                address.State   = (USState)Enum.Parse(typeof(USState), addr.Element("State").Value);
                address.Type    = AddressType.Other;
                address.ZipCode = (int)addr.Element("Zip");
                contact.Addresses.Add(address);

                var phones = contact.Phones;
                phones.Add(ParsePhoneNumber(entry.Element("MainPhone")));
                foreach (var v in entry.Descendants("PhoneNumber"))
                {
                    phones.Add(ParsePhoneNumber(v));
                }

                phones.RemoveAll(p => p == null);
                data.Add(contact);
            }
        }
        private void lstAddresses_AddClick(object sender, EventArgs e)
        {
            var address = new StreetAddress
            {
                City    = "West Allis",
                Line1   = "1111 South Fake Street",
                Line2   = "",
                State   = USState.WI,
                Type    = AddressType.Other,
                ZipCode = 12345,
            };

            using (var dlg = new EditStreetAddressDialog(address))
            {
                dlg.Text = "Add Address";
                if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    addresses.Add(address);
                }
            }
        }