protected override void OnNavigatedTo(NavigationEventArgs e) { Monument_Detail_View m = new Monument_Detail_View(); Tag[] f = e.Parameter as Tag[]; foreach (Tag t in f) { if (t.Name != null || t.Name != "") { m = new Monument_Detail_View(); m.Title = t.Name; m.Image = null; m.Desc = null; } MList.Add(m); } DiaryView.DataContext = MList; }
protected async override void OnNavigatedTo(NavigationEventArgs e) { m = e.Parameter as Monument_Detail_View; string s = m.Title; // string s = "Qutb complex"; HttpClient cl = new HttpClient(); s = Uri.EscapeDataString(s); string url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=" + s + "&key=AIzaSyBMzL7mptHo33PNsuKmT9xKppNgkXotBOM"; // string url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=28.661904,77.2232688&radius=50000&type=point_of_interest&keyword=" + s + "&key=AIzaSyBMzL7mptHo33PNsuKmT9xKppNgkXotBOM"; string picUrl = "https://maps.googleapis.com/maps/api/place/photo?maxwidth=300&photoreference="; try { s = await cl.GetStringAsync(url); gp = JsonConvert.DeserializeObject <googlePlaceApi>(s); picUrl += gp.results[0].photos[0].photo_reference + "&key=AIzaSyBMzL7mptHo33PNsuKmT9xKppNgkXotBOM"; var stream = await cl.GetStreamAsync(picUrl); BitmapImage Image = new BitmapImage(); using (var memStream = new MemoryStream()) { await stream.CopyToAsync(memStream); memStream.Position = 0; Image.SetSource(memStream.AsRandomAccessStream()); } img.Source = Image; name.Text = gp.results[0].name; //desc.Text = gp.results[0].vicinity; // parse the string in json and get the details } catch (Exception ex) { } }
private async void Web_DOMContentLoaded(WebView sender, WebViewDOMContentLoadedEventArgs args) { Monument_Detail_View m = new Monument_Detail_View(); m.MyLat = pos.Coordinate.Latitude; m.MyLon = pos.Coordinate.Longitude; bool con = false; s = await web.InvokeScriptAsync("eval", new string[] { "document.documentElement.outerHTML;" }); try { int i = s.IndexOf("<a class=\"_gUb"); int j = s.IndexOf(">", i); i = s.IndexOf("<", j); s = s.Substring(j + 1, i - j - 1); s = Check_File(s); if (s != null) { con = true; } //load file and get exact name and put it in s } catch { } //if match found if (con) { m.Title = s; button.IsEnabled = true; button2.IsEnabled = true; PB.Visibility = Visibility.Collapsed; Frame.Navigate(typeof(monument_Detail), m); } else { VisionServiceClient cl = new VisionServiceClient("db82ef68dc95459fad7b46d7a50bb944"); VisualFeature[] vf = new VisualFeature[] { VisualFeature.Tags, VisualFeature.Categories }; AnalysisResult ar = await cl.AnalyzeImageAsync(blobUrl, vf); Tag[] f = ar.Tags; Category[] c = ar.Categories; int i = 0; bool tex = false; foreach (Tag t in f) { if (t.Name.Contains("text")) { tex = true; break; } } foreach (Category ct in c) { if (ct.Name.Contains("text")) { tex = true; break; } } if (tex) { try { string text = ""; cl = new VisionServiceClient("db82ef68dc95459fad7b46d7a50bb944"); OcrResults ocr = await cl.RecognizeTextAsync(blobUrl); foreach (Region r in ocr.Regions) { foreach (Line l in r.Lines) { foreach (Word w in l.Words) { text = text + " " + w.Text; } } } button.IsEnabled = true; button2.IsEnabled = true; PB.Visibility = Visibility.Collapsed; Frame.Navigate(typeof(Ocr_Detail), text); } catch (Exception ex) { } } else { button.IsEnabled = true; button2.IsEnabled = true; PB.Visibility = Visibility.Collapsed; Frame.Navigate(typeof(Activity_Detail), f); } } }
private void DiaryView_ItemClick(object sender, ItemClickEventArgs e) { Monument_Detail_View m = e.ClickedItem as Monument_Detail_View; Frame.Navigate(typeof(Store), m.Title); }