コード例 #1
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            Movie movie = PhoneApplicationService.Current.State["Movie"] as Movie;

            if (this.progress == null)
            {
                this.progress = new Phone.Controls.ProgressIndicator();
            }

            if (!isNetworkAvailable)
            {
                MessageBox.Show("Network is not available!");
                NavigationService.Navigate(new Uri("/MainPage/", UriKind.Relative));
            }

            Dictionary<string, List<Movie>> MoviesDict = PhoneApplicationService.Current.State["MoviesDict"] as Dictionary<string, List<Movie>>;
            string Type = PhoneApplicationService.Current.State["Type"] as string;

            bool MovieCached = false;

            foreach (var MovieItem in MoviesDict[Type])
            {
                if (MovieItem.RottenTomatoesId == movie.RottenTomatoesId && movie.IndvidualMovieDataDownloaded)
                {
                    DisplayMovieDetails(MovieItem);
                    MovieCached = true;
                    break;
                }
            }

            if (!MovieCached)
            {

                var url = String.Format(APIEndpoints.MOVIE_INDIVIDUAL_INFORMATION, movie.RottenTomatoesId);
                Uri uri = new Uri(url, UriKind.Absolute);

                WebClient client = new WebClient();
                client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_OpenReadCompleted);
                client.DownloadStringAsync(uri);
               
                //System.Diagnostics.Debug.WriteLine(movie.Genres);
                //System.Diagnostics.Debug.WriteLine(movie.Cast);
                this.progress.ProgressType = Phone.Controls.ProgressTypes.WaitCursor;
                this.progress.Show();
            }
        }
コード例 #2
0
        // 建構函式
        public MainPage()
        {
            InitializeComponent();

            if (m_Progress == null)
            {
                m_Progress = new Phone.Controls.ProgressIndicator();
                m_Progress.ProgressType = ProgressTypes.WaitCursor;
                m_Progress.Text         = "讀取中…請稍候…";
            }

            DataContext = ViewModel;

            timerShowTime          = new DispatcherTimer();
            timerShowTime.Interval = TimeSpan.FromSeconds(20.0);
            timerShowTime.Tick    += new EventHandler(OnShowTimerTick);
            timerShowTime.Start();

            ViewModel.LoadDataStarted   += OnLoadDataStarted;
            ViewModel.LoadDataCompleted += OnLoadDataCompleted;
            viewModel.LoadDataError     += OnLoadDataError;
        }
コード例 #3
0
        public void Show(PhoneApplicationPage sender)
        {
            stoped = false;
            p      = sender;

            if (this.progress == null)
            {
                this.progress = new Phone.Controls.ProgressIndicator();
            }

            // Initiaze background worker
            if (backgroundWorker == null)
            {
                backgroundWorker                     = new BackgroundWorker();
                backgroundWorker.DoWork             += new DoWorkEventHandler(backgroundWorker_DoWork);
                backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker_RunWorkerCompleted);
                backgroundWorker.ProgressChanged    += new ProgressChangedEventHandler(backgroundWorker_ProgressChanged);
            }
            progress.ProgressType = ProgressTypes.WaitCursor;
            backgroundWorker.WorkerReportsProgress = false;

            progress.Show();
            backgroundWorker.RunWorkerAsync();
        }
コード例 #4
0
ファイル: DownloadNote.xaml.cs プロジェクト: rheza/ezNote
        private void showProgress()
        {

            this.progress = new ProgressIndicator();

            progress.ProgressType = ProgressTypes.WaitCursor;

            progress.Show();
        }
コード例 #5
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (!isNetworkAvailable)
            {
                MessageBox.Show("Network is not available!");
                NavigationService.Navigate(new Uri("/MainPage/", UriKind.Relative));
            }

            if (this.progress == null)
            {
                this.progress = new Phone.Controls.ProgressIndicator();
            }

            string query;
            NavigationContext.QueryString.TryGetValue("Query", out query);

            string type;
            NavigationContext.QueryString.TryGetValue("Type", out type);

            //set page title
            if (type == "Theaters")
            {
                PageTitle.Text = "In Theaters";
            }
            else if (type == "BoxOffice")
            {
                PageTitle.Text = "Box Office";
            }
            else if (type == "Query")
            {
                PageTitle.Text = "Search Results";
            }
            else if (type == "Openings")
            {
                PageTitle.Text = "Openings";
            }
            else if (type == "Upcoming")
            {
                PageTitle.Text = "Upcoming";
            }
            //DVD
            else if (type == "DVDTop")
            {
                PageTitle.Text = "DVD Top Rentals";
            }
            else if (type == "DVDCurrentReleases")
            {
                PageTitle.Text = "DVD Current Releases";
            }
            else if (type == "DVDNewReleases")
            {
                PageTitle.Text = "DVD New Releases";
            }
            else if (type == "DVDUpcoming")
            {
                PageTitle.Text = "DVD Upcoming";
            }
            else if (type == "Similar")
            {
                PageTitle.Text = "Similar Movies";
            }

            Dictionary<string, List<Movie>> MoviesDict = PhoneApplicationService.Current.State["MoviesDict"] as Dictionary<string, List<Movie>>;
            PhoneApplicationService.Current.State["Type"] = type;

            MoviesDict = CheckMoviesDictionary(MoviesDict, type);

            //check if movies list is already cached
            //caching should not be active for custom movie search query and similar movies functionality
            if (MoviesDict.ContainsKey(type) && MoviesDict[type].Count != 0 && type != "Similar" && type != "Query")
            {
                DisplayMovies(MoviesDict, type);
            }
            //list is not cached - query rottentomatoes API then
            else
            {
                // Movies
                if (type == "Theaters")
                {
                    QueryRottenTomatoes(APIEndpoints.LIST_IN_THEATERS);                    
                }
                else if (type == "BoxOffice")
                {
                    QueryRottenTomatoes(APIEndpoints.LIST_BOX_OFFICE);                                        
                }
                else if (type == "Query")
                {
                    string url = String.Format(APIEndpoints.MOVIE_SEARCH, query, APIEndpoints.PAGE_LIMIT);
                    QueryRottenTomatoes(url);                        
                }
                else if (type == "Openings")
                {
                    QueryRottenTomatoes(APIEndpoints.LIST_OPENING_SOON);                         
                }
                else if (type == "Upcoming")
                {
                    QueryRottenTomatoes(APIEndpoints.LIST_UPCOMING);                                                                 
                }
                //DVD
                else if (type == "DVDTop")
                {
                    QueryRottenTomatoes(APIEndpoints.TOP_DVD_RENTALS);                                                                                     
                }
                else if (type == "DVDCurrentReleases")
                {
                    QueryRottenTomatoes(APIEndpoints.DVD_CURRENT_RELEASES);                                                                                                         
                }
                else if (type == "DVDNewReleases")
                {
                    QueryRottenTomatoes(APIEndpoints.DVD_NEW_RELEASES);                             
                }
                else if (type == "DVDUpcoming")
                {
                    QueryRottenTomatoes(APIEndpoints.DVD_UPCOMING);                                                 
                }
                else if (type == "Similar")
                {
                    string url = String.Format(APIEndpoints.SIMILAR, query, APIEndpoints.PAGE_LIMIT);
                    QueryRottenTomatoes(url);            
                }
            }
        }