ComponentFactory.Krypton.Toolkit.RenderStandard.GetTabBorderDisplayPadding C# (CSharp) Method

GetTabBorderDisplayPadding() public method

Gets the padding used to position display elements completely inside border drawing.
public GetTabBorderDisplayPadding ( ViewLayoutContext context, IPaletteBorder palette, PaletteState state, VisualOrientation orientation, TabBorderStyle tabBorderStyle ) : Padding
context ViewLayoutContext View layout context.
palette IPaletteBorder Palette used for drawing.
state PaletteState State associated with rendering.
orientation VisualOrientation Visual orientation of the border.
tabBorderStyle TabBorderStyle Style of tab border.
return Padding
        public override Padding GetTabBorderDisplayPadding(ViewLayoutContext context,
                                                           IPaletteBorder palette,
                                                           PaletteState state,
                                                           VisualOrientation orientation,
                                                           TabBorderStyle tabBorderStyle)
        {
            Debug.Assert(palette != null);

            // Validate parameter reference
            if (palette == null) throw new ArgumentNullException("palette");

            // Get the width of the border
            int borderWidth = palette.GetBorderWidth(state);

            // Cache the right to left setting
            bool rtl = (context.Control.RightToLeft == RightToLeft.Yes);

            Padding ret = Padding.Empty;

            switch (tabBorderStyle)
            {
                case TabBorderStyle.DockEqual:
                case TabBorderStyle.SquareEqualMedium:
                case TabBorderStyle.SquareEqualSmall:
                case TabBorderStyle.SquareEqualLarge:
                case TabBorderStyle.RoundedEqualMedium:
                case TabBorderStyle.RoundedEqualSmall:
                case TabBorderStyle.RoundedEqualLarge:
                    ret = new Padding(borderWidth, borderWidth, borderWidth, 0);
                    break;
                case TabBorderStyle.DockOutsize:
                    ret = new Padding(borderWidth + _spacingTabDockOutsize, borderWidth + _spacingTabSquareOutsizeLarge, borderWidth + _spacingTabDockOutsize, 0);
                    break;
                case TabBorderStyle.SquareOutsizeMedium:
                case TabBorderStyle.SquareOutsizeSmall:
                case TabBorderStyle.SquareOutsizeLarge:
                case TabBorderStyle.RoundedOutsizeMedium:
                case TabBorderStyle.RoundedOutsizeSmall:
                case TabBorderStyle.RoundedOutsizeLarge:
                    ret = new Padding(borderWidth + _spacingTabOutsizePadding, borderWidth + _spacingTabOutsizePadding, borderWidth + _spacingTabOutsizePadding, 0);
                    break;
                case TabBorderStyle.SlantEqualNear:
                case TabBorderStyle.SlantOutsizeNear:
                    // Calculte the extra needed for the outsize variant
                    int x = (tabBorderStyle == TabBorderStyle.SlantOutsizeNear ? _spacingTabOutsizePadding : 0);

                    switch(orientation)
                    {
                        case VisualOrientation.Top:
                            if (rtl)
                                ret = new Padding(borderWidth + x, borderWidth + x, borderWidth + x + _spacingTabSlantPadding - 1, 0);
                            else
                                ret = new Padding(borderWidth + x + _spacingTabSlantPadding - 1, borderWidth + x, borderWidth + x, 0);
                            break;
                        case VisualOrientation.Left:
                            ret = new Padding(borderWidth + x + _spacingTabSlantPadding - 1, borderWidth + x, borderWidth + x, 0);
                            break;
                        case VisualOrientation.Right:
                            ret = new Padding(borderWidth + x, borderWidth + x, borderWidth + x + _spacingTabSlantPadding - 1, 0);
                            break;
                        case VisualOrientation.Bottom:
                            if (rtl)
                                ret = new Padding(borderWidth + x + _spacingTabSlantPadding - 1, borderWidth + x, borderWidth + x, 0);
                            else
                                ret = new Padding(borderWidth + x, borderWidth + x, borderWidth + x + _spacingTabSlantPadding - 1, 0);
                            break;
                    }
                    break;
                case TabBorderStyle.SlantEqualFar:
                case TabBorderStyle.SlantOutsizeFar:
                    // Calculte the extra needed for the outsize variant
                    int y = (tabBorderStyle == TabBorderStyle.SlantOutsizeFar ? _spacingTabOutsizePadding : 0);

                    switch (orientation)
                    {
                        case VisualOrientation.Top:
                            if (rtl)
                                ret = new Padding(borderWidth + y + _spacingTabSlantPadding - 1, borderWidth + y, borderWidth + y, 0);
                            else
                                ret = new Padding(borderWidth + y, borderWidth + y, borderWidth + y + _spacingTabSlantPadding - 1, 0);
                            break;
                        case VisualOrientation.Left:
                            ret = new Padding(borderWidth + y, borderWidth + y, borderWidth + y + _spacingTabSlantPadding - 1, 0);
                            break;
                        case VisualOrientation.Right:
                            ret = new Padding(borderWidth + y + _spacingTabSlantPadding - 1, borderWidth + y, borderWidth + y, 0);
                            break;
                        case VisualOrientation.Bottom:
                            if (rtl)
                                ret = new Padding(borderWidth + y, borderWidth + y, borderWidth + y + _spacingTabSlantPadding - 1, 0);
                            else
                                ret = new Padding(borderWidth + y + _spacingTabSlantPadding - 1, borderWidth + y, borderWidth + y, 0);
                            break;
                    }
                    break;
                case TabBorderStyle.SlantEqualBoth:
                case TabBorderStyle.SlantOutsizeBoth:
                    // Calculte the extra needed for the outsize variant
                    int z = (tabBorderStyle == TabBorderStyle.SlantOutsizeBoth ? _spacingTabOutsizePadding : 0);

                    ret = new Padding(borderWidth + z + _spacingTabSlantPadding - 1, borderWidth + z,
                                      borderWidth + z + _spacingTabSlantPadding - 1, 0);
                    break;
                case TabBorderStyle.OneNote:
                    // Is the current tab selected?
                    bool selected = (state == PaletteState.CheckedNormal) ||
                                    (state == PaletteState.CheckedPressed) ||
                                    (state == PaletteState.CheckedTracking);

                    // Find the correct edge padding values to use
                    int lp = (selected ? _spacingTabOneNoteLPS : _spacingTabOneNoteLPI);
                    int tp = (selected ? _spacingTabOneNoteTPS : _spacingTabOneNoteTPI);
                    int bp = (selected ? _spacingTabOneNoteBPS : _spacingTabOneNoteBPI);
                    int rp = (selected ? _spacingTabOneNoteRPS : _spacingTabOneNoteRPI);

                    switch (orientation)
                    {
                        case VisualOrientation.Top:
                            if (rtl)
                                ret = new Padding(borderWidth + rp, borderWidth + tp, borderWidth + lp, bp);
                            else
                                ret = new Padding(borderWidth + lp, borderWidth + tp, borderWidth + rp, bp);
                            break;
                        case VisualOrientation.Left:
                            ret = new Padding(borderWidth + rp, borderWidth + tp, borderWidth + lp, bp);
                            break;
                        case VisualOrientation.Right:
                            ret = new Padding(borderWidth + lp, borderWidth + tp, borderWidth + rp, bp);
                            break;
                        case VisualOrientation.Bottom:
                            if (rtl)
                                ret = new Padding(borderWidth + lp, borderWidth + tp, borderWidth + rp, bp);
                            else
                                ret = new Padding(borderWidth + rp, borderWidth + tp, borderWidth + lp, bp);
                            break;
                    }
                    break;
                case TabBorderStyle.SmoothEqual:
                    ret = new Padding(borderWidth + _spacingTabSmoothLRE, borderWidth + _spacingTabSmoothTE, borderWidth + _spacingTabSmoothLRE, 0);
                    break;
                case TabBorderStyle.SmoothOutsize:
                    ret = new Padding(borderWidth + _spacingTabSmoothLRO, borderWidth + _spacingTabSmoothTO, borderWidth + _spacingTabSmoothLRO, 0);
                    break;
                default:
                    // Should never happen!
                    Debug.Assert(false);
                    break;
            }

            return ret;
        }
RenderStandard