public void drawOnArtistList() { toolStrip3.Items.Clear(); for (int i = 0; i < Artists.getLength(); i++) { Artist art = Artists.getValue(i); ToolStripButton Artist = new ToolStripButton(); Artist.AutoSize = false; Artist.Size = new Size(182, 70); Artist.Name = (art.getName()); Artist.AutoSize = false; Artist.Text = art.getName(); Artist.Image = art.GetImage(); Artist.ImageAlign = ContentAlignment.MiddleLeft; Artist.TextImageRelation = TextImageRelation.ImageBeforeText; Artist.ImageScaling = ToolStripItemImageScaling.None; Artist.Font = new Font("MS Reference Sans Serif", 9); Artist.ForeColor = SystemColors.ControlLightLight; Artist.BackColor = Color.Transparent; toolStrip3.Items.Add(Artist); } }
//Search private void toolStripButton6_Click(object sender, EventArgs e) { AlbumForArtist.Images.Clear(); Searches.Visible = true; String search = toolStripTextBox2.Text; ArtistList artList = toServer.getSearchedArtist(search); AlbumList albList = toServer.getSearchedAlbum(search); List songList = toServer.getSearchedSong(search); //Artists for (int i = 0; i < artList.getLength(); i++) { Artist artist = artList.getValue(i); ListViewItem art = new ListViewItem(artist.getName(), i, listView3.Groups[0]); AlbumForArtist.Images.Add(artist.GetImage()); art.Text = artist.getName(); listView3.Items.Add(art); } //Albums for (int i = 0; i < albList.getLength(); i++) { Album album = albList.getValue(i); ListViewItem art = new ListViewItem(album.getName(), (artList.getLength() - 1 + i), listView3.Groups[1]); AlbumForArtist.Images.Add(album.GetBitImage()); art.SubItems.Add(album.getArtist().getName()); art.Text = album.getName(); listView3.Items.Add(art); } //Songs for (int i = 0; i < songList.getLength(); i++) { Song song = songList.getValue(i); ListViewItem art = new ListViewItem(song.getName(), (artList.getLength() - 1 + albList.getLength() - 1 + i), listView3.Groups[2]); AlbumForArtist.Images.Add(song.getAlbum().GetBitImage()); art.SubItems.Add(song.getArtist().getName()); art.SubItems.Add(song.getAlbum().getName()); art.Text = song.getName(); listView3.Items.Add(art); } }
private Album changeAlbum(string Name, Artist art) { Album alb; if (art.getAlbums().searchName(Name)) { alb = Artists.searchArtist(art.getName()).getAlbums().searchAlbum(Name); } else { alb = new Album(Name, art, Properties.Resources.album); art.getAlbums().add(alb); } return(alb); }
private void songInfoToolStripMenuItem_Click(object sender, EventArgs e) { foreach (ListViewItem item in lstSongs.SelectedItems) { System.IO.Stream albumResponseStream; int it = item.Index; Song song = Artists.getTotalValue(it); Form2 data = new Form2(); data.update(song.getName(), song.getArtist().getName(), song.getAlbum().getName(), song.getAlbumIndex().ToString(), song.getYear().ToString()); data.ShowDialog(); song.setName(data.SongName); Artist art = changeArtist(data.SongArtist); song.setArtist(art); //Change only for the song Album alb = changeAlbum(data.SongAlbum, art); song.setAlbum(alb); //Change only for the album uint indexer = touInt(data.Index); song.setAlbumIndex(indexer); uint yeari = touInt(data.Year); song.setYear(yeari); lstSongs.Items.Clear(); drawOnSongList(); if (data.Sync == true) { try { string API_KEY = "3d0dcf1274bfd9661a56e69161c405e1"; string API_SECRET = "67f9285e92ec64c788ad56cf6cb5a27d"; Session session = new Session(API_KEY, API_SECRET); Lastfm.ProxySupport.Proxy = new System.Net.WebProxy("221.2.216.38", 8080); // Test it out... Track track = new Track(art.getName(), song.getName(), session); //Console.WriteLine(track.Title + ", "+ track.Artist.Name + ", " + track.GetAlbum().Name); //Set Metadata song.setName(track.Title); Artist LastArtist = changeArtist(track.Artist.Name); //Image for Artist System.Net.WebRequest artistRequest = System.Net.WebRequest.Create(track.Artist.GetImageURL()); System.Net.WebResponse artistResponse = artistRequest.GetResponse(); System.IO.Stream artistResponseStream = artistResponse.GetResponseStream(); Image img = Image.FromStream(artistResponseStream); LastArtist.SetImage(new Bitmap(img, new Size(50, 50))); song.setArtist(LastArtist);//Change only for the song Album LastAlbum = changeAlbum(track.GetAlbum().Name, LastArtist); //Image for Album System.Net.WebRequest albumRequest = System.Net.WebRequest.Create(track.GetAlbum().GetImageURL()); System.Net.WebResponse albumResponse = albumRequest.GetResponse(); albumResponseStream = albumResponse.GetResponseStream(); LastAlbum.SetBitImage(new Bitmap(albumResponseStream)); song.setAlbum(LastAlbum);//Change only for the album //uint LastIndex = touInt(track.); //song.setAlbumIndex(indexer); //uint LasyYear = touInt(track.GetAlbum().; //song.setYear(yeari); } catch { } } //Edit File Metadata TagLib.File tip = TagLib.File.Create(song.getURL()); tip.Tag.Title = song.getName(); #pragma warning disable CS0618 // El tipo o el miembro están obsoletos tip.Tag.Artists[0] = song.getArtist().getName(); #pragma warning restore CS0618 // El tipo o el miembro están obsoletos tip.Tag.Album = song.getAlbum().getName(); tip.Tag.Year = song.getYear(); tip.Tag.Track = song.getAlbumIndex(); try{ tip.Save(); } catch { } lstSongs.Items.Clear(); drawOnSongList(); } }