コード例 #1
0
ファイル: InputModule.cs プロジェクト: michael16574/MusicLog
        private void button2_Click(object sender, EventArgs e)
        {
            var checkedArtists = new List <SpotifyArtist>();

            // Adds any checked albums to database
            foreach (TreeNode node in treeView1.Nodes)
            {
                if (node.Checked)
                {
                    var newArtist = new SpotifyArtist();
                    newArtist.Name      = node.Text;
                    newArtist.SpotifyID = (string)node.Tag;
                    checkedArtists.Add(newArtist);
                }
            }

            List <SpotifyAlbum> allSpotifyAlbums = new List <SpotifyAlbum>();

            foreach (SpotifyArtist artist in checkedArtists)
            {
                var albumQuery = _musicLog.GetSpotifyAlbums(artist);
                _musicLog.AddAlbums(albumQuery, artist);
                allSpotifyAlbums.AddRange(albumQuery);
            }

            foreach (SpotifyAlbum album in allSpotifyAlbums)
            {
                var trackQuery = _musicLog.GetSpotifyTracks(album);
                _musicLog.AddTracks(trackQuery, album);
            }

            _musicLog.Save();
        }
コード例 #2
0
        private void RetrieveMissingAlbums_ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Adding missing albums
            var selectedArtist  = (SpotifyArtist)ArtistListView.SelectedItems[0].Tag;
            var retrievedAlbums = _musicLog.GetSpotifyAlbums(selectedArtist);

            _musicLog.AddAlbums(retrievedAlbums, selectedArtist);
            foreach (SpotifyAlbum album in retrievedAlbums)
            {
                _musicLog.AddTracks(_musicLog.GetSpotifyTracks(album), album);
            }

            // Updating listview
            ArtistListView_SelectedIndexChanged(this, EventArgs.Empty);
            TrackListView.Items.Clear();
        }