private async void btn_fetch_Click(object sender, RoutedEventArgs e)
        {
            ButtonsEnabled(false);
            if (first)
            {
                first = false;
            }
            if (!first)
            {
                ResetVariables();
            }
            ClearVideoList();
            img_loader.Visibility = Visibility.Visible;
            img_loader.StartAnimation();

            try
            {
                playlists = await YouTubeServiceBuilder.GetUserPlaylists();

                playlistVideos = await YouTubeServiceBuilder.GetPlaylistVideos(playlists, cb_playlists.Text);
            }
            catch (System.Net.Http.HttpRequestException)
            {
                System.Windows.MessageBox.Show("Please check your internet connect and try again.", "No Internet Connection Detected", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (InvalidOperationException)
            {
                System.Windows.MessageBox.Show("Please select a playlist.", "No Playlist Selected", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            img_loader.StopAnimation();
            img_loader.Visibility = Visibility.Hidden;
            PopulateVideoList();
            ButtonsEnabled(true);
        }
Example #2
0
        private async void btn_fetch_Click(object sender, EventArgs e)
        {
            ButtonsEnabled(false);
            if (first)
            {
                first = false;
            }
            if (!first)
            {
                resetVariables();
            }
            clearVideoList();

            PictureBox loader = new PictureBox();

            loader.Image     = Image.FromFile("img/loader.gif");
            loader.SizeMode  = PictureBoxSizeMode.AutoSize;
            loader.BackColor = Color.Transparent;
            loader.Location  = new Point(pnl_videos.Width / 2, 200);
            pnl_videos.Controls.Add(loader);

            try
            {
                playlists = await YouTubeServiceBuilder.GetUserPlaylists();

                playlistVideos = await YouTubeServiceBuilder.GetPlaylistVideos(playlists, cb_playlists.Text);
            }
            catch (System.Net.Http.HttpRequestException)
            {
                MessageBox.Show("Please check your internet connect and try again.", "No Internet Connection Detected", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Please select a playlist.", "No Playlist Selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            pnl_videos.Controls.Remove(loader);

            populateVideoList();
            ButtonsEnabled(true);
        }
 private void ResetVariables()
 {
     playlists      = DependencyManager.Resolve <IYouTubePlaylists>();
     playlistVideos = DependencyManager.Resolve <IYouTubeVideos>();
 }