Esempio 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();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create a graph node and add it to the view-model.
        /// </summary>
        public NetworkNodeViewModel CreateArtistGraphNode(IHierarchyNode hierarchyNode, Point nodeLocation)
        {
            Debug.Assert(hierarchyNode is ArtistHierarchyNode);

            ArtistViewModel            viewModel = ((ArtistHierarchyNode)hierarchyNode).ArtistViewModel;
            ArtistNetworkNodeViewModel node      = new ArtistNetworkNodeViewModel(viewModel, _hierarchy, ((ArtistHierarchyNode)hierarchyNode), PlaylistService.GetCurrentPlaylist());

            // Initialize any style modifiers.
            node.X = nodeLocation.X;
            node.Y = nodeLocation.Y;
            node.InputConnectors.Add(new ConnectorViewModel("", ConnectorType.Input));
            node.OutputConnectors.Add(new ConnectorViewModel("", ConnectorType.Output));

            hierarchyNode.GraphNodeViewModel = node;

            // Add the node to the view-model.
            //
            this.Network.Nodes.Add(node);

            return(node);
        }
Esempio n. 3
0
        /// <summary>
        /// Event handler for unfollowing an artist.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnUnfollowArtistClick(object sender, RoutedEventArgs e)
        {
            ArtistNetworkNodeViewModel viewModel = (ArtistNetworkNodeViewModel)((FrameworkElement)sender).Tag;

            viewModel.UnfollowArtist();
        }