Пример #1
0
        //
        // OnPaint event handler
        //
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            // Draw the dragging region
            AhslColor lightColor = BackColor.ToAhsl();
            AhslColor darkColor  = BackColor.ToAhsl();

            lightColor = new AhslColor(lightColor.A, lightColor.H, lightColor.S, lightColor.L + 6);
            darkColor  = new AhslColor(darkColor.A, darkColor.H, darkColor.S, darkColor.L - 19);

            Pen lightPen = new Pen(lightColor.ToColor());
            Pen darkPen  = new Pen(darkColor.ToColor());

            // Draw the light stripes
            for (int x = 3; x <= 15; x += 3)
            {
                e.Graphics.DrawLine(lightPen, x, 2, 2, x);
                e.Graphics.DrawLine(lightPen, 16, x + 1, x + 1, 16);
            }

            // Draw the dark stripes
            for (int x = 4; x <= 16; x += 3)
            {
                e.Graphics.DrawLine(darkPen, x, 2, 2, x);

                if (x <= 14)
                {
                    e.Graphics.DrawLine(darkPen, 16, x + 1, x + 1, 16);
                }
            }

            lightPen.Dispose();
            darkPen.Dispose();
        }