GetAlignedRectangle() public method

Calculate a rectangle in control coodinates that is aligned for gradient drawing.
public GetAlignedRectangle ( PaletteRectangleAlign align, Rectangle local ) : Rectangle
align PaletteRectangleAlign How to align the gradient.
local System.Drawing.Rectangle Rectangle of the local element.
return System.Drawing.Rectangle
コード例 #1
0
ファイル: RenderStandard.cs プロジェクト: Cocotteseb/Krypton
        /// <summary>
        /// Perform draw of content using provided memento.
        /// </summary>
        /// <param name="context">Render context.</param>
        /// <param name="displayRect">Display area available for drawing.</param>
        /// <param name="palette">Content palette details.</param>
        /// <param name="memento">Cached values from layout call.</param>
        /// <param name="orientation">Visual orientation of the content.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="composition">Drawing onto a composition element.</param>
        /// <param name="glowing">If composition should glowing be drawn.</param>
        /// <param name="allowFocusRect">Allow drawing of focus rectangle.</param>
        public override void DrawContent(RenderContext context, 
										 Rectangle displayRect,
										 IPaletteContent palette,
										 IDisposable memento,
										 VisualOrientation orientation,
										 PaletteState state,
                                         bool composition,
                                         bool glowing,
                                         bool allowFocusRect)
        {
            Debug.Assert(context != null);
            Debug.Assert(memento != null);
            Debug.Assert(memento is StandardContentMemento);

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

            Debug.Assert(context.Control != null);
            Debug.Assert(!context.Control.IsDisposed);

            // Cast the incoming memento to the correct type
            StandardContentMemento standard = (StandardContentMemento)memento;

            if (standard.DrawImage)
            {
                DrawImageHelper(context,
                                standard.Image,
                                standard.ImageTransparentColor,
                                standard.ImageRect,
                                orientation,
                                palette.GetContentImageEffect(state),
                                palette.GetContentImageColorMap(state),
                                palette.GetContentImageColorTo(state));
            }

            if (standard.DrawShortText)
            {
                using (GraphicsTextHint hint = new GraphicsTextHint(context.Graphics, standard.ShortTextHint))
                {
                    // Get the rectangle to use when dealing with gradients
                    Rectangle gradientRect = context.GetAlignedRectangle(palette.GetContentShortTextColorAlign(state), standard.ShortTextRect);

                    // Use standard helper routine to create appropriate color brush
                    Color color1 = palette.GetContentShortTextColor1(state);
                    PaletteColorStyle colorStyle = palette.GetContentShortTextColorStyle(state);
                    using (Brush colorBrush = CreateColorBrush(gradientRect,
                                                               color1,
                                                               palette.GetContentShortTextColor2(state),
                                                               colorStyle,
                                                               palette.GetContentShortTextColorAngle(state),
                                                               orientation))
                    {
                        if (!AccurateText.DrawString(context.Graphics,
                                                     colorBrush,
                                                     standard.ShortTextRect,
                                                     context.Control.RightToLeft,
                                                     standard.Orientation,
                                                     composition,
                                                     glowing,
                                                     state,
                                                     standard.ShortTextMemento))
                        {
                            // Failed to draw means the font is likely to be invalid, get a fresh font
                            standard.ShortTextMemento.Font = palette.GetContentShortTextNewFont(state);

                            // Try again using the new font
                            AccurateText.DrawString(context.Graphics,
                                                    colorBrush,
                                                    standard.ShortTextRect,
                                                    context.Control.RightToLeft,
                                                    standard.Orientation,
                                                    composition,
                                                    glowing,
                                                    state,
                                                    standard.ShortTextMemento);
                        }
                    }

                    Image shortImage = palette.GetContentShortTextImage(state);
                    PaletteImageStyle shortImageStyle = palette.GetContentShortTextImageStyle(state);

                    // Do we need to draw the image?
                    if (ShouldDrawImage(shortImage))
                    {
                        // Get the rectangle to use when dealing with gradients
                        Rectangle imageRect = context.GetAlignedRectangle(palette.GetContentShortTextImageAlign(state), standard.ShortTextRect);

                        // Use standard helper routine to create appropriate image brush
                        using (Brush imageBrush = CreateImageBrush(imageRect, shortImage, shortImageStyle))
                        {
                            if (!AccurateText.DrawString(context.Graphics,
                                                         imageBrush,
                                                         standard.ShortTextRect,
                                                         context.Control.RightToLeft,
                                                         standard.Orientation,
                                                         composition,
                                                         glowing,
                                                         state,
                                                         standard.ShortTextMemento))
                            {
                                // Failed to draw means the font is likely to be invalid, get a fresh font
                                standard.ShortTextMemento.Font = palette.GetContentShortTextNewFont(state);

                                AccurateText.DrawString(context.Graphics,
                                                        imageBrush,
                                                        standard.ShortTextRect,
                                                        context.Control.RightToLeft,
                                                        standard.Orientation,
                                                        composition,
                                                        glowing,
                                                        state,
                                                        standard.ShortTextMemento);
                            }
                        }
                    }
                }
            }

            if (standard.DrawLongText)
            {
                using (GraphicsTextHint hint = new GraphicsTextHint(context.Graphics, standard.LongTextHint))
                {
                    // Get the rectangle to use when dealing with gradients
                    Rectangle gradientRect = context.GetAlignedRectangle(palette.GetContentLongTextColorAlign(state), standard.LongTextRect);

                    // Use standard helper routine to create appropriate color brush
                    Color color1 = palette.GetContentLongTextColor1(state);
                    PaletteColorStyle colorStyle = palette.GetContentLongTextColorStyle(state);
                    using (Brush colorBrush = CreateColorBrush(gradientRect,
                                                               color1,
                                                               palette.GetContentLongTextColor2(state),
                                                               colorStyle,
                                                               palette.GetContentLongTextColorAngle(state),
                                                               orientation))
                    {
                        if (!AccurateText.DrawString(context.Graphics,
                                                     colorBrush,
                                                     standard.LongTextRect,
                                                     context.Control.RightToLeft,
                                                     standard.Orientation,
                                                     composition,
                                                     glowing,
                                                     state,
                                                     standard.LongTextMemento))
                        {
                            // Failed to draw means the font is likely to be invalid, get a fresh font
                            standard.LongTextMemento.Font = palette.GetContentLongTextNewFont(state);

                            AccurateText.DrawString(context.Graphics,
                                                    colorBrush,
                                                    standard.LongTextRect,
                                                    context.Control.RightToLeft,
                                                    standard.Orientation,
                                                    composition,
                                                    glowing,
                                                    state,
                                                    standard.LongTextMemento);
                        }
                    }

                    Image longImage = palette.GetContentLongTextImage(state);
                    PaletteImageStyle longImageStyle = palette.GetContentLongTextImageStyle(state);

                    // Do we need to draw the image?
                    if (ShouldDrawImage(longImage))
                    {
                        // Get the rectangle to use when dealing with gradients
                        Rectangle imageRect = context.GetAlignedRectangle(palette.GetContentLongTextImageAlign(state), standard.LongTextRect);

                        // Use standard helper routine to create appropriate image brush
                        using (Brush imageBrush = CreateImageBrush(imageRect, longImage, longImageStyle))
                        {
                            if (!AccurateText.DrawString(context.Graphics,
                                                         imageBrush,
                                                         standard.LongTextRect,
                                                         context.Control.RightToLeft,
                                                         standard.Orientation,
                                                         composition,
                                                         glowing,
                                                         state,
                                                         standard.LongTextMemento))
                            {
                                // Failed to draw means the font is likely to be invalid, get a fresh font
                                standard.LongTextMemento.Font = palette.GetContentLongTextNewFont(state);

                                AccurateText.DrawString(context.Graphics,
                                                        imageBrush,
                                                        standard.LongTextRect,
                                                        context.Control.RightToLeft,
                                                        standard.Orientation,
                                                        composition,
                                                        glowing,
                                                        state,
                                                        standard.LongTextMemento);
                            }
                        }
                    }
                }
            }

            // Do we need to show this content has the focus?
            if (allowFocusRect && (palette.GetContentDrawFocus(state) == InheritBool.True))
            {
                // Place the rectangle 1 pixel inside the content display area
                displayRect.Inflate(-1, -1);

                // Use window forms provided helper class for drawing
                ControlPaint.DrawFocusRectangle(context.Graphics, displayRect);
            }
        }
コード例 #2
0
ファイル: RenderStandard.cs プロジェクト: Cocotteseb/Krypton
        /// <summary>
        /// Draw background to fill the specified path.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        /// <param name="rect">Target rectangle that encloses path.</param>
        /// <param name="path">Graphics path.</param>
        /// <param name="palette">Palette used for drawing.</param>
        /// <param name="orientation">Visual orientation of the border.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="memento">Cache used for drawing.</param>
        public override IDisposable DrawBack(RenderContext context,
									         Rectangle rect,
									         GraphicsPath path,
									         IPaletteBack palette,
									         VisualOrientation orientation,
									         PaletteState state,
                                             IDisposable memento)
        {
            Debug.Assert(context != null);
            Debug.Assert(path != null);
            Debug.Assert(palette != null);

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

            Debug.Assert(context.Control != null);
            Debug.Assert(!context.Control.IsDisposed);

            // Is there anything to actually draw?
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                // We want to draw using anti aliasing for a nice smooth effect
                using (GraphicsHint smooth = new GraphicsHint(context.Graphics, palette.GetBackGraphicsHint(state)))
                {
                    // Cache commonly used values
                    Image backImage = palette.GetBackImage(state);
                    PaletteImageStyle backImageStyle = palette.GetBackImageStyle(state);
                    PaletteColorStyle backColorStyle = palette.GetBackColorStyle(state);
                    Color backColor1 = palette.GetBackColor1(state);
                    Color backColor2 = palette.GetBackColor2(state);
                    float backColorAngle = palette.GetBackColorAngle(state);

                    // Get the rectangle to use when dealing with gradients
                    Rectangle gradientRect = context.GetAlignedRectangle(palette.GetBackColorAlign(state), rect);

                    switch (backColorStyle)
                    {
                        case PaletteColorStyle.GlassSimpleFull:
                            memento = RenderGlassHelpers.DrawBackGlassSimpleFull(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassNormalFull:
                            memento = RenderGlassHelpers.DrawBackGlassNormalFull(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassTrackingFull:
                            memento = RenderGlassHelpers.DrawBackGlassTrackingFull(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassPressedFull:
                            memento = RenderGlassHelpers.DrawBackGlassPressedFull(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassCheckedFull:
                            memento = RenderGlassHelpers.DrawBackGlassCheckedFull(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassCheckedTrackingFull:
                            memento = RenderGlassHelpers.DrawBackGlassCheckedTrackingFull(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassNormalStump:
                            memento = RenderGlassHelpers.DrawBackGlassNormalStump(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassTrackingStump:
                            memento = RenderGlassHelpers.DrawBackGlassTrackingStump(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassPressedStump:
                            memento = RenderGlassHelpers.DrawBackGlassPressedStump(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassCheckedStump:
                            memento = RenderGlassHelpers.DrawBackGlassCheckedStump(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassCheckedTrackingStump:
                            memento = RenderGlassHelpers.DrawBackGlassCheckedTrackingStump(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassThreeEdge:
                            memento = RenderGlassHelpers.DrawBackGlassThreeEdge(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassNormalSimple:
                            memento = RenderGlassHelpers.DrawBackGlassNormalSimple(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassTrackingSimple:
                            memento = RenderGlassHelpers.DrawBackGlassTrackingSimple(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassPressedSimple:
                            memento = RenderGlassHelpers.DrawBackGlassPressedSimple(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassCheckedSimple:
                            memento = RenderGlassHelpers.DrawBackGlassCheckedSimple(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassCheckedTrackingSimple:
                            memento = RenderGlassHelpers.DrawBackGlassCheckedTrackingSimple(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassCenter:
                            memento = RenderGlassHelpers.DrawBackGlassCenter(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassBottom:
                            memento = RenderGlassHelpers.DrawBackGlassBottom(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.GlassFade:
                            memento = RenderGlassHelpers.DrawBackGlassFade(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.ExpertTracking:
                            memento = RenderExpertHelpers.DrawBackExpertTracking(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.ExpertPressed:
                            memento = RenderExpertHelpers.DrawBackExpertPressed(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.ExpertChecked:
                            memento = RenderExpertHelpers.DrawBackExpertChecked(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.ExpertCheckedTracking:
                            memento = RenderExpertHelpers.DrawBackExpertCheckedTracking(context, rect, backColor1, backColor2, orientation, path, memento);
                            break;
                        case PaletteColorStyle.ExpertSquareHighlight:
                            memento = RenderExpertHelpers.DrawBackExpertSquareHighlight(context, rect, backColor1, backColor2, orientation, path, memento, false);
                            break;
                        case PaletteColorStyle.ExpertSquareHighlight2:
                            memento = RenderExpertHelpers.DrawBackExpertSquareHighlight(context, rect, backColor1, backColor2, orientation, path, memento, true);
                            break;
                        case PaletteColorStyle.SolidInside:
                            DrawBackSolidInside(context, gradientRect, backColor1, backColor2, path);
                            break;
                        case PaletteColorStyle.SolidLeftLine:
                        case PaletteColorStyle.SolidRightLine:
                        case PaletteColorStyle.SolidTopLine:
                        case PaletteColorStyle.SolidBottomLine:
                        case PaletteColorStyle.SolidAllLine:
                            DrawBackSolidLine(context, rect, backColor1, backColor2, backColorStyle, path);
                            break;
                        case PaletteColorStyle.OneNote:
                            DrawBackOneNote(context, gradientRect, backColor1, backColor2,
                                            backColorStyle, backColorAngle, orientation, path);
                            break;
                        case PaletteColorStyle.RoundedTopLeftWhite:
                            DrawBackRoundedTopLeftWhite(context, rect, gradientRect, backColor1, backColor2,
                                                        backColorStyle, backColorAngle, orientation, path);
                            break;
                        case PaletteColorStyle.RoundedTopLight:
                            DrawBackRoundedTopLight(context, rect, gradientRect, backColor1, backColor2,
                                                    backColorStyle, backColorAngle, orientation, path);
                            break;
                        case PaletteColorStyle.Rounding4:
                            DrawBackRounded4(context, rect, gradientRect, backColor1, backColor2,
                                             backColorStyle, backColorAngle, orientation, path);
                            break;
                        case PaletteColorStyle.Rounding5:
                            DrawBackRounding5(context, rect, gradientRect, backColor1, backColor2,
                                                  backColorStyle, backColorAngle, orientation, path);
                            break;
                        case PaletteColorStyle.LinearShadow:
                            DrawBackLinearShadow(context, rect, gradientRect, backColor1, backColor2,
                                                 backColorStyle, backColorAngle, orientation, path);
                            break;
                        default:
                            // Use standard helper routine to create appropriate color brush
                            using (Brush backBrush = CreateColorBrush(gradientRect, backColor1, backColor2,
                                                                      backColorStyle, backColorAngle, orientation))
                            {
                                context.Graphics.FillPath(backBrush, path);
                            }
                            break;
                    }

                    // Do we need to draw the image?
                    if (ShouldDrawImage(backImage))
                    {
                        // Get the rectangle to use when dealing with gradients
                        Rectangle imageRect = context.GetAlignedRectangle(palette.GetBackImageAlign(state), rect);

                        // Use standard helper routine to create appropriate image brush
                        using (Brush backBrush = CreateImageBrush(imageRect, backImage, backImageStyle))
                            context.Graphics.FillPath(backBrush, path);
                    }
                }
            }

            return memento;
        }
コード例 #3
0
ファイル: RenderStandard.cs プロジェクト: Cocotteseb/Krypton
        /// <summary>
        /// Draw border on the inside edge of the specified rectangle.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        /// <param name="rect">Target rectangle.</param>
        /// <param name="palette">Palette used for drawing.</param>
        /// <param name="orientation">Visual orientation of the border.</param>
        /// <param name="state">State associated with rendering.</param>
        public override void DrawBorder(RenderContext context,
									    Rectangle rect,
									    IPaletteBorder palette,
										VisualOrientation orientation,
										PaletteState state)
        {
            Debug.Assert(context != null);
            Debug.Assert(palette != null);

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

            Debug.Assert(context.Control != null);
            Debug.Assert(!context.Control.IsDisposed);

            PaletteDrawBorders borders = palette.GetBorderDrawBorders(state);

            // Is there anything to actually draw?
            if ((rect.Width > 0) && (rect.Height > 0) && CommonHelper.HasABorder(borders))
            {
                // Only use anti aliasing if the border is rounded
                SmoothingMode smoothMode = (palette.GetBorderRounding(state) > 0 ? SmoothingMode.AntiAlias : SmoothingMode.Default);

                // We want to draw using anti aliasing for a nice smooth effect
                using (GraphicsHint hint = new GraphicsHint(context.Graphics, palette.GetBorderGraphicsHint(state)))
                {
                    // Cache commonly used values
                    int borderWidth = palette.GetBorderWidth(state);

                    // Get the orientation correct borders value
                    borders = CommonHelper.OrientateDrawBorders(borders, orientation);

                    // Is there any border to actually draw?
                    if (borderWidth > 0)
                    {
                        using (Clipping clip = new Clipping(context.Graphics, rect))
                        {
                            // We always create the first border path variant
                            GraphicsPath borderPath0 = CreateBorderBackPath(true, true, rect, borders, borderWidth,
                                                                            palette.GetBorderRounding(state),
                                                                            (smoothMode == SmoothingMode.AntiAlias), 0);

                            GraphicsPath borderPath1 = null;

                            // We only need the second border path if the two borders used are opposite each other
                            if ((borders == PaletteDrawBorders.TopBottom) ||
                                (borders == PaletteDrawBorders.LeftRight))
                            {
                                borderPath1 = CreateBorderBackPath(true, true, rect, borders, borderWidth,
                                                                   palette.GetBorderRounding(state),
                                                                   (smoothMode == SmoothingMode.AntiAlias), 1);
                            }

                            // Get the rectangle to use when dealing with gradients
                            Rectangle gradientRect = context.GetAlignedRectangle(palette.GetBorderColorAlign(state), rect);

                            // Use standard helper routine to create appropriate color brush
                            PaletteColorStyle colorStyle = palette.GetBorderColorStyle(state);
                            using (Pen borderPen = new Pen(CreateColorBrush(gradientRect,
                                                                            palette.GetBorderColor1(state),
                                                                            palette.GetBorderColor2(state),
                                                                            colorStyle,
                                                                            palette.GetBorderColorAngle(state),
                                                                            orientation), borderWidth))
                            {
                                if (colorStyle == PaletteColorStyle.Dashed)
                                    borderPen.DashPattern = new float[] { 2, 2 };

                                context.Graphics.DrawPath(borderPen, borderPath0);

                                // Optionally also draw the second path
                                if (borderPath1 != null)
                                    context.Graphics.DrawPath(borderPen, borderPath1);
                            }

                            Image borderImage = palette.GetBorderImage(state);
                            PaletteImageStyle borderImageStyle = palette.GetBorderImageStyle(state);

                            // Do we need to draw the image?
                            if (ShouldDrawImage(borderImage))
                            {
                                // Get the rectangle to use when dealing with gradients
                                Rectangle imageRect = context.GetAlignedRectangle(palette.GetBorderImageAlign(state), rect);

                                // Use standard helper routine to create appropriate image brush
                                using (Pen borderPen = new Pen(CreateImageBrush(imageRect, borderImage, borderImageStyle), borderWidth))
                                {
                                    context.Graphics.DrawPath(borderPen, borderPath0);

                                    // Optionally also draw the second path
                                    if (borderPath1 != null)
                                        context.Graphics.DrawPath(borderPen, borderPath1);
                                }
                            }

                            // Remember to dispose of resources
                            borderPath0.Dispose();

                            if (borderPath1 != null)
                                borderPath1.Dispose();
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: RenderStandard.cs プロジェクト: Cocotteseb/Krypton
        /// <summary>
        /// Draw border on the inside edge of the specified rectangle.
        /// </summary>
        /// <param name="context">Rendering context.</param>
        /// <param name="rect">Target rectangle.</param>
        /// <param name="palette">Palette used for drawing.</param>
        /// <param name="orientation">Visual orientation of the border.</param>
        /// <param name="state">State associated with rendering.</param>
        /// <param name="tabBorderStyle">Style of tab border.</param>
        public override void DrawTabBorder(RenderContext context,
                                           Rectangle rect,
                                           IPaletteBorder palette,
                                           VisualOrientation orientation,
                                           PaletteState state,
                                           TabBorderStyle tabBorderStyle)
        {
            Debug.Assert(context != null);
            Debug.Assert(palette != null);

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

            Debug.Assert(context.Control != null);
            Debug.Assert(!context.Control.IsDisposed);

            // Is there anything to actually draw?
            if ((rect.Width > 0) && (rect.Height > 0))
            {
                // Decide if we need to use anti aliasing for a smoother looking visual
                using (GraphicsHint hint = new GraphicsHint(context.Graphics, palette.GetBorderGraphicsHint(state)))
                {
                    // Cache commonly used values
                    int borderWidth = palette.GetBorderWidth(state);

                    // Is there any border to actually draw?
                    if (borderWidth > 0)
                    {
                        // Create the path that represents the entire tab border
                        using (GraphicsPath borderPath = CreateTabBorderBackPath(context.Control.RightToLeft, state, true, rect,
                                                                                 borderWidth, tabBorderStyle, orientation,
                                                                                 (palette.GetBorderGraphicsHint(state) == PaletteGraphicsHint.AntiAlias)))
                        {
                            // Get the rectangle to use when dealing with gradients
                            Rectangle gradientRect = context.GetAlignedRectangle(palette.GetBorderColorAlign(state), rect);

                            // Use standard helper routine to create appropriate color brush
                            using(Brush borderBrush = CreateColorBrush(gradientRect,
                                                                       palette.GetBorderColor1(state),
                                                                       palette.GetBorderColor2(state),
                                                                       palette.GetBorderColorStyle(state),
                                                                       palette.GetBorderColorAngle(state),
                                                                       orientation))
                            {
                                using (Pen borderPen = new Pen(borderBrush, borderWidth))
                                    context.Graphics.DrawPath(borderPen, borderPath);
                            }

                            Image borderImage = palette.GetBorderImage(state);

                            // Do we need to draw the image?
                            if (ShouldDrawImage(borderImage))
                            {
                                // Get the rectangle to use when dealing with gradients
                                Rectangle imageRect = context.GetAlignedRectangle(palette.GetBorderImageAlign(state), rect);

                                // Get the image style to use for the image brush
                                PaletteImageStyle borderImageStyle = palette.GetBorderImageStyle(state);

                                // Use standard helper routine to create appropriate image brush
                                using (Pen borderPen = new Pen(CreateImageBrush(imageRect, borderImage, borderImageStyle), borderWidth))
                                {
                                    context.Graphics.DrawPath(borderPen, borderPath);
                                }
                            }
                        }
                    }
                }
            }
        }