Example #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();
            }
        }
Example #2
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();
            }
        }