Metallic Shading

Team Fly 

Page 635

Metallic Shading

One of the best ways to avoid dull-looking forms is to use gradient metallic shading. It's subtle and conservative enough for any business application, yet considerably more attractive than plain gray.

You can create gradients with Adobe's Photoshop, Corel's Picture Publisher, or most any photo-retouching program. Here's how to do it.

The best metallic gradient is a gradual shift between two shades: white and the typical Windows gray (the light gray often used as shading on windows and controls).

You can use the code in Listing 21.4 to add the top-left to lower-right metallic gradient to a form, as shown in Figure 21.10.

LISTING 21.4: CREATING METALLIC CRADIENTS

Imports System.Drawing
Imports System.Drawing.Drawing2D

Private Sub Form1_Paint(ByVal sender As Object, _
 ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

       Dim g As Graphics = Me.CreateGraphics

       'coordinates for both the gradient and the fillRectangle routine:
       Dim x As Integer = Me.Width
       Dim y As Integer = Me.Height

       Dim lgBrush As New LinearGradientBrush( _
          New Point(0, 0), New Point(x, y), _
           Color.White, Color.FromArgb(190, 190, 190))


       'linGrBrush.GammaCorrection = True 'smooth the transition
       g.FillRectangle(lgBrush, 0, 0, x, y)

End Sub

To draw gradients on buttons and such, you either can create a gradient the button's size in a graphics program (including caption), then import the graphic into the button's Image property, or you can use this code:

 Dim g As Graphics = Button1.CreateGraphics         Dim x As Integer = Button1.Width - 3         Dim y As Integer = Button1.Height - 3 
Team Fly 


Visual Basic  .NET Power Tools
Visual Basic .NET Power Tools
ISBN: 0782142427
EAN: 2147483647
Year: 2003
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net