async void apiInvokeReviews_OnResponse(object sender, APIMASHEvent e) { var cc = (ReviewControl)ReviewPopup.Child; var response = (MovieReviews)e.Object; if ((e.Status == APIMASHStatus.SUCCESS) && (response.Reviews.Length > 0)) { var mg = new MovieReviewGroup(); mg.Copy(response); cc.MovieReviews = mg; cc.Initialize(); ReviewPopup.IsOpen = true; } else { if (response.Reviews.Length <= 0) { e.Message = "There are no previews"; } var md = new MessageDialog(e.Message, "Error"); bool?result = null; md.Commands.Add(new UICommand("Ok", new UICommandInvokedHandler((cmd) => result = true))); await md.ShowAsync(); // issue here intermitment } }
async private void _apiInvokeModelSpecs_OnResponse(object sender, APIMASHEvent e) { var response = (ModelSpecCollection)e.Object; if (e.Status == APIMASHStatus.SUCCESS) { if (response.ModelSpecs != null) { if (response.ModelSpecs.Length > 0) { if (response.ModelSpecs[0].Styles != null) { if (response.ModelSpecs[0].Styles.Length > 0) { InvokePhotoById(response.ModelSpecs[0].Styles[0].Id); } } } else { // this vehicle did not return spec data so display image place holders DisplayPlaceholderImages(); } } } else { // this vehicle did not return spec data so display image place holders DisplayPlaceholderImages(); } }
void apiInvoke_OnResponse(object sender, APIMASHEvent e) { try { if (e.Object is ArtistRootobject) { apiInvoke_OnArtistResponse(sender, e); } else if (e.Object is ImagesRootobject) { apiInvoke_OnImagesResponse(sender, e); } else if (e.Object is NewsRootobject) { apiInvoke_OnNewsResponse(sender, e); } else if (e.Object is SongsRootobject) { apiInvoke_OnArtistSongsResponse(sender, e); } } catch (Exception ex) { } }
void api_OnResponse(object sender, APIMASHEvent e) { StackExchangeQuestions response = (StackExchangeQuestions)e.Object; if (e.Status == APIMASHStatus.SUCCESS) { // copy data into bindable format for UI APIMASH_StackExchangeCollection.Copy(response, System.Guid.NewGuid().ToString(), "All"); Items = APIMASH_StackExchangeCollection.GetGroups("AllGroups").FirstOrDefault().Items; } }
async private void apiInvoke_OnArtistSongsResponse(object sender, APIMASHEvent e) { if (e.Status == APIMASHStatus.SUCCESS) { var songs = (SongsRootobject)e.Object; Copy(songs.response.songs); } else { throw new Exception(e.Message); } }
async void _apiInvokePhotoByStyleId_OnResponse(object sender, APIMASHEvent e) { var response = (PhotoCollection)e.Object; const int maxImages = 9; var images = new ImageSource[maxImages]; if (e.Status == APIMASHStatus.SUCCESS) { App.PhotoViewModel.Copy(response); if (App.PhotoViewModel.PhotoCollection[0].Pictures.Count > 0) { var maxPictures = App.PhotoViewModel.PhotoCollection.Count; var totalImages = 0; totalImages = maxPictures < maxImages ? maxPictures : maxImages; for (var i = 0; i < maxImages; i++) { images[i] = new BitmapImage(new Uri("ms-appx:///Assets/Car.png")); } for (var i = 0; i < totalImages; i++) { images[i] = new BitmapImage(new Uri(App.PhotoViewModel.PhotoCollection[i].Pictures[0])); } ErrMessage.Visibility = Visibility.Collapsed; VehicleImage1.Source = images[0]; VehicleImage2.Source = images[1]; VehicleImage3.Source = images[2]; VehicleImage4.Source = images[3]; VehicleImage5.Source = images[4]; VehicleImage6.Source = images[5]; VehicleImage7.Source = images[6]; VehicleImage8.Source = images[7]; VehicleImage9.Source = images[8]; } else { // no imnages DisplayErrMessge(); } } else { // no images DisplayErrMessge(); } }
void apiInvokeYearMakeModel_OnResponse(object sender, APIMASHEvent e) { var response = (MakeCollection)e.Object; if (e.Status == APIMASHStatus.SUCCESS) { App.MakeModelViewModel.Copy(response); App.MakeModelViewModel.IsDataLoaded = true; } else { MessageBox.Show(e.Message); } }
async private void apiInvoke_OnResponse(object sender, APIMASHEvent e) { var response = (CNorrisJoke)e.Object; if (e.Status == APIMASHStatus.SUCCESS) { var s = response.Value.Joke; s = s.Replace(""", "'"); Joke.Text = s; } else { MessageBox.Show(e.Message); } }
async private void apiInvoke_OnNewsResponse(object sender, APIMASHEvent e) { if (e.Status == APIMASHStatus.SUCCESS) { var images = (NewsRootobject)e.Object; Copy(images.response.news); var songrequest = @"http://developer.echonest.com/api/v4/song/search?api_key=" + APIKEY + @"&format=json&results=50&start=0&bucket=id:7digital-US&bucket=audio_summary&bucket=tracks&artist=" + this.Artist.Name; apiInvoke.Invoke <SongsRootobject>(songrequest); } else { throw new Exception(e.Message); } }
async private void apiInvoke_OnImagesResponse(object sender, APIMASHEvent e) { if (e.Status == APIMASHStatus.SUCCESS) { var images = (ImagesRootobject)e.Object; Copy(images.response.images); var newsrequest = @"http://developer.echonest.com/api/v4/artist/news?api_key=" + APIKEY + @"&format=json&results=10&start=0&id=" + this.Artist.Id; apiInvoke.Invoke <NewsRootobject>(newsrequest); } else { throw new Exception(e.Message); } }
async void _apiInvokePhotoByStyleId_OnResponse(object sender, APIMASHEvent e) { var response = (PhotoCollection)e.Object; const int maxImages = 9; var images = new ImageSource[maxImages]; if (e.Status == APIMASHStatus.SUCCESS) { APIMASH_EdmundsPhotoCollection.Copy(response); if (APIMASH_EdmundsPhotoCollection.Photos.All[0].Pictures.Count > 0) { var maxPictures = APIMASH_EdmundsPhotoCollection.Photos.All.Count; var totalImages = 0; totalImages = maxPictures < maxImages ? maxPictures : maxImages; for (var i = 0; i < maxImages; i++) { images[i] = new BitmapImage(new Uri("ms-appx:///Assets/Car.png")); } for (var i = 0; i < totalImages; i++) { images[i] = new BitmapImage(new Uri(APIMASH_EdmundsPhotoCollection.Photos.All[i].Pictures[0])); } VehicleImage1.Source = images[0]; VehicleImage2.Source = images[1]; VehicleImage3.Source = images[2]; VehicleImage4.Source = images[3]; VehicleImage5.Source = images[4]; VehicleImage6.Source = images[5]; VehicleImage7.Source = images[6]; VehicleImage8.Source = images[7]; VehicleImage9.Source = images[8]; } else { DisplayPlaceholderImages(); } } else { DisplayPlaceholderImages(); } }
async private void apiInvoke_OnResponse(object sender, APIMASHEvent e) { StackExchangeQuestions response = (StackExchangeQuestions)e.Object; if (e.Status == APIMASHStatus.SUCCESS) { // copy data into bindable format for UI APIMASH_StackExchangeCollection.Copy(response, System.Guid.NewGuid().ToString(), "All"); this.DefaultViewModel["AllGroups"] = APIMASH_StackExchangeCollection.GetGroups("AllGroups"); _loaded = true; } else { var md = new MessageDialog(e.Message, "Error"); md.Commands.Add(new UICommand("Ok", new UICommandInvokedHandler((cmd) => { }))); await md.ShowAsync(); } }
async private void apiInvoke_OnResponse(object sender, APIMASHEvent e) { var response = (CNorrisJoke)e.Object; if (e.Status == APIMASHStatus.SUCCESS) { var s = response.Value.Joke; s = s.Replace(""", "'"); Joke.Text = s; } else { var md = new MessageDialog(e.Message, "Error"); bool?result = null; md.Commands.Add(new UICommand("Ok", new UICommandInvokedHandler((cmd) => result = true))); await md.ShowAsync(); } }
async private void apiInvoke_OnResponse(object sender, APIMASHEvent e) { Progress.IsActive = false; Yelp_Response response = (Yelp_Response)e.Object; if ((e.Status == APIMASHStatus.SUCCESS) && (response.businesses.Length > 0)) { var bg = new BusinessGroup(); bg.Copy(response.businesses); BusinessGridView.ItemsSource = bg.Items; } else { MessageDialog md = new MessageDialog(e.Message, "Error"); bool? result = null; md.Commands.Add(new UICommand("Ok", new UICommandInvokedHandler((cmd) => result = true))); await md.ShowAsync(); } }
async private void apiInvoke_OnResponseInTheaters(object sender, APIMASHEvent e) { var response = (RottenTomatoesMovies)e.Object; if (e.Status == APIMASHStatus.SUCCESS) { // copy data into bindable format for UI APIMASH_RottenTomatoesCollection.Copy(response, System.Guid.NewGuid().ToString(), "In Theaters"); //APIMASH_RottenTomatoesCollection.Copy(response, System.Guid.NewGuid().ToString(), "DVD Top Rentals"); this.DefaultViewModel["AllGroups"] = APIMASH_RottenTomatoesCollection.GetGroups("AllGroups"); _loaded = true; } else { var md = new MessageDialog(e.Message, "Error"); bool?result = null; md.Commands.Add(new UICommand("Ok", new UICommandInvokedHandler((cmd) => result = true))); await md.ShowAsync(); } }
async void apiInvokeYearMakeModel_OnResponse(object sender, APIMASHEvent e) { var response = (MakeCollection)e.Object; if (e.Status == APIMASHStatus.SUCCESS) { APIMASH_EdmundsCarCollection.Copy(response); this.DefaultViewModel["Makes"] = APIMASH_EdmundsCarCollection.AllMakes(); MakeCombo.ItemsSource = APIMASH_EdmundsCarCollection.AllMakes(); MakeCombo.SelectedIndex = 1; ModelList.ItemsSource = APIMASH_EdmundsCarCollection.Cars.All[1].Models; ModelList.SelectedIndex = 0; } else { var md = new MessageDialog(e.Message, "Error"); var result = true; md.Commands.Add(new UICommand("Ok", new UICommandInvokedHandler((cmd) => result = true))); await md.ShowAsync(); } }
async void apiInvokePreviews_OnResponse(object sender, APIMASHEvent e) { var cc = (PreviewControl)PreviewPopup.Child; var response = (MoviePreviews)e.Object; if ((e.Status == APIMASHStatus.SUCCESS) && (response.Clips != null)) { PreviewPopup.IsOpen = true; cc.Navigate(response.Clips[0].Links.Alternate); } else { if (response.Clips == null) { e.Message = "There are no previews"; } var md = new MessageDialog(e.Message, "Error"); bool?result = null; md.Commands.Add(new UICommand("Ok", new UICommandInvokedHandler((cmd) => result = true))); await md.ShowAsync(); } }
async private void apiInvoke_OnArtistResponse(object sender, APIMASHEvent e) { if (e.Status == APIMASHStatus.SUCCESS) { var artist = (ArtistRootobject)e.Object; if (artist.response.artists != null && artist.response.artists.Count() > 0) { Copy(artist.response.artists.First()); } else { throw new Exception("This artist was not found."); } var imagerequest = @"http://developer.echonest.com/api/v4/artist/images?api_key=" + APIKEY + @"&format=json&results=15&start=0&id=" + artist.response.artists.First().id; apiInvoke.Invoke <ImagesRootobject>(imagerequest); } else { throw new Exception(e.Message); } }
async private void _apiInvokeModelSpecs_OnResponse(object sender, APIMASHEvent e) { var response = (ModelSpecCollection)e.Object; if (e.Status == APIMASHStatus.SUCCESS) { if (response.ModelSpecs != null) { if (response.ModelSpecs.Length > 0) { if (response.ModelSpecs[0].Styles != null) { if (response.ModelSpecs[0].Styles.Length > 0) { InvokePhotoById(response.ModelSpecs[0].Styles[0].Id); } } } // no model spec DisplayErrMessge(); } } }