Esempio n. 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //Get the history list from the data base
            HistoryList HistoryListItems = new HistoryDatabase().GetHistoryList();

            this.HistoryList.DataContext = HistoryListItems;
        }
Esempio n. 2
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            IsolatedStorageFile IsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();

            int ListCount = new HistoryDatabase().GetHistoryList().Count;

            if (IsolatedStorage.FileExists("HistoryDB") && ListCount > 0)
            {
                MessageBoxResult mbr = MessageBox.Show("Are you sure you want to delete all your history?", "Warning", MessageBoxButton.OKCancel);

                if (mbr == MessageBoxResult.OK)
                {
                    IsolatedStorage.DeleteFile("HistoryDB");
                    this.HistoryList.DataContext = new HistoryDatabase().GetHistoryList();; //Update the list view
                }
            }
            else
            {
                MessageBox.Show("History list is empty.", "Empty", MessageBoxButton.OK);
            }
        }
Esempio n. 3
0
        private async void YouTubeVideo(string videoId)
        {
            try
            {
                //Get The Video Uri and set it as a player source
                var url = await YouTube.GetVideoUriAsync(videoId, YouTubeQuality.Quality360P);

                string VideoTitle = await YouTube.GetVideoTitleAsync(videoId);

                HistoryDatabase history          = new HistoryDatabase();
                HistoryList     HistoryListItems = new HistoryDatabase().GetHistoryList();

                int lastId = 0; //Set the list id to 0

                if (HistoryListItems.Count > 0)
                {
                    lastId = HistoryListItems[0].Id; //Last item id is the id of the first item of the list
                }
                history.AddItem(new HistoryData()
                {
                    Id = lastId + 1, Title = VideoTitle, Image = "Assets/Video.png", Tag_Type = "Video", Tag_id = NavigationContext.QueryString["t"]
                });

                PhoneApplicationService.Current.State["videoURI"] = url.Uri;

                NavigationService.Navigate(new Uri("/video.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Couldn't get YouTube video\n\nERROR:" + ex.Message);

                //Go back to the main page
                NavigationService.Navigate(new Uri("/start.xaml", UriKind.Relative));
                //Don't allow to navigate back to the scanner with the back button
                NavigationService.RemoveBackEntry();
            }
        }