ImageGlass.ImageBox.DrawImageBorder C# (CSharp) Method

DrawImageBorder() protected method

Draws a border around the image.
protected DrawImageBorder ( Graphics graphics ) : void
graphics System.Drawing.Graphics The graphics.
return void
        protected virtual void DrawImageBorder(Graphics graphics)
        {
            if (ImageBorderStyle != ImageBoxBorderStyle.None)
            {
                Rectangle viewPort;

                graphics.SetClip(GetInsideViewPort()); // make sure the image border doesn't overwrite the control border

                viewPort = GetImageViewPort();
                viewPort = new Rectangle(viewPort.Left - 1, viewPort.Top - 1, viewPort.Width + 1, viewPort.Height + 1);

                using (Pen borderPen = new Pen(ImageBorderColor))
                {
                    graphics.DrawRectangle(borderPen, viewPort);
                }

                switch (ImageBorderStyle)
                {
                    case ImageBoxBorderStyle.FixedSingleDropShadow:
                        DrawDropShadow(graphics, viewPort);
                        break;
                    case ImageBoxBorderStyle.FixedSingleGlowShadow:
                        DrawGlowShadow(graphics, viewPort);
                        break;
                }

                graphics.ResetClip();
            }
        }
ImageBox