private void GenerateNodes(IHierarchyNode parentNode, NetworkNodeViewModel parentGraphNode, Point point) { int offset = 0; foreach (IHierarchyNode hierarchyNode in parentNode.Children) { Point graphNodeLocation = new Point(point.X, offset); NetworkNodeViewModel graphNode = null; if (hierarchyNode is ArtistHierarchyNode) { graphNode = CreateArtistGraphNode(hierarchyNode, graphNodeLocation); } else if (hierarchyNode is NewReleaseHierarchyNode) { graphNode = CreateNewReleasesGraphNode(hierarchyNode, graphNodeLocation); } ConnectionViewModel connection = new ConnectionViewModel(); connection.SourceConnector = parentGraphNode.OutputConnectors[0]; connection.DestConnector = graphNode.InputConnectors[0]; // Add the connection to the graph. this.Network.Connections.Add(connection); //Generate any children. GenerateNodes(hierarchyNode, graphNode, new Point(point.X + 1, 0)); offset++; } }
/// <summary> /// Event handler to expand an artist's node with all other related artists. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnExpandAllRelatedArtistsButtonClick(object sender, RoutedEventArgs e) { NetworkNodeViewModel targetNode = (NetworkNodeViewModel)((FrameworkElement)sender).Tag; targetNode.OnExpand(AtlasExpandChildSetting.CreateAllChildren); UpdateNetwork(); }
public void GenerateNetwork() { //Once we have the hierarchy, assemble the nodes. this.Network = new NetworkViewModel(); int offset = 0; foreach (IHierarchyNode hierarchyNode in _hierarchy.RootNodes) { Point graphNodeLocation = new Point(0, offset); NetworkNodeViewModel graphNode = null; if (hierarchyNode is ArtistHierarchyNode) { graphNode = CreateArtistGraphNode(hierarchyNode, graphNodeLocation); } else if (hierarchyNode is NewReleaseHierarchyNode) { graphNode = CreateNewReleasesGraphNode(hierarchyNode, graphNodeLocation); } GenerateNodes(hierarchyNode, graphNode, new Point(1, 0)); offset++; } }
/// <summary> /// Delete the node from the view-model. /// Also deletes any connections to or from the node. /// </summary> public void DeleteNode(NetworkNodeViewModel node) { // // Remove all connections attached to the node. // this.Network.Connections.RemoveRange(node.AttachedConnections); // // Remove the node from the network. // this.Network.Nodes.Remove(node); }
/// <summary> /// Determine the area covered by the specified list of nodes. /// </summary> private Rect DetermineAreaOfNodes(IList nodes) { NetworkNodeViewModel firstNode = (NetworkNodeViewModel)nodes[0]; Rect actualContentRect = new Rect(firstNode.X, firstNode.Y, firstNode.Size.Width, firstNode.Size.Height); for (int i = 1; i < nodes.Count; ++i) { NetworkNodeViewModel node = (NetworkNodeViewModel)nodes[i]; Rect nodeRect = new Rect(node.X, node.Y, node.Size.Width, node.Size.Height); actualContentRect = Rect.Union(actualContentRect, nodeRect); } return(actualContentRect); }
/// <summary> /// Event handler for following an artist. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnFollowArtistClick(object sender, RoutedEventArgs e) { NetworkNodeViewModel viewModel = (NetworkNodeViewModel)((FrameworkElement)sender).Tag; viewModel.FollowArtist(); }
/// <summary> /// Event handler for adding tracks. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnAddTracksClick(object sender, RoutedEventArgs e) { NetworkNodeViewModel viewModel = (NetworkNodeViewModel)((FrameworkElement)sender).Tag; viewModel.AddTracks(); }