public async Task alias() { showProcessRing(); if (Type.SelectedIndex.Equals(0)) { type1 = "Food"; } else if (Type.SelectedIndex.Equals(1)) { type1 = "Clothing"; } if (AreaName.IsEnabled == true) { string page = "http://maps.google.com/maps/api/geocode/xml?address=" + AreaName.Text + "&sensor=false"; // ... Use HttpClient. using (HttpClient client = new HttpClient()) using (HttpResponseMessage response = await client.GetAsync(page)) using (HttpContent content = response.Content) { // ... Read the string. string result = await content.ReadAsStringAsync(); // ... Display the result. if (result != null) { Util.debugLog(result + "..."); Util.debugLog(result.IndexOf("location").ToString()); int start = result.IndexOf("location") + 19; int end = result.IndexOf("location") + 28; string x = ""; for (int s = start; s <= end; s++) { x = x + result[s]; } areaLatitude = x; start = result.IndexOf("location") + 45; end = result.IndexOf("location") + 54; x = ""; for (int s = start; s <= end; s++) { x = x + result[s]; } areaLongitude = x; } } } else { Geolocator geolocator = new Geolocator(); geolocator.DesiredAccuracyInMeters = 50; try { Geoposition geoposition = await geolocator.GetGeopositionAsync( maximumAge: TimeSpan.FromMinutes(5), timeout: TimeSpan.FromSeconds(10) ); areaLatitude = geoposition.Coordinate.Point.Position.Latitude.ToString("0.00"); areaLongitude = geoposition.Coordinate.Point.Position.Longitude.ToString("0.00"); } catch (Exception ex) { if ((uint)ex.HResult == 0x80004004) { // the application does not have the right capability or the location master switch is off // Util.displayMessage("", "Location is disabled in phone settings"); Util.debugLog("Location is disabled in phone settings"); } else { // Util.displayMessage("", "Something else happened acquring the location"); Util.debugLog("Couldn't get location"); } } } landMark = LandMarkName.Text.ToString(); title1 = TitleTextBox.Text.ToString(); message = MsgTextBox.Text.ToString(); // Util.debugLog(str, "Maddy"); items item = new items { description = message, emailid = Constants.EMAIL_ID, image = str , latitude = areaLatitude, longitude = areaLongitude, landmark = landMark, type = type1, title = title1 }; try { await App.MobileService.GetTable<items>().InsertAsync(item); Frame.Navigate(typeof(HomePage)); hideProcessRing(); } catch (Exception ex) { Util.debugLog(ex.ToString()); hideProcessRing(); } }
private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { List<string> list_string = new List<string>(); list_string = (List<string>)e.NavigationParameter; Util.debugLog(list_string[0], list_string[1]); if (list_string[1].Equals("All")) { item = DataSource.GetBean_All(Convert.ToInt32(list_string[0])); } else { item = DataSource.GetBean_Location(Convert.ToInt32(list_string[0])); } title1 = item.title; Title.Text = item.title; Type.Text = item.type; Status.Text = item.status; Landmark.Text = item.landmark; Description.Text = item.description; Util.debugLog("Testing"); Util.debugLog(item.image.Length.ToString()); if (!item.image.Equals("")) { Util.debugLog("Testing into description !!!"); Util.debugLog(item.image.Length.ToString()); ///PostDetailsImage.Source = new BitmapImage(new Uri(item.image)); byte[] byteBuffer = Convert.FromBase64String(item.image); // PostDetailsImage.Source = byteArrayToImage(byteBuffer); byteArrayToImage(byteBuffer); } latitude = item.latitude; longitude = item.longitude; }