/// <summary>
        /// Perform a render of the elements.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        public override void Render(RenderContext context)
        {
            Debug.Assert(context != null);

            // Perform rendering before any children
            RenderBefore(context);

            // We need to update the redirector for drawing each crumb
            PaletteRedirectBreadCrumb redirect = _kryptonBreadCrumb.GetRedirector() as PaletteRedirectBreadCrumb;

            var first = true;

            for (var i = 0; i < Count; i++)
            {
                if (this[i].Visible)
                {
                    // Do not show the left border on the first crumb
                    if (first)
                    {
                        redirect.Left = true;
                        first         = false;
                    }
                    else
                    {
                        redirect.Left = false;
                    }

                    this[i].Render(context);
                }
            }

            // Perform rendering after that of children
            RenderAfter(context);
        }
        /// <summary>
        /// Discover the preferred size of the element.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override Size GetPreferredSize(ViewLayoutContext context)
        {
            // Create/delete child elements to match the current selected bread crumb path
            SyncBreadCrumbs();

            // We need to update the redirector for drawing each crumb
            PaletteRedirectBreadCrumb redirect = _kryptonBreadCrumb.GetRedirector() as PaletteRedirectBreadCrumb;

            Size preferredSize = Size.Empty;

            for (var i = 1; i < Count; i++)
            {
                // Do not show the left border on the first crumb
                redirect.Left = i == 0;

                // Find size of the child
                Size childSize = this[i].GetPreferredSize(context);

                // Accumulate in width
                preferredSize.Width += childSize.Width;

                // Find maximum height
                preferredSize.Height = Math.Max(preferredSize.Height, childSize.Height);
            }

            // Add on the control level padding
            preferredSize.Width  += _kryptonBreadCrumb.Padding.Horizontal;
            preferredSize.Height += _kryptonBreadCrumb.Padding.Vertical;

            return(preferredSize);
        }
        /// <summary>
        /// Perform a layout of the elements.
        /// </summary>
        /// <param name="context">Layout context.</param>
        public override void Layout(ViewLayoutContext context)
        {
            Debug.Assert(context != null);

            // We need to update the redirector for drawing each crumb
            PaletteRedirectBreadCrumb redirect = _kryptonBreadCrumb.GetRedirector() as PaletteRedirectBreadCrumb;

            // We take on all the available display area
            ClientRectangle = context.DisplayRectangle;

            // Create/delete child elements to match the current selected bread crumb path
            SyncBreadCrumbs();

            // Positioning rectangle is our client rectangle reduced by control padding
            Rectangle layoutRect = new(ClientLocation.X + _kryptonBreadCrumb.Padding.Left,
                                       ClientLocation.Y + _kryptonBreadCrumb.Padding.Top,
                                       ClientWidth - _kryptonBreadCrumb.Padding.Horizontal,
                                       ClientHeight - _kryptonBreadCrumb.Padding.Vertical);

            // Position from left to right all items except the overflow button
            var offset = layoutRect.X;

            for (var i = 1; i < Count; i++)
            {
                // Do not show the left border on the first crumb
                redirect.Left = i == 0;

                // Find size of the child
                Size childSize = this[i].GetPreferredSize(context);
                context.DisplayRectangle = new Rectangle(offset, layoutRect.Y, childSize.Width, layoutRect.Height);

                // Position the child
                this[i].Layout(context);
                this[i].Visible = true;

                // Move across
                offset += childSize.Width;
            }

            // If we overflowed then we need to use the overflow button
            if (offset > ClientWidth)
            {
                // Overflow button must be visible
                this[0].Visible = true;

                // How much space do we need to save?
                var overflowed = offset - ClientWidth;

                // Position overflow button and only the last items to fit space
                offset = layoutRect.X;
                for (var i = 0; i < Count; i++)
                {
                    // Decide if the crumb (not the overflow button) can be visible
                    if (i > 0)
                    {
                        this[i].Visible = overflowed <= 0;
                    }

                    if (this[i].Visible)
                    {
                        // Do not show the left border on the first crumb
                        redirect.Left = i == 0;

                        // Recover the already calculated size
                        Size childSize = this[i].GetPreferredSize(context);
                        context.DisplayRectangle = new Rectangle(offset, layoutRect.Y, childSize.Width, layoutRect.Height);

                        // Position the child
                        this[i].Layout(context);

                        // Move across
                        offset += childSize.Width;
                    }

                    // Adjust overflow space depending on if we are positioning crumb or overflow
                    if (i != 0)
                    {
                        overflowed -= this[i].ClientWidth;
                    }
                    else
                    {
                        overflowed += this[i].ClientWidth;
                    }
                }
            }
            else
            {
                // No overflow then no need for the overflow button
                this[0].Visible = false;
            }

            // Must restore the display rectangle to the same size as when it entered
            context.DisplayRectangle = ClientRectangle;
        }