コード例 #1
0
        /// <summary>
        ///  Draws the header's background.
        /// </summary>
        public void DrawBackground()
        {
            if (Application.RenderWithVisualStyles)
            {
                var vsr = new VisualStyleRenderer(VisualStyleElement.Header.Item.Normal);
                vsr.DrawBackground(Graphics, Bounds);
            }
            else
            {
                using (var backBrush = BackColor.GetCachedSolidBrushScope())
                {
                    Graphics.FillRectangle(backBrush, Bounds);
                }

                // Draw the 3d header
                Rectangle r = Bounds;

                r.Width  -= 1;
                r.Height -= 1;

                // Draw the dark border around the whole thing
                Graphics.DrawRectangle(SystemPens.ControlDarkDark, r);

                r.Width  -= 1;
                r.Height -= 1;

                // Draw the light 3D border
                Graphics.DrawLine(SystemPens.ControlLightLight, r.X, r.Y, r.Right, r.Y);
                Graphics.DrawLine(SystemPens.ControlLightLight, r.X, r.Y, r.X, r.Bottom);

                // Draw the dark 3D Border
                Graphics.DrawLine(SystemPens.ControlDark, r.X + 1, r.Bottom, r.Right, r.Bottom);
                Graphics.DrawLine(SystemPens.ControlDark, r.Right, r.Y + 1, r.Right, r.Bottom);
            }
        }