Exemplo n.º 1
0
        //Searches for a movie with the given name, places it in the public Movie variable for access after its done.
        public async void GetMovieByName(string name)
        {
            string requestURL = makeRequestURL(name);

            try
            {
                string responseBody;

                updateStatus("Requesting movie...");
                HttpResponseMessage response = await client.GetAsync(requestURL);

                response.EnsureSuccessStatusCode();
                updateStatus("Parsing Retrieved Data...");
                responseBody = await response.Content.ReadAsStringAsync();

                responseBody = responseBody.Replace("<br>", Environment.NewLine);
                _movie       = parseMovieFromJSON(responseBody);
                updateStatus("Finished");
                if (RequestFinishedCallback != null)
                {
                    RequestFinishedCallback();
                }
            }
            catch (Exception)
            {
                updateStatus("Movie Request Failed");
                throw;
            }
        }
Exemplo n.º 2
0
 public ItemsPage()
 {
     stale        = true;
     controlDown  = false;
     webRequester = new WebRequester("http://twilio.nints.com:8885");
     mainSource   = new MovieDataSourceTest();
     foundItem    = null;
     webRequester.UpdateStatusAction      += UpdateStatus;
     webRequester.RequestFinishedCallback += ReqComplete;
     webRequester.AvailabilityCallback    += MovieAvaliablilityFunct;
     this.KeyUp   += ItemsPage_KeyUp;
     this.KeyDown += ItemsPage_KeyDown;
     this.InitializeComponent();
     Task.Run(() => CheckMovies());
 }
Exemplo n.º 3
0
        private void Add_Movie()
        {
            if (foundItem != null)
            {
                //TODO hide everything again...
                searchTitleScroll.Visibility  = Windows.UI.Xaml.Visibility.Collapsed;
                searchDetailScroll.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                searchResultImg.Visibility    = Windows.UI.Xaml.Visibility.Collapsed;
                addButton.Visibility          = Windows.UI.Xaml.Visibility.Collapsed;

                // add this to our watch list
                MovieDataSourceTest.AddItem(foundItem);
            }
            foundItem = null;
            searching = false;
        }
Exemplo n.º 4
0
        private void Search_Done(MovieDataItem newItem)
        {
            if (newItem != null)
            {
                searchTitleScroll.Visibility  = Windows.UI.Xaml.Visibility.Visible;
                searchDetailScroll.Visibility = Windows.UI.Xaml.Visibility.Visible;
                searchResultImg.Visibility    = Windows.UI.Xaml.Visibility.Visible;
                addButton.Visibility          = Windows.UI.Xaml.Visibility.Visible;


                searchResultDetail.Text = newItem.Description;
                searchResultTitle.Text  = newItem.Title;
                searchResultImg.Source  = newItem.Image;
                SearchBox.Text          = "";
                foundItem = newItem;
            }
        }
Exemplo n.º 5
0
        public async void CheckAvailablilityByName(string name)
        {
            string requestURL = makeRequestURL(name);

            try
            {
                string responseBody;

                HttpResponseMessage response = await client.GetAsync(requestURL);

                response.EnsureSuccessStatusCode();
                responseBody = await response.Content.ReadAsStringAsync();

                responseBody = responseBody.Replace("<br>", Environment.NewLine);
                MovieDataItem mov = parseMovieFromJSON(responseBody);
                if (AvailabilityCallback != null)
                {
                    AvailabilityCallback(name, mov.OnNetflix);
                }
            }
            catch (Exception)
            {
            }
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            var item = MovieDataSourceTest.GetItem((String)navigationParameter);

            this.pageItem             = item;
            this.pageTitle.Text       = pageItem.Title;
            this.itemImage.Source     = pageItem.Image;
            this.itemDescription.Text = pageItem.Description;
            //Notifier.GenerateToast("Detail Viewed");
            if (pageItem.OnNetflix)
            {
                this.watchOnNetflixButton.Visibility = Windows.UI.Xaml.Visibility.Visible;
                // Show the button.
            }

            //this.itemImage.

            if (pageState == null)
            {
                // When this is a new page, select the first item automatically unless logical page
                // navigation is being used (see the logical page navigation #region below.)
                if (!this.UsingLogicalPageNavigation() && this.itemsViewSource.View != null)
                {
                    this.itemsViewSource.View.MoveCurrentToFirst();
                }
            }
            else
            {
                // Restore the previously saved state associated with this page
                if (pageState.ContainsKey("SelectedItem") && this.itemsViewSource.View != null)
                {
                    var selectedItem = MovieDataSourceTest.GetItem((String)pageState["SelectedItem"]);
                    this.itemsViewSource.View.MoveCurrentTo(selectedItem);
                }
            }
        }