/// <summary> /// Adds the group archetype to add to the menu. /// </summary> /// <param name="groupArchetype">The group.</param> public void AddGroup(GroupArchetype groupArchetype) { // Check if can create group for them to be spawned via GUI if (groupArchetype.Archetypes.Any(x => (x.Flags & NodeFlags.NoSpawnViaGUI) == 0)) { Profiler.BeginEvent("VisjectCM.AddGroup"); var group = new VisjectCMGroup(this, groupArchetype); group.HeaderText = groupArchetype.Name; group.Close(false); foreach (var nodeArchetype in groupArchetype.Archetypes) { var item = new VisjectCMItem(group, groupArchetype, nodeArchetype); item.Parent = group; } group.SortChildren(); group.Parent = _groupsPanel; _groups.Add(group); if (!IsLayoutLocked) { group.UnlockChildrenRecursive(); SortGroups(); group.PerformLayout(); if (_searchBox.TextLength != 0) { OnSearchFilterChanged(); } } Profiler.EndEvent(); } }
/// <summary> /// Adds the group archetypes to add to the menu. /// </summary> /// <param name="groupArchetypes">The groups.</param> public void AddGroups(IEnumerable <GroupArchetype> groupArchetypes) { // Check if can create group for them to be spawned via GUI if (groupArchetypes.Any(g => g.Archetypes.Any(x => (x.Flags & NodeFlags.NoSpawnViaGUI) == 0))) { Profiler.BeginEvent("VisjectCM.AddGroups"); var isLayoutLocked = IsLayoutLocked; LockChildrenRecursive(); Profiler.BeginEvent("Create Groups"); var groups = new List <VisjectCMGroup>(); foreach (var groupArchetype in groupArchetypes) { var group = new VisjectCMGroup(this, groupArchetype) { HeaderText = groupArchetype.Name }; group.Close(false); foreach (var nodeArchetype in groupArchetype.Archetypes) { var item = new VisjectCMItem(group, groupArchetype, nodeArchetype) { Parent = group }; } group.SortChildren(); group.Parent = _groupsPanel; _groups.Add(group); groups.Add(group); } Profiler.EndEvent(); if (!isLayoutLocked) { SortGroups(); Profiler.BeginEvent("Perform Layout"); UnlockChildrenRecursive(); foreach (var group in groups) { group.PerformLayout(); } PerformLayout(); Profiler.EndEvent(); if (_searchBox.TextLength != 0) { OnSearchFilterChanged(); } } Profiler.EndEvent(); } }