Beispiel #1
0
 public void LoadAlbum(string[] data)
 {
     if (!IsLoaded)
     {
         var userId = data[0];
         var token = data[1];
         var albumId = data[2];
         playlist = new PlayListVk();
         playlist.DownloadAlbumTracks(userId, token, albumId);
         IsLoaded = true;
     }
 }
Beispiel #2
0
 private bool IsNeedCache(PlayListVk playlist)
 {
     if (playlist == playlistAll)
         return true;
     if (playlist == albums.GetSelectedAlbum().playlist)
         return true;
     return false;
 }
Beispiel #3
0
 void lstItemRecommed_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     playlist = recommendations.Playlist;
     playlist.SelTrack = listRecommedTracksBox.SelectedIndex;
     if (checkBoxShuffle.IsChecked == true)
         if (cherga.Count > 0 && cherga[cherga.Count - 1] != playlist.SelTrack)
             cherga.Add(playlist.SelTrack);
     PlayTrack();
 }
Beispiel #4
0
 void lstItemUser_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     playlist = users.GetSelectedUserPlaylist();
     playlist.SelTrack = listUserTracksBox.SelectedIndex;
     if (checkBoxShuffle.IsChecked == true)
         if (cherga.Count > 0 && cherga[cherga.Count - 1] != playlist.SelTrack)
             cherga.Add(playlist.SelTrack);
     PlayTrack();
 }
Beispiel #5
0
 void lstItemAlbum_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     playlist = albums.GetSelectedAlbum().playlist;
     playlist.SelTrack = listAlbumBox.SelectedIndex;
     if (checkBoxShuffle.IsChecked == true)
         if (cherga.Count > 0 && cherga[cherga.Count - 1] != playlist.SelTrack)
             cherga.Add(playlist.SelTrack);
     PlayTrack();
 }
Beispiel #6
0
        private void FillListBox(PlayListVk pls, ListBox listbx, bool allowAdding, bool allowDeleting, bool isMyAudioTab)
        {
            int count = 1;
            listbx.Items.Clear();
            foreach (var elm in pls.GetTrackListVK())
            {
                var listItem = CreateListItem(listbx, elm, count, allowAdding, allowDeleting, isMyAudioTab);
                listbx.Items.Add(listItem);
                count++;

            }
        }
Beispiel #7
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 #8
0
 private void DoubleRecommListBoxClick()
 {
     if (playlist != recommendations.Playlist)
     {
         cherga.Clear();
         playlist = recommendations.Playlist;
     }
     playlist.SelTrack = listRecommedTracksBox.SelectedIndex;
     if (sett.EnableShuffling)
         if (cherga.Count > 0)
         {
             if (cherga[cherga.Count - 1] != playlist.SelTrack)
                 cherga.Add(playlist.SelTrack);
         }
         else
             cherga.Add(playlist.SelTrack);
     PlayTrack();
 }
Beispiel #9
0
 private void DoubleSearchListBoxClick()
 {
     if (playlist != search.Playlist)
     {
         cherga.Clear();
         playlist = search.Playlist;
     }
     playlist.SelTrack = listSearchedTracksBox.SelectedIndex;
     if (sett.EnableShuffling)
         if (cherga.Count > 0)
         {
             if (cherga[cherga.Count - 1] != playlist.SelTrack)
                 cherga.Add(playlist.SelTrack);
         }
         else
             cherga.Add(playlist.SelTrack);
     PlayTrack();
 }
Beispiel #10
0
 private void DoubleUserListBoxClick()
 {
     if (playlist != users.GetSelectedUserPlaylist())
     {
         cherga.Clear();
         playlist = users.GetSelectedUserPlaylist();
     }
     playlist.SelTrack = listUserBox.SelectedIndex;
     if (sett.EnableShuffling)
         if (cherga.Count > 0)
         {
             if (cherga[cherga.Count - 1] != playlist.SelTrack)
                 cherga.Add(playlist.SelTrack);
         }
         else
             cherga.Add(playlist.SelTrack);
     PlayTrack();
 }
Beispiel #11
0
 private void DoubleAlbumListBoxClick()
 {
     if (playlist != albums.GetSelectedAlbum().playlist)
         cherga.Clear();
     playlist = albums.GetSelectedAlbum().playlist;
     playlist.SelTrack = listAlbumBox.SelectedIndex;
     if (sett.EnableShuffling)
         if (cherga.Count > 0)
         {
             if (cherga[cherga.Count - 1] != playlist.SelTrack)
                 cherga.Add(playlist.SelTrack);
         }
         else
             cherga.Add(playlist.SelTrack);
     PlayTrack();
 }
Beispiel #12
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;
        }
Beispiel #13
0
        private async void updateButton_Click(object sender, RoutedEventArgs e)
        {
            bool isPlaying = playlistAll == playlist;
            var currTrack = ((PlayListVk)playlistAll).GetCurrentTrackVK();
            string selTrack = "";
            if (currTrack != null)
                selTrack = currTrack.aid;
            listBox.Items.Clear();
            tracksCountLabel.Content = "0 треків";
            playlistAll = new PlayListVk();
            await Task.Factory.StartNew(() => playlistAll.DownloadTracks(new string[] { sett.UserId, sett.VKToken }));

            tracksCountLabel.Content = playlistAll.Count() + " треків";

            FillListBox((PlayListVk)playlistAll, listBox, false, true, true);

            if (isPlaying)
                playlist = playlistAll;

            if (currTrack != null)
            {
                ((PlayListVk)playlistAll).SelectTrackByAid(selTrack);
                listBox.SelectedIndex = ((PlayListVk)playlistAll).SelTrack;
            }

        }