protected void AddGroupToSequence(TabGroupSequence tgs, TabGroupLeaf sourceLeaf, bool before) { // Remember original auto compact mode bool autoCompact = _tabbedGroups.AutoCompact; // Turn mode off as it interferes with reorganisation _tabbedGroups.AutoCompact = false; // Find our index into parent collection int pos = tgs.IndexOf(this); TabGroupLeaf newGroup = null; // New group inserted before existing one? if (before) { newGroup = tgs.InsertNewLeaf(pos); } else { // No, are we at the end of the collection? if (pos == (tgs.Count - 1)) { newGroup = tgs.AddNewLeaf(); } else { newGroup = tgs.InsertNewLeaf(pos + 1); } } // Get tab control for source leaf Controls.TabControl tc = sourceLeaf.GroupControl as Controls.TabControl; TabPage tp = tc.SelectedTab; // Remove page from ourself tc.TabPages.Remove(tp); // Add into the new leaf newGroup.TabPages.Add(tp); // Reset compacting mode as we have updated the structure _tabbedGroups.AutoCompact = autoCompact; // Do we need to compact? if (_tabbedGroups.AutoCompact) { _tabbedGroups.Compact(); } }
internal void EnforceAtLeastOneLeaf() { // Should not add items during compacting operation if (!_compacting) { // Ensure we enfore policy of at least one leaf if (_atLeastOneLeaf) { // Is there at least one? if (_numLeafs == 0) { // No, create a default entry for the root sequence _root.AddNewLeaf(); // Update the active leaf ActiveLeaf = FirstLeaf(); // Mark layout as dirty if (_autoCalculateDirty) _dirty = true; } } } }