Exemple #1
0
        /// <summary>
        /// Handler for when the 'Get Tracks' button is clicked
        /// </summary>
        private async void GetTracksBtn_Click(object sender, EventArgs e)
        {
            // Indicate to the user that it is loading by setting the cursor.
            Cursor = Cursors.WaitCursor;
            // Clear any existing display.
            SongDisplayPanel.Controls.Clear();
            controlBarPanel.Hide();
            RecommendationsLabel.Hide();
            CurrentArticleIndex = 0;

            // Get results from the recommender.
            Dictionary <string, List <FullTrack> > result = await Recommender.GetRecommendedTracks(!UseAllCategories, SelectedCategory);

            // Dynamically size the display panel to take up most of the screen.
            SongDisplayPanel.Size = new Size(this.Width - 100, this.Height - 350);

            // Convert to an array for easy indexing.
            Results = result.ToArray();

            // Display the current article.
            ShowCurrentArticle();

            // Reset the cursor.
            Cursor = Cursors.Default;
        }
Exemple #2
0
        /// <summary>
        /// Method to handle logic for displaying the current article.
        /// </summary>
        private void ShowCurrentArticle()
        {
            // Is the current article index a valid value?
            if (CurrentArticleIndex >= 0 && CurrentArticleIndex < Results.Length)
            {
                // Clear existing display
                SongDisplayPanel.Controls.Clear();
                // Display it.
                DisplayRecommendation(Results[CurrentArticleIndex]);

                // Show the container components
                controlBarPanel.Show();
                RecommendationsLabel.Show();
                showingLabel.Text = $"Showing Article {CurrentArticleIndex + 1} of {Results.Length}";
            }
            else if (CurrentArticleIndex < 0)
            {
                // The index is below 0, wrap back around to the end.
                CurrentArticleIndex = Results.Length - 1;
                ShowCurrentArticle();
            }
            else if (CurrentArticleIndex >= Results.Length)
            {
                // The index is above the end of the results, wrap back around to the start.
                CurrentArticleIndex = 0;
                ShowCurrentArticle();
            }
        }