using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Printing;

namespace Print_Simple_Designer
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Drawing.Printing.PrintDocument printDocument1;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItemPrint;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.printDocument1 = new System.Drawing.Printing.PrintDocument();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItemPrint = new System.Windows.Forms.MenuItem();
//
// printDocument1
//
this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItemPrint});
//
// menuItemPrint
//
this.menuItemPrint.Index = 0;
this.menuItemPrint.Text = "Print";
this.menuItemPrint.Click += new System.EventHandler(this.menuItemPrint_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.Text = "Simple Printing using the VS Designer";

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
// this is where we specify what is to be printed
Graphics g = e.Graphics;
Font printFont = new Font("Arial", 12);
float fltLineHeight = printFont.GetHeight() + 2;
float x = e.MarginBounds.Left;
float y = e.MarginBounds.Top;
g.DrawString("Hello Printer", printFont, Brushes.Black, x, y);
y += fltLineHeight;
g.DrawRectangle(Pens.Black, x, y, 100, 50);
y += 70;
g.DrawEllipse(Pens.Black, x, y, 100, 50);
}

private void menuItemPrint_Click(object sender, System.EventArgs e)
{
printDocument1.Print();
}
}
}