Esempio n. 1
0
        private void Draw3DBorderNormal(Graphics g, ref Rectangle bounds, ColorData colors) {
            using( WindowsGraphics wg = WindowsGraphics.FromGraphics(g) ) {

                // Draw counter-clock-wise.
                Point p1 = new Point(bounds.X + bounds.Width - 1, bounds.Y );  // upper inner right.
                Point p2 = new Point(bounds.X                   , bounds.Y );  // upper left.
                Point p3 = new Point(bounds.X                   , bounds.Y + bounds.Height - 1 );  // bottom inner left.
                Point p4 = new Point(bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1 );  // inner bottom right.

                // top + left
                WindowsPen pen = new WindowsPen(wg.DeviceContext, colors.buttonShadowDark);
                try {
                    wg.DrawLine(pen, p1, p2); // top (right-left)
                    wg.DrawLine(pen, p2, p3); // left(up-down)
                }
                finally {
                    pen.Dispose();    
                }
            
                // bottom + right
                pen = new WindowsPen(wg.DeviceContext, colors.highlight);
                try {
                    p1.Offset(0,-1); // need to paint last pixel too.
                    wg.DrawLine(pen, p3, p4); // bottom(left-right)
                    wg.DrawLine(pen, p4, p1); // right (bottom-up)
                }
                finally {
                    pen.Dispose();
                }

                // Draw inset

                pen = new WindowsPen(wg.DeviceContext, colors.buttonFace);

                p1.Offset(-1, 2); 
                p2.Offset( 1, 1);
                p3.Offset( 1,-1);
                p4.Offset(-1,-1);

                // top + left inset
                try {
                    wg.DrawLine(pen, p1, p2); // top (right-left)
                    wg.DrawLine(pen, p2, p3); // left(up-down)
                }
                finally {
                    pen.Dispose();    
                }

                // bottom + right inset
                if (colors.buttonFace.ToKnownColor() == SystemColors.Control.ToKnownColor()) {
                    pen = new WindowsPen(wg.DeviceContext, SystemColors.ControlLight);
                }
                else {
                    pen = new WindowsPen(wg.DeviceContext, colors.buttonFace);
                }

                try {
                    p1.Offset(0,-1); // need to paint last pixel too.
                    wg.DrawLine(pen, p3, p4); // bottom(left-right)
                    wg.DrawLine(pen, p4, p1); // right (bottom-up)
                }
                finally {
                    pen.Dispose();
                }
            }
        }
 private void Draw3DBorderNormal(Graphics g, ref Rectangle bounds, ColorData colors)
 {
     using (WindowsGraphics graphics = WindowsGraphics.FromGraphics(g))
     {
         WindowsPen pen;
         Point point = new Point((bounds.X + bounds.Width) - 1, bounds.Y);
         Point point2 = new Point(bounds.X, bounds.Y);
         Point point3 = new Point(bounds.X, (bounds.Y + bounds.Height) - 1);
         Point point4 = new Point((bounds.X + bounds.Width) - 1, (bounds.Y + bounds.Height) - 1);
         using (pen = new WindowsPen(graphics.DeviceContext, colors.buttonShadowDark))
         {
             graphics.DrawLine(pen, point, point2);
             graphics.DrawLine(pen, point2, point3);
         }
         using (pen = new WindowsPen(graphics.DeviceContext, colors.highlight))
         {
             point.Offset(0, -1);
             graphics.DrawLine(pen, point3, point4);
             graphics.DrawLine(pen, point4, point);
         }
         pen = new WindowsPen(graphics.DeviceContext, colors.buttonFace);
         point.Offset(-1, 2);
         point2.Offset(1, 1);
         point3.Offset(1, -1);
         point4.Offset(-1, -1);
         try
         {
             graphics.DrawLine(pen, point, point2);
             graphics.DrawLine(pen, point2, point3);
         }
         finally
         {
             pen.Dispose();
         }
         if (colors.buttonFace.ToKnownColor() == SystemColors.Control.ToKnownColor())
         {
             pen = new WindowsPen(graphics.DeviceContext, SystemColors.ControlLight);
         }
         else
         {
             pen = new WindowsPen(graphics.DeviceContext, colors.buttonFace);
         }
         try
         {
             point.Offset(0, -1);
             graphics.DrawLine(pen, point3, point4);
             graphics.DrawLine(pen, point4, point);
         }
         finally
         {
             pen.Dispose();
         }
     }
 }