Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'The LoadPlaylist ID click function. As you can see it parses the playlist integer entered into the textbox, then calls @h@'some functions that I refactored to make it easier to write.
- Private Sub btnLoadPlaylistId_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
- If Not String.IsNullOrWhiteSpace(txtPlaylistID.Text) Then
- Try
- ClearDownloadList()
- Dim i As Integer = Integer.Parse(txtPlaylistID.Text)
- SearchPlaylistID(i)
- SelectAllResults()
- AddResults()
- Catch ex As Exception
- End Try
- End If
- End Sub
- 'As you can see the clear downloaded list is just a function taken from your menu call
- Private Sub mniClearDownloadList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
- ClearDownloadList()
- End Sub
- 'The refactored function
- Private Sub ClearDownloadList()
- If Not DownloadEnabled Then
- dagDownload.ItemsSource = Nothing
- DownloadResultsTable.Rows.Clear()
- DownloadResults.Clear()
- DownloadResults = Nothing
- DownloadResultsTable = Nothing
- DownloadResults = New List(Of ResultGrid)()
- DownloadResultsTable = ResultGrid.ReturnBaseTable
- dagDownload.ItemsSource = DownloadResultsTable.AsDataView
- SetDownloadTableColumnNames()
- End If
- End Sub
- 'My playlist searching function, again copied from yours.
- Private Sub SearchPlaylistID(ByVal PlaylistID As Integer)
- Call DoSearch(grooveClient.GetPlaylistSongs(PlaylistID).result.Songs)
- tabMain.SelectedIndex = 0
- End Sub
- 'You will probably need to update it a bit, to make it fit yours, but as a quick test it works for me :
- Private Sub btnFetchPlaylists_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
- Dim PlaylistID As Integer = cmbFetchPlaylists.SelectedIndex
- Try
- BlockSearchButtons(Skin.getLanguageText("LangFetchingPlaylist", "Fetching Playlist") & " (" & PlaylistID & ")...")
- Call DoSearch(grooveClient.GetPlaylistSongs(playlistResponse.result.Playlists(PlaylistID).playlistID).result.Songs)
- Catch ex As Exception
- AddDebug("Error: " & ex.GetType.ToString & " - " & ex.Message & " - " & "Playlist Song fetching error")
- End Try
- tabMain.SelectedIndex = 0
- End Sub
- 'Again, I refactored the select all button_click method for ease of use
- Private Sub btnSelectAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
- SelectAllResults()
- End Sub
- Private Sub SelectAllResults()
- For i = 0 To FoundResults.Count - 1
- FoundResults(i).Load = True
- FoundResultsTable.Rows(i).Item("Load") = True
- Next
- End Sub
- 'And last of all the Add to download list funciton
- Private Sub btnAddToDownloadList_Click(ByVal sender As Object, ByVal e As EventArgs)
- AddResults()
- End Sub
- Private Sub AddResults()
- Try
- For I = 0 To FoundResults.Count - 1
- Dim AddResult As ResultGrid = New ResultGrid(FoundResults(I).Result)
- If FoundResultsTable.Rows(I).Field(Of Boolean)("Load") And Not DownloadResults.Contains(AddResult) Then
- DownloadResults.Add(AddResult)
- DownloadResultsTable.Rows.Add(ResultGrid.CreateBaseTableRow(DownloadResultsTable, DownloadResults.Last))
- End If
- If myConfig.Settings.UncheckAfterAdd Then FoundResultsTable.Rows(I).Item("Load") = False
- Next
- Catch
- End Try
- dagDownload.ItemsSource = DownloadResultsTable.AsDataView
- SetDownloadTableColumnNames()
- Call ExportAllDownloadResults()
- End Sub
- 'And I also added a textbox for the playlist ID and a button to load it.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement