/// <summary> /// Recursively adds a collection of directories to the treeview. /// </summary> /// <param name="directoryLookup">A cache of all the PhotoDirectory objects.</param> /// <param name="dirBrowser">A reference to a DirectoryBrowser object.</param> /// <param name="dirs">A collection of PhotoDirectory objects.</param> /// <param name="parentNode">A reference to the parent tree node object, or null if at the root of the tree view.</param> private void addDirectoryNodes(Hashtable directoryLookup, DirectoryBrowser dirBrowser, PhotoDirectories dirs, squishyWARE.WebComponents.squishyTREE.TreeNode parentNode) { IEnumerator enumerator = dirs.GetEnumerator(); while (enumerator.MoveNext()) { PhotoDirectory dir = (PhotoDirectory)enumerator.Current; squishyWARE.WebComponents.squishyTREE.TreeNode node; if (parentNode == null) { node = tvwMain.AddNode(HttpUtility.HtmlEncode(dir.Name), dir.Id.ToString()); } else { node = parentNode.AddNode(HttpUtility.HtmlEncode(dir.Name), dir.Id.ToString()); } addDirectoryNodes(directoryLookup, dirBrowser, dir.GetDirectories(), node); if (!directoryLookup.Contains(dir.Id)) { directoryLookup.Add(dir.Id, dir); } } }
private void addChildNode(XmlNode node, string textAttribute, string keyAttribute, TreeNode tNode, string checkAttribute, string checkDefaultsAttribute) { string text; string key = ""; bool checkbox = false; bool isChecked = false; text = node.Attributes[textAttribute].Value; if (node.Attributes[keyAttribute] != null) { key = node.Attributes[keyAttribute].Value; } if (node.Attributes[checkAttribute] != null) { checkbox = Convert.ToBoolean(node.Attributes[checkAttribute].Value); } if (node.Attributes[checkDefaultsAttribute] != null) { isChecked = Convert.ToBoolean(node.Attributes[checkDefaultsAttribute].Value); } TreeNode n; if (tNode == null) { //add to the TreeView n = this.AddNode(text, key, checkbox); } else { //add to the TreeNode n = tNode.AddNode(text, key, checkbox); } //get the tagged values XmlNodeList taggedValues = node.SelectNodes("taggedValue"); int tagCount = 0; foreach (XmlNode tg in taggedValues) { tagCount++; string tagName = tg.Attributes["tagName"].Value; string tagValue = tg.Attributes["tagValue"].Value; n.AddTaggedValue(tagName, tagValue); } if (node.ChildNodes.Count - tagCount > 0) { //add the child nodes of this node foreach (XmlNode child in node.ChildNodes) { if (child.Name != "taggedValue") { this.addChildNode(child, textAttribute, keyAttribute, n, checkAttribute, checkDefaultsAttribute); } } } if (checkDefaultsAttribute != "" && node.Attributes[checkDefaultsAttribute] != null && node.Attributes[checkDefaultsAttribute].Value.Trim() != "") { if (!this.Page.IsPostBack) { n.Check(isChecked); } } }
private void AddChildNode(DataRow row, string textColumn, string keyColumn, string checkColumn, string checkDefaultsColumn, TreeNode node) { string text; string key; bool checkbox = false; bool isChecked = false; text = row[textColumn].ToString(); key = row[keyColumn].ToString(); if (checkColumn != "") { if (row[checkColumn] != DBNull.Value) { checkbox = Convert.ToBoolean(row[checkColumn]); } if (row[checkDefaultsColumn] != DBNull.Value) { isChecked = Convert.ToBoolean(row[checkDefaultsColumn]); } } TreeNode n; if (node == null) { //add to the treeview n = this.AddNode(text, key, checkbox); } else { //add to the node n = node.AddNode(text, key, checkbox); } //now add the tagged values if (this.headers.Count != 0) { foreach (object[] o in this.headers) { //only add the tagged value if this row contains the column in question if (row.Table.Columns.Contains(o[0].ToString())) { //o[0] is the column name n.AddTaggedValue(o[0].ToString(), row[o[0].ToString()].ToString()); } } } //now look for child rows if (row.Table.ChildRelations.Count > 0) { foreach (DataRelation r in row.Table.ChildRelations) { DataRow[] childRows = row.GetChildRows(r); foreach (DataRow childRow in childRows) { this.AddChildNode(childRow, textColumn, keyColumn, checkColumn, checkDefaultsColumn, n); } } } if (checkbox) { if (!this.Page.IsPostBack) { n.Check(isChecked); } } }