//------------------------------------------------------------------------------------ /// <summary> /// Given a treeID for this product's feature tree, returns the full path for that /// tree node. /// </summary> //------------------------------------------------------------------------------------ public virtual string GetTreePath(int treeID, ProductTreeFormat treeFormat) { DatastoreItemList storeItemList = GetStoreItemList(); if (storeItemList != null) { ProductStudio.PsCoreTreeTypeEnum treeType = ProductStudio.PsCoreTreeTypeEnum.psCoreTreeTypeProduct; ProductStudio.Node rootNode = storeItemList.Datastore.get_RootNodeEx(treeType); ProductStudio.Node currNode = rootNode.FindNodeInSubtree(treeID); List <string> nodeNames = new List <string>(); while (currNode != null && currNode.ID > 1) { nodeNames.Insert(0, currNode.Name); currNode = currNode.Parent; } string fullPath = treeFormat == ProductTreeFormat.IncludeProduct ? StoreID.Name : ""; foreach (string name in nodeNames) { fullPath += "\\" + name; } return(fullPath); } return(null); }
//------------------------------------------------------------------------------------ /// <summary> /// Returns the complete product tree for the current product. The root will have /// parent id = -200. The returned tree is a depth-first representation of the product /// hierarchy. /// </summary> //------------------------------------------------------------------------------------ public virtual void PopulateTree(TreeView treeView, int startingTreeID) { DatastoreItemList storeItemList = GetStoreItemList(); if (storeItemList != null) { ProductStudio.PsCoreTreeTypeEnum treeType = ProductStudio.PsCoreTreeTypeEnum.psCoreTreeTypeProduct; ProductStudio.Node rootNode = storeItemList.Datastore.get_RootNodeEx(treeType); ProductAreaTree tree = new ProductAreaTree(rootNode); tree.PopulateTree(treeView, startingTreeID); } }
public List <int> GetTreeIDChildNodes(int treeID) { List <int> nodes = new List <int>(); nodes.Add(treeID); DatastoreItemList storeItemList = GetStoreItemList(); if (storeItemList != null) { ProductStudio.Node rootNode = storeItemList.Datastore.get_RootNodeEx(ProductStudio.PsCoreTreeTypeEnum.psCoreTreeTypeProduct); Node startingNode = rootNode.FindNodeInSubtree(treeID); if (startingNode != null) { AddTreeIDChildNode(startingNode, nodes); } } return(nodes); }
public bool IsItemUnderTreeID(int treeID, int itemTreeID) { if (treeID == itemTreeID) { return(true); } DatastoreItemList storeItemList = GetStoreItemList(); if (storeItemList != null) { ProductStudio.Node rootNode = storeItemList.Datastore.get_RootNodeEx(ProductStudio.PsCoreTreeTypeEnum.psCoreTreeTypeProduct); Node startingNode = rootNode.FindNodeInSubtree(treeID); if (startingNode != null) { return(IsItemUnderTreeNode(startingNode, itemTreeID)); } } return(false); }
//------------------------------------------------------------------------------------ /// <summary> /// Given a path in this store's tree hierarchy, returns the treeID for that path. If /// the path isn't found, zero will be returned. /// </summary> //------------------------------------------------------------------------------------ public int GetTreePathID(string treePath) { if (treePath == null) { return(0); } DatastoreItemList storeItemList = GetStoreItemList(); if (storeItemList == null) { return(0); } char[] trim = { '\\' }; treePath = treePath.Trim(trim); ProductStudio.Node currentNode = storeItemList.Datastore.get_RootNodeEx(ProductStudio.PsCoreTreeTypeEnum.psCoreTreeTypeProduct); string[] pathNodes = treePath.Split('\\'); foreach (string pathNode in pathNodes) { bool foundNode = false; foreach (Node node in currentNode.Nodes) { if (node.Name == pathNode) { currentNode = node; foundNode = true; break; } } if (!foundNode) { return(0); } } return(currentNode.ID); }