/// <summary> /// Defines a new NodeGroup which will be shown in the node explorer. /// </summary> /// <param name="name">The displayed name of the group.</param> /// <param name="icon">The displayed icon of the group and its children.</param> /// <param name="parent">The parent of the group, can be null.</param> public NodeGroup(string name, NodeIcon icon, NodeGroup parent) { _name = name; _icon = icon; if (parent != null) { parent.Children.Add(this); } }
private static void initFrequentlyUsedNodeGroup() { _frequentlyUsedNodeGroups.Clear(); NodeGroup group = new NodeGroup(Resources.Attachments, NodeIcon.FolderClosed, null); _frequentlyUsedNodeGroups.Add(group); group = new NodeGroup(Resources.Conditions, NodeIcon.FolderClosed, null); _frequentlyUsedNodeGroups.Add(group); group = new NodeGroup(Resources.Actions, NodeIcon.FolderClosed, null); _frequentlyUsedNodeGroups.Add(group); group = new NodeGroup(Resources.Composites, NodeIcon.FolderClosed, null); _frequentlyUsedNodeGroups.Add(group); group = new NodeGroup(Resources.Decorators, NodeIcon.FolderClosed, null); _frequentlyUsedNodeGroups.Add(group); }
private static void copyNodeItems(NodeGroup source, NodeGroup target) { foreach(NodeItem nodeItem in source.Items) { if (nodeItem.Type != null && Plugin.FrequentlyUsedNodes.Contains(nodeItem.Type.FullName)) { target.Items.Add(nodeItem); } } foreach(NodeGroup nodeGroup in source.Children) { copyNodeItems(nodeGroup, target); } }
public static void SetFrequentlyUsedNodeGroups() { initFrequentlyUsedNodeGroup(); foreach(NodeGroup nodeGroup in _nodeGroups) { NodeGroup group = null; foreach(NodeGroup fuNodeGroup in _frequentlyUsedNodeGroups) { if (fuNodeGroup.Name == nodeGroup.Name) { group = fuNodeGroup; break; } } if (group == null) { group = new NodeGroup(nodeGroup.Name, nodeGroup.Icon, null); _frequentlyUsedNodeGroups.Add(group); } copyNodeItems(nodeGroup, group); } // clear the empty group for (int g = 0; g < _frequentlyUsedNodeGroups.Count; g++) { if (_frequentlyUsedNodeGroups[g].Children.Count == 0 && _frequentlyUsedNodeGroups[g].Items.Count == 0) { _frequentlyUsedNodeGroups.RemoveAt(g); g--; } } }
public static List<Image> RegisterNodeDesc(Assembly a, int iconCount = 0) { List<Image> nodeImages = new List<Image>(); Type[] types = a.GetTypes(); foreach(Type type in types) { // to skip it if confiured in the filter nodes if (FilterNodes.Contains(type.FullName)) { continue; } Attribute[] attributes = (Attribute[])type.GetCustomAttributes(typeof(Behaviac.Design.NodeDescAttribute), false); if (attributes.Length > 0) { NodeDescAttribute nodeDescAttr = attributes[0] as NodeDescAttribute; NodeGroup curGroup = null; IList<NodeGroup> curNodeGroups = _nodeGroups; string[] nameTree = nodeDescAttr.Group.Split(new Char[] { ':' }); for (int i = 0; i < nameTree.Length; ++i) { string name = Resources.ResourceManager.GetString(nameTree[i], Resources.Culture); if (string.IsNullOrEmpty(name)) { name = nameTree[i]; } NodeGroup group = GetNodeGroup(curNodeGroups, name); if (group == null) { group = new NodeGroup(name, NodeIcon.FolderClosed, curGroup); if (curGroup == null) { curNodeGroups.Add(group); } } curGroup = group; curNodeGroups = group.Children; } if (!curGroup.ContainType(type)) { NodeIcon icon = nodeDescAttr.Icon; Image image = GetResourceImage(nodeDescAttr.ImageName); if (image != null) { nodeImages.Add(image); icon = (NodeIcon)(iconCount + nodeImages.Count - 1); } curGroup.Items.Add(new NodeItem(type, icon)); } } } return nodeImages; }
public static void InitNodeGroups() { _nodeGroups.Clear(); NodeGroup group = new NodeGroup(Resources.Attachments, NodeIcon.FolderClosed, null); _nodeGroups.Add(group); group = new NodeGroup(Resources.Conditions, NodeIcon.FolderClosed, null); _nodeGroups.Add(group); new NodeGroup(Resources.Leaf, NodeIcon.FolderClosed, group); group = new NodeGroup(Resources.Actions, NodeIcon.FolderClosed, null); _nodeGroups.Add(group); group = new NodeGroup(Resources.Composites, NodeIcon.FolderClosed, null); _nodeGroups.Add(group); new NodeGroup(Resources.Selectors, NodeIcon.FolderClosed, group); new NodeGroup(Resources.Sequences, NodeIcon.FolderClosed, group); new NodeGroup(Resources.EventHandling, NodeIcon.FolderClosed, group); group = new NodeGroup(Resources.Decorators, NodeIcon.FolderClosed, null); _nodeGroups.Add(group); }