public IEnumerable <ElementNode> GenerateElements(IEnumerable <ElementNode> selectedNodes = null) { List <ElementNode> result = new List <ElementNode>(); if (treename.Length == 0) { Logging.Error("starburst is null"); return(result); } if (stringcount < 0) { Logging.Error("negative count"); return(result); } if (pixeltree && pixelsperstring < 0) { Logging.Error("negative pixelsperstring"); return(result); } //Optimize the name check for performance. We know we are going to create a bunch of them and we can handle it ourselves more efficiently HashSet <string> elementNames = new HashSet <string>(VixenSystem.Nodes.Select(x => x.Name)); ElementNode head = ElementNodeService.Instance.CreateSingle(null, TemplateUtilities.Uniquify(elementNames, treename), true, false); result.Add(head); for (int i = 0; i < stringcount; i++) { string stringname = head.Name + " S" + (i + 1); ElementNode stringnode = ElementNodeService.Instance.CreateSingle(head, TemplateUtilities.Uniquify(elementNames, stringname), true, false); result.Add(stringnode); if (pixeltree) { for (int j = 0; j < pixelsperstring; j++) { string pixelname = stringnode.Name + " Px" + (j + 1); ElementNode pixelnode = ElementNodeService.Instance.CreateSingle(stringnode, TemplateUtilities.Uniquify(elementNames, pixelname), true, false); result.Add(pixelnode); } } } return(result); }
public IEnumerable <ElementNode> GenerateElements(IEnumerable <ElementNode> selectedNodes = null) { List <ElementNode> result = new List <ElementNode>(); if (groupname.Length == 0) { Logging.Error("groupname is null"); return(result); } if (prefix.Length == 0) { Logging.Error("prefix is null"); return(result); } if (count < 0) { Logging.Error("negative count"); return(result); } // changed my mind; always make the group at the root level. //ElementNode parent = null; //if (selectedNodes != null) { // parent = selectedNodes.First(); // if (selectedNodes.Count() > 0) { // Logging.Warn("multiple parent nodes selected; creating new nodes under first parent: " + parent.Name); // } //} //Optimize the name check for performance. We know we are going to create a bunch of them and we can handle it ourselves more efficiently HashSet <string> elementNames = new HashSet <string>(VixenSystem.Nodes.Select(x => x.Name)); ElementNode grouphead = ElementNodeService.Instance.CreateSingle(null, TemplateUtilities.Uniquify(elementNames, groupname), true, false); result.Add(grouphead); for (int i = 0; i < count; i++) { string newname = prefix + "-" + (i + 1); ElementNode newnode = ElementNodeService.Instance.CreateSingle(grouphead, TemplateUtilities.Uniquify(elementNames, newname), true, false); result.Add(newnode); } return(result); }
public IEnumerable <ElementNode> GenerateElements(IEnumerable <ElementNode> selectedNodes = null) { List <ElementNode> result = new List <ElementNode>(); if (gridname.Length == 0) { Logging.Error("gridname is null"); return(result); } if (rows < 0) { Logging.Error("negative rows"); return(result); } if (columns < 0) { Logging.Error("negative columns"); return(result); } //Optimize the name check for performance. We know we are going to create a bunch of them and we can handle it ourselves more efficiently HashSet <string> elementNames = new HashSet <string>(VixenSystem.Nodes.Select(x => x.Name)); ElementNode head = ElementNodeService.Instance.CreateSingle(null, TemplateUtilities.Uniquify(elementNames, gridname), true, false); result.Add(head); int firstlimit, secondlimit; string firstprefix, secondprefix; if (rowsfirst) { firstlimit = rows; secondlimit = columns; firstprefix = " R"; secondprefix = " C"; } else { firstlimit = columns; secondlimit = rows; firstprefix = " C"; secondprefix = " R"; } for (int i = 0; i < firstlimit; i++) { string firstname = head.Name + firstprefix + (i + 1); ElementNode firstnode = ElementNodeService.Instance.CreateSingle(head, TemplateUtilities.Uniquify(elementNames, firstname), true, false); result.Add(firstnode); for (int j = 0; j < secondlimit; j++) { string secondname = firstnode.Name + secondprefix + (j + 1); ElementNode secondnode = ElementNodeService.Instance.CreateSingle(firstnode, TemplateUtilities.Uniquify(elementNames, secondname), true, false); result.Add(secondnode); } } return(result); }