private void tvClassifications_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e) { classTreeNode ctn = e.Node as classTreeNode; if (ctn != null && !ctn.FilledIn) { Cursor.Current = Cursors.WaitCursor; PopulateClassNode(ctn); Cursor.Current = Cursors.Default; } }
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 ArrayList BuildClassificationTree(MOG_Project proj) { ArrayList nodeList = new ArrayList(); foreach (string rootName in proj.GetRootClassificationNames()) { classTreeNode rootNode = BuildClassificationTree_Helper(rootName, proj); nodeList.Add(rootNode); } return(nodeList); }
private void tvClassifications_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { classTreeNode newSelectedNode = e.Node as classTreeNode; if (newSelectedNode != null) { this.propertyGrid.SelectedObject = newSelectedNode.props; // MIGRATION: this caused a warning // if (newSelectedNode.IsNewClass) // newSelectedNode = newSelectedNode; } }
private void PopulateNode(classTreeNode ctn) { if (ctn != null) { if (ctn.props == null) { // need to get a brand new props if (ctn.IsAssetFilenameNode) { // Get a new properties that we can edit ctn.props = MOG_Properties.OpenFileProperties(new MOG_PropertiesIni()); // Load its inherited properties ctn.props.PopulateInheritance(new MOG_Filename(ctn.FullPath).GetAssetClassification()); // Make sure we trigger the propertyGrid to redisplay this new props this.propertyGrid.SelectedObject = ctn.props; } else { // Get the classification's properties that we can edit ctn.props = MOG_Properties.OpenClassificationProperties(ctn.FullPath); ctn.props.SetImmeadiateMode(true); // build synctargetpath if (ctn.assetTreeNode != null && ctn.assetTreeNode.FileFullPath != "") // "" indicates don't set sync data path { string syncDataPath = ctn.assetTreeNode.FileFullPath; if (syncDataPath.ToLower().StartsWith(this.projectRootPath.ToLower())) { syncDataPath = syncDataPath.Substring(this.projectRootPath.Length).Trim("\\".ToCharArray()); } ctn.props.SyncTargetPath = syncDataPath; } // Make sure we trigger the propertyGrid to redisplay this new props this.propertyGrid.SelectedObject = ctn.props; } // // mark node as populated // ctn.FilledIn = true; } else { // need to update the existing props if (ctn.props.PopulateInheritance()) { // Make sure we trigger the propertyGrid to redisplay this updated props this.propertyGrid.SelectedObject = ctn.props; } } } }
private void PopulateClassNodeProps(classTreeNode ctn) { if (ctn != null) { // Get the classification's properties that we can edit ctn.props = MOG_Properties.OpenClassificationProperties(ctn.FullPath); ctn.props.SetImmeadiateMode(true); this.propertyGrid.SelectedObject = ctn.props; // MIGRATION: this code was a warning - JWW // if (ctn.IsNewClass) // ctn = ctn; } }
private void tvClassifications_MouseDown2(object sender, System.Windows.Forms.MouseEventArgs e) { classTreeNode newSelectedNode = this.tvClassifications.GetNodeAt(e.X, e.Y) as classTreeNode; if (newSelectedNode == null) { return; } this.tvClassifications.SelectedNodes.Clear(); this.tvClassifications.SelectedNodes.Add(newSelectedNode); PopulateClassNodeProps(newSelectedNode); }
// helps CountClassifications() private int CountClassifications_helper(classTreeNode tn) { int count = 0; if (!tn.IsAssetFilenameNode) { count = 1; // count tn } foreach (classTreeNode subNode in tn.Nodes) { count += CountClassifications_helper(subNode); } return(count); }
private void CreateAllExtantClasses_Helper(MOG_Project proj, classTreeNode ctn) { if (ctn == null || ctn.TreeView == null) { return; } string fullClass = ctn.FullPath.Replace(ctn.TreeView.PathSeparator, "~"); proj.ClassificationAdd(fullClass); foreach (classTreeNode subNode in ctn.Nodes) { CreateAllExtantClasses_Helper(proj, subNode); } }
// remove a class node private void RemoveClassificationNode(classTreeNode node) { if (node == null || node.TreeView == null) { return; } if (ClassTreeContainsAssets(node.FullPath)) { // can't remove it because it's got children ProjectConfigUtils.ShowMessageBoxExclamation("This Classification cannot be removed becuase it or its Subclassifications contain Assets.\nThese Assets must be removed before the Classification can be deleted.\nYou can use the 'Generate Report' feature in the MOG Client to remove this Classification's Assets.", "Unable to Remove Classification"); return; } // make sure they know what they're doing if (ProjectConfigUtils.ShowMessageBoxConfirmation("Are you sure you want to remove this Classification and all its Subclassifications (if any)?", "Confirm Classification Removal") != DialogResult.Yes) { return; } if (this.immediateMode) { // kill it no matter what MOG_ControllerProject.GetProject().ClassificationRemove(node.FullPath); node.Remove(); return; } if (node.IsNewClass) { // this is a new node, so it hasn't been saved to the DB yet -- so just remove its node and that's that node.Remove(); if (this.newClasses.Contains(node)) { this.newClasses.Remove(node); } } else { // add it to the remove list so we'll remove it from the databse/INIs node.props.Classification = node.FullPath; this.removedClasses.Add(node); node.Remove(); } }
protected override void AddClassificationNode(classTreeNode parentNode) { if (parentNode == null) { if (this.tvClassifications.Nodes.Count > 0) { parentNode = this.tvClassifications.Nodes[0] as classTreeNode; } else { return; } } if (!parentNode.IsAssetFilenameNode) { base.AddClassificationNode(parentNode); } }
public void LoadAssetTree(TreeNodeCollection nodes) { this.sourceNodes = nodes; this.tvClassifications.Nodes.Clear(); this.tvClassifications.BeforeExpand += new TreeViewCancelEventHandler(tvClassifications_BeforeExpand); this.tvClassifications.MouseDown += new MouseEventHandler(tvClassifications_MouseDown); this.tvClassifications.AfterSelect += new TreeViewEventHandler(tvClassifications_AfterSelect); // populate first level foreach (AssetTreeNode atn in nodes) { classTreeNode classNode = EncodeNode(atn, null); this.tvClassifications.Nodes.Add(classNode); classNode.Expand(); } }
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; } }
private void tvClassifications_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { classTreeNode newSelectedNode = this.tvClassifications.GetNodeAt(e.X, e.Y) as classTreeNode; this.tvClassifications.SelectedNodes.Clear(); this.tvClassifications.SelectedNodes.Add(newSelectedNode); if (newSelectedNode != null) { this.propertyGrid.SelectedObject = newSelectedNode.props; //if (newSelectedNode.IsNewClass) // newSelectedNode = newSelectedNode; } else { MessageBox.Show("Selected node has no properties object"); } //if (this.tvClassifications.SelectedNodes[0] != null && this.tvClassifications.SelectedNodes[0] is classTreeNode) // this.propertyGrid.SelectedObject = ((classTreeNode)this.tvClassifications.SelectedNodes[0]).props; }
private void tvClassifications_AfterSelect(object sender, TreeViewEventArgs e) { classTreeNode ctn = e.Node as classTreeNode; PopulateNode(ctn); }
private ArrayList BuildClassTreeFromClassNames(ArrayList classNames) { ArrayList classNodes = new ArrayList(); if (classNames == null) { return(classNodes); } // now, sort them into ArrayLists based on how many tildes (~) they have int numTildes = 0; // start with no tildes (i.e., the root classifications) ArrayList classLists = new ArrayList(); while (classNames.Count > 0) { ArrayList classList = new ArrayList(); foreach (string className in classNames) { if (CountTildes(className) == numTildes) { classList.Add(className); } } // now, remove all the class names with 'numTildes' tildes from allClassNames foreach (string className in classList) { classNames.Remove(className); } // add classList to our list of lists classLists.Add(classList); ++numTildes; } // okay, now we have an ArrayList of ArrayLists, each of which contains the class names with the number of blah blah blah util_MapList nodeMap = new util_MapList(); for (int i = 0; i < classLists.Count; i++) { ArrayList classList = (ArrayList)classLists[i]; foreach (string className in classList) { if (i == 0) { // root nodes are a special case classTreeNode rootNode = new classTreeNode(className); rootNode.ImageIndex = BLUEDOT_INDEX; rootNode.SelectedImageIndex = BLUEDOT_INDEX; rootNode.ForeColor = Color.Red; nodeMap.Add(className.ToLower(), rootNode); // add so we can look up the node later by its classification classNodes.Add(rootNode); // add it to return value } else { // try to look up parent node string parentClassName = GetParentClassName(className); string classLeafName = GetLeafClassName(className); classTreeNode parentNode = nodeMap.Get(parentClassName.ToLower()) as classTreeNode; if (parentNode != null) { // if we found a parent node, add a new node representing className to it, otherwise ignore classTreeNode classNode = new classTreeNode(classLeafName); classNode.ImageIndex = ARROW_INDEX; classNode.SelectedImageIndex = ARROW_INDEX; classNode.ForeColor = Color.Red; parentNode.Nodes.Add(classNode); nodeMap.Add(className.ToLower(), classNode); // add for lookup later (to add children to this node) } } } } return(classNodes); }
private void tvClassifications_AfterSelect2(object sender, TreeViewEventArgs e) { classTreeNode newSelectedNode = e.Node as classTreeNode; PopulateClassNodeProps(newSelectedNode); }