Ejemplo n.º 1
0
        //Metodos
        public void quickSort(int lowerIndex, int higherIndex)
        {//Quicksort
            int init  = lowerIndex;
            int finit = higherIndex;

            //calculate pivot number
            Song pivot = this.getValue(init + (finit - init) / 2);

            //
            while (init <= finit)
            {
                while (this.getValue(init).GetDisc() <= pivot.GetDisc())
                {
                    if (this.getValue(init).GetDisc() < pivot.GetDisc())
                    {
                        init++;
                    }
                    else
                    {
                        if (this.getValue(init).getAlbumIndex() < pivot.getAlbumIndex())
                        {
                            init++;
                        }
                    }
                }
                while (this.getValue(finit).GetDisc() >= pivot.GetDisc())
                {
                    if (this.getValue(finit).GetDisc() > pivot.GetDisc())
                    {
                        finit++;
                    }
                    else
                    {
                        if (this.getValue(init).getAlbumIndex() > pivot.getAlbumIndex())
                        {
                            finit++;
                        }
                    }
                }
                if (init <= finit)
                {
                    swapSongs(init, finit);
                    //move index to next position on both sides
                    init++;
                    finit--;
                }
            }
            // call quickSort() method recursively
            if (lowerIndex < finit)
            {
                quickSort(lowerIndex, finit);
            }
            if (init < higherIndex)
            {
                quickSort(init, higherIndex);
            }
        }
Ejemplo n.º 2
0
        private void toolStrip3_ItemClicked_1(object sender, ToolStripItemClickedEventArgs e)
        {
            //SongOrAlbumLV1 = false;
            listView1.FullRowSelect = true;
            listView1.Groups.Clear();
            listView1.Items.Clear();
            AlbumForArtist.Images.Clear();
            listView1.Visible = true;
            ToolStripItem var = e.ClickedItem;

            Console.WriteLine(var.Name);
            Artist art = Artists.searchArtist(var.Name);

            for (int i = 0; i < art.getAlbums().getLength(); i++)
            {
                Album alb = art.getAlbums().getValue(i);
                AlbumForArtist.Images.Add(alb.GetBitImage());
                ListViewGroup albumArt = new ListViewGroup(alb.getName(), HorizontalAlignment.Left);
                albumArt.Name = alb.getName();
                listView1.Groups.Add(albumArt);
                Console.WriteLine("album" + listView1.Groups[i].Name);
                //listView1.Items.Add(new ListViewItem("", i,albumArt)); #Tried to display image



                for (int j = 0; j < alb.getSongs().getLength(); j++)
                {
                    Song         song    = alb.getSongs().getValue(j);
                    ListViewItem songArt = new ListViewItem(song.getName(), albumArt);
                    songArt.Name = song.getName();

                    albumArt.Items[j].Text = song.getAlbumIndex().ToString();
                    songArt.SubItems.Add(song.getName());
                    songArt.SubItems.Add(setTime(TagLib.File.Create(song.getURL()).Properties.Duration.ToString()));
                    songArt.SubItems.Add(song.getArtist().getName());
                    Console.WriteLine("song" + albumArt.Items[j].Name);
                    listView1.Items.Add(songArt);
                }
            }
        }
Ejemplo n.º 3
0
        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();
            }
        }
Ejemplo n.º 4
0
        private void songInfoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in lstSongs.SelectedItems)
            {
                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();
            }
        }