public void AddRange( HTreeNode[] nodes ) { foreach( HTreeNode node in nodes ) { this.Add( node ); } }
private void buildNode(HTreeNode node) { String path = getPathFromNode(node); DirectoryInfo di = new DirectoryInfo(path); try { DirectoryInfo[] dirs = di.GetDirectories(); node.Nodes.Clear(); foreach (DirectoryInfo d in dirs) { node.Nodes.Add(new HTreeNode(d.Name, folder_icon)); } //add dummy childs foreach (HTreeNode n in node.Nodes) { n.Nodes.Add(new HTreeNode("dummy")); } } catch { node.Nodes.Clear(); Console.WriteLine("Cannot acces folder!"); } }
public void Add(HTreeNode node) { List.Add(node); if (NodeAdded != null) { NodeAdded(this, new NodeAddEventArgs(node)); } }
public void Remove(HTreeNode node) { this.List.Remove(node); if (NodeRemoved != null) { NodeRemoved(this, new NodeRemoveEventArgs(node)); } }
public virtual void OnTestCollapseRow(object sender, TestCollapseRowArgs args) { HTreeNode node = getNodeFromIter(args.Iter); if (BeforeNodeCollapse != null) { BeforeNodeCollapse(sender, new NodeEventArgs(node)); } }
public void selectNode(HTreeNode node) { //this.Selection.SelectIter( node.InnerIter ); TreePath path = Model.GetPath(node.InnerIter); this.Selection.SelectPath(path); //move cursor to selection this.SetCursor(path, this.Columns[0], false); }
protected virtual void OnFolderTreeCursorChanged(object sender, System.EventArgs e) { HTreeNode node = FolderTree.SelectedNode; if (node != null) { ChangeFatherPath(getPathFromNode(node)); } }
//checkbox cell function private void OnChkDataFunc( Gtk.TreeViewColumn col, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter ) { HTreeNode nod = getNodeFromIter(iter); CellRendererToggle c = cell as CellRendererToggle; c.Active = nod.Checked; }
protected virtual void OnFolderTreeBeforeNodeExpand(object sender, HollyLibrary.NodeEventArgs args) { HTreeNode node = args.Node; String path = getPathFromNode(node); buildNode(node); //select the expanded node FolderTree.selectNode(node); ChangeFatherPath(path); }
public virtual void OnCollapseRow(object sender, RowCollapsedArgs args) { HTreeNode nod = getNodeFromIter(args.Iter); nod.IsExpanded = false; if (NodeCollapsed != null) { NodeCollapsed(this, new NodeEventArgs(nod)); } QueueDraw(); }
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 ); } }
//text cell function private void OnTextDataFunc( Gtk.TreeViewColumn col, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter ) { //renderer node text HTreeNode nod = getNodeFromIter(iter); CellRendererCustom c = cell as CellRendererCustom; c.Text = nod.Text; c.Iter = iter; }
private string getPathFromNode(HTreeNode node) { String ret = node.Text; HTreeNode parent = node.ParentNode; while (parent != null) { ret = parent.Text + separator + ret; parent = parent.ParentNode; } ret = ret.Replace(separator + "" + separator, separator + ""); return(ret); }
private void OnTextEdited(object sender, EditedArgs args) { TreeIter iter; store.GetIter(out iter, new TreePath(args.Path)); HTreeNode node = getNodeFromIter(iter); node.Text = args.NewText; if (NodeEdited != null) { NodeEdited(this, new NodeEventArgs(node)); } }
private void SetPath(String path) { HTreeNode current_node = FolderTree.SelectedNode; String current_path = ""; if (current_node != null) { current_path = getPathFromNode(current_node); } //daca pathul este valid si diferit de ce e deja selectat, //construieste calea catre el if (Directory.Exists(path) && !path.Equals(current_path)) { FolderTree.CollapseAll(); //get drive first //TODO: check if in windows it's working String drive = path.Substring(0, path.IndexOf(separator) + 1); //then the rest of the path path = path.Substring(path.IndexOf(separator) + 1); String[] path_parts = path.Split(separator); List <String> parts = new List <String>(); parts.Add(drive); parts.AddRange(path_parts); NodeCollection nodes = FolderTree.Nodes; for (int i = 0; i < parts.Count; i++) { String node_text = parts[i]; //search the node with that text HTreeNode node = null; foreach (HTreeNode n in nodes) { if (!n.Text.Equals(node_text)) { continue; } node = n; break; } //clear nodes childs node.Nodes.Clear(); //build node childs buildNode(node); //expand node FolderTree.expandNode(node); nodes = node.Nodes; } } }
//returns a HTreeNode from an iter public HTreeNode getNodeFromIter(TreeIter iter) { HTreeNode ret = null; try { ret = store.GetValue(iter, 0) as HTreeNode; } catch { ret = null; } return(ret); }
public HTreeNode this[int index] { get { return((HTreeNode)this.List[index]); } set { HTreeNode oldnode = (HTreeNode)this.List[index]; this.List[index] = value; if (NodeUpdated != null) { NodeUpdated(this, new NodeUpdateEventArgs(oldnode, value)); } } }
private void OnKeyReleased(object sender, KeyReleaseEventArgs args) { //if selected node has children nodes, expanded or collapsed //on right/left arrow button press HTreeNode node = SelectedNode; if (node != null && node.Nodes.Count > 0) { if (args.Event.Key == Gdk.Key.Right) { expandNode(node); } else if (args.Event.Key == Gdk.Key.Left) { collapseNode(node); } } }
//icon data function private void OnIconDataFunc( Gtk.TreeViewColumn col, Gtk.CellRenderer cell, Gtk.TreeModel model, Gtk.TreeIter iter) { //get the treenode linked to the iter; HTreeNode nod = getNodeFromIter(iter); CellRendererPixbuf c = cell as CellRendererPixbuf; //if cell is expanded show opened icon, else show closed icon if (nod.OpenedIcon != null && c.IsExpanded) { c.Pixbuf = nod.OpenedIcon; } else { c.Pixbuf = nod.Icon; } }
//checkbox state changed private void OnCelltoggled(object sender, ToggledArgs args) { TreeIter iter; if (store.GetIterFromString(out iter, args.Path)) { HTreeNode nod = getNodeFromIter(iter); nod.Checked = !nod.Checked; //(de)select all childs if (nod.Checked) { nod.selectAllChilds(); } else { nod.deselectAllChilds(); } } }
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("")); } }
protected override bool OnButtonPressEvent(Gdk.EventButton evnt) { if (evnt.Button == 3) { //get path at current mouse position TreePath path; this.GetPathAtPos((int)evnt.X, (int)evnt.Y, out path); //get iter from path TreeIter iter; store.GetIter(out iter, path); if (NodeRightClick != null) { //get node from iter HTreeNode node = getNodeFromIter(iter); //raise event NodeRightClick(this, new NodeEventArgs(node)); } } return(base.OnButtonPressEvent(evnt)); }
protected virtual void OnBtnNewFolderClicked(object sender, System.EventArgs e) { //add new folder here HTreeNode node = FolderTree.SelectedNode; Console.WriteLine(node.Text); String name = TxtNewFolder.Text.Trim(); if (node != null && !name.Equals("")) { String path = getPathFromNode(node); path += separator + name; try { Directory.CreateDirectory(path); node.Nodes.Add(new HTreeNode(name, folder_icon)); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
private string getPathFromNode( HTreeNode node ) { String ret = node.Text; HTreeNode parent = node.ParentNode; while( parent != null ) { ret = parent.Text + separator + ret; parent = parent.ParentNode; } ret = ret.Replace( separator + "" + separator,separator + ""); return ret; }
private void buildNode( HTreeNode node ) { String path = getPathFromNode(node); DirectoryInfo di = new DirectoryInfo( path ); try { DirectoryInfo[] dirs = di.GetDirectories(); node.Nodes.Clear(); foreach( DirectoryInfo d in dirs ) { node.Nodes.Add( new HTreeNode( d.Name, folder_icon ) ); } //add dummy childs foreach( HTreeNode n in node.Nodes ) { n.Nodes.Add( new HTreeNode("dummy") ); } } catch { node.Nodes.Clear(); Console.WriteLine("Cannot acces folder!"); } }
public bool Contains(HTreeNode node) { return(this.List.Contains(node)); }
public int IndexOf( HTreeNode node) { return this.List.IndexOf(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; }
public void selectNode( HTreeNode node ) { //this.Selection.SelectIter( node.InnerIter ); TreePath path = Model.GetPath( node.InnerIter ); this.Selection.SelectPath( path ); //move cursor to selection this.SetCursor( path, this.Columns[0], false ); }
public void collapseNode(HTreeNode node) { TreePath path = this.Model.GetPath(node.InnerIter); CollapseRow(path); }
public void expandNode(HTreeNode node) { TreePath path = this.Model.GetPath(node.InnerIter); ExpandToPath(path); }
public int IndexOf(HTreeNode node) { return(this.List.IndexOf(node)); }
public void Add(HTreeNode node) { List.Add(node); if( NodeAdded != null ) NodeAdded( this, new NodeAddEventArgs( node ) ); }
public bool Contains(HTreeNode node) { return this.List.Contains(node); }
public NodeRemoveEventArgs( HTreeNode node ) { this.node = node; }
public void collapseNode( HTreeNode node ) { TreePath path = this.Model.GetPath( node.InnerIter ); CollapseRow( path ); }
public void expandNode( HTreeNode node ) { TreePath path = this.Model.GetPath( node.InnerIter ); ExpandToPath( path ); }
public NodeUpdateEventArgs(HTreeNode old_node, HTreeNode new_node) { this.old_node = old_node; this.new_node = 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; }
public NodeAddEventArgs(HTreeNode val) { this.val = val; }
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); } }
public NodeRemoveEventArgs(HTreeNode node) { this.node = node; }
public NodeAddEventArgs( HTreeNode val ) { this.val = val; }
public void Remove( HTreeNode node ) { this.List.Remove(node); if( NodeRemoved != null ) NodeRemoved( this, new NodeRemoveEventArgs( node ) ); }
public NodeUpdateEventArgs( HTreeNode old_node, HTreeNode new_node ) { this.old_node = old_node; this.new_node = new_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 ); }