private classTreeNode BuildClassificationTree_Helper(string className, MOG_Project proj) { // create a new class treenode classTreeNode classNode = new classTreeNode(className.Substring(className.LastIndexOf("~") + 1)); // extract only last part of the name foreach (string subclassName in proj.GetSubClassificationNames(className)) { classNode.Nodes.Add(BuildClassificationTree_Helper(className + "~" + subclassName, proj)); } return(classNode); }
private imTreeNode LoadProjectClasses_Helper(MOG_Project proj, string baseClass) { string baseClassName = baseClass; if (baseClassName.IndexOf("~") != -1) { baseClassName = baseClass.Substring(baseClass.LastIndexOf("~") + 1); } imTreeNode node = new imTreeNode(baseClassName, "class"); foreach (string className in proj.GetSubClassificationNames(baseClass)) { node.Nodes.Add(LoadProjectClasses_Helper(proj, baseClass + "~" + className)); } return(node); }
public void LoadProjectClassifications2(MOG_Project proj) { if (proj != null) { this.tvClassifications.Nodes.Clear(); this.newClasses.Clear(); this.imageList = new ImageList(); this.imageArrayList = new ArrayList(); this.tvClassifications.Enabled = true; foreach (string rootClassName in proj.GetRootClassificationNames()) { classTreeNode rootClassNode = new classTreeNode(rootClassName); if (proj.GetSubClassificationNames(rootClassName).Count > 0) { rootClassNode.Nodes.Add(new classTreeNode("DUMMY_NODE")); } this.tvClassifications.Nodes.Add(rootClassNode); } // setup events this.tvClassifications.MouseDown -= new MouseEventHandler(tvClassifications_MouseDown); this.tvClassifications.MouseDown += new MouseEventHandler(tvClassifications_MouseDown2); this.tvClassifications.AfterSelect += new TreeViewEventHandler(tvClassifications_AfterSelect2); this.tvClassifications.BeforeExpand += new TreeViewCancelEventHandler(tvClassifications_BeforeExpand); // expand the first level of nodes foreach (TreeNode tn in this.tvClassifications.Nodes) { tn.Expand(); } } else { // disable everything this.tvClassifications.Nodes.Add(new classTreeNode("<NO CURRENT PROJECT>")); this.tvClassifications.Enabled = false; } }
// recursively check baseClass to see if it or any of its child classes contain assets private bool ClassTreeContainsAssets(string baseClass) { if (MOG_DBAssetAPI.GetAllAssetsByClassification(baseClass).Count > 0) { return(true); } // recurse by looking up child classes MOG_Project proj = MOG_ControllerProject.GetProject(); if (proj != null) { foreach (string className in proj.GetSubClassificationNames(baseClass)) { if (ClassTreeContainsAssets(baseClass + "~" + className)) { return(true); } } } return(false); }