home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Jugar con las fuentes / GradientText / GradientText.cs next >
Encoding:
Text File  |  2002-06-18  |  1.2 KB  |  36 lines

  1. //-------------------------------------------
  2. // GradientText.cs ⌐ 2001 by Charles Petzold
  3. //-------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8.  
  9. class GradientText: FontMenuForm
  10. {
  11.      public new static void Main()
  12.      {
  13.           Application.Run(new GradientText());
  14.      }
  15.      public GradientText()
  16.      {
  17.           Text = "Texto degradado";
  18.           Width *= 3;
  19.           strText = "Degradado";
  20.           font = new Font("Times New Roman", 144, FontStyle.Italic);
  21.      }
  22.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  23.      {
  24.           SizeF  sizef  = grfx.MeasureString(strText, font);
  25.           PointF ptf    = new PointF((cx - sizef.Width) / 2,
  26.                                      (cy - sizef.Height) / 2);
  27.           RectangleF rectf = new RectangleF(ptf, sizef);
  28.  
  29.           LinearGradientBrush lgbrush = new LinearGradientBrush(rectf, 
  30.                                         Color.White, Color.Black, 
  31.                                         LinearGradientMode.ForwardDiagonal);
  32.           grfx.Clear(Color.Gray);
  33.           grfx.DrawString(strText, font, lgbrush, ptf);
  34.      }
  35. }
  36.