// screen.cs // C:>csc /t:winexe screen.cs // Well we want our program to be in a GUI window, so we need to inherit // from Form, which is in the library 'System.Windows.Forms'. using System; using System.Drawing; using System.Windows.Forms; class SimpleWindow : System.Windows.Forms.Form { private void OnPaint(object sender, System.Windows.Forms.PaintEventArgs e) { Rectangle r = this.ClientRectangle; System.Drawing.Graphics g = e.Graphics; g.FillRectangle(System.Drawing.Brushes.Blue, r); // Draw a line from top left to bottom right g.DrawLine(System.Drawing.Pens.Green, 0, 0, r.Right, r.Bottom); // Draw a small red square for colour :) g.FillRectangle(System.Drawing.Brushes.Red, 30, 30, 30, 30); }// End of OnPaint(..) // Window constructor SimpleWindow() { //** Important ** Important ** Important ** Important ** Important ** // Don't forget to inform our window, which function will be handling // the repainting. this.Paint += new System.Windows.Forms.PaintEventHandler(this.OnPaint); } // Our program entry point. static void Main() { System.Windows.Forms.Application.Run(new SimpleWindow()); } }// End of SimpleWindow Class