internal override void OnMemberLeft(Address mbr, NodeIdentity identity) { PartNodeInfo partNodeInfo = new PartNodeInfo(mbr, identity.SubGroupName, false); _existingMembers.Remove(partNodeInfo.NodeAddress); _subGroupMap.Remove(partNodeInfo.NodeAddress); ArrayList groupNodes = (ArrayList)_partitionNodesInfo[partNodeInfo.SubGroup]; PartNodeInfo coordinator; if (groupNodes != null) { if (groupNodes.Contains(partNodeInfo)) { groupNodes.Remove(partNodeInfo); if (groupNodes.Count > 0) { coordinator = (PartNodeInfo)groupNodes[0]; coordinator.IsCoordinator = true; if (!_existingMembers.Contains(coordinator.NodeAddress)) { _existingMembers.Add(coordinator.NodeAddress); } } else { _partitionNodesInfo.Remove(partNodeInfo.SubGroup); } } } }
// Adds child Sketch nodes to treeView1 node, given a TreeNode private void AddSketchesToPartNode(TreeNode partNode) { PartNodeInfo pNodeInfo = (PartNodeInfo)partNode.Tag; // Retrieve the custom NodeInfo class from the node's Tag object ModelDoc2 currentModel = default(ModelDoc2); currentModel = GetSolidworksModelFromFile(pNodeInfo.FilePath); List <Feature> listOfSketches = new List <Feature>(); listOfSketches = EnumerateSketchesInSolidworksPart(currentModel); if (listOfSketches == null) { ShowNonFatalError("Failed to get sketches from part '" + pNodeInfo.FileName + "'"); return; } var sketchNode = new TreeNode(); for (int i = 0; i < listOfSketches.Count; i++) { SketchNodeInfo sNodeInfo = new SketchNodeInfo(pNodeInfo, listOfSketches[i], i); // A custom class (ie. NodeInfo) to track the heirarchy of the Nodes sketchNode = new TreeNode(sNodeInfo.Name); // Make the Node title the file's name sketchNode.Tag = sNodeInfo; partNode.Nodes.Add(sketchNode); // Add this child file node under the student folder node } }
internal override void OnMemberJoined(Address mbr, NodeIdentity identity) { ArrayList partitionNodes; PartNodeInfo partNodeInfo = new PartNodeInfo(mbr, identity.SubGroupName, false); //assuming existing members doesnot contain the newly added member. if (!_partitionNodesInfo.ContainsKey(partNodeInfo.SubGroup)) { partitionNodes = new ArrayList(); partNodeInfo.IsCoordinator = true; partitionNodes.Add(partNodeInfo); _subGroupMap[partNodeInfo.NodeAddress] = partNodeInfo.SubGroup; _partitionNodesInfo.Add(partNodeInfo.SubGroup, partitionNodes); base.OnMemberJoined(mbr, identity); } else { partitionNodes = (ArrayList)_partitionNodesInfo[partNodeInfo.SubGroup]; if (!partitionNodes.Contains(partNodeInfo)) { partitionNodes.Add(partNodeInfo); _subGroupMap[partNodeInfo.NodeAddress] = partNodeInfo.SubGroup; } } }
private bool IsLastNodeInPartition(PartNodeInfo nInfo) { ArrayList groupNodes = (ArrayList)_partitionNodesInfo[nInfo.SubGroup]; if (groupNodes.Count == 1) { return(true); } return(false); }
// Opens a Solidworks part, given a part TreeNode private bool OpenPartFromNode(TreeNode partNode) { // Gets the current part's name (if open), to break if new part is already open ModelDoc2 currentPart = default(ModelDoc2); currentPart = swApp.IActiveDoc2; string currentPartName; if (currentPart == null) { currentPartName = ""; } else { currentPartName = currentPart.GetTitle(); } // Get custom PartNodeInfo object from this node PartNodeInfo pNodeInfo = (PartNodeInfo)partNode.Tag; string fileName = pNodeInfo.FileName; // Exit if same part is already open if (fileName == currentPartName) { Console.WriteLine("Part is already opened. Skipping PartOpen."); currentModel = currentPart; // Exit out of any opened sketches if (currentModel.SketchManager.ActiveSketch != null) { currentModel.InsertSketch2(true); } return(true); } // Close current part and open new part Console.WriteLine("Opening student {0}'s part file: '{1}'.", pNodeInfo.Student.Name, fileName); CloseCurrentPart(); ModelDoc2 newPart = default(ModelDoc2); newPart = GetSolidworksModelFromFile(pNodeInfo.FilePath); if (newPart == null) // Opens up the new part { Console.WriteLine("Failed to open part file '{0}'", fileName); return(false); } currentModel = newPart; Console.WriteLine("Opened part successfully."); ExpandAllSolidworksFeaturesInTree(newPart); return(true); }
// Lets check if the node to be removed is co-orinator or not private bool IsCoordinatorNodeInPartition(PartNodeInfo nInfo) { ArrayList groupNodes = (ArrayList)_partitionNodesInfo[nInfo.SubGroup]; PartNodeInfo temp = (PartNodeInfo)groupNodes[0]; if (temp.NodeAddress.Equals(nInfo.NodeAddress)) { nInfo.IsCoordinator = true; return(true); } return(false); }
public SketchNodeInfo(PartNodeInfo partNodeInfo, Feature sketchFeature, int sketchIndex) : base(partNodeInfo.Student, partNodeInfo.PartIndex) { NodeLevel = "Sketch"; SketchIndex = sketchIndex; ConstrainedString = "??"; if (sketchFeature != null) { ConstrainedString = ConvertConstrainedToString(sketchFeature.GetSpecificFeature2().GetConstrainedStatus()); SketchName = sketchFeature.Name; } Name = ConstrainedString + " " + SketchName; }
// Fill the TreeView control with each student folder and their .SLDPRT files private void PopulateTreeViewWithStudents() { treeView1.Nodes.Clear(); StudentInfo student; var rootNode = new TreeNode(new DirectoryInfo(rootDirectory).Name); // Get node name from rootDirectory folder name (from path) NodeInfo nodeInfo = new NodeInfo("Root"); // A custom class (ie. NodeInfo) to track the heirarchy of the Nodes nodeInfo.FolderPath = rootDirectory; rootNode.Tag = nodeInfo; // Loop through all student folders in root directory for (int i = 0; i < numSubmissions; i++) { student = listOfStudents[i]; StudentNodeInfo folderNodeInfo = new StudentNodeInfo(student); // A custom class (ie. NodeInfo) to track the heirarchy of the Nodes student.NodeInfo = folderNodeInfo; // Assign each student it's position in the tree (ie. using studentIndex = i) var childFolderNode = new TreeNode(folderNodeInfo.Name); // Make a new child node with text = Student's name childFolderNode.Tag = folderNodeInfo; // Store NodeInfo in this Node's Tag object (retrieve later by casting Tag to NodeInfo) rootNode.Nodes.Add(childFolderNode); // Add this child student folder node under the root node // Loop through all files in current student folder for (int j = 0; j < student.NumFiles; j++) { PartNodeInfo fileNodeInfo = new PartNodeInfo(student, j); // A custom class (ie. NodeInfo) to track the heirarchy of the Nodes var childFileNode = new TreeNode(fileNodeInfo.Name); // Make the Node title the file's name childFileNode.Tag = fileNodeInfo; childFolderNode.Nodes.Add(childFileNode); // Add this child file node under the student folder node } } treeView1.Nodes.Add(rootNode); PrintAllNodeTags(rootNode); }