protected virtual void OnBtnQueueSongClicked(object sender, System.EventArgs e) { HTreeNode theNode = tvLibrary.SelectedNode; // Check if node has children if (theNode.Nodes.Count > 0) { // Will add all children to queue } else { // Node is a leaf (song) SubsonicItem theItem = GetNodeItem(theNode); // Confirm that the item is asong if (theItem.itemType == SubsonicItem.SubsonicItemType.Song) { //slPlaylist.Items.Add(theItem); Dictionary <string, string> songId = new Dictionary <string, string>(); songId.Add("id", theItem.id); string streamURL = Subsonic.BuildDirectURL("download.view", songId); System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = "vlc"; proc.StartInfo.Arguments = "--one-instance --playlist-enqueue " + streamURL; proc.Start(); } } }
private void OnBtnEditClicked(object sender, EventArgs args) { //change the text/icon to the selected node HTreeNode node = tree.SelectedNode; if (node != null) { node.Text = "new and shiny modified value!"; node.Icon = GraphUtil.pixbufFromStock("gtk-add", IconSize.Button); } }
private void OnBtnAddChildClicked(object sender, EventArgs args) { //add a new child node if (cmb.Tree.SelectedNode != null) { HTreeNode father_node = cmb.Tree.SelectedNode; Gdk.Pixbuf icon = GraphUtil.pixbufFromStock("gtk-remove", IconSize.Button); HTreeNode new_node = new HTreeNode("gigi kent", icon); father_node.Nodes.Add(new_node); } }
private SubsonicItem GetNodeItem(HTreeNode theNode) { // Get path to the selected node Queue <string> nodePath = GetNodePath(theNode); // Dive into library to selected node SubsonicItem thisItem = Subsonic.MyLibrary; while (nodePath.Count > 0) { thisItem = thisItem.GetChildByName(nodePath.Dequeue()); } return(thisItem); }
private void OnBtnRemoveClicked(object sender, EventArgs args) { //remove the selected node HTreeNode node = tree.SelectedNode; if (node != null) { if (node.ParentNode == null) { tree.Nodes.Remove(node); } else { node.ParentNode.Nodes.Remove(node); } } }
private void OnBtnAddClicked(object sender, EventArgs args) { //make a icon from a stock image Gdk.Pixbuf icon = GraphUtil.pixbufFromStock("gtk-yes", IconSize.Button); //create the new node HTreeNode node = new HTreeNode("new node!", icon); //check if there is a node selected HTreeNode selected_node = tree.SelectedNode; //if no node is selected, add the new node directly to the base if (selected_node == null) { tree.Nodes.Add(node); } else { selected_node.Nodes.Add(node); } }
private Queue <string> GetNodePath(HTreeNode theNode) { // Create a queue that will hold the name of all parent objects Queue <string> nodePath; if (theNode.ParentNode != null) { // If this node has a parent, then recurse nodePath = GetNodePath(theNode.ParentNode); } else { // If the praent, then initialize the path nodePath = new Queue <string>(); } // Add enqueue this item in the path nodePath.Enqueue(theNode.Text); return(nodePath); }
protected virtual void OnBtnLogin2Clicked(object sender, System.EventArgs e) { string server = tbServer.Text; string user = tbUsername.Text; string passw0rdd = tbPaassw0rd.Text; string loginResult = Subsonic.LogIn(server, user, passw0rdd); Console.WriteLine("Login Result: " + loginResult); SubsonicItem thisLibrary = Subsonic.MyLibrary; foreach (SubsonicItem artist in thisLibrary.children) { HTreeNode artistNode = new HTreeNode(artist.name); tvLibrary.Nodes.Add(artistNode); // Adding a dummy node for the artist artistNode.Nodes.Add(new HTreeNode("")); } }
void tvLibraryNodeExpanded(object sender, NodeEventArgs args) { // Fetch any items inside the node... HTreeNode thisNode = args.Node; // Check to see if it has any children if (thisNode.Nodes.Count == 1 && thisNode.Nodes[0].Text == "") { // Node child is a dummy thisNode.Nodes[0].Text = "Loading..."; // Get path to the selected node to expandsimp Queue <string> nodePath = GetNodePath(thisNode); // Dive into library to selected node SubsonicItem thisItem = Subsonic.MyLibrary; while (nodePath.Count > 0) { thisItem = thisItem.GetChildByName(nodePath.Dequeue()); } // Should now have the correct selected item foreach (SubsonicItem child in thisItem.children) { HTreeNode childNode = new HTreeNode(child.name); thisNode.Nodes.Add(childNode); // Adding a dummy node for any Folders if (child.itemType == SubsonicItem.SubsonicItemType.Folder) { childNode.Nodes.Add(new HTreeNode("")); } } // Remove dummy node thisNode.Nodes.RemoveAt(0); } }