/// <summary> /// Get an image from Google's Maps API /// </summary> /// <param name="address"></param> /// <param name="city"></param> /// <param name="state"></param> /// <returns></returns> public static Image GetImage(String address, String city, US_State state) { String fullAddress = String.Format("{0}, {1}, {2}", address, city, state.Abbreviation); String requestUri = String.Format("http://maps.googleapis.com/maps/api/staticmap?center={0}&zoom=17&size=400x400&sensor=false", Uri.EscapeDataString(fullAddress)); WebRequest request = WebRequest.Create(requestUri); return Image.FromStream(request.GetResponse().GetResponseStream()); }
/// <summary> /// Updates contact data. /// </summary> /// <param name="lastName"></param> /// <param name="firstName"></param> /// <param name="middleInitial"></param> /// <param name="address"></param> /// <param name="addressExt"></param> /// <param name="city"></param> /// <param name="state"></param> /// <param name="postalCode"></param> /// <param name="phonePrimary"></param> /// <param name="phoneAlternate"></param> /// <param name="birthday"></param> /// <param name="portrait"></param> /// <param name="resultString"></param> /// <returns>true if data is properly formatted, false otherwise</returns> public void Save(String lastName, String firstName, String middleInitial, String address, String addressExt, String city, US_State state, String postalCode, String phonePrimary, String phoneAlternate, DateTime birthday, String email) { /* Save non-validated fields */ _lastName = lastName.Trim(); _firstName = firstName.Trim(); _middleInitial = middleInitial.Trim().ToUpper(); _address = address.Trim(); _addressExt = addressExt.Trim(); _city = city.Trim(); _state = state; _birthday = birthday; /* Save validated fields */ _phonePrimary = GetPhoneNumberIfValid(phonePrimary); _phoneAlternate = GetPhoneNumberIfValid(phoneAlternate); _postalCode = GetPostalCodeIfValid(postalCode); _email = GetEmailAddressIfValid(email); /* Update address map */ if (_address != String.Empty && _city != String.Empty && _state != null) { _mapImage = MapAddress.GetImage(_address, _city, _state); } }