/* * A C# program that creates a custom component with its own renderer. * * Ben Bederson, January 30, 2002 */ using System; using System.Drawing; using System.Windows.Forms; public class BasicGraphics : System.Windows.Forms.Form { static public void Main() { Application.Run(new BasicGraphics()); } public BasicGraphics() { Size = new Size(400, 400); StartPosition = FormStartPosition.CenterScreen; BasicControl control = new BasicControl(); control.Location = new Point(0, 0); control.Size = new Size(400, 400); Controls.Add(control); } } class BasicControl : Control { static Brush blackBrush = new SolidBrush(Color.Black); static Font font = new Font("Arial", 15); protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; BackColor = Color.White; g.DrawString("Hello World!", font, blackBrush, 100, 100); } }