// Fig. 16.9 UsingFonts.cs // Fonts and FontStyles. using System; using System.Drawing; using System.Windows.Forms; // demonstrate font constructors and properties public partial class UsingFonts : Form { // default constructor public UsingFonts() { InitializeComponent(); } // end constructor // demonstrate various font and style settings protected override void OnPaint( PaintEventArgs paintEvent ) { Graphics graphicsObject = paintEvent.Graphics; SolidBrush brush = new SolidBrush( Color.DarkBlue ); // arial, 12 pt bold FontStyle style = FontStyle.Bold; Font arial = new Font( "Arial" , 12, style ); // times new roman, 12 pt regular style = FontStyle.Regular; Font timesNewRoman = new Font( "Times New Roman", 12, style ); // courier new, 16 pt bold and italic style = FontStyle.Bold | FontStyle.Italic; Font courierNew = new Font( "Courier New", 16, style ); // tahoma, 18 pt strikeout style = FontStyle.Strikeout; Font tahoma = new Font( "Tahoma", 18, style ); graphicsObject.DrawString( arial.Name + " 12 point bold.", arial, brush, 10, 10 ); graphicsObject.DrawString( timesNewRoman.Name + " 12 point plain.", timesNewRoman, brush, 10, 30 ); graphicsObject.DrawString( courierNew.Name + " 16 point bold and italic.", courierNew, brush, 10, 54 ); graphicsObject.DrawString( tahoma.Name + " 18 point strikeout.", tahoma, brush, 10, 75 ); } // end method OnPaint } // end class UsingFonts /************************************************************************** * (C) Copyright 1992-2006 by Deitel & Associates, Inc. and * * Pearson Education, Inc. All Rights Reserved. * * * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing of the theories and programs * * to determine their effectiveness. The authors and publisher make * * no warranty of any kind, expressed or implied, with regard to these * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or * * consequential damages in connection with, or arising out of, the * * furnishing, performance, or use of these programs. * *************************************************************************/