Exemplo n.º 1
0
        private void OnRecommend(object sender, RoutedEventArgs e)
        {
            Playlist selectedPlaylist = (Playlist)this.NavigationControl.ViewModel.SelectedPlaylist;
            if (selectedPlaylist == null)
                return;

            RecommendationEngine engine = new RecommendationEngine();
            Artist recommendedArtist = engine.Recommend(SpotifyClientService.Client, selectedPlaylist);

            RecommendationWindow recommendationWindow = new RecommendationWindow(recommendedArtist);
            bool? result = recommendationWindow.ShowDialog();

            if (result != null && result.Value == true)
            {
                ArtistNetworkNodeViewModel targetNodeViewModel = this.AtlasView.ViewModel.FindNode<ArtistNetworkNodeViewModel>(recommendedArtist.ID);

                if (targetNodeViewModel == null) {
                    List<Artist> recommendedArtistList = new List<Artist>() {recommendedArtist};
                    AtlasViewOptions options = new AtlasViewOptions(1);
                    this.AtlasView.ViewModel.AddArtistsToHierarchy(recommendedArtistList.AsReadOnly(), options);
                    this.AtlasView.UpdateNetwork();

                    targetNodeViewModel = this.AtlasView.ViewModel.FindNode<ArtistNetworkNodeViewModel>(recommendedArtist.ID);
                }

                targetNodeViewModel.AddTracks();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Event handler when the search popup is closed.  Adds the artist to the atlas
        /// if there a valid selection.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnSearchControlPopupClosed(object sender, EventArgs e)
        {
            Artist selectedArtist = this.SearchControlPopup.SelectedItem;

            if (selectedArtist == null)
                return;

            List<Artist> artistList = new List<Artist>() { selectedArtist };
            AtlasViewOptions options = new AtlasViewOptions(1);
            this.AtlasView.ViewModel.AddArtistsToHierarchy(artistList.AsReadOnly(), options);
            this.AtlasView.UpdateNetwork();
        }
Exemplo n.º 3
0
 public IEnumerable <Pile> GetPiles()
 {
     return(Piles.AsReadOnly());
 }