/// <summary>The load operation data.</summary> /// <param name="libraries">The libraries.</param> /// <returns>The <see cref="TreeNode"/>.</returns> public List<TreeNode> LoadOperationData(List<string> libraries) { var nodes = new List<TreeNode>(); // Iterate all libraries foreach (var lib in libraries) { FileManager.New(false); if (FileManager.Open(lib)) { var operations = SearchManager.GetOperations(); if (operations.Any()) { var library = new TreeNode(lib) { Tag = "library" }; // Only supported operations and those with a valid tool foreach (var operation in operations.Where(operation => this.OperationTypeSupported(operation.Type) & operation.OperationTool != null)) { var thisOperation = new MastercamOperation { Operation = operation, Path = Path.GetFullPath(lib), OperationType = operation.Type, Name = Path.GetFileName(lib) }; var operationInformation = this.CreateOperationList(operation); var toolinformation = this.CreateToolList(operation); var index = this.GetToolIconIndex(thisOperation); var node = new TreeNode(operation.Name, index, index) { Tag = thisOperation, }; var op = new TreeNode(operation.Type.ToString(), (int)TreeIconIndex.Params, (int)TreeIconIndex.Params); var tool = new TreeNode(LocalizationStrings.Tool, (int)TreeIconIndex.MillFlat, (int)TreeIconIndex.MillFlat); op.Nodes.AddRange(operationInformation.ToArray()); tool.Nodes.AddRange(toolinformation.ToArray()); node.Nodes.Add(op); node.Nodes.Add(tool); library.Nodes.Add(node); } nodes.Add(library); } } } return nodes.Any() ? nodes : null; }
/// <summary>Loads a strategy object into the Levels tree</summary> /// <param name="strategy">The strategy to load</param> /// <returns>The <see cref="TreeNode"/> tree nodes collection</returns> public List<TreeNode> LoadStrategyData(Strategy strategy) { var nodes = new List<TreeNode>(); foreach (var mapping in strategy.MappedLevels) { var lib = mapping.Library; if (File.Exists(lib)) { FileManager.New(false); if (FileManager.Open(lib)) { var operations = SearchManager.GetOperations(); if (operations.Any()) { var name = mapping.Comment; var level = new TreeNode(mapping.Level) { Tag = "level" }; var operation = OperationsManager.ImportOperation(lib, name, false); if (operation != null) { var thisOperation = new MastercamOperation { Operation = operation, Path = Path.GetFullPath(lib), OperationType = operation.Type, Name = Path.GetFileName(lib) }; var operationInformation = this.CreateOperationList(operation); var toolinformation = this.CreateToolList(operation); var index = this.GetToolIconIndex(thisOperation); var node = new TreeNode(operation.Name, index, index) { Tag = thisOperation, }; var op = new TreeNode(operation.Type.ToString(), (int)TreeIconIndex.Params, (int)TreeIconIndex.Params); var tool = new TreeNode(LocalizationStrings.Tool, (int)TreeIconIndex.MillFlat, (int)TreeIconIndex.MillFlat); op.Nodes.AddRange(operationInformation.ToArray()); tool.Nodes.AddRange(toolinformation.ToArray()); node.Nodes.Add(op); node.Nodes.Add(tool); level.Nodes.Add(node); nodes.Add(level); } } } } } return nodes.Any() ? nodes : null; }