コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="subTreeNode"></param>
        /// <returns>Returns whether the sub-tree has been fully expanded in the hierarchy.</returns>
        public void GenerateSubTree(HierarchyNode subTreeNode)
        {
            ArtistGroup relatedArtistList = Client.GetRelatedArtists(subTreeNode.ArtistViewModel.Artist.ID);

            //First determine which artists are new; add those.
            List <Artist> newArtists = new List <Artist>();
            int           nodesAdded = 0;

            foreach (Artist relatedArtist in relatedArtistList.Artists)
            {
                if (NodeDictionary.ContainsKey(relatedArtist.Name))
                {
                    continue;
                }

                if (nodesAdded < MaxChildren)
                {
                    newArtists.Add(relatedArtist);

                    ArtistViewModel artistViewModel   = new ArtistViewModel(relatedArtist);
                    HierarchyNode   relatedArtistNode = new HierarchyNode(artistViewModel, subTreeNode, subTreeNode.Level + 1);
                    subTreeNode.Children.Add(relatedArtistNode);
                    artistViewModel.SetHierarchyNode(relatedArtistNode);
                    NodeDictionary.Add(relatedArtist.Name, relatedArtistNode);

                    nodesAdded++;
                }
                else
                {
                    return;
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        /// <returns>Returns whether the sub-tree has been fully expanded in the hierarchy.</returns>
        public override void GenerateSubTree(IHierarchyNode node)
        {
            ArtistHierarchyNode subTreeNode       = (ArtistHierarchyNode)node;
            ArtistGroup         relatedArtistList = Client.GetRelatedArtists(subTreeNode.ArtistViewModel.Artist.ID);

            //First determine which artists are new; add those.
            int nodesAdded = 0;

            foreach (Artist relatedArtist in relatedArtistList.Artists)
            {
                if (NodeDictionary.ContainsKey(relatedArtist.Name))
                {
                    continue;
                }

                if (nodesAdded < AddChildrenLimit)
                {
                    ArtistViewModel     artistViewModel   = new ArtistViewModel(relatedArtist);
                    ArtistHierarchyNode relatedArtistNode = new ArtistHierarchyNode(artistViewModel, this, subTreeNode, subTreeNode.Level + 1);
                    subTreeNode.Children.Add(relatedArtistNode);
                    NodeDictionary.Add(relatedArtist.Name, relatedArtistNode);
                    nodesAdded++;
                }
                else
                {
                    return;
                }
            }
        }
コード例 #3
0
 public HierarchyNode(ArtistViewModel artistViewModel, HierarchyNode parent, int level)
 {
     ArtistViewModel = artistViewModel;
     GraphNodeViewModel = null;
     Parent = parent;
     Children = new List<HierarchyNode>();
     Level = level;
 }
コード例 #4
0
 public HierarchyNode(ArtistViewModel artistViewModel, HierarchyNode parent, int level)
 {
     ArtistViewModel    = artistViewModel;
     GraphNodeViewModel = null;
     Parent             = parent;
     Children           = new List <HierarchyNode>();
     Level = level;
 }
コード例 #5
0
        private void GenerateTree(String artistName)
        {
            //Going to separate artists based on the genres used to describe them.
            //Assume that the first artist is what we're pivoting on.

            if (NodeDictionary.ContainsKey(artistName))
            {
                return;
            }

            ArtistList rootArtistList = Client.GetArtist(artistName);

            //TODO: Using the first one for now.  Since there could be multiple roots, we'll need to handle this.
            Artist          rootArtist    = rootArtistList.Artists.Items[0];
            ArtistViewModel rootViewModel = new ArtistViewModel(rootArtist);
            HierarchyNode   root          = new HierarchyNode(rootViewModel, null, 0);

            RootNodes.Add(root);
            rootViewModel.SetHierarchyNode(root);
            NodeDictionary.Add(rootArtist.Name, root);

            ArtistGroup relatedArtistList = Client.GetRelatedArtists(rootArtist.ID);

            //First determine which artists are new; add those.
            List <Artist> newArtists = new List <Artist>();
            int           nodesAdded = 0;

            foreach (Artist relatedArtist in relatedArtistList.Artists)
            {
                if (NodeDictionary.ContainsKey(relatedArtist.Name))
                {
                    continue;
                }

                if (nodesAdded < MaxChildren)
                {
                    newArtists.Add(relatedArtist);

                    ArtistViewModel artistViewModel   = new ArtistViewModel(relatedArtist);
                    HierarchyNode   relatedArtistNode = new HierarchyNode(artistViewModel, root, 1);
                    root.Children.Add(relatedArtistNode);
                    artistViewModel.SetHierarchyNode(relatedArtistNode);
                    NodeDictionary.Add(relatedArtist.Name, relatedArtistNode);

                    nodesAdded++;
                }
                else
                {
                    break;
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Generates the tree from the root artist.
        /// </summary>
        /// <param name="artist"></param>
        protected override void GenerateTree(object obj)
        {
            Artist artist = (Artist)obj;

            if (NodeDictionary.ContainsKey(artist.Name))
            {
                return;
            }

            ArtistViewModel     rootViewModel = new ArtistViewModel(artist);
            ArtistHierarchyNode root          = new ArtistHierarchyNode(rootViewModel, this, null, 0);

            RootNodes.Add(root);
            NodeDictionary.Add(artist.Name, root);

            ArtistGroup relatedArtistList = Client.GetRelatedArtists(artist.ID);

            //First determine which artists are new; add those.
            List <Artist> newArtists = new List <Artist>();
            int           nodesAdded = 0;

            foreach (Artist relatedArtist in relatedArtistList.Artists)
            {
                if (NodeDictionary.ContainsKey(relatedArtist.Name))
                {
                    continue;
                }

                if (nodesAdded < AddChildrenLimit)
                {
                    newArtists.Add(relatedArtist);

                    ArtistViewModel     artistViewModel   = new ArtistViewModel(relatedArtist);
                    ArtistHierarchyNode relatedArtistNode = new ArtistHierarchyNode(artistViewModel, this, root, 1);
                    root.Children.Add(relatedArtistNode);
                    NodeDictionary.Add(relatedArtist.Name, relatedArtistNode);

                    nodesAdded++;
                }
                else
                {
                    break;
                }
            }
        }
コード例 #7
0
        public ArtistNetworkNodeViewModel(
            ArtistViewModel viewModel, 
            AtlasHierarchy hierarchy, 
            IHierarchyNode hierarchyNode,
            IPlaylistView playlist)
            : base(viewModel.Name)
        {
            ArtistViewModel = viewModel;

            Debug.Assert(hierarchyNode is ArtistHierarchyNode);
            _hierarchyNode = (ArtistHierarchyNode) hierarchyNode; 
            _hierarchy = hierarchy;
            _playlist = playlist;

            _numTracks = GetArtistTrackCount();

            IsHighlighted = SpotifyCacheService.IsArtistFollowed(ArtistViewModel.Artist);
        }
コード例 #8
0
        public ArtistNetworkNodeViewModel(
            ArtistViewModel viewModel,
            AtlasHierarchy hierarchy,
            IHierarchyNode hierarchyNode,
            IPlaylistView playlist)
            : base(viewModel.Name)
        {
            ArtistViewModel = viewModel;

            Debug.Assert(hierarchyNode is ArtistHierarchyNode);
            _hierarchyNode = (ArtistHierarchyNode)hierarchyNode;
            _hierarchy     = hierarchy;
            _playlist      = playlist;

            _numTracks = GetArtistTrackCount();

            IsHighlighted = SpotifyCacheService.IsArtistFollowed(ArtistViewModel.Artist);
        }
コード例 #9
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);
        }
コード例 #10
0
        /// <summary>
        /// Generates the tree from the root artist.
        /// </summary>
        /// <param name="artist"></param>
        protected override void GenerateTree(object obj)
        {
            Artist artist = (Artist)obj;
            if (NodeDictionary.ContainsKey(artist.Name))
                return;

            ArtistViewModel rootViewModel = new ArtistViewModel(artist);
            ArtistHierarchyNode root = new ArtistHierarchyNode(rootViewModel, this, null, 0);
            RootNodes.Add(root);
            NodeDictionary.Add(artist.Name, root);

            ArtistGroup relatedArtistList = Client.GetRelatedArtists(artist.ID);

            //First determine which artists are new; add those.
            List<Artist> newArtists = new List<Artist>();
            int nodesAdded = 0;

            foreach (Artist relatedArtist in relatedArtistList.Artists)
            {
                if (NodeDictionary.ContainsKey(relatedArtist.Name))
                    continue;

                if (nodesAdded < AddChildrenLimit)
                {
                    newArtists.Add(relatedArtist);

                    ArtistViewModel artistViewModel = new ArtistViewModel(relatedArtist);
                    ArtistHierarchyNode relatedArtistNode = new ArtistHierarchyNode(artistViewModel, this, root, 1);
                    root.Children.Add(relatedArtistNode);
                    NodeDictionary.Add(relatedArtist.Name, relatedArtistNode);

                    nodesAdded++;
                }
                else
                {
                    break;
                }
            }
        }
コード例 #11
0
 public ArtistHierarchyNode(ArtistViewModel artistViewModel, AtlasHierarchy hierarchy, IHierarchyNode parent, int level)
     : base(hierarchy, parent, level)
 {
     ArtistViewModel = artistViewModel;
 }
コード例 #12
0
        private void GenerateTree(String artistName)
        {
            //Going to separate artists based on the genres used to describe them.  
            //Assume that the first artist is what we're pivoting on.

            if (NodeDictionary.ContainsKey(artistName)) 
                return;

            ArtistList rootArtistList = Client.GetArtist(artistName);

            //TODO: Using the first one for now.  Since there could be multiple roots, we'll need to handle this.
            Artist rootArtist = rootArtistList.Artists.Items[0];
            ArtistViewModel rootViewModel = new ArtistViewModel(rootArtist);
            HierarchyNode root = new HierarchyNode(rootViewModel, null, 0);
            RootNodes.Add(root);
            rootViewModel.SetHierarchyNode(root);
            NodeDictionary.Add(rootArtist.Name, root);

            ArtistGroup relatedArtistList = Client.GetRelatedArtists(rootArtist.ID);

            //First determine which artists are new; add those.
            List<Artist> newArtists = new List<Artist>();
            int nodesAdded = 0;

            foreach (Artist relatedArtist in relatedArtistList.Artists)
            {
                if (NodeDictionary.ContainsKey(relatedArtist.Name))
                    continue;

                if (nodesAdded < MaxChildren)
                {
                    newArtists.Add(relatedArtist);

                    ArtistViewModel artistViewModel = new ArtistViewModel(relatedArtist);
                    HierarchyNode relatedArtistNode = new HierarchyNode(artistViewModel, root, 1);
                    root.Children.Add(relatedArtistNode);
                    artistViewModel.SetHierarchyNode(relatedArtistNode);
                    NodeDictionary.Add(relatedArtist.Name, relatedArtistNode);

                    nodesAdded++;
                }
                else
                {
                    break;
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="subTreeNode"></param>
        /// <returns>Returns whether the sub-tree has been fully expanded in the hierarchy.</returns>
        public void GenerateSubTree(HierarchyNode subTreeNode)
        {
            ArtistGroup relatedArtistList = Client.GetRelatedArtists(subTreeNode.ArtistViewModel.Artist.ID);

            //First determine which artists are new; add those.
            List<Artist> newArtists = new List<Artist>();
            int nodesAdded = 0;
            foreach (Artist relatedArtist in relatedArtistList.Artists)
            {
                if (NodeDictionary.ContainsKey(relatedArtist.Name))
                    continue;

                if (nodesAdded < MaxChildren)
                {
                    newArtists.Add(relatedArtist);

                    ArtistViewModel artistViewModel = new ArtistViewModel(relatedArtist);
                    HierarchyNode relatedArtistNode = new HierarchyNode(artistViewModel, subTreeNode, subTreeNode.Level + 1);
                    subTreeNode.Children.Add(relatedArtistNode);
                    artistViewModel.SetHierarchyNode(relatedArtistNode);
                    NodeDictionary.Add(relatedArtist.Name, relatedArtistNode);

                    nodesAdded++;
                }
                else
                {
                    return;
                }
            }
        }
コード例 #14
0
 public ArtistHierarchyNode(ArtistViewModel artistViewModel, AtlasHierarchy hierarchy, IHierarchyNode parent, int level)
     : base(hierarchy, parent, level)
 {
     ArtistViewModel = artistViewModel;
 }
コード例 #15
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        /// <returns>Returns whether the sub-tree has been fully expanded in the hierarchy.</returns>
        public override void GenerateSubTree(IHierarchyNode node) {
            ArtistHierarchyNode subTreeNode = (ArtistHierarchyNode) node;
            ArtistGroup relatedArtistList = Client.GetRelatedArtists(subTreeNode.ArtistViewModel.Artist.ID);

            //First determine which artists are new; add those.
            int nodesAdded = 0;
            foreach (Artist relatedArtist in relatedArtistList.Artists)
            {
                if (NodeDictionary.ContainsKey(relatedArtist.Name))
                    continue;

                if (nodesAdded < AddChildrenLimit)
                {
                    ArtistViewModel artistViewModel = new ArtistViewModel(relatedArtist);
                    ArtistHierarchyNode relatedArtistNode = new ArtistHierarchyNode(artistViewModel, this, subTreeNode, subTreeNode.Level + 1);
                    subTreeNode.Children.Add(relatedArtistNode);
                    NodeDictionary.Add(relatedArtist.Name, relatedArtistNode);
                    nodesAdded++;
                }
                else
                {
                    return;
                }
            }
        }