Adds the group archetype to add to the menu. The group. True if merge group items into any existing group of the same name.
(GroupArchetype groupArchetype, bool withGroupMerge = true)
| 387 | /// <param name="groupArchetype">The group.</param> |
| 388 | /// <param name="withGroupMerge">True if merge group items into any existing group of the same name.</param> |
| 389 | public void AddGroup(GroupArchetype groupArchetype, bool withGroupMerge = true) |
| 390 | { |
| 391 | // Check if can create group for them to be spawned via GUI |
| 392 | if (groupArchetype.Archetypes.Any(x => (x.Flags & NodeFlags.NoSpawnViaGUI) == 0)) |
| 393 | { |
| 394 | Profiler.BeginEvent("VisjectCM.AddGroup"); |
| 395 | |
| 396 | var group = CreateGroup(groupArchetype, withGroupMerge); |
| 397 | group.Close(false); |
| 398 | |
| 399 | foreach (var nodeArchetype in groupArchetype.Archetypes) |
| 400 | { |
| 401 | var item = new VisjectCMItem(group, groupArchetype, nodeArchetype) |
| 402 | { |
| 403 | Parent = group |
| 404 | }; |
| 405 | } |
| 406 | group.SortChildren(); |
| 407 | group.Parent = _groupsPanel; |
| 408 | |
| 409 | _groups.Add(group); |
| 410 | |
| 411 | if (!IsLayoutLocked) |
| 412 | { |
| 413 | group.UnlockChildrenRecursive(); |
| 414 | // TODO: Improve filtering to be based on boxes with the most common things instead of first box |
| 415 | if (_contextSensitiveSearchEnabled && _selectedBoxes.Count > 0 && _selectedBoxes[0] != null) |
| 416 | UpdateFilters(); |
| 417 | else |
| 418 | SortGroups(); |
| 419 | if (ShowExpanded) |
| 420 | group.Open(false); |
| 421 | group.PerformLayout(); |
| 422 | if (_searchBox.TextLength != 0) |
| 423 | { |
| 424 | OnSearchFilterChanged(); |
| 425 | } |
| 426 | } |
| 427 | else if (_contextSensitiveSearchEnabled && _selectedBoxes.Count > 0) |
| 428 | { |
| 429 | // TODO: Filtering could be improved here as well |
| 430 | group.EvaluateVisibilityWithBox(_selectedBoxes[0]); |
| 431 | } |
| 432 | |
| 433 | Profiler.EndEvent(); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | /// <summary> |
| 438 | /// Adds the group archetypes to add to the menu. |
no test coverage detected