Beispiel #1
0
        private async void logInButton_Click(object sender, RoutedEventArgs e)
        {
            GetAuth();
            if (sett.VKToken != "")
            {
                //albums
                albums = new Albums();
                await Task.Factory.StartNew(() => albums.DownloadAlbums(new string[] { sett.UserId, sett.VKToken }));
                FillAlbums(albums);

                //my tracks
                playlist = new PlayListVk();
                playlistAll = playlist;
                await Task.Factory.StartNew(() => playlist.DownloadTracks(new string[] { sett.UserId, sett.VKToken }));

                tracksCountLabel.Content = playlist.Count() + " треків";
                FillListBox((PlayListVk)playlist, listBox, false, true, true);


                //users
                loadFriendList();

                //search
                search = new Search(sett.VKToken);
                //recommeds
                recommendations = new Reccomendations(sett.VKToken);
                UpdateRecommendations();
            }
        }
Beispiel #2
0
        private void updateAlbumsButton_Click(object sender, RoutedEventArgs e)
        {
            var curAlbum = albums.GetSelectedAlbum();
            KeyValuePair<string, string>[] selectedTracks = null;
            selectedTracks = albums.GetSelectedTracksForAlbum();
            bool isAlbumPlaying = curAlbum != null ? albums.GetSelectedAlbum().playlist == playlist : false;
            listAlbumBox.Items.Clear();
            tracksCountAlbumLabel.Content = "0 треків";

            albums = new Albums();

            albums.DownloadAlbums(new string[] { sett.UserId, sett.VKToken });

            FillAlbums(albums);

            if (curAlbum != null)
            {
                var index = Array.IndexOf(albums.GetAlbumsIds(), curAlbum.Id, 0);
                albumsCombobox.SelectedIndex = index;
                albumsCombobox_SelectionChanged(null, null);
                curAlbum = albums.GetSelectedAlbum();
                tracksCountAlbumLabel.Content = curAlbum.playlist.Count() + " треків";
            }
            else
                if (albums.Count() > 0)
                {
                    albumsCombobox.SelectedIndex = 0;
                    albumsCombobox_SelectionChanged(null, null);
                    curAlbum = albums.GetSelectedAlbum();
                    tracksCountAlbumLabel.Content = albums.GetSelectedAlbum().playlist.Count() + " треків";
                }
            if (selectedTracks != null)
                albums.SetSelectedTracksForAlbum(selectedTracks);


            if (curAlbum != null)
                FillListBox(albums.GetSelectedAlbum().playlist, listAlbumBox, false, true, false);
            else
                listAlbumBox.Items.Clear();

            if (curAlbum != null)
                listAlbumBox.SelectedIndex = albums.GetSelectedAlbum().playlist.SelTrack;

            if (isAlbumPlaying)
                playlist = albums.GetSelectedAlbum().playlist;
        }