Пример #1
0
        private void PopulatePlaylists()
        {
            var playlists = SpotifyEasyApiHandler.GetCurrentUsersPlaylists();

            if (playlists == null)
            {
                return;
            }
            foreach (var playlist in playlists.Items)
            {
                var x = new Label
                {
                    BorderStyle = BorderStyle.FixedSingle,
                    ForeColor   = Color.LightGray
                };
                x.Font              = new Font(x.Font.Name, 12f, x.Font.Style, x.Font.Unit);
                x.AutoSize          = false;
                x.Size              = new Size(180, 30);
                x.MouseEnter       += XOnMouseEnter;
                x.MouseLeave       += X_MouseLeave;
                x.MouseDoubleClick += X_MouseDoubleClick;
                x.Text              = playlist.Name;
                x.Name              = playlist.Id;
                x.ContextMenuStrip  = contextMenuStrip1;
                PlaylistPanel.Controls.Add(x);
            }
        }
Пример #2
0
        private async void TrackCard_Load(object sender, EventArgs e)
        {
            var artistNameList = _track.Artists.Select(simpleArtist => simpleArtist.Name).ToList();

            radPopupEditor1.Hide();
            try
            {
                _fullTrackCard = new FullTrackCard
                {
                    TrackName   = { Text = _track.Name },
                    Album       = { Text = _track.Album.Name },
                    ReleaseDate = { Text = _track.Album.ReleaseDate },
                    Artist      = { Text = Join(", ", artistNameList) },
                    Popularity  = { Value1 = _track.Popularity },
                    label1      = { Text = Join(", ", await SpotifyEasyApiHandler.GetGenresAsync(_track).ConfigureAwait(false)) }
                };
                _fullTrackCard.pictureBox1.LoadAsync(AlbumImage.ImageLocation);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void X_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            var plSender   = sender as Label;
            var playlistId = plSender?.Name;

            Console.WriteLine(playlistId);
            var playlist = await SpotifyEasyApiHandler.GetFullPlaylistAsync(playlistId);

            await DisplayPlaylistsSongsAsync(playlist).ConfigureAwait(false);

            foreach (var item in Enum.GetValues(typeof(PlaylistInfoHelper.AudioFeature)))
            {
                switch (Convert.ToInt32(item))
                {
                case 0:
                    await PlaylistInfoHelper
                    .GetAverageAsync(playlist, PlaylistInfoHelper.AudioFeature.Acousticness)
                    .ConfigureAwait(false);

                    break;

                case 1:
                    var danceability = await PlaylistInfoHelper
                                       .GetAverageAsync(playlist, PlaylistInfoHelper.AudioFeature.Danceability)
                                       .ConfigureAwait(false);

                    DanceabilityProgress.Value1 = Convert.ToInt32(danceability);
                    break;

                case 2:
                    var energy = await PlaylistInfoHelper.GetAverageAsync(playlist, PlaylistInfoHelper.AudioFeature.Energy)
                                 .ConfigureAwait(false);

                    EnergyProgress.Value1 = Convert.ToInt32(energy);
                    break;

                case 3:
                    var instrumentalness = await PlaylistInfoHelper
                                           .GetAverageAsync(playlist, PlaylistInfoHelper.AudioFeature.Instrumentalness)
                                           .ConfigureAwait(false);

                    IntrumentalnessProgress.Value1 = Convert.ToInt32(instrumentalness);
                    break;

                case 4:
                    var loudness = await PlaylistInfoHelper.GetAverageAsync(playlist, PlaylistInfoHelper.AudioFeature.Loudness)
                                   .ConfigureAwait(false);

                    LoudnessProgress.Value1 = Convert.ToInt32(loudness + 60);
                    break;

                case 5:
                    var valence = await PlaylistInfoHelper.GetAverageAsync(playlist, PlaylistInfoHelper.AudioFeature.Valence)
                                  .ConfigureAwait(false);

                    ValenceProgress.Value1 = Convert.ToInt32(valence);
                    break;

                case 6:
                    var tempo = await PlaylistInfoHelper.GetAverageAsync(playlist, PlaylistInfoHelper.AudioFeature.Tempo)
                                .ConfigureAwait(false);

                    TempProgress.Value1 = Convert.ToInt32(tempo);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(item), item, null);
                }
            }

            // PlaylistInfo playlistInfo = new PlaylistInfo(acousticness, danceability, energy, instrumentalness, loudness,
            //     valence, tempo, default, playlist);
        }
Пример #4
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            _songItems = await GenreReleaseHandler.Feed().ConfigureAwait(false);

            SpotifyEasyApiHandler.SpotifyInit();
        }
Пример #5
0
        public static void SetMonthPlaylistId()
        {
            var s                = Assembly.GetExecutingAssembly().Location;
            var directory        = Path.GetDirectoryName(s);
            var playlistMonthIds = (from object month in Enum.GetValues(typeof(MainForm.Months)) let playlist = SpotifyEasyApiHandler.NewPlaylist(SpotifyEasyApiHandler.UserId, "Hardstyle " + month.ToString()) select new PlaylistMonthId {
                Month = Convert.ToInt32(month), PlaylistId = playlist.Id
            }).ToList();

            using var file = File.CreateText(directory + @"\PlaylistMonths.json");
            var serializer = new JsonSerializer();

            serializer.Serialize(file, playlistMonthIds);
        }