ZForge.Controls.HeaderPanel.DrawBorder C# (CSharp) Method

DrawBorder() private method

private DrawBorder ( Graphics canvas ) : void
canvas Graphics
return void
        private void DrawBorder(Graphics canvas)
        {
            Pen penDark = null;
            Pen penLight = null;

            try
            {
                switch (menm_BorderStyle)
                {
                    case HeaderPanelBorderStyles.Shadow:
                        penDark = new Pen(mclr_BorderColor);
                        canvas.DrawRectangle(penDark, 0, 0, Width - 6,
                                                                                Height - 6);
                        break;
                    case HeaderPanelBorderStyles.Single:
                        penDark = new Pen(mclr_BorderColor);
                        canvas.DrawRectangle(penDark, 0, 0,
                                                                Width - DEFAULT_BORDER_WIDTH,
                                                                Height - DEFAULT_BORDER_WIDTH);
                        break;
                    case HeaderPanelBorderStyles.Inset:
                        penDark = new Pen(SystemColors.ButtonShadow);
                        penLight = new Pen(SystemColors.ButtonHighlight);
                        canvas.DrawLine(penLight, 0, 0,
                                                                        Width - DEFAULT_BORDER_WIDTH, 0);
                        canvas.DrawLine(penLight, 0, 0, 0,
                                                                Height - DEFAULT_BORDER_WIDTH);
                        canvas.DrawLine(penDark, Width - DEFAULT_BORDER_WIDTH,
                                                                        0, Width - DEFAULT_BORDER_WIDTH,
                                                                        Height - DEFAULT_BORDER_WIDTH);
                        canvas.DrawLine(penDark, 0, Height - DEFAULT_BORDER_WIDTH,
                                                                        Width - DEFAULT_BORDER_WIDTH,
                                                                        Height - DEFAULT_BORDER_WIDTH);
                        break;
                    case HeaderPanelBorderStyles.Outset:
                        penDark = new Pen(SystemColors.ButtonShadow);
                        penLight = new Pen(SystemColors.ButtonHighlight);
                        canvas.DrawLine(penDark, 0, 0,
                                                                        Width - DEFAULT_BORDER_WIDTH, 0);
                        canvas.DrawLine(penDark, 0, 0, 0,
                                                                Height - DEFAULT_BORDER_WIDTH);
                        canvas.DrawLine(penLight, Width - DEFAULT_BORDER_WIDTH,
                                                                        0, Width - DEFAULT_BORDER_WIDTH,
                                                                        Height - DEFAULT_BORDER_WIDTH);
                        canvas.DrawLine(penLight, 0, Height - DEFAULT_BORDER_WIDTH,
                                                                        Width - DEFAULT_BORDER_WIDTH,
                                                                        Height - DEFAULT_BORDER_WIDTH);
                        break;
                    case HeaderPanelBorderStyles.Groove:
                        penDark = new Pen(SystemColors.ButtonShadow);
                        penLight = new Pen(SystemColors.ButtonHighlight);
                        canvas.DrawRectangle(penLight,
                                        new Rectangle(1, 1, Width - (2 * DEFAULT_BORDER_WIDTH),
                                                                        Height - (2 * DEFAULT_BORDER_WIDTH)));
                        canvas.DrawRectangle(penDark,
                                        new Rectangle(0, 0, Width - (2 * DEFAULT_BORDER_WIDTH),
                                                                        Height - (2 * DEFAULT_BORDER_WIDTH)));
                        break;
                    case HeaderPanelBorderStyles.Ridge:

                        penDark = new Pen(SystemColors.ButtonShadow);
                        penLight = new Pen(SystemColors.ButtonHighlight);
                        canvas.DrawRectangle(penLight,
                                        new Rectangle(0, 0, Width - (2 * DEFAULT_BORDER_WIDTH),
                                                                        Height - (2 * DEFAULT_BORDER_WIDTH)));
                        canvas.DrawRectangle(penDark,
                                        new Rectangle(1, 1, Width - (2 * DEFAULT_BORDER_WIDTH),
                                                                        Height - (2 * DEFAULT_BORDER_WIDTH)));
                        break;
                    default:
                        break;
                }
            }
            finally
            {
                if (penDark != null)
                {
                    penDark.Dispose();
                    penDark = null;
                }
                if (penLight != null)
                {
                    penLight.Dispose();
                    penLight = null;
                }
            }
        }