Gonzo.Elements.UIButton.DrawBorder C# (CSharp) Method

DrawBorder() public method

Draws a border around this button, for debugging purposes.
public DrawBorder ( SpriteBatch SBatch, Rectangle rectangleToDraw, int thicknessOfBorder, Microsoft.Xna.Framework.Color borderColor ) : void
SBatch Microsoft.Xna.Framework.Graphics.SpriteBatch A Spritebatch to draw with.
rectangleToDraw Microsoft.Xna.Framework.Rectangle A rectangle that will make up the border.
thicknessOfBorder int Thickness of border to be drawn.
borderColor Microsoft.Xna.Framework.Color Color of border.
return void
        public void DrawBorder(SpriteBatch SBatch, Rectangle rectangleToDraw, int thicknessOfBorder, Color borderColor)
        {
            // At the top of your class:
            Texture2D pixel;

            // Somewhere in your LoadContent() method:
            pixel = new Texture2D(m_Screen.Manager.Graphics, 1, 1, false, SurfaceFormat.Color);
            pixel.SetData(new[] { Color.White }); // so that we can draw whatever color we want on top of it

            // Draw top line
            SBatch.Draw(pixel, new Rectangle(rectangleToDraw.X, rectangleToDraw.Y, rectangleToDraw.Width, thicknessOfBorder), borderColor);

            // Draw left line
            SBatch.Draw(pixel, new Rectangle(rectangleToDraw.X, rectangleToDraw.Y, thicknessOfBorder, rectangleToDraw.Height), borderColor);

            // Draw right line
            SBatch.Draw(pixel, new Rectangle((rectangleToDraw.X + rectangleToDraw.Width - thicknessOfBorder),
                                            rectangleToDraw.Y,
                                            thicknessOfBorder,
                                            rectangleToDraw.Height), borderColor);
            // Draw bottom line
            SBatch.Draw(pixel, new Rectangle(rectangleToDraw.X,
                                            rectangleToDraw.Y + rectangleToDraw.Height - thicknessOfBorder,
                                            rectangleToDraw.Width,
                                            thicknessOfBorder), borderColor);
        }