Пример #1
0
        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
            }
        }
Пример #2
0
        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();
            }
        }
Пример #3
0
 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)
     {
     }
 }
Пример #4
0
        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;
            }
        }
Пример #5
0
 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);
     }
 }
Пример #6
0
        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();
            }
        }
Пример #7
0
        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);
            }
        }
Пример #8
0
        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("&quot;", "'");
                Joke.Text = s;
            }
            else
            {
                MessageBox.Show(e.Message);
            }
        }
Пример #9
0
        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);
            }
        }
Пример #10
0
        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);
            }
        }
Пример #11
0
        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();
            }
        }
Пример #12
0
        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();
            }
        }
Пример #13
0
        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("&quot;", "'");
                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();
            }
        }
Пример #14
0
        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();
            }
        }
Пример #16
0
        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();
            }
        }
Пример #17
0
        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();
            }
        }
Пример #18
0
        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);
            }
        }
Пример #19
0
        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();
                }
            }
        }