ComponentFactory.Krypton.Workspace.KryptonWorkspaceSequence.CompactPromoteLeafs C# (CSharp) Method

CompactPromoteLeafs() private method

private CompactPromoteLeafs ( CompactFlags flags ) : void
flags CompactFlags
return void
        private void CompactPromoteLeafs(CompactFlags flags)
        {
            if ((flags & CompactFlags.PromoteLeafs) == CompactFlags.PromoteLeafs)
            {
                // Search for child sequence items
                for (int i = Children.Count - 1; i >= 0; i--)
                {
                    // If a sequence and that sequence has just a single child
                    KryptonWorkspaceSequence sequence = Children[i] as KryptonWorkspaceSequence;
                    if ((sequence != null) && (sequence.Children.Count == 1))
                    {
                        // Extract the leaf
                        Component leaf = sequence.Children[0];
                        sequence.Children.RemoveAt(0);

                        // Use the sequence size in the promoted child so the display remains constant
                        if (leaf is KryptonWorkspaceCell)
                            ((KryptonWorkspaceCell)leaf).StarSize = sequence.StarSize;

                        if (leaf is KryptonWorkspaceSequence)
                            ((KryptonWorkspaceSequence)leaf).StarSize = sequence.StarSize;

                        // Replace the sequence with its leaf child
                        Children.RemoveAt(i);
                        Children.Insert(i, leaf);
                    }
                }
            }
        }