private void SearchButton_Click(object sender, EventArgs e) { this.ResultsFlowLayoutPanel.Controls.Clear(); IHttpMessageConverter njsonConverter = new NJsonHttpMessageConverter(); njsonConverter.SupportedMediaTypes.Add(new MediaType("text", "javascript")); RestTemplate template = new RestTemplate(); template.MessageConverters.Add(njsonConverter); template.GetForObjectAsync <JToken>("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&q={query}", delegate(RestOperationCompletedEventArgs <JToken> r) { if (r.Error == null) { foreach (JToken jToken in r.Response.Value <JToken>("responseData").Value <JArray>("results")) { PictureBox pBox = new PictureBox(); pBox.ImageLocation = jToken.Value <string>("tbUrl"); pBox.Height = jToken.Value <int>("tbHeight"); pBox.Width = jToken.Value <int>("tbWidth"); ToolTip tt = new ToolTip(); tt.SetToolTip(pBox, jToken.Value <string>("visibleUrl")); this.ResultsFlowLayoutPanel.Controls.Add(pBox); } } }, this.SearchTextBox.Text); /* * template.GetForObjectAsync<GImagesResponse>("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&q={query}", * delegate(RestOperationCompletedEventArgs<GImagesResponse> r) * { * if (r.Error == null) * { * foreach (GImage gImage in r.Response.Data.Items) * { * PictureBox pBox = new PictureBox(); * pBox.ImageLocation = gImage.ThumbnailUrl; * pBox.Height = gImage.ThumbnailHeight; * pBox.Width = gImage.ThumbnailWidth; * * ToolTip tt = new ToolTip(); * tt.SetToolTip(pBox, gImage.SiteUrl); * * this.ResultsFlowLayoutPanel.Controls.Add(pBox); * } * } * }, this.SearchTextBox.Text); */ }
private void SearchButton_Click(object sender, EventArgs e) { this.ResultsFlowLayoutPanel.Controls.Clear(); IHttpMessageConverter njsonConverter = new NJsonHttpMessageConverter(); njsonConverter.SupportedMediaTypes.Add(new MediaType("text", "javascript")); RestTemplate template = new RestTemplate(); template.MessageConverters.Add(njsonConverter); template.GetForObjectAsync<JToken>("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&q={query}", delegate(RestOperationCompletedEventArgs<JToken> r) { if (r.Error == null) { foreach (JToken jToken in r.Response.Value<JToken>("responseData").Value<JArray>("results")) { PictureBox pBox = new PictureBox(); pBox.ImageLocation = jToken.Value<string>("tbUrl"); pBox.Height = jToken.Value<int>("tbHeight"); pBox.Width = jToken.Value<int>("tbWidth"); ToolTip tt = new ToolTip(); tt.SetToolTip(pBox, jToken.Value<string>("visibleUrl")); this.ResultsFlowLayoutPanel.Controls.Add(pBox); } } }, this.SearchTextBox.Text); /* template.GetForObjectAsync<GImagesResponse>("https://ajax.googleapis.com/ajax/services/search/images?v=1.0&rsz=8&q={query}", delegate(RestOperationCompletedEventArgs<GImagesResponse> r) { if (r.Error == null) { foreach (GImage gImage in r.Response.Data.Items) { PictureBox pBox = new PictureBox(); pBox.ImageLocation = gImage.ThumbnailUrl; pBox.Height = gImage.ThumbnailHeight; pBox.Width = gImage.ThumbnailWidth; ToolTip tt = new ToolTip(); tt.SetToolTip(pBox, gImage.SiteUrl); this.ResultsFlowLayoutPanel.Controls.Add(pBox); } } }, this.SearchTextBox.Text); */ }
public void SetUp() { converter = new NJsonHttpMessageConverter(); }