Exemplo n.º 1
0
 private void SongListUpdateTimer_Tick(object sender, EventArgs e)
 {
     SongListView.BeginUpdate();
     foreach (var downloadInfo in downloadData)
     {
         if (downloadInfo != null)
         {
             string[] row          = { downloadInfo.Message, downloadInfo.FileName };
             var      listViewItem = new ListViewItem(row);
             listViewItem.ImageIndex = downloadInfo.Image;
             if (SongListView.Items[downloadInfo.Number] == null)
             {
                 SongListView.Items.Add(listViewItem);
             }
             else
             {
                 SongListView.Items[downloadInfo.Number] = (listViewItem);
             }
         }
     }
     SongListView.EndUpdate();
 }
Exemplo n.º 2
0
        private void SearchSpotify(string code, int session)
        {
            int           num         = 0;
            PassArguments spotifyName = GetSpotifyName(code);
            bool          add         = true;

            foreach (PassArguments[] songArrayInArray in songArray)
            {
                if (songArrayInArray != null)
                {
                    foreach (var songThing in songArrayInArray)
                    {
                        if (songThing != null)
                        {
                            if (songThing.PassedFileName.Equals(spotifyName.PassedSong + " - " + spotifyName.PassedArtist))
                            {
                                //File already in list
                                _songs--;
                                songsArray[_current]--;
                                add = false;
                                Log("[Attention] The song " + spotifyName.PassedSong + " - " + spotifyName.PassedArtist +
                                    " was already added.");
                            }
                        }
                    }
                }
            }
            if (File.Exists(_dir + EscapeFilename(spotifyName.PassedFileName) + ".mp3"))
            {
                //File already exsists/Downloaded
                _songs--;
                songsArray[_current]--;
                add = false;
            }

            try
            {
                if (add)
                {
                    {
                        SongListView.BeginUpdate();
                        string[] row          = { "Waiting", spotifyName.PassedSong + " - " + spotifyName.PassedArtist };
                        var      listViewItem = new ListViewItem(row);
                        listViewItem.ImageIndex = 1;
                        SongListView.Items.Add(listViewItem);
                        SetLabelVisible(false);
                        num = listViewItem.Index;
                        SongListView.EndUpdate();

                        songArray[session][num] = (new PassArguments
                        {
                            PassedSong = spotifyName.PassedSong,
                            PassedArtist = spotifyName.PassedArtist,
                            PassedNum = num,
                            PassedFileName = spotifyName.PassedSong + " - " + spotifyName.PassedArtist,
                            PassedAlbum = spotifyName.PassedAlbum,
                            PassedAlbumId = spotifyName.PassedAlbumId,
                            PassedLength = spotifyName.PassedLength,
                            PassedLengthMs = spotifyName.PassedLengthMs,
                            PassedimageURL = spotifyName.PassedimageURL
                        });
                    }
                }

//                if (SongListView.Items.Count == songs)
                int result = songArray[session].Count(s => s != null);
//                Log(result + " | " + songsArray[current]);
                if (result == songsArray[_current])
                {
                    Log(songsArray[_current] + " songs added. Total songs: " + _songs);
                    SearchSongArray(session);
                }
            }
            catch (Exception ex)
            {
                Log("[Error: x1] " + ex.Message + Environment.NewLine + num, true);
            }
        }